diff options
author | Chris Robinson <[email protected]> | 2012-08-18 15:58:04 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-08-18 15:58:04 -0700 |
commit | 0865db564fa86df6c02ab10ec62cfbbe98f8c917 (patch) | |
tree | c3ea9c6c1dc274776fd29c409e2231fa949e9742 /Alc | |
parent | 2b020040b41a8a8a19869263ad2816daad2e1361 (diff) |
Move the device lock into the backend function table
For backend-specific implementations: this should hold the audio mixer loop for
playback devices, and provide recursive mutex behavior.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 23 | ||||
-rw-r--r-- | Alc/ALu.c | 8 | ||||
-rw-r--r-- | Alc/backends/alsa.c | 2 | ||||
-rw-r--r-- | Alc/backends/coreaudio.c | 2 | ||||
-rw-r--r-- | Alc/backends/dsound.c | 2 | ||||
-rw-r--r-- | Alc/backends/loopback.c | 2 | ||||
-rw-r--r-- | Alc/backends/mmdevapi.c | 2 | ||||
-rw-r--r-- | Alc/backends/null.c | 2 | ||||
-rw-r--r-- | Alc/backends/opensl.c | 2 | ||||
-rw-r--r-- | Alc/backends/oss.c | 2 | ||||
-rw-r--r-- | Alc/backends/portaudio.c | 2 | ||||
-rw-r--r-- | Alc/backends/pulseaudio.c | 2 | ||||
-rw-r--r-- | Alc/backends/sndio.c | 2 | ||||
-rw-r--r-- | Alc/backends/solaris.c | 2 | ||||
-rw-r--r-- | Alc/backends/wave.c | 2 | ||||
-rw-r--r-- | Alc/backends/winmm.c | 2 |
16 files changed, 48 insertions, 11 deletions
@@ -43,7 +43,7 @@ /************************************************ * Backends ************************************************/ -#define EmptyFuncs { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } +#define EmptyFuncs { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } static struct BackendInfo BackendList[] = { #ifdef HAVE_PULSEAUDIO { "pulse", alc_pulse_init, alc_pulse_deinit, alc_pulse_probe, EmptyFuncs }, @@ -1259,6 +1259,15 @@ static ALCboolean IsValidALCChannels(ALCenum channels) * Miscellaneous ALC helpers ************************************************/ +void ALCdevice_LockDefault(ALCdevice *device) +{ + EnterCriticalSection(&device->Mutex); +} +void ALCdevice_UnlockDefault(ALCdevice *device) +{ + LeaveCriticalSection(&device->Mutex); +} + /* SetDefaultWFXChannelOrder * * Sets the default channel order used by WaveFormatEx. @@ -1609,7 +1618,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->Flags |= DEVICE_WIDE_STEREO; oldMode = SetMixerFPUMode(); - LockDevice(device); + ALCdevice_Lock(device); context = device->ContextList; while(context) { @@ -1624,7 +1633,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(ALeffectState_DeviceUpdate(slot->EffectState, device) == AL_FALSE) { UnlockUIntMapRead(&context->EffectSlotMap); - UnlockDevice(device); + ALCdevice_Unlock(device); RestoreFPUMode(oldMode); return ALC_INVALID_DEVICE; } @@ -1660,14 +1669,14 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(ALeffectState_DeviceUpdate(slot->EffectState, device) == AL_FALSE) { - UnlockDevice(device); + ALCdevice_Unlock(device); RestoreFPUMode(oldMode); return ALC_INVALID_DEVICE; } slot->NeedsUpdate = AL_FALSE; ALeffectState_Update(slot->EffectState, device, slot); } - UnlockDevice(device); + ALCdevice_Unlock(device); RestoreFPUMode(oldMode); if(ALCdevice_StartPlayback(device) == ALC_FALSE) @@ -1876,7 +1885,7 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device) if(CompExchangePtr((XchgPtr*)&GlobalContext, context, NULL)) ALCcontext_DecRef(context); - LockDevice(device); + ALCdevice_Lock(device); tmp_ctx = &device->ContextList; while(*tmp_ctx) { @@ -1884,7 +1893,7 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device) break; tmp_ctx = &(*tmp_ctx)->next; } - UnlockDevice(device); + ALCdevice_Unlock(device); ALCcontext_DecRef(context); } @@ -921,7 +921,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) SamplesToDo = minu(size, BUFFERSIZE); memset(device->DryBuffer, 0, SamplesToDo*MaxChannels*sizeof(ALfloat)); - LockDevice(device); + ALCdevice_Lock(device); ctx = device->ContextList; while(ctx) { @@ -999,7 +999,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) for(i = 0;i < SamplesToDo;i++) (*slot)->WetBuffer[i] = 0.0f; } - UnlockDevice(device); + ALCdevice_Unlock(device); /* Click-removal. Could do better; this only really handles immediate * changes between updates where a predictive sample could be @@ -1092,7 +1092,7 @@ ALvoid aluHandleDisconnect(ALCdevice *device) { ALCcontext *Context; - LockDevice(device); + ALCdevice_Lock(device); device->Connected = ALC_FALSE; Context = device->ContextList; @@ -1117,5 +1117,5 @@ ALvoid aluHandleDisconnect(ALCdevice *device) Context = Context->next; } - UnlockDevice(device); + ALCdevice_Unlock(device); } diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index 880f7ac9..38653aa1 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -1254,6 +1254,8 @@ static const BackendFuncs alsa_funcs = { alsa_stop_capture, alsa_capture_samples, alsa_available_samples, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, alsa_get_latency }; diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c index df28d706..c3a67c81 100644 --- a/Alc/backends/coreaudio.c +++ b/Alc/backends/coreaudio.c @@ -682,6 +682,8 @@ static const BackendFuncs ca_funcs = { ca_stop_capture, ca_capture_samples, ca_available_samples, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, ca_get_latency }; diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c index 89910c7f..e38bf30f 100644 --- a/Alc/backends/dsound.c +++ b/Alc/backends/dsound.c @@ -954,6 +954,8 @@ static const BackendFuncs DSoundFuncs = { DSoundStopCapture, DSoundCaptureSamples, DSoundAvailableSamples, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, DSoundGetLatency }; diff --git a/Alc/backends/loopback.c b/Alc/backends/loopback.c index ae7e32b4..2597a392 100644 --- a/Alc/backends/loopback.c +++ b/Alc/backends/loopback.c @@ -74,6 +74,8 @@ static const BackendFuncs loopback_funcs = { NULL, NULL, NULL, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, loopback_get_latency }; diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index bffc463a..4fa933ac 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -956,6 +956,8 @@ static const BackendFuncs MMDevApiFuncs = { NULL, NULL, NULL, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, MMDevApiGetLatency }; diff --git a/Alc/backends/null.c b/Alc/backends/null.c index f39d3071..8ae9479c 100644 --- a/Alc/backends/null.c +++ b/Alc/backends/null.c @@ -149,6 +149,8 @@ static const BackendFuncs null_funcs = { NULL, NULL, NULL, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, null_get_latency }; diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c index f2df0218..14d0061b 100644 --- a/Alc/backends/opensl.c +++ b/Alc/backends/opensl.c @@ -420,6 +420,8 @@ static const BackendFuncs opensl_funcs = { NULL, NULL, NULL, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, opensl_get_latency }; diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c index 6786f8c6..02150a8b 100644 --- a/Alc/backends/oss.c +++ b/Alc/backends/oss.c @@ -495,6 +495,8 @@ static const BackendFuncs oss_funcs = { oss_stop_capture, oss_capture_samples, oss_available_samples, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, oss_get_latency }; diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c index 1558e89f..e55f6842 100644 --- a/Alc/backends/portaudio.c +++ b/Alc/backends/portaudio.c @@ -438,6 +438,8 @@ static const BackendFuncs pa_funcs = { pa_stop_capture, pa_capture_samples, pa_available_samples, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, pa_get_latency }; diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index 87a04946..de8a40d0 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -1407,6 +1407,8 @@ static const BackendFuncs pulse_funcs = { pulse_stop_capture, pulse_capture_samples, pulse_available_samples, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, pulse_get_latency }; diff --git a/Alc/backends/sndio.c b/Alc/backends/sndio.c index c1dbc1a6..4698d5e3 100644 --- a/Alc/backends/sndio.c +++ b/Alc/backends/sndio.c @@ -271,6 +271,8 @@ static const BackendFuncs sndio_funcs = { NULL, NULL, NULL, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, sndio_get_latency }; diff --git a/Alc/backends/solaris.c b/Alc/backends/solaris.c index 4be32a50..8d31104e 100644 --- a/Alc/backends/solaris.c +++ b/Alc/backends/solaris.c @@ -255,6 +255,8 @@ static const BackendFuncs solaris_funcs = { NULL, NULL, NULL, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, solaris_get_latency }; diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c index fb118ee8..7d28fab0 100644 --- a/Alc/backends/wave.c +++ b/Alc/backends/wave.c @@ -342,6 +342,8 @@ static const BackendFuncs wave_funcs = { NULL, NULL, NULL, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, wave_get_latency }; diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c index ecd76e52..13012d81 100644 --- a/Alc/backends/winmm.c +++ b/Alc/backends/winmm.c @@ -724,6 +724,8 @@ static const BackendFuncs WinMMFuncs = { WinMMStopCapture, WinMMCaptureSamples, WinMMAvailableSamples, + ALCdevice_LockDefault, + ALCdevice_UnlockDefault, WinMMGetLatency }; |