diff options
author | Chris Robinson <[email protected]> | 2012-02-15 15:22:44 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-02-15 15:22:44 -0800 |
commit | 9afd6b28586150a6c55f63c85ee3ba60e24f9076 (patch) | |
tree | b7a9334d674b5052b66640eb541ee4015b81a344 | |
parent | 670c88a64c87c23a505d941ea7e72785918d304c (diff) |
Separate the format config option into channels and sample-type
-rw-r--r-- | Alc/ALc.c | 153 | ||||
-rw-r--r-- | alsoftrc.sample | 38 |
2 files changed, 119 insertions, 72 deletions
@@ -2392,51 +2392,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *Context) } -static void GetFormatFromString(const char *str, enum DevFmtChannels *chans, enum DevFmtType *type) -{ - 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); - *chans = DevFmtStereo; - *type = DevFmtShort; -} - /* alcOpenDevice * * Open the Device specified. @@ -2490,10 +2445,111 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) InitUIntMap(&device->FilterMap, ~0); //Set output format + device->FmtChans = DevFmtStereo; + device->FmtType = DevFmtFloat; + device->Frequency = DEFAULT_OUTPUT_RATE; device->NumUpdates = 4; device->UpdateSize = 1024; - device->Frequency = DEFAULT_OUTPUT_RATE; + if(ConfigValueStr(NULL, "format", &fmt)) + { + 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(fmt, formats[i].name) == 0) + { + if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) + device->FmtChans = formats[i].channels; + device->FmtType = formats[i].type; + device->Flags |= DEVICE_CHANNELS_REQUEST; + break; + } + } + if(i == sizeof(formats)/sizeof(formats[0])) + ERR("Unsupported format: %s\n", fmt); + } + if(ConfigValueStr(NULL, "channels", &fmt)) + { + static const struct { + const char name[16]; + enum DevFmtChannels chans; + } chanlist[] = { + { "mono", DevFmtMono }, + { "stereo", DevFmtStereo }, + { "quad", DevFmtQuad }, + { "surround51", DevFmtX51 }, + { "surround61", DevFmtX61 }, + { "surround71", DevFmtX71 }, + }; + size_t i; + + for(i = 0;i < sizeof(chanlist)/sizeof(chanlist[0]);i++) + { + if(strcasecmp(chanlist[i].name, fmt) == 0) + { + device->FmtChans = chanlist[i].chans; + device->Flags |= DEVICE_CHANNELS_REQUEST; + break; + } + } + if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) + ERR("Unsupported channels: %s\n", fmt); + } + if(ConfigValueStr(NULL, "sample-type", &fmt)) + { + static const struct { + const char name[16]; + enum DevFmtType type; + } chanlist[] = { + { "int8", DevFmtByte }, + { "uint8", DevFmtUByte }, + { "int16", DevFmtShort }, + { "uint16", DevFmtUShort }, + { "int32", DevFmtInt }, + { "uint32", DevFmtUInt }, + { "float32", DevFmtFloat }, + }; + size_t i; + + for(i = 0;i < sizeof(chanlist)/sizeof(chanlist[0]);i++) + { + if(strcasecmp(chanlist[i].name, fmt) == 0) + { + device->FmtType = chanlist[i].type; + break; + } + } + if(i == sizeof(chanlist)/sizeof(chanlist[0])) + ERR("Unsupported sample-type: %s\n", fmt); + } + if(ConfigValueUInt(NULL, "frequency", &device->Frequency)) { device->Flags |= DEVICE_FREQUENCY_REQUEST; @@ -2502,11 +2558,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->Frequency = maxu(device->Frequency, MIN_OUTPUT_RATE); } - fmt = "AL_FORMAT_STEREO32"; - if(ConfigValueStr(NULL, "format", &fmt)) - device->Flags |= DEVICE_CHANNELS_REQUEST; - GetFormatFromString(fmt, &device->FmtChans, &device->FmtType); - ConfigValueUInt(NULL, "periods", &device->NumUpdates); if(device->NumUpdates < 2) device->NumUpdates = 4; diff --git a/alsoftrc.sample b/alsoftrc.sample index 51603f9f..0f3ceb59 100644 --- a/alsoftrc.sample +++ b/alsoftrc.sample @@ -13,27 +13,23 @@ # possible). Note: options that are left unset may default to app- or system- # specified values. These are the current available settings: -## format: -# Sets the output format. Can be one of: -# AL_FORMAT_MONO8 (8-bit mono) -# AL_FORMAT_STEREO8 (8-bit stereo) -# AL_FORMAT_QUAD8 (8-bit 4-channel) -# AL_FORMAT_51CHN8 (8-bit 5.1 output) -# AL_FORMAT_61CHN8 (8-bit 6.1 output) -# AL_FORMAT_71CHN8 (8-bit 7.1 output) -# AL_FORMAT_MONO16 (16-bit mono) -# AL_FORMAT_STEREO16 (16-bit stereo) -# AL_FORMAT_QUAD16 (16-bit 4-channel) -# AL_FORMAT_51CHN16 (16-bit 5.1 output) -# AL_FORMAT_61CHN16 (16-bit 6.1 output) -# AL_FORMAT_71CHN16 (16-bit 7.1 output) -# AL_FORMAT_MONO32 (32-bit float mono) -# AL_FORMAT_STEREO32 (32-bit float stereo) -# AL_FORMAT_QUAD32 (32-bit float 4-channel) -# AL_FORMAT_51CHN32 (32-bit float 5.1 output) -# AL_FORMAT_61CHN32 (32-bit float 6.1 output) -# AL_FORMAT_71CHN32 (32-bit float 7.1 output) -#format = AL_FORMAT_STEREO32 +## channels: +# Sets the output channel configuration. If left unspecified, one will try to +# be detected from the system, and defaulting to stereo. The available values +# are: mono, stereo, quad, surround51, surround61, surround71 +#channels = stereo + +## sample-type: +# Sets the output sample type. Currently, all mixing is done with 32-bit float +# and converted to the output sample type as needed. Available values are: +# int8 - signed 8-bit int +# uint8 - unsigned 8-bit int +# int16 - signed 16-bit int +# uint16 - unsigned 16-bit int +# int32 - signed 32-bit int +# uint32 - unsigned 32-bit int +# float32 - 32-bit float +#sample-type = float32 ## hrtf: # Enables HRTF filters. These filters provide for better sound spatialization |