From 1778c0d7d8c6b71e00bef227bf10b503707c0e3a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 28 May 2011 21:37:33 -0700 Subject: Get the device format directly from the string --- Alc/ALc.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 114 insertions(+), 29 deletions(-) (limited to 'Alc/ALc.c') diff --git a/Alc/ALc.c b/Alc/ALc.c index c03c5cc4..cc8f1091 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -2310,31 +2310,122 @@ void SetDefaultWFXChannelOrder(ALCdevice *device) } } -static ALenum GetFormatFromString(const char *str) +static void GetFormatFromString(const char *str, enum DevFmtChannels *chans, enum DevFmtType *type) { - if(strcasecmp(str, "AL_FORMAT_MONO32") == 0) return AL_FORMAT_MONO_FLOAT32; - if(strcasecmp(str, "AL_FORMAT_STEREO32") == 0) return AL_FORMAT_STEREO_FLOAT32; - if(strcasecmp(str, "AL_FORMAT_QUAD32") == 0) return AL_FORMAT_QUAD32; - if(strcasecmp(str, "AL_FORMAT_51CHN32") == 0) return AL_FORMAT_51CHN32; - if(strcasecmp(str, "AL_FORMAT_61CHN32") == 0) return AL_FORMAT_61CHN32; - if(strcasecmp(str, "AL_FORMAT_71CHN32") == 0) return AL_FORMAT_71CHN32; - - if(strcasecmp(str, "AL_FORMAT_MONO16") == 0) return AL_FORMAT_MONO16; - if(strcasecmp(str, "AL_FORMAT_STEREO16") == 0) return AL_FORMAT_STEREO16; - if(strcasecmp(str, "AL_FORMAT_QUAD16") == 0) return AL_FORMAT_QUAD16; - if(strcasecmp(str, "AL_FORMAT_51CHN16") == 0) return AL_FORMAT_51CHN16; - if(strcasecmp(str, "AL_FORMAT_61CHN16") == 0) return AL_FORMAT_61CHN16; - if(strcasecmp(str, "AL_FORMAT_71CHN16") == 0) return AL_FORMAT_71CHN16; - - if(strcasecmp(str, "AL_FORMAT_MONO8") == 0) return AL_FORMAT_MONO8; - if(strcasecmp(str, "AL_FORMAT_STEREO8") == 0) return AL_FORMAT_STEREO8; - if(strcasecmp(str, "AL_FORMAT_QUAD8") == 0) return AL_FORMAT_QUAD8; - if(strcasecmp(str, "AL_FORMAT_51CHN8") == 0) return AL_FORMAT_51CHN8; - if(strcasecmp(str, "AL_FORMAT_61CHN8") == 0) return AL_FORMAT_61CHN8; - if(strcasecmp(str, "AL_FORMAT_71CHN8") == 0) return AL_FORMAT_71CHN8; + if(strcasecmp(str, "AL_FORMAT_MONO32") == 0) + { + *chans = DevFmtMono; + *type = DevFmtFloat; + return; + } + if(strcasecmp(str, "AL_FORMAT_STEREO32") == 0) + { + *chans = DevFmtStereo; + *type = DevFmtFloat; + return; + } + if(strcasecmp(str, "AL_FORMAT_QUAD32") == 0) + { + *chans = DevFmtQuad; + *type = DevFmtFloat; + return; + } + if(strcasecmp(str, "AL_FORMAT_51CHN32") == 0) + { + *chans = DevFmtX51; + *type = DevFmtFloat; + return; + } + if(strcasecmp(str, "AL_FORMAT_61CHN32") == 0) + { + *chans = DevFmtX61; + *type = DevFmtFloat; + return; + } + if(strcasecmp(str, "AL_FORMAT_71CHN32") == 0) + { + *chans = DevFmtX71; + *type = DevFmtFloat; + return; + } + + if(strcasecmp(str, "AL_FORMAT_MONO16") == 0) + { + *chans = DevFmtMono; + *type = DevFmtShort; + return; + } + if(strcasecmp(str, "AL_FORMAT_STEREO16") == 0) + { + *chans = DevFmtStereo; + *type = DevFmtShort; + return; + } + if(strcasecmp(str, "AL_FORMAT_QUAD16") == 0) + { + *chans = DevFmtQuad; + *type = DevFmtShort; + return; + } + if(strcasecmp(str, "AL_FORMAT_51CHN16") == 0) + { + *chans = DevFmtX51; + *type = DevFmtShort; + return; + } + if(strcasecmp(str, "AL_FORMAT_61CHN16") == 0) + { + *chans = DevFmtX61; + *type = DevFmtShort; + return; + } + if(strcasecmp(str, "AL_FORMAT_71CHN16") == 0) + { + *chans = DevFmtX71; + *type = DevFmtShort; + return; + } + + if(strcasecmp(str, "AL_FORMAT_MONO8") == 0) + { + *chans = DevFmtMono; + *type = DevFmtByte; + return; + } + if(strcasecmp(str, "AL_FORMAT_STEREO8") == 0) + { + *chans = DevFmtStereo; + *type = DevFmtByte; + return; + } + if(strcasecmp(str, "AL_FORMAT_QUAD8") == 0) + { + *chans = DevFmtQuad; + *type = DevFmtByte; + return; + } + if(strcasecmp(str, "AL_FORMAT_51CHN8") == 0) + { + *chans = DevFmtX51; + *type = DevFmtByte; + return; + } + if(strcasecmp(str, "AL_FORMAT_61CHN8") == 0) + { + *chans = DevFmtX61; + *type = DevFmtByte; + return; + } + if(strcasecmp(str, "AL_FORMAT_71CHN8") == 0) + { + *chans = DevFmtX71; + *type = DevFmtByte; + return; + } AL_PRINT("Unknown format: \"%s\"\n", str); - return AL_FORMAT_STEREO16; + *chans = DevFmtStereo; + *type = DevFmtShort; } /* @@ -2387,13 +2478,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) if(ConfigValueExists(NULL, "format")) device->Flags |= DEVICE_CHANNELS_REQUEST; fmt = GetConfigValue(NULL, "format", "AL_FORMAT_STEREO16"); - if(DecomposeDevFormat(GetFormatFromString(fmt), - &device->FmtChans, &device->FmtType) == AL_FALSE) - { - /* Should never happen... */ - device->FmtChans = DevFmtStereo; - device->FmtType = DevFmtShort; - } + GetFormatFromString(fmt, &device->FmtChans, &device->FmtType); device->NumUpdates = GetConfigValueInt(NULL, "periods", 4); if(device->NumUpdates < 2) -- cgit v1.2.3