diff options
author | Chris Robinson <[email protected]> | 2015-09-04 21:43:50 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-09-04 23:59:24 -0700 |
commit | 703f1fdec2215200bde774a6328522f5516f0b2b (patch) | |
tree | 3c5d837d956c26aef910cf8ed4a6d68ebff10ff8 /Alc/backends | |
parent | 28a516e8a51ee6a69a2a49b01d54b62bffd9bb43 (diff) |
Specify the pa_channel_map directly instead of through a string
Diffstat (limited to 'Alc/backends')
-rw-r--r-- | Alc/backends/pulseaudio.c | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index 6130a150..ffbf04b2 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -650,26 +650,44 @@ static void ALCpulsePlayback_streamWriteCallback(pa_stream* UNUSED(p), size_t UN static void ALCpulsePlayback_sinkInfoCallback(pa_context *UNUSED(context), const pa_sink_info *info, int eol, void *pdata) { - ALCpulsePlayback *self = pdata; - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; - const struct { - const char *str; + static const struct { enum DevFmtChannels chans; + pa_channel_map map; } chanmaps[] = { - { "front-left,front-right,front-center,lfe,rear-left,rear-right,side-left,side-right", - DevFmtX71 }, - { "front-left,front-right,front-center,lfe,rear-center,side-left,side-right", - DevFmtX61 }, - { "front-left,front-right,front-center,lfe,side-left,side-right", - DevFmtX51 }, - { "front-left,front-right,front-center,lfe,rear-left,rear-right", - DevFmtX51Rear }, - { "front-left,front-right,rear-left,rear-right", DevFmtQuad }, - { "front-left,front-right", DevFmtStereo }, - { "mono", DevFmtMono }, - { NULL, 0 } + { DevFmtX71, { 8, { + PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE, + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT, + PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT + } } }, + { DevFmtX61, { 7, { + PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE, + PA_CHANNEL_POSITION_REAR_CENTER, + PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT + } } }, + { DevFmtX51, { 6, { + PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE, + PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT + } } }, + { DevFmtX51Rear, { 6, { + PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE, + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT + } } }, + { DevFmtQuad, { 4, { + PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT + } } }, + { DevFmtStereo, { 2, { + PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT + } } }, + { DevFmtMono, { 1, {PA_CHANNEL_POSITION_MONO} } } }; - int i; + ALCpulsePlayback *self = pdata; + ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + size_t i; if(eol) { @@ -677,32 +695,27 @@ static void ALCpulsePlayback_sinkInfoCallback(pa_context *UNUSED(context), const return; } - for(i = 0;chanmaps[i].str;i++) + for(i = 0;i < COUNTOF(chanmaps);i++) { - pa_channel_map map; - if(!pa_channel_map_parse(&map, chanmaps[i].str)) - continue; - - if(pa_channel_map_superset(&info->channel_map, &map)) + if(pa_channel_map_superset(&info->channel_map, &chanmaps[i].map)) { if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) device->FmtChans = chanmaps[i].chans; break; } } + if(i == COUNTOF(chanmaps)) + { + char chanmap_str[PA_CHANNEL_MAP_SNPRINT_MAX] = ""; + pa_channel_map_snprint(chanmap_str, sizeof(chanmap_str), &info->channel_map); + WARN("Failed to find format for channel map:\n %s\n", chanmap_str); + } if(info->active_port) TRACE("Active port: %s (%s)\n", info->active_port->name, info->active_port->description); device->IsHeadphones = (info->active_port && strcmp(info->active_port->name, "analog-output-headphones") == 0 && device->FmtChans == DevFmtStereo); - - if(!chanmaps[i].str) - { - char chanmap_str[PA_CHANNEL_MAP_SNPRINT_MAX] = ""; - pa_channel_map_snprint(chanmap_str, sizeof(chanmap_str), &info->channel_map); - WARN("Failed to find format for channel map:\n %s\n", chanmap_str); - } } static void ALCpulsePlayback_sinkNameCallback(pa_context *UNUSED(context), const pa_sink_info *info, int eol, void *pdata) |