diff options
author | Chris Robinson <[email protected]> | 2012-03-05 07:11:09 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-03-05 07:11:09 -0800 |
commit | fe6e532c876bf3ec6776f76f9542038ac9c94d68 (patch) | |
tree | 31d29eb21462dbc02287030d8e3b6174dcab92cc /Alc/backends/winmm.c | |
parent | 5cdeeb47f3b4dedefd1ceb2b32c2f7754abc058d (diff) |
Use a separate backend callback to start playback of the device
This allows us to properly update the ALCdevice and its resources with the new
parameters before starting playback, instead of expecting the mixer to block
and wait after it has begun.
This also lets us avoid holding the device lock while resetting and starting
the device, which helps prevent lock inversion on some backends (ie, one thread
locking A then B, and another thread locking B then A), ultimately allowing
certain backends to asynchronously update the ALCdevice without risk of lockup.
Capture still has issues here, however.
Diffstat (limited to 'Alc/backends/winmm.c')
-rw-r--r-- | Alc/backends/winmm.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c index 9f2c6316..57d27974 100644 --- a/Alc/backends/winmm.c +++ b/Alc/backends/winmm.c @@ -397,6 +397,21 @@ static void WinMMClosePlayback(ALCdevice *device) static ALCboolean WinMMResetPlayback(ALCdevice *device) { WinMMData *pData = (WinMMData*)device->ExtraData; + + device->UpdateSize = (ALuint)((ALuint64)device->UpdateSize * + pData->Frequency / device->Frequency); + device->UpdateSize = device->UpdateSize*device->NumUpdates / 4; + device->NumUpdates = 4; + device->Frequency = pData->Frequency; + + SetDefaultWFXChannelOrder(device); + + return ALC_TRUE; +} + +static ALCboolean WinMMStartPlayback(ALCdevice *device) +{ + WinMMData *pData = (WinMMData*)device->ExtraData; ALbyte *BufferData; ALint lBufferSize; ALuint i; @@ -405,12 +420,6 @@ static ALCboolean WinMMResetPlayback(ALCdevice *device) if(pData->hWaveThread == NULL) return ALC_FALSE; - device->UpdateSize = (ALuint)((ALuint64)device->UpdateSize * - pData->Frequency / device->Frequency); - device->Frequency = pData->Frequency; - - SetDefaultWFXChannelOrder(device); - pData->lWaveBuffersCommitted = 0; // Create 4 Buffers @@ -689,6 +698,7 @@ static const BackendFuncs WinMMFuncs = { WinMMOpenPlayback, WinMMClosePlayback, WinMMResetPlayback, + WinMMStartPlayback, WinMMStopPlayback, WinMMOpenCapture, WinMMCloseCapture, |