diff options
author | Chris Robinson <[email protected]> | 2011-06-16 09:14:41 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-06-16 09:14:41 -0700 |
commit | 7d73ac440552babe27395a7985ff3f693303c61b (patch) | |
tree | 9d93807ba62608a62686172d9da58fc8d56de560 /OpenAL32/alSource.c | |
parent | c429a5be25978b2c0228af5cc448308110e7154c (diff) |
Avoid calling some AL functions from under the context lock
There are still some more occurances to clear out (deletion in gen error,
effects, some filters), which shall be coming up. There is a possibility for a
deadlock between the listlock and the global/context lock, if another attempt
to get the listlock is made while under the context lock.
Diffstat (limited to 'OpenAL32/alSource.c')
-rw-r--r-- | OpenAL32/alSource.c | 270 |
1 files changed, 147 insertions, 123 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 7dc4a2a9..fd163804 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -442,6 +442,37 @@ AL_API ALvoid AL_APIENTRY alSourcefv(ALuint source, ALenum eParam, const ALfloat { ALCcontext *pContext; + if(pflValues) + { + switch(eParam) + { + case AL_PITCH: + case AL_CONE_INNER_ANGLE: + case AL_CONE_OUTER_ANGLE: + case AL_GAIN: + case AL_MAX_DISTANCE: + case AL_ROLLOFF_FACTOR: + case AL_REFERENCE_DISTANCE: + case AL_MIN_GAIN: + case AL_MAX_GAIN: + case AL_CONE_OUTER_GAIN: + case AL_CONE_OUTER_GAINHF: + case AL_SEC_OFFSET: + case AL_SAMPLE_OFFSET: + case AL_BYTE_OFFSET: + case AL_AIR_ABSORPTION_FACTOR: + case AL_ROOM_ROLLOFF_FACTOR: + alSourcef(source, eParam, pflValues[0]); + return; + + case AL_POSITION: + case AL_VELOCITY: + case AL_DIRECTION: + alSource3f(source, eParam, pflValues[0], pflValues[1], pflValues[2]); + return; + } + } + pContext = GetContextSuspended(); if(!pContext) return; @@ -451,31 +482,6 @@ AL_API ALvoid AL_APIENTRY alSourcefv(ALuint source, ALenum eParam, const ALfloat { switch(eParam) { - case AL_PITCH: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_GAIN: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_REFERENCE_DISTANCE: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_CONE_OUTER_GAIN: - case AL_CONE_OUTER_GAINHF: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - alSourcef(source, eParam, pflValues[0]); - break; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alSource3f(source, eParam, pflValues[0], pflValues[1], pflValues[2]); - break; - default: alSetError(pContext, AL_INVALID_ENUM); break; @@ -497,6 +503,17 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) ALsource *Source; ALbufferlistitem *BufferListItem; + switch(eParam) + { + case AL_MAX_DISTANCE: + case AL_ROLLOFF_FACTOR: + case AL_CONE_INNER_ANGLE: + case AL_CONE_OUTER_ANGLE: + case AL_REFERENCE_DISTANCE: + alSourcef(source, eParam, (ALfloat)lValue); + return; + } + pContext = GetContextSuspended(); if(!pContext) return; @@ -506,14 +523,6 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) switch(eParam) { - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_REFERENCE_DISTANCE: - alSourcef(source, eParam, (ALfloat)lValue); - break; - case AL_SOURCE_RELATIVE: if(lValue == AL_FALSE || lValue == AL_TRUE) { @@ -706,6 +715,15 @@ AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, ALCcontext *pContext; ALsource *Source; + switch(eParam) + { + case AL_POSITION: + case AL_VELOCITY: + case AL_DIRECTION: + alSource3f(source, eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3); + return; + } + pContext = GetContextSuspended(); if(!pContext) return; @@ -713,14 +731,8 @@ AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, { ALCdevice *device = pContext->Device; - switch (eParam) + switch(eParam) { - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alSource3f(source, eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3); - break; - case AL_AUXILIARY_SEND_FILTER: { ALeffectslot *ALEffectSlot = NULL; ALfilter *ALFilter = NULL; @@ -769,6 +781,39 @@ AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum eParam, const ALint* pl { ALCcontext *pContext; + if(plValues) + { + switch(eParam) + { + case AL_SOURCE_RELATIVE: + case AL_CONE_INNER_ANGLE: + case AL_CONE_OUTER_ANGLE: + case AL_LOOPING: + case AL_BUFFER: + case AL_SOURCE_STATE: + case AL_SEC_OFFSET: + case AL_SAMPLE_OFFSET: + case AL_BYTE_OFFSET: + case AL_MAX_DISTANCE: + case AL_ROLLOFF_FACTOR: + case AL_REFERENCE_DISTANCE: + case AL_DIRECT_FILTER: + case AL_DIRECT_FILTER_GAINHF_AUTO: + case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: + case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: + case AL_DISTANCE_MODEL: + alSourcei(source, eParam, plValues[0]); + return; + + case AL_POSITION: + case AL_VELOCITY: + case AL_DIRECTION: + case AL_AUXILIARY_SEND_FILTER: + alSource3i(source, eParam, plValues[0], plValues[1], plValues[2]); + return; + } + } + pContext = GetContextSuspended(); if(!pContext) return; @@ -778,33 +823,6 @@ AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum eParam, const ALint* pl { switch(eParam) { - case AL_SOURCE_RELATIVE: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_LOOPING: - case AL_BUFFER: - case AL_SOURCE_STATE: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_REFERENCE_DISTANCE: - case AL_DIRECT_FILTER: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DISTANCE_MODEL: - alSourcei(source, eParam, plValues[0]); - break; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - case AL_AUXILIARY_SEND_FILTER: - alSource3i(source, eParam, plValues[0], plValues[1], plValues[2]); - break; - default: alSetError(pContext, AL_INVALID_ENUM); break; @@ -970,6 +988,35 @@ AL_API ALvoid AL_APIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *p ALdouble Offsets[2]; ALdouble updateLen; + switch(eParam) + { + case AL_PITCH: + case AL_GAIN: + case AL_MIN_GAIN: + case AL_MAX_GAIN: + case AL_MAX_DISTANCE: + case AL_ROLLOFF_FACTOR: + case AL_DOPPLER_FACTOR: + case AL_CONE_OUTER_GAIN: + case AL_SEC_OFFSET: + case AL_SAMPLE_OFFSET: + case AL_BYTE_OFFSET: + case AL_CONE_INNER_ANGLE: + case AL_CONE_OUTER_ANGLE: + case AL_REFERENCE_DISTANCE: + case AL_CONE_OUTER_GAINHF: + case AL_AIR_ABSORPTION_FACTOR: + case AL_ROOM_ROLLOFF_FACTOR: + alGetSourcef(source, eParam, pflValues); + return; + + case AL_POSITION: + case AL_VELOCITY: + case AL_DIRECTION: + alGetSource3f(source, eParam, pflValues+0, pflValues+1, pflValues+2); + return; + } + pContext = GetContextSuspended(); if(!pContext) return; @@ -979,32 +1026,6 @@ AL_API ALvoid AL_APIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *p { switch(eParam) { - case AL_PITCH: - case AL_GAIN: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_DOPPLER_FACTOR: - case AL_CONE_OUTER_GAIN: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_REFERENCE_DISTANCE: - case AL_CONE_OUTER_GAINHF: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - alGetSourcef(source, eParam, pflValues); - break; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alGetSource3f(source, eParam, pflValues+0, pflValues+1, pflValues+2); - break; - case AL_SAMPLE_RW_OFFSETS_SOFT: case AL_BYTE_RW_OFFSETS_SOFT: updateLen = (ALdouble)pContext->Device->UpdateSize / @@ -1202,6 +1223,39 @@ AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum eParam, ALint* plVal ALdouble Offsets[2]; ALdouble updateLen; + switch(eParam) + { + case AL_SOURCE_RELATIVE: + case AL_CONE_INNER_ANGLE: + case AL_CONE_OUTER_ANGLE: + case AL_LOOPING: + case AL_BUFFER: + case AL_SOURCE_STATE: + case AL_BUFFERS_QUEUED: + case AL_BUFFERS_PROCESSED: + case AL_SEC_OFFSET: + case AL_SAMPLE_OFFSET: + case AL_BYTE_OFFSET: + case AL_MAX_DISTANCE: + case AL_ROLLOFF_FACTOR: + case AL_DOPPLER_FACTOR: + case AL_REFERENCE_DISTANCE: + case AL_SOURCE_TYPE: + case AL_DIRECT_FILTER: + case AL_DIRECT_FILTER_GAINHF_AUTO: + case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: + case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: + case AL_DISTANCE_MODEL: + alGetSourcei(source, eParam, plValues); + return; + + case AL_POSITION: + case AL_VELOCITY: + case AL_DIRECTION: + alGetSource3i(source, eParam, plValues+0, plValues+1, plValues+2); + return; + } + pContext = GetContextSuspended(); if(!pContext) return; @@ -1211,36 +1265,6 @@ AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum eParam, ALint* plVal { switch(eParam) { - case AL_SOURCE_RELATIVE: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_LOOPING: - case AL_BUFFER: - case AL_SOURCE_STATE: - case AL_BUFFERS_QUEUED: - case AL_BUFFERS_PROCESSED: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_DOPPLER_FACTOR: - case AL_REFERENCE_DISTANCE: - case AL_SOURCE_TYPE: - case AL_DIRECT_FILTER: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DISTANCE_MODEL: - alGetSourcei(source, eParam, plValues); - break; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alGetSource3i(source, eParam, plValues+0, plValues+1, plValues+2); - break; - case AL_SAMPLE_RW_OFFSETS_SOFT: case AL_BYTE_RW_OFFSETS_SOFT: updateLen = (ALdouble)pContext->Device->UpdateSize / |