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.
This commit is contained in:
Chris Robinson 2012-12-02 11:20:20 -08:00
parent dd34daed42
commit 1fb9311d82
10 changed files with 31 additions and 2 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;