mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 17:19:44 -06:00
Replaced Common::CriticalSection with a std::mutex implementation. 64bit Windows builds now use SRWLocks and ConditionVariables(requires Vista/7, x64 builds will no longer work on Windows XP x64). Tell me if you hate that. Removed Common::EventEx. Common::Event now uses a std::condition_variable impl.(using ConditionVariables on Windows x64, Events on x86, or posix condition variables elsewhere). I experience slight speed improvements with these changes.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7294 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -47,9 +47,11 @@ void AOSound::SoundLoop()
|
||||
while (!threadData)
|
||||
{
|
||||
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
|
||||
soundCriticalSection.Enter();
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(soundCriticalSection);
|
||||
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
|
||||
soundCriticalSection.Leave();
|
||||
}
|
||||
|
||||
soundSyncEvent.Wait();
|
||||
}
|
||||
@ -58,8 +60,6 @@ void AOSound::SoundLoop()
|
||||
bool AOSound::Start()
|
||||
{
|
||||
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
|
||||
|
||||
soundSyncEvent.Init();
|
||||
|
||||
thread = std::thread(std::mem_fun(&AOSound::SoundLoop), this);
|
||||
return true;
|
||||
@ -75,7 +75,8 @@ void AOSound::Stop()
|
||||
threadData = 1;
|
||||
soundSyncEvent.Set();
|
||||
|
||||
soundCriticalSection.Enter();
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(soundCriticalSection);
|
||||
thread.join();
|
||||
|
||||
if (device)
|
||||
@ -84,9 +85,7 @@ void AOSound::Stop()
|
||||
ao_shutdown();
|
||||
|
||||
device = NULL;
|
||||
soundCriticalSection.Leave();
|
||||
|
||||
soundSyncEvent.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
AOSound::~AOSound()
|
||||
|
@ -30,7 +30,7 @@ class AOSound : public SoundStream
|
||||
{
|
||||
#if defined(HAVE_AO) && HAVE_AO
|
||||
std::thread thread;
|
||||
Common::CriticalSection soundCriticalSection;
|
||||
std::mutex soundCriticalSection;
|
||||
Common::Event soundSyncEvent;
|
||||
|
||||
int buf_size;
|
||||
|
@ -119,8 +119,6 @@ void DSound::SoundLoop()
|
||||
|
||||
bool DSound::Start()
|
||||
{
|
||||
soundSyncEvent.Init();
|
||||
|
||||
if (FAILED(DirectSoundCreate8(0, &ds, 0)))
|
||||
return false;
|
||||
if (hWnd)
|
||||
@ -180,7 +178,5 @@ void DSound::Stop()
|
||||
dsBuffer->Stop();
|
||||
dsBuffer->Release();
|
||||
ds->Release();
|
||||
|
||||
soundSyncEvent.Shutdown();
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class DSound : public SoundStream
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::thread thread;
|
||||
Common::EventEx soundSyncEvent;
|
||||
Common::Event soundSyncEvent;
|
||||
void *hWnd;
|
||||
|
||||
IDirectSound8* ds;
|
||||
|
@ -32,8 +32,6 @@ bool OpenALStream::Start()
|
||||
ALCdevice *pDevice = NULL;
|
||||
bool bReturn = false;
|
||||
|
||||
soundSyncEvent.Init();
|
||||
|
||||
pDeviceList = new ALDeviceList();
|
||||
if ((pDeviceList) && (pDeviceList->GetNumDevices()))
|
||||
{
|
||||
@ -92,8 +90,6 @@ void OpenALStream::Stop()
|
||||
alcMakeContextCurrent(NULL);
|
||||
alcDestroyContext(pContext);
|
||||
alcCloseDevice(pDevice);
|
||||
|
||||
soundSyncEvent.Shutdown();
|
||||
}
|
||||
|
||||
void OpenALStream::SetVolume(int volume)
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
|
||||
private:
|
||||
std::thread thread;
|
||||
Common::EventEx soundSyncEvent;
|
||||
Common::Event soundSyncEvent;
|
||||
|
||||
short realtimeBuffer[OAL_MAX_SAMPLES * 2];
|
||||
ALuint uiBuffers[OAL_NUM_BUFFERS];
|
||||
|
@ -22,10 +22,10 @@ struct StreamingVoiceContext : public IXAudio2VoiceCallback
|
||||
{
|
||||
IXAudio2SourceVoice* pSourceVoice;
|
||||
CMixer *m_mixer;
|
||||
Common::EventEx *soundSyncEvent;
|
||||
Common::Event *soundSyncEvent;
|
||||
short *xaBuffer;
|
||||
|
||||
StreamingVoiceContext(IXAudio2 *pXAudio2, CMixer *pMixer, Common::EventEx *pSyncEvent)
|
||||
StreamingVoiceContext(IXAudio2 *pXAudio2, CMixer *pMixer, Common::Event *pSyncEvent)
|
||||
{
|
||||
|
||||
m_mixer = pMixer;
|
||||
@ -100,7 +100,6 @@ struct StreamingVoiceContext : public IXAudio2VoiceCallback
|
||||
//
|
||||
if( !pSourceVoice || !context) return;
|
||||
|
||||
//soundSyncEvent->Init();
|
||||
//soundSyncEvent->Wait(); //sync
|
||||
//soundSyncEvent->Spin(); //or tight sync
|
||||
|
||||
@ -123,8 +122,6 @@ StreamingVoiceContext* pVoiceContext = 0;
|
||||
|
||||
bool XAudio2::Start()
|
||||
{
|
||||
//soundSyncEvent.Init();
|
||||
|
||||
// XAudio2 init
|
||||
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
HRESULT hr;
|
||||
@ -207,5 +204,4 @@ void XAudio2::Stop()
|
||||
safe_release(pXAudio2);
|
||||
pMasteringVoice = NULL;
|
||||
CoUninitialize();
|
||||
//soundSyncEvent.Shutdown();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class XAudio2 : public SoundStream
|
||||
IXAudio2MasteringVoice *pMasteringVoice;
|
||||
IXAudio2SourceVoice *pSourceVoice;
|
||||
|
||||
Common::EventEx soundSyncEvent;
|
||||
Common::Event soundSyncEvent;
|
||||
float m_volume;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user