aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-12-02 11:20:20 -0800
committerChris Robinson <[email protected]>2012-12-02 11:30:23 -0800
commit1fb9311d82ff7e591aabb209eb5aaba108efc20e (patch)
tree5d7a6485ec0723394f18f4a60a43d7ec917e1940 /Alc
parentdd34daed42adb98fe2a167f6fc9aaf98947a3cc3 (diff)
Lock the device before calling aluHandleDisconnect
PulseAudio causes an assert if being relocked inside a callback on the worker thread, where aluHandleDisconnect is called. We can assume it's already locked there, so just make sure the device is locked before being calling it.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c4
-rw-r--r--Alc/ALu.c2
-rw-r--r--Alc/backends/alsa.c4
-rw-r--r--Alc/backends/dsound.c6
-rw-r--r--Alc/backends/mmdevapi.c6
-rw-r--r--Alc/backends/oss.c4
-rw-r--r--Alc/backends/sndio.c2
-rw-r--r--Alc/backends/solaris.c2
-rw-r--r--Alc/backends/wave.c2
9 files changed, 30 insertions, 2 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index abd2a01f..33580dad 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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;
}
diff --git a/Alc/ALu.c b/Alc/ALu.c
index a44c04b3..2ce2685b 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -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;
}
}