mirror of https://github.com/snes9xgit/snes9x.git
Win32: use event for soundsync
This commit is contained in:
parent
8a8d7b5646
commit
dce8f6a1ff
|
@ -489,7 +489,8 @@ void CDirectSound::MixSound()
|
|||
S9xMixSamples(B2,(Settings.SixteenBitSound?S2>>1:S2));
|
||||
}
|
||||
LeaveCriticalSection(&GUI.SoundCritSect);
|
||||
|
||||
|
||||
SetEvent(GUI.SoundSyncEvent);
|
||||
|
||||
hResult = lpDSB -> Unlock (B1, S1, B2, S2);
|
||||
if (!SUCCEEDED(hResult))
|
||||
|
|
|
@ -357,6 +357,8 @@ F_CALLBACKAPI CFMOD::FMODStreamCallback (FSOUND_STREAM *stream, void *buff, int
|
|||
|
||||
LeaveCriticalSection(&GUI.SoundCritSect);
|
||||
|
||||
SetEvent(GUI.SoundSyncEvent);
|
||||
|
||||
|
||||
|
||||
#if defined (FSOUND_LOADRAW)
|
||||
|
@ -364,4 +366,4 @@ F_CALLBACKAPI CFMOD::FMODStreamCallback (FSOUND_STREAM *stream, void *buff, int
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -135,7 +135,9 @@ FMOD_RESULT F_CALLBACK CFMODEx::FMODExStreamCallback(
|
|||
|
||||
LeaveCriticalSection(&GUI.SoundCritSect);
|
||||
|
||||
SetEvent(GUI.SoundSyncEvent);
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -308,6 +308,7 @@ pBufferContext - unused
|
|||
void CXAudio2::OnBufferEnd(void *pBufferContext)
|
||||
{
|
||||
InterlockedDecrement(&bufferCount);
|
||||
SetEvent(GUI.SoundSyncEvent);
|
||||
}
|
||||
|
||||
/* CXAudio2::PushBuffer
|
||||
|
|
|
@ -2624,7 +2624,7 @@ void RenderBlarggNTSCRgb( SSurface Src, SSurface Dst, RECT *rect)
|
|||
void RenderBlarggNTSC( SSurface Src, SSurface Dst, RECT *rect)
|
||||
{
|
||||
SetRect(rect, 256, 239, 2);
|
||||
rect->right = 604;
|
||||
rect->right = SNES_NTSC_OUT_WIDTH(256);
|
||||
|
||||
const unsigned int srcRowPixels = Src.Pitch/2;
|
||||
|
||||
|
|
|
@ -986,6 +986,7 @@ void InitSnes9X( void)
|
|||
GFX.Screen = (uint16*)(ScreenBuffer);
|
||||
|
||||
InitializeCriticalSection(&GUI.SoundCritSect);
|
||||
GUI.SoundSyncEvent = CreateEvent(NULL,TRUE,TRUE,NULL);
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
|
||||
S9xInitAPU();
|
||||
|
@ -1005,6 +1006,7 @@ void DeinitS9x()
|
|||
delete [] ScreenBuf;
|
||||
|
||||
DeleteCriticalSection(&GUI.SoundCritSect);
|
||||
CloseHandle(GUI.SoundSyncEvent);
|
||||
CoUninitialize();
|
||||
if(GUI.GunSight)
|
||||
DestroyCursor(GUI.GunSight);//= LoadCursor (hInstance, MAKEINTRESOURCE (IDC_CURSOR_SCOPE));
|
||||
|
|
|
@ -3304,7 +3304,6 @@ int WINAPI WinMain(
|
|||
ChangeInputDevice();
|
||||
|
||||
DWORD lastTime = timeGetTime();
|
||||
DWORD sSyncTime,sSyncWaited;
|
||||
|
||||
MSG msg;
|
||||
|
||||
|
@ -3421,15 +3420,10 @@ int WINAPI WinMain(
|
|||
{
|
||||
ProcessInput();
|
||||
|
||||
sSyncTime=timeGetTime();
|
||||
|
||||
while(!S9xSyncSound()) {
|
||||
Sleep(2);
|
||||
sSyncWaited=timeGetTime();
|
||||
if(sSyncWaited-sSyncTime > 1000) {
|
||||
S9xClearSamples();
|
||||
break;
|
||||
}
|
||||
ResetEvent(GUI.SoundSyncEvent);
|
||||
if(WaitForSingleObject(GUI.SoundSyncEvent,1000) != WAIT_OBJECT_0)
|
||||
S9xClearSamples();
|
||||
}
|
||||
|
||||
S9xMainLoop();
|
||||
|
|
|
@ -369,6 +369,7 @@ struct sGUI {
|
|||
bool Mute;
|
||||
// used for sync sound synchronization
|
||||
CRITICAL_SECTION SoundCritSect;
|
||||
HANDLE SoundSyncEvent;
|
||||
|
||||
TCHAR RomDir [_MAX_PATH];
|
||||
TCHAR ScreensDir [_MAX_PATH];
|
||||
|
|
Loading…
Reference in New Issue