diff options
| author | Tony Wasserka <neobrainx@gmail.com> | 2014-06-13 22:37:33 +0200 |
|---|---|---|
| committer | Tony Wasserka <neobrainx@gmail.com> | 2014-06-13 22:37:33 +0200 |
| commit | 2f6e559978908a4906523d685d1c7ac4869a6943 (patch) | |
| tree | 0b2a662c1495a189b07a3e4ba34b4de419dc5b61 /Source/Core/AudioCommon/DSoundStream.cpp | |
| parent | a8f32adcab9553e6b08cb0d3d5bac773e9a5fad0 (diff) | |
| parent | 87a804fdfc6ccc1c2eb0ca07d3c116a99d7e27a4 (diff) | |
Merge pull request #440 from magumagu/dsound-revert
Revert "DSound: use DSound notifications to produce sound."
Diffstat (limited to 'Source/Core/AudioCommon/DSoundStream.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/DSoundStream.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/Source/Core/AudioCommon/DSoundStream.cpp b/Source/Core/AudioCommon/DSoundStream.cpp index d25ebf5804..df96a9551f 100644 --- a/Source/Core/AudioCommon/DSoundStream.cpp +++ b/Source/Core/AudioCommon/DSoundStream.cpp @@ -29,7 +29,7 @@ bool DSound::CreateBuffer() // Fill out DSound buffer description. dsbdesc.dwSize = sizeof(DSBUFFERDESC); - dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLPOSITIONNOTIFY; + dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS; dsbdesc.dwBufferBytes = bufferSize = BUFSIZE; dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&pcmwf; dsbdesc.guid3DAlgorithm = DS3DALG_DEFAULT; @@ -39,20 +39,6 @@ bool DSound::CreateBuffer() { dsBuffer->SetCurrentPosition(0); dsBuffer->SetVolume(m_volume); - - soundSyncEvent = CreateEvent(NULL, TRUE, FALSE, TEXT("DSound Buffer Notification")); - - IDirectSoundNotify *dsnotify; - dsBuffer->QueryInterface(IID_IDirectSoundNotify, (void**)&dsnotify); - DSBPOSITIONNOTIFY notify_positions[3]; - for (unsigned i = 0; i < ARRAYSIZE(notify_positions); ++i) - { - notify_positions[i].dwOffset = i * (BUFSIZE / ARRAYSIZE(notify_positions)); - notify_positions[i].hEventNotify = soundSyncEvent; - } - dsnotify->SetNotificationPositions(ARRAYSIZE(notify_positions), notify_positions); - dsnotify->Release(); - return true; } else @@ -117,7 +103,7 @@ void DSound::SoundLoop() WriteDataToBuffer(lastPos, (char*)realtimeBuffer, numBytesToRender); lastPos = ModBufferSize(lastPos + numBytesToRender); } - WaitForSingleObject(soundSyncEvent, INFINITE); + soundSyncEvent.Wait(); } } @@ -150,6 +136,11 @@ void DSound::SetVolume(int volume) dsBuffer->SetVolume(m_volume); } +void DSound::Update() +{ + soundSyncEvent.Set(); +} + void DSound::Clear(bool mute) { m_muted = mute; @@ -171,12 +162,11 @@ void DSound::Stop() { threadData = 1; // kick the thread if it's waiting - SetEvent(soundSyncEvent); + soundSyncEvent.Set(); thread.join(); dsBuffer->Stop(); dsBuffer->Release(); ds->Release(); - CloseHandle(soundSyncEvent); } |
