summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-09 21:33:18 -0700
committerChris Robinson <[email protected]>2011-09-09 21:33:18 -0700
commit477215883fe48ff86b5c09cfa8670fe5ade99419 (patch)
treebdd7b6c7b168a0c8afb2e5d93506ef0d3c926621 /Alc
parent05114815baed650eb2f6930456c6fe3762f30cd7 (diff)
Use an array to get the device format from the user config string
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c145
1 files changed, 36 insertions, 109 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 627cc8c8..339b5907 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2281,115 +2281,42 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
static void GetFormatFromString(const char *str, enum DevFmtChannels *chans, enum DevFmtType *type)
{
- 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;
+ static const struct {
+ const char name[32];
+ enum DevFmtChannels channels;
+ enum DevFmtType type;
+ } formats[] = {
+ { "AL_FORMAT_MONO32", DevFmtMono, DevFmtFloat },
+ { "AL_FORMAT_STEREO32", DevFmtStereo, DevFmtFloat },
+ { "AL_FORMAT_QUAD32", DevFmtQuad, DevFmtFloat },
+ { "AL_FORMAT_51CHN32", DevFmtX51, DevFmtFloat },
+ { "AL_FORMAT_61CHN32", DevFmtX61, DevFmtFloat },
+ { "AL_FORMAT_71CHN32", DevFmtX71, DevFmtFloat },
+
+ { "AL_FORMAT_MONO16", DevFmtMono, DevFmtShort },
+ { "AL_FORMAT_STEREO16", DevFmtStereo, DevFmtShort },
+ { "AL_FORMAT_QUAD16", DevFmtQuad, DevFmtShort },
+ { "AL_FORMAT_51CHN16", DevFmtX51, DevFmtShort },
+ { "AL_FORMAT_61CHN16", DevFmtX61, DevFmtShort },
+ { "AL_FORMAT_71CHN16", DevFmtX71, DevFmtShort },
+
+ { "AL_FORMAT_MONO8", DevFmtMono, DevFmtByte },
+ { "AL_FORMAT_STEREO8", DevFmtStereo, DevFmtByte },
+ { "AL_FORMAT_QUAD8", DevFmtQuad, DevFmtByte },
+ { "AL_FORMAT_51CHN8", DevFmtX51, DevFmtByte },
+ { "AL_FORMAT_61CHN8", DevFmtX61, DevFmtByte },
+ { "AL_FORMAT_71CHN8", DevFmtX71, DevFmtByte }
+ };
+ size_t i;
+
+ for(i = 0;i < sizeof(formats)/sizeof(formats[0]);i++)
+ {
+ if(strcasecmp(str, formats[i].name) == 0)
+ {
+ *chans = formats[i].channels;
+ *type = formats[i].type;
+ return;
+ }
}
ERR("Unknown format: \"%s\"\n", str);