AVWriters now implement UsesAudio and UsesVideo so that the frontend can decide how much work it needs to tell the core to do to fulfill the AVWriter's needs (fixes #593)

This commit is contained in:
zeromus 2016-03-05 17:19:12 -06:00
parent 9b75d9c359
commit de576bb067
11 changed files with 40 additions and 1 deletions

View File

@ -175,6 +175,9 @@ namespace BizHawk.Client.EmuHawk
{ {
protected IVideoWriter w; protected IVideoWriter w;
public bool UsesAudio { get { return w.UsesAudio; } }
public bool UsesVideo { get { return w.UsesVideo; } }
public void SetVideoCodecToken(IDisposable token) public void SetVideoCodecToken(IDisposable token)
{ {
w.SetVideoCodecToken(token); w.SetVideoCodecToken(token);

View File

@ -857,6 +857,9 @@ namespace BizHawk.Client.EmuHawk
{ {
return "avi"; return "avi";
} }
public bool UsesAudio { get { return parameters.has_audio; } }
public bool UsesVideo { get { return true; } }
} }
} }

View File

@ -291,5 +291,8 @@ namespace BizHawk.Client.EmuHawk
{ {
token = FFmpegWriterForm.FormatPreset.GetDefaultPreset(); token = FFmpegWriterForm.FormatPreset.GetDefaultPreset();
} }
public bool UsesAudio { get { return true; } }
public bool UsesVideo { get { return true; } }
} }
} }

View File

@ -227,5 +227,8 @@ namespace BizHawk.Client.EmuHawk
f = null; f = null;
} }
} }
public bool UsesAudio { get { return false; } }
public bool UsesVideo { get { return true; } }
} }
} }

View File

@ -19,6 +19,15 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
void SetDefaultVideoCodecToken(); void SetDefaultVideoCodecToken();
/// <summary>
/// Returns whether this videowriter dumps audio
/// </summary>
bool UsesAudio { get; }
/// <summary>
/// Returns whether this videowriter dumps video
/// </summary>
bool UsesVideo { get; }
// why no OpenFile(IEnumerator<string>) ? // why no OpenFile(IEnumerator<string>) ?
// different video writers may have different ideas of how and why splitting is to occur // different video writers may have different ideas of how and why splitting is to occur

View File

@ -24,6 +24,8 @@ namespace BizHawk.Client.EmuHawk
{ {
} }
public bool UsesAudio { get { return false; } }
public bool UsesVideo { get { return true; } }
public void OpenFile(string baseName) public void OpenFile(string baseName)
{ {

View File

@ -790,5 +790,10 @@ namespace BizHawk.Client.EmuHawk
} }
public void SetFrame(int frame) { } public void SetFrame(int frame) { }
public bool UsesAudio { get { return true; } }
public bool UsesVideo { get { return true; } }
} }
} }

View File

@ -138,5 +138,8 @@ namespace BizHawk.Client.EmuHawk
{ {
// ignored // ignored
} }
public bool UsesAudio { get { return true; } }
public bool UsesVideo { get { return true; } }
} }
} }

View File

@ -68,6 +68,9 @@ namespace BizHawk.Client.EmuHawk
wwv.Dispose(); wwv.Dispose();
} }
public bool UsesAudio { get { return true; } }
public bool UsesVideo { get { return true; } }
class DummyDisposable : IDisposable { public void Dispose() { } } class DummyDisposable : IDisposable { public void Dispose() { } }
public IDisposable AcquireVideoCodecToken(IWin32Window hwnd) { return new DummyDisposable(); } public IDisposable AcquireVideoCodecToken(IWin32Window hwnd) { return new DummyDisposable(); }

View File

@ -205,6 +205,9 @@ namespace BizHawk.Client.EmuHawk
public void SetVideoParameters(int width, int height) { } public void SetVideoParameters(int width, int height) { }
public void SetFrame(int frame) { } public void SetFrame(int frame) { }
public bool UsesAudio { get { return true; } }
public bool UsesVideo { get { return false; } }
class WavWriterVToken : IDisposable class WavWriterVToken : IDisposable
{ {
public void Dispose() { } public void Dispose() { }

View File

@ -2817,8 +2817,10 @@ namespace BizHawk.Client.EmuHawk
coreskipaudio = true; coreskipaudio = true;
{ {
bool render = !_throttle.skipnextframe || _currAviWriter != null; bool render = !_throttle.skipnextframe;
bool renderSound = !coreskipaudio; bool renderSound = !coreskipaudio;
if (_currAviWriter != null && _currAviWriter.UsesVideo) render = true;
if (_currAviWriter != null && _currAviWriter.UsesAudio) renderSound = true;
Global.Emulator.FrameAdvance(render, renderSound); Global.Emulator.FrameAdvance(render, renderSound);
} }