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

Unified Diff: content/renderer/media/media_stream_audio_processor.cc

Issue 594233002: Strip away the keyboard mic channel if no audio processing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@change_stream_layout_to_kmic
Patch Set: 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: content/renderer/media/media_stream_audio_processor.cc
diff --git a/content/renderer/media/media_stream_audio_processor.cc b/content/renderer/media/media_stream_audio_processor.cc
index ac41187c832214d49f44e0a759d87c07361b6d8e..6dfe6b04e7365114e2ca49b16f19fe5880bf0e8f 100644
--- a/content/renderer/media/media_stream_audio_processor.cc
+++ b/content/renderer/media/media_stream_audio_processor.cc
@@ -227,7 +227,22 @@ void MediaStreamAudioProcessor::PushCaptureData(
const media::AudioBus* audio_source) {
DCHECK(capture_thread_checker_.CalledOnValidThread());
- capture_fifo_->Push(audio_source);
+ // If we don't use audio processing we strip any keyboard mic channel before
+ // putting it in the fifo.
+ if (input_format_.channel_layout() ==
no longer working on chromium 2014/09/24 12:41:27 you should move these code to MediaStreamAudioFifo
Henrik Grunell 2014/09/24 20:01:29 Yep, but I need the additional info about layout a
Henrik Grunell 2014/09/26 10:04:27 Changed to what I proposed offline: take source an
+ media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC &&
+ !audio_processing_) {
+ scoped_ptr<media::AudioBus> audio_source_stereo =
no longer working on chromium 2014/09/24 12:41:27 use a member in MediaStreamAudioFifo, and set it u
Henrik Grunell 2014/09/26 10:04:27 Done.
+ media::AudioBus::CreateWrapper(2);
+ audio_source_stereo->SetChannelData(
+ 0, const_cast<float*>(audio_source->channel(0)));
+ audio_source_stereo->SetChannelData(
+ 1, const_cast<float*>(audio_source->channel(1)));
+ audio_source_stereo->set_frames(audio_source->frames());
+ capture_fifo_->Push(audio_source_stereo.get());
+ } else {
+ capture_fifo_->Push(audio_source);
+ }
}
bool MediaStreamAudioProcessor::ProcessAndConsumeData(
@@ -466,7 +481,7 @@ void MediaStreamAudioProcessor::InitializeCaptureFifo(
// format it would prefer.
const int output_sample_rate = audio_processing_ ?
kAudioProcessingSampleRate : input_format.sample_rate();
- const media::ChannelLayout output_channel_layout = audio_processing_ ?
+ media::ChannelLayout output_channel_layout = audio_processing_ ?
media::GuessChannelLayout(kAudioProcessingNumberOfChannels) :
input_format.channel_layout();
no longer working on chromium 2014/09/24 12:41:27 can the output_channel_layout be media::CHANNEL_LA
Henrik Grunell 2014/09/24 20:01:29 No.
@@ -487,6 +502,19 @@ void MediaStreamAudioProcessor::InitializeCaptureFifo(
output_frames = processing_frames;
}
+ int capture_fifo_channels = input_format.channels();
+
+ // Special cases for if we have a keyboard mic channel on the input and no
+ // audio processing is used. We will then strip away that channel before
+ // putting it in the fifo. We keep the layout in |input_format_| since that's
+ // what we expect as input to this class.
+ if (input_format.channel_layout() ==
+ media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC &&
+ !audio_processing_) {
+ capture_fifo_channels = 2;
+ output_channel_layout = media::CHANNEL_LAYOUT_STEREO;
+ }
+
output_format_ = media::AudioParameters(
media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
output_channel_layout,
@@ -495,7 +523,7 @@ void MediaStreamAudioProcessor::InitializeCaptureFifo(
output_frames);
capture_fifo_.reset(
- new MediaStreamAudioFifo(input_format.channels(),
+ new MediaStreamAudioFifo(capture_fifo_channels,
no longer working on chromium 2014/09/24 12:41:27 how about modify MediaStreamAudioFifo constructor
Henrik Grunell 2014/09/24 20:01:29 Yes, but the fifo would need to know about the lay
input_format.frames_per_buffer(),
processing_frames));
« 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