Return the error code from UpdateDeviceParams

This commit is contained in:
Chris Robinson 2012-01-25 20:00:34 -08:00
parent f87b607a53
commit 3ee92a2b33

View File

@ -1041,7 +1041,7 @@ static void alcSetError(ALCdevice *device, ALCenum errorCode)
* Updates device parameters according to the attribute list (caller is * Updates device parameters according to the attribute list (caller is
* responsible for holding the list lock). * responsible for holding the list lock).
*/ */
static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
{ {
ALCcontext *context; ALCcontext *context;
enum DevFmtChannels oldChans; enum DevFmtChannels oldChans;
@ -1083,10 +1083,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
{ {
ALCint val = attrList[attrIdx + 1]; ALCint val = attrList[attrIdx + 1];
if(!IsValidALCChannels(val) || !ChannelsFromDevFmt(val)) if(!IsValidALCChannels(val) || !ChannelsFromDevFmt(val))
{ return ALC_INVALID_VALUE;
alcSetError(device, ALC_INVALID_VALUE);
return ALC_FALSE;
}
schans = val; schans = val;
gotFmt |= GotChans; gotFmt |= GotChans;
} }
@ -1096,10 +1093,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
{ {
ALCint val = attrList[attrIdx + 1]; ALCint val = attrList[attrIdx + 1];
if(!IsValidALCType(val) || !BytesFromDevFmt(val)) if(!IsValidALCType(val) || !BytesFromDevFmt(val))
{ return ALC_INVALID_VALUE;
alcSetError(device, ALC_INVALID_VALUE);
return ALC_FALSE;
}
stype = val; stype = val;
gotFmt |= GotType; gotFmt |= GotType;
} }
@ -1110,10 +1104,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
{ {
freq = attrList[attrIdx + 1]; freq = attrList[attrIdx + 1];
if(freq < 8000) if(freq < 8000)
{ return ALC_INVALID_VALUE;
alcSetError(device, ALC_INVALID_VALUE);
return ALC_FALSE;
}
gotFmt |= GotFreq; gotFmt |= GotFreq;
} }
else else
@ -1143,8 +1134,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
if(gotFmt != GotAll) if(gotFmt != GotAll)
{ {
WARN("Missing format for loopback device\n"); WARN("Missing format for loopback device\n");
alcSetError(device, ALC_INVALID_VALUE); return ALC_INVALID_VALUE;
return ALC_FALSE;
} }
} }
else else
@ -1167,7 +1157,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
} }
if((device->Flags&DEVICE_RUNNING)) if((device->Flags&DEVICE_RUNNING))
return ALC_TRUE; return ALC_NO_ERROR;
LockDevice(device); LockDevice(device);
@ -1184,7 +1174,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
if(ALCdevice_ResetPlayback(device) == ALC_FALSE) if(ALCdevice_ResetPlayback(device) == ALC_FALSE)
{ {
UnlockDevice(device); UnlockDevice(device);
return ALC_FALSE; return ALC_INVALID_DEVICE;
} }
device->Flags |= DEVICE_RUNNING; device->Flags |= DEVICE_RUNNING;
@ -1276,7 +1266,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
UnlockDevice(device); UnlockDevice(device);
ALCdevice_StopPlayback(device); ALCdevice_StopPlayback(device);
device->Flags &= ~DEVICE_RUNNING; device->Flags &= ~DEVICE_RUNNING;
return ALC_FALSE; return ALC_INVALID_DEVICE;
} }
slot->NeedsUpdate = AL_FALSE; slot->NeedsUpdate = AL_FALSE;
ALeffectState_Update(slot->EffectState, context, slot); ALeffectState_Update(slot->EffectState, context, slot);
@ -1307,7 +1297,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
RestoreFPUMode(oldMode); RestoreFPUMode(oldMode);
UnlockDevice(device); UnlockDevice(device);
return ALC_TRUE; return ALC_NO_ERROR;
} }
/* FreeDevice /* FreeDevice
@ -2208,6 +2198,7 @@ ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *e
ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrList) ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrList)
{ {
ALCcontext *ALContext; ALCcontext *ALContext;
ALCenum err;
LockLists(); LockLists();
if(!(device=VerifyDevice(device)) || device->IsCaptureDevice || !device->Connected) if(!(device=VerifyDevice(device)) || device->IsCaptureDevice || !device->Connected)
@ -2221,11 +2212,12 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
/* Reset Context Last Error code */ /* Reset Context Last Error code */
device->LastError = ALC_NO_ERROR; device->LastError = ALC_NO_ERROR;
if(UpdateDeviceParams(device, attrList) == ALC_FALSE) if((err=UpdateDeviceParams(device, attrList)) != ALC_NO_ERROR)
{ {
UnlockLists(); UnlockLists();
alcSetError(device, ALC_INVALID_DEVICE); alcSetError(device, err);
aluHandleDisconnect(device); if(err == ALC_INVALID_DEVICE)
aluHandleDisconnect(device);
ALCdevice_DecRef(device); ALCdevice_DecRef(device);
return NULL; return NULL;
} }