Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: media/audio/cras/cras_input.cc

Issue 531523002: Convert channel layout for cras_input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment to channel conversion Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/cras/cras_input.cc
diff --git a/media/audio/cras/cras_input.cc b/media/audio/cras/cras_input.cc
index afdabb21d1feb5a8fe50c419aca0952138b841c7..ec90bed8e831019f82ba705b859b8c5530b3e04d 100644
--- a/media/audio/cras/cras_input.cc
+++ b/media/audio/cras/cras_input.cc
@@ -102,6 +102,22 @@ void CrasInputStream::Start(AudioInputCallback* callback) {
DCHECK(client_);
DCHECK(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
+ };
+
// If already playing, stop before re-starting.
if (started_)
return;
@@ -123,6 +139,23 @@ void CrasInputStream::Start(AudioInputCallback* callback) {
return;
}
+ // Inivialize channel layout to all -1 to indicate that non of
dgreid 2014/09/02 16:07:27 none
+ // the channels is set in the layout.
+ int8 layout[CRAS_CH_MAX];
+ for (size_t i = 0; i < CRAS_CH_MAX; i++)
+ layout[i] = -1;
+
+ // Converts to CRAS defined channels. ChannelOrder will return -1
+ // for channels that does not present in params_.channel_layout().
dgreid 2014/09/02 16:07:27 s/does/are/
+ 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;
+ }
+
unsigned int frames_per_packet = params_.frames_per_buffer();
cras_stream_params* stream_params = cras_client_stream_params_create(
stream_direction_,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698