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

Unified Diff: content/browser/renderer_host/media/audio_input_device_manager.cc

Issue 23731007: Implicit audio output device selection for getUserMedia. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 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 | content/browser/renderer_host/media/audio_input_device_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/audio_input_device_manager.cc
diff --git a/content/browser/renderer_host/media/audio_input_device_manager.cc b/content/browser/renderer_host/media/audio_input_device_manager.cc
index b4959567a3179f1db9c045dbed6f5c9a9bdd0c39..50bb3ec8310507354f76a1af115853951caebf4c 100644
--- a/content/browser/renderer_host/media/audio_input_device_manager.cc
+++ b/content/browser/renderer_host/media/audio_input_device_manager.cc
@@ -34,7 +34,8 @@ AudioInputDeviceManager::AudioInputDeviceManager(
StreamDeviceInfo fake_device(MEDIA_DEVICE_AUDIO_CAPTURE,
media::AudioManagerBase::kDefaultDeviceName,
media::AudioManagerBase::kDefaultDeviceId,
- 44100, media::CHANNEL_LAYOUT_STEREO, false);
+ 44100, media::CHANNEL_LAYOUT_STEREO,
+ 0, false);
fake_device.session_id = kFakeOpenSessionId;
devices_.push_back(fake_device);
}
@@ -169,19 +170,37 @@ void AudioInputDeviceManager::OpenOnDeviceThread(
DCHECK(IsOnDeviceThread());
StreamDeviceInfo out(info.device.type, info.device.name, info.device.id,
- 0, 0, false);
+ 0, 0, 0, false);
out.session_id = session_id;
+
+ MediaStreamDevice::AudioDeviceParameters& input_params = out.device.input;
+
if (use_fake_device_) {
// Don't need to query the hardware information if using fake device.
- out.device.sample_rate = 44100;
- out.device.channel_layout = media::CHANNEL_LAYOUT_STEREO;
+ input_params.sample_rate = 44100;
+ input_params.channel_layout = media::CHANNEL_LAYOUT_STEREO;
} else {
// Get the preferred sample rate and channel configuration for the
// audio device.
media::AudioParameters params =
audio_manager_->GetInputStreamParameters(info.device.id);
- out.device.sample_rate = params.sample_rate();
- out.device.channel_layout = params.channel_layout();
+ input_params.sample_rate = params.sample_rate();
+ input_params.channel_layout = params.channel_layout();
+ input_params.frames_per_buffer = params.frames_per_buffer();
+
+ // Add preferred output device information if a matching output device
+ // exists.
+ out.device.matched_output_device_id =
+ audio_manager_->GetAssociatedOutputDeviceID(info.device.id);
+ if (!out.device.matched_output_device_id.empty()) {
+ params = audio_manager_->GetOutputStreamParameters(
+ out.device.matched_output_device_id);
+ MediaStreamDevice::AudioDeviceParameters& matched_output_params =
+ out.device.matched_output;
+ matched_output_params.sample_rate = params.sample_rate();
+ matched_output_params.channel_layout = params.channel_layout();
+ matched_output_params.frames_per_buffer = params.frames_per_buffer();
+ }
}
// Return the |session_id| through the listener by posting a task on
@@ -206,6 +225,7 @@ void AudioInputDeviceManager::OpenedOnIOThread(int session_id,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK_EQ(session_id, info.session_id);
DCHECK(GetDevice(session_id) == devices_.end());
+
devices_.push_back(info);
if (listener_)
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_device_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698