diff options
author | Chris Robinson <[email protected]> | 2011-07-02 02:51:33 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-07-02 02:51:33 -0700 |
commit | 14bfe0293a94c240be5b8c23998af6a6b8bbea20 (patch) | |
tree | bb1cfe76c9a7ab683db8b2a2fd1ba5dd7933a552 | |
parent | 931d422443758062b9622b84782c8b2194ba6b51 (diff) |
Use separate functions to find valid ALC loopback device formats
-rw-r--r-- | Alc/ALc.c | 47 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 4 |
2 files changed, 39 insertions, 12 deletions
@@ -1001,6 +1001,38 @@ ALboolean DecomposeDevFormat(ALenum format, enum DevFmtChannels *chans, return AL_FALSE; } +static ALCboolean IsValidALCType(ALCenum type) +{ + switch(type) + { + case ALC_BYTE: + case ALC_UNSIGNED_BYTE: + case ALC_SHORT: + case ALC_UNSIGNED_SHORT: + case ALC_INT: + case ALC_UNSIGNED_INT: + case ALC_FLOAT: + return ALC_TRUE; + } + return ALC_FALSE; +} + +static ALCboolean IsValidALCChannels(ALCenum channels) +{ + switch(channels) + { + case ALC_MONO: + case ALC_STEREO: + case ALC_QUAD: + case ALC_5POINT1: + case ALC_6POINT1: + case ALC_7POINT1: + return ALC_TRUE; + } + return ALC_FALSE; +} + + ALboolean IsValidType(ALenum type) { switch(type) @@ -1261,7 +1293,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->IsLoopbackDevice) { ALCint val = attrList[attrIdx + 1]; - if(!IsValidChannels(val) || !ChannelsFromDevFmt(val)) + if(!IsValidALCChannels(val) || !ChannelsFromDevFmt(val)) { alcSetError(device, ALC_INVALID_VALUE); return ALC_FALSE; @@ -1273,7 +1305,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->IsLoopbackDevice) { ALCint val = attrList[attrIdx + 1]; - if(!IsValidType(val) || !BytesFromDevFmt(val)) + if(!IsValidALCType(val) || !BytesFromDevFmt(val)) { alcSetError(device, ALC_INVALID_VALUE); return ALC_FALSE; @@ -2841,7 +2873,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(void) return device; } -ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALenum channels, ALenum type) +ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type) { ALCboolean ret = ALC_FALSE; @@ -2850,16 +2882,11 @@ ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device alcSetError(device, ALC_INVALID_DEVICE); else if(freq <= 0) alcSetError(device, ALC_INVALID_VALUE); - else if(IsValidType(type) == AL_FALSE || - IsValidChannels(channels) == AL_FALSE) + else if(!IsValidALCType(type) || !IsValidALCChannels(channels)) alcSetError(device, ALC_INVALID_ENUM); else { - if((type == DevFmtByte || type == DevFmtUByte || type == DevFmtShort || - type == DevFmtUShort || type == DevFmtFloat) && - (channels == DevFmtMono || channels == DevFmtStereo || - channels == DevFmtQuad || channels == DevFmtX51 || - channels == DevFmtX61 || channels == DevFmtX71) && + if(BytesFromDevFmt(type) > 0 && ChannelsFromDevFmt(channels) > 0 && freq >= 8000) ret = ALC_TRUE; } diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index c6de6f0f..ff1b3d4f 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -36,11 +36,11 @@ #define ALC_7POINT1 0x1506 /* (WFX order) */ typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(void); -typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice *device, ALCsizei freq, ALenum channels, ALenum type); +typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type); typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); #ifdef AL_ALEXT_PROTOTYPES ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(void); -ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALenum channels, ALenum type); +ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type); ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); #endif #endif |