Chromium Code Reviews| 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_, |