diff options
author | agoode <agoode@chromium.org> | 2015-06-08 09:55:04 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-08 16:55:25 +0000 |
commit | c82a9b30c769a37a9343a2e26c3b3ab423da7f37 (patch) | |
tree | 2dbfe9c31fd1c7ce0c5be0ac64878bfa822c4353 /media | |
parent | cfcbd6e133a4cc61375d476c20042f6d24b0690c (diff) | |
download | chromium_src-c82a9b30c769a37a9343a2e26c3b3ab423da7f37.zip chromium_src-c82a9b30c769a37a9343a2e26c3b3ab423da7f37.tar.gz chromium_src-c82a9b30c769a37a9343a2e26c3b3ab423da7f37.tar.bz2 |
Use proper channel map for PulseAudio in the CHANNEL_LAYOUT_MONO case
Prior to this change, PulseAudio would only output on the center channel for multichannel audio setups. See ChannelLayoutToChannelConfig in media/audio/win/core_audio_util_win.cc for the analogous code on Windows.
The function added to media/audio/pulse/pulse.sigs has been in pulseaudio since at least 2006 (confirmed by git blame).
BUG=453876
Review URL: https://codereview.chromium.org/1164813005
Cr-Commit-Position: refs/heads/master@{#333279}
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/pulse/pulse.sigs | 1 | ||||
-rw-r--r-- | media/audio/pulse/pulse_util.cc | 26 |
2 files changed, 17 insertions, 10 deletions
diff --git a/media/audio/pulse/pulse.sigs b/media/audio/pulse/pulse.sigs index b9c8088..522efcb 100644 --- a/media/audio/pulse/pulse.sigs +++ b/media/audio/pulse/pulse.sigs @@ -16,6 +16,7 @@ void pa_threaded_mainloop_stop(pa_threaded_mainloop* m); void pa_threaded_mainloop_unlock(pa_threaded_mainloop* m); void pa_threaded_mainloop_wait(pa_threaded_mainloop* m); pa_channel_map* pa_channel_map_init(pa_channel_map* m); +pa_channel_map* pa_channel_map_init_mono(pa_channel_map* m); int pa_context_connect(pa_context* c, const char* server, pa_context_flags_t flags, const pa_spawn_api* api); void pa_context_disconnect(pa_context* c); pa_operation* pa_context_get_server_info(pa_context* c, pa_server_info_cb_t cb, void* userdata); diff --git a/media/audio/pulse/pulse_util.cc b/media/audio/pulse/pulse_util.cc index 7e579d5..ee37c03 100644 --- a/media/audio/pulse/pulse_util.cc +++ b/media/audio/pulse/pulse_util.cc @@ -99,16 +99,22 @@ pa_sample_format_t BitsToPASampleFormat(int bits_per_sample) { pa_channel_map ChannelLayoutToPAChannelMap(ChannelLayout channel_layout) { pa_channel_map channel_map; - pa_channel_map_init(&channel_map); - - channel_map.channels = ChannelLayoutToChannelCount(channel_layout); - for (Channels ch = LEFT; ch <= CHANNELS_MAX; - ch = static_cast<Channels>(ch + 1)) { - int channel_index = ChannelOrder(channel_layout, ch); - if (channel_index < 0) - continue; - - channel_map.map[channel_index] = ChromiumToPAChannelPosition(ch); + if (channel_layout == CHANNEL_LAYOUT_MONO) { + // CHANNEL_LAYOUT_MONO only specifies audio on the C channel, but we + // want PulseAudio to play single-channel audio on more than just that. + pa_channel_map_init_mono(&channel_map); + } else { + pa_channel_map_init(&channel_map); + + channel_map.channels = ChannelLayoutToChannelCount(channel_layout); + for (Channels ch = LEFT; ch <= CHANNELS_MAX; + ch = static_cast<Channels>(ch + 1)) { + int channel_index = ChannelOrder(channel_layout, ch); + if (channel_index < 0) + continue; + + channel_map.map[channel_index] = ChromiumToPAChannelPosition(ch); + } } return channel_map; |