change CoreOutputComm to use exact integers to specify VsyncRate. Helps for AV dumping with formats that require exact integer rates (AVI), and for emulators that aren't exactly 50hz/60hz (none yet).

This commit is contained in:
goyuken 2012-07-11 21:37:35 +00:00
parent 3a73f8a427
commit fd7a0b2fe7
3 changed files with 23 additions and 10 deletions

View File

@ -74,7 +74,8 @@ namespace BizHawk.Emulation.Consoles.Sega
Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize); Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize);
RomBanks = (byte)(RomData.Length / BankSize); RomBanks = (byte)(RomData.Length / BankSize);
DisplayType = DisplayType.NTSC; DisplayType = DisplayType.NTSC;
CoreOutputComm.VsyncRate = DisplayType == DisplayType.NTSC ? 60d : 50d; CoreOutputComm.VsyncNum = DisplayType == DisplayType.NTSC ? 60 : 50;
CoreOutputComm.VsyncDen = 1;
if (game["PAL"]) DisplayType = DisplayType.PAL; if (game["PAL"]) DisplayType = DisplayType.PAL;
if (game["Japan"]) Region = "Japan"; if (game["Japan"]) Region = "Japan";
if (game.NotInDatabase || game["FM"] && game["UseFM"]) if (game.NotInDatabase || game["FM"] && game["UseFM"])

View File

@ -11,7 +11,15 @@
public class CoreOutputComm public class CoreOutputComm
{ {
public double VsyncRate = 60; public double VsyncRate
{
get
{
return VsyncNum / (double)VsyncDen;
}
}
public int VsyncNum = 60;
public int VsyncDen = 1;
public string RomStatusAnnotation; public string RomStatusAnnotation;
public string RomStatusDetails; public string RomStatusDetails;
} }

View File

@ -43,7 +43,8 @@ namespace BizHawk.MultiClient
/// an audio proxy used for dumping /// an audio proxy used for dumping
/// </summary> /// </summary>
Emulation.Sound.Utilities.DualSound DumpProxy = null; Emulation.Sound.Utilities.DualSound DumpProxy = null;
/// <summary>audio timekeeping for video dumping</summary>
long SoundRemainder = 0;
//runloop control //runloop control
bool exit; bool exit;
@ -366,6 +367,7 @@ namespace BizHawk.MultiClient
bool fastforward = Global.ClientControls["Fast Forward"] || FastForward; bool fastforward = Global.ClientControls["Fast Forward"] || FastForward;
Global.ForceNoVsync = unthrottled || fastforward; Global.ForceNoVsync = unthrottled || fastforward;
// realtime throttle is never going to be so exact that using a double here is wrong
throttle.SetCoreFps(Global.Emulator.CoreOutputComm.VsyncRate); throttle.SetCoreFps(Global.Emulator.CoreOutputComm.VsyncRate);
throttle.signal_paused = EmulatorPaused || Global.Emulator is NullEmulator; throttle.signal_paused = EmulatorPaused || Global.Emulator is NullEmulator;
@ -1940,9 +1942,12 @@ namespace BizHawk.MultiClient
//======================================= //=======================================
if (CurrAviWriter != null) if (CurrAviWriter != null)
{ {
//TODO - this will stray over time! have AviWriter keep an accumulation! long nsampnum = 44100 * (long)Global.Emulator.CoreOutputComm.VsyncDen + SoundRemainder;
int samples = (int)(44100 / Global.Emulator.CoreOutputComm.VsyncRate); long nsamp = nsampnum / Global.Emulator.CoreOutputComm.VsyncNum;
short[] temp = new short[samples * 2]; // exactly remember fractional parts of an audio sample
SoundRemainder = nsampnum % Global.Emulator.CoreOutputComm.VsyncNum;
short[] temp = new short[nsamp * 2];
//Global.Emulator.SoundProvider.GetSamples(temp); //Global.Emulator.SoundProvider.GetSamples(temp);
DumpProxy.GetSamples(temp); DumpProxy.GetSamples(temp);
//genSound = false; //genSound = false;
@ -2767,10 +2772,7 @@ namespace BizHawk.MultiClient
try try
{ {
//TODO - cores should be able to specify exact values for these instead of relying on this to calculate them aw.SetMovieParameters(Global.Emulator.CoreOutputComm.VsyncNum, Global.Emulator.CoreOutputComm.VsyncDen);
int fps = (int)(Global.Emulator.CoreOutputComm.VsyncRate * 0x01000000);
aw.SetMovieParameters(fps, 0x01000000);
aw.SetVideoParameters(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight); aw.SetVideoParameters(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight);
aw.SetAudioParameters(44100, 2, 16); aw.SetAudioParameters(44100, 2, 16);
@ -2828,6 +2830,7 @@ namespace BizHawk.MultiClient
// buffersize here is entirely guess // buffersize here is entirely guess
DumpProxy = new Emulation.Sound.Utilities.DualSound(Global.Emulator.SoundProvider, 8192); DumpProxy = new Emulation.Sound.Utilities.DualSound(Global.Emulator.SoundProvider, 8192);
SoundRemainder = 0;
} }
public void StopAVI() public void StopAVI()
@ -2843,6 +2846,7 @@ namespace BizHawk.MultiClient
AVIStatusLabel.Image = BizHawk.MultiClient.Properties.Resources.Blank; AVIStatusLabel.Image = BizHawk.MultiClient.Properties.Resources.Blank;
AVIStatusLabel.ToolTipText = ""; AVIStatusLabel.ToolTipText = "";
DumpProxy = null; // return to normal sound output DumpProxy = null; // return to normal sound output
SoundRemainder = 0;
} }
private void SwapBackupSavestate(string path) private void SwapBackupSavestate(string path)