aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-05-15 14:12:56 -0700
committerChris Robinson <[email protected]>2016-05-15 14:12:56 -0700
commit63e98481eef0eb02dac14b889be80836a300eecc (patch)
tree84327def8889ea59b8c64916317724b17501a383 /Alc
parentc522658d19f7e82748400731bddb4633847c2a40 (diff)
Allocate context storage before starting/resetting the device
In case allocation fails, we don't have to worry about the playing status of the backend.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index dfbb6c63..0019de9e 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -3078,20 +3078,6 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
ATOMIC_STORE(&device->LastError, ALC_NO_ERROR);
- if((err=UpdateDeviceParams(device, attrList)) != ALC_NO_ERROR)
- {
- UnlockLists();
- alcSetError(device, err);
- if(err == ALC_INVALID_DEVICE)
- {
- V0(device->Backend,lock)();
- aluHandleDisconnect(device);
- V0(device->Backend,unlock)();
- }
- ALCdevice_DecRef(device);
- return NULL;
- }
-
ALContext = al_calloc(16, sizeof(ALCcontext)+sizeof(ALlistener));
if(ALContext)
{
@@ -3106,11 +3092,6 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
}
if(!ALContext || !ALContext->Voices)
{
- if(!ATOMIC_LOAD(&device->ContextList))
- {
- V0(device->Backend,stop)();
- device->Flags &= ~DEVICE_RUNNING;
- }
UnlockLists();
if(ALContext)
@@ -3129,6 +3110,29 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
return NULL;
}
+ if((err=UpdateDeviceParams(device, attrList)) != ALC_NO_ERROR)
+ {
+ UnlockLists();
+
+ al_free(ALContext->Voices);
+ ALContext->Voices = NULL;
+
+ VECTOR_DEINIT(ALContext->ActiveAuxSlots);
+
+ al_free(ALContext);
+ ALContext = NULL;
+
+ alcSetError(device, err);
+ if(err == ALC_INVALID_DEVICE)
+ {
+ V0(device->Backend,lock)();
+ aluHandleDisconnect(device);
+ V0(device->Backend,unlock)();
+ }
+ ALCdevice_DecRef(device);
+ return NULL;
+ }
+
ALContext->Device = device;
ALCdevice_IncRef(device);
InitContext(ALContext);