summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhychao@chromium.org <hychao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-30 00:19:21 +0000
committerhychao@chromium.org <hychao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-30 00:19:21 +0000
commit45d5d8187e18346f5ee208fbdc189b27e5450a5b (patch)
tree802aa8df869c6e49c2a48b7ce86929586451b605
parentf93857bd62ee013686a18f55c83fc6dfc11e5f9a (diff)
downloadchromium_src-45d5d8187e18346f5ee208fbdc189b27e5450a5b.zip
chromium_src-45d5d8187e18346f5ee208fbdc189b27e5450a5b.tar.gz
chromium_src-45d5d8187e18346f5ee208fbdc189b27e5450a5b.tar.bz2
cras_unified: set channel layout
Convert the channel layout value and set to created cras_audio_format. This will allow CRAS to do correct down mix and channel mapping. BUG=214597 TEST=Build and deploy Chrome to Pixel, add debug log to CRAS, play a 6-channel .wav file to verify the channel_layout is set. Review URL: https://codereview.chromium.org/32543002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231677 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/audio/cras/cras_unified.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/media/audio/cras/cras_unified.cc b/media/audio/cras/cras_unified.cc
index fe2c7b0..906f209 100644
--- a/media/audio/cras/cras_unified.cc
+++ b/media/audio/cras/cras_unified.cc
@@ -161,6 +161,23 @@ void CrasUnifiedStream::Close() {
void CrasUnifiedStream::Start(AudioSourceCallback* callback) {
CHECK(callback);
+
+ // Channel map to CRAS_CHANNEL, values in the same order of
+ // corresponding source in Chromium defined Channels.
+ static const int kChannelMap[] = {
+ CRAS_CH_FL,
+ CRAS_CH_FR,
+ CRAS_CH_FC,
+ CRAS_CH_LFE,
+ CRAS_CH_RL,
+ CRAS_CH_RR,
+ CRAS_CH_FLC,
+ CRAS_CH_FRC,
+ CRAS_CH_RC,
+ CRAS_CH_SL,
+ CRAS_CH_SR
+ };
+
source_callback_ = callback;
// Only start if we can enter the playing state.
@@ -179,6 +196,22 @@ void CrasUnifiedStream::Start(AudioSourceCallback* callback) {
return;
}
+ // Initialize channel layout to all -1 to indicate that none of
+ // the channels is set in the layout.
+ int8 layout[CRAS_CH_MAX] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
+
+ // Converts to CRAS defined channels. ChannelOrder will return -1
+ // for channels that does not present in params_.channel_layout().
+ for (size_t i = 0; i < arraysize(kChannelMap); ++i)
+ layout[kChannelMap[i]] = ChannelOrder(params_.channel_layout(),
+ static_cast<Channels>(i));
+
+ if (cras_audio_format_set_channel_layout(audio_format, layout)) {
+ LOG(WARNING) << "Error setting channel layout.";
+ callback->OnError(this);
+ return;
+ }
+
cras_stream_params* stream_params = cras_client_unified_params_create(
stream_direction_,
params_.frames_per_buffer(),