diff options
-rw-r--r-- | Alc/ALc.c | 4 | ||||
-rw-r--r-- | Alc/ALu.c | 2 | ||||
-rw-r--r-- | Alc/backends/alsa.c | 4 | ||||
-rw-r--r-- | Alc/backends/dsound.c | 6 | ||||
-rw-r--r-- | Alc/backends/mmdevapi.c | 6 | ||||
-rw-r--r-- | Alc/backends/oss.c | 4 | ||||
-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-- | OpenAL32/Include/alu.h | 1 |
10 files changed, 31 insertions, 2 deletions
@@ -2474,7 +2474,11 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin UnlockLists(); alcSetError(device, err); if(err == ALC_INVALID_DEVICE) + { + ALCdevice_Lock(device); aluHandleDisconnect(device); + ALCdevice_Unlock(device); + } ALCdevice_DecRef(device); return NULL; } @@ -1169,7 +1169,6 @@ ALvoid aluHandleDisconnect(ALCdevice *device) { ALCcontext *Context; - ALCdevice_Lock(device); device->Connected = ALC_FALSE; Context = device->ContextList; @@ -1194,5 +1193,4 @@ ALvoid aluHandleDisconnect(ALCdevice *device) Context = Context->next; } - ALCdevice_Unlock(device); } diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index 035d38e9..5ff6307f 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -472,7 +472,9 @@ static ALuint ALSAProc(ALvoid *ptr) if(state < 0) { ERR("Invalid state detected: %s\n", snd_strerror(state)); + ALCdevice_Lock(Device); aluHandleDisconnect(Device); + ALCdevice_Unlock(Device); break; } @@ -559,7 +561,9 @@ static ALuint ALSANoMMapProc(ALvoid *ptr) if(state < 0) { ERR("Invalid state detected: %s\n", snd_strerror(state)); + ALCdevice_Lock(Device); aluHandleDisconnect(Device); + ALCdevice_Unlock(Device); break; } diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c index 512667cc..c6f666e1 100644 --- a/Alc/backends/dsound.c +++ b/Alc/backends/dsound.c @@ -244,7 +244,9 @@ static ALuint DSoundPlaybackProc(ALvoid *ptr) if(FAILED(err)) { ERR("Failed to get buffer caps: 0x%lx\n", err); + ALCdevice_Lock(Device); aluHandleDisconnect(Device); + ALCdevice_Unlock(Device); return 1; } @@ -266,7 +268,9 @@ static ALuint DSoundPlaybackProc(ALvoid *ptr) if(FAILED(err)) { ERR("Failed to play buffer: 0x%lx\n", err); + ALCdevice_Lock(Device); aluHandleDisconnect(Device); + ALCdevice_Unlock(Device); return 1; } Playing = TRUE; @@ -310,7 +314,9 @@ static ALuint DSoundPlaybackProc(ALvoid *ptr) else { ERR("Buffer lock error: %#lx\n", err); + ALCdevice_Lock(Device); aluHandleDisconnect(Device); + ALCdevice_Unlock(Device); return 1; } diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index de4201dd..9c934095 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -229,7 +229,9 @@ static ALuint MMDevApiProc(ALvoid *ptr) if(FAILED(hr)) { ERR("CoInitialize(NULL) failed: 0x%08lx\n", hr); + ALCdevice_Lock(device); aluHandleDisconnect(device); + ALCdevice_Unlock(device); return 0; } @@ -243,7 +245,9 @@ static ALuint MMDevApiProc(ALvoid *ptr) if(FAILED(hr)) { ERR("Failed to get padding: 0x%08lx\n", hr); + ALCdevice_Lock(device); aluHandleDisconnect(device); + ALCdevice_Unlock(device); break; } data->Padding = written; @@ -271,7 +275,9 @@ static ALuint MMDevApiProc(ALvoid *ptr) if(FAILED(hr)) { ERR("Failed to buffer data: 0x%08lx\n", hr); + ALCdevice_Lock(device); aluHandleDisconnect(device); + ALCdevice_Unlock(device); break; } } diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c index ba11faf0..0ed49517 100644 --- a/Alc/backends/oss.c +++ b/Alc/backends/oss.c @@ -102,7 +102,9 @@ static ALuint OSSProc(ALvoid *ptr) if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) { ERR("write failed: %s\n", strerror(errno)); + ALCdevice_Lock(Device); aluHandleDisconnect(Device); + ALCdevice_Unlock(Device); break; } @@ -135,7 +137,9 @@ static ALuint OSSCaptureProc(ALvoid *ptr) if(amt < 0) { ERR("read failed: %s\n", strerror(errno)); + ALCdevice_Lock(Device); aluHandleDisconnect(Device); + ALCdevice_Unlock(Device); break; } if(amt == 0) diff --git a/Alc/backends/sndio.c b/Alc/backends/sndio.c index 771a7b90..2be88746 100644 --- a/Alc/backends/sndio.c +++ b/Alc/backends/sndio.c @@ -73,7 +73,9 @@ static ALuint sndio_proc(ALvoid *ptr) if(wrote == 0) { ERR("sio_write failed\n"); + ALCdevice_Lock(device); aluHandleDisconnect(device); + ALCdevice_Unlock(device); break; } diff --git a/Alc/backends/solaris.c b/Alc/backends/solaris.c index b84bb839..1c781387 100644 --- a/Alc/backends/solaris.c +++ b/Alc/backends/solaris.c @@ -76,7 +76,9 @@ static ALuint SolarisProc(ALvoid *ptr) if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) { ERR("write failed: %s\n", strerror(errno)); + ALCdevice_Lock(Device); aluHandleDisconnect(Device); + ALCdevice_Unlock(Device); break; } diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c index 38932819..be528c9a 100644 --- a/Alc/backends/wave.c +++ b/Alc/backends/wave.c @@ -151,7 +151,9 @@ static ALuint WaveProc(ALvoid *ptr) if(ferror(data->f)) { ERR("Error writing to file\n"); + ALCdevice_Lock(Device); aluHandleDisconnect(Device); + ALCdevice_Unlock(Device); break; } } diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 11c03332..01d3ca29 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -113,6 +113,7 @@ ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALCo ALvoid MixSource(struct ALsource *Source, ALCdevice *Device, ALuint SamplesToDo); ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size); +/* Caller must lock the device. */ ALvoid aluHandleDisconnect(ALCdevice *device); extern ALfloat ConeScale; |