Win32: use event for soundsync

This commit is contained in:
OV2 2012-01-22 20:18:15 +01:00
parent 8a8d7b5646
commit dce8f6a1ff
8 changed files with 16 additions and 13 deletions

View File

@ -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))

View File

@ -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

View File

@ -135,7 +135,9 @@ FMOD_RESULT F_CALLBACK CFMODEx::FMODExStreamCallback(
LeaveCriticalSection(&GUI.SoundCritSect);
SetEvent(GUI.SoundSyncEvent);
return FMOD_OK;
}
#endif
#endif
#endif

View File

@ -308,6 +308,7 @@ pBufferContext - unused
void CXAudio2::OnBufferEnd(void *pBufferContext)
{
InterlockedDecrement(&bufferCount);
SetEvent(GUI.SoundSyncEvent);
}
/* CXAudio2::PushBuffer

View File

@ -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;

View File

@ -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));

View File

@ -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();

View File

@ -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];