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