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

Unified Diff: content/browser/renderer_host/media/audio_renderer_host.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
Index: content/browser/renderer_host/media/audio_renderer_host.cc
diff --git a/content/browser/renderer_host/media/audio_renderer_host.cc b/content/browser/renderer_host/media/audio_renderer_host.cc
index 1e1065aca5e225a3d75ca4f006553ece32771cff..c09dc6ce08b00df873adee71e86cd47da72099c3 100644
--- a/content/browser/renderer_host/media/audio_renderer_host.cc
+++ b/content/browser/renderer_host/media/audio_renderer_host.cc
@@ -36,6 +36,7 @@ class AudioRendererHost::AudioEntry
int stream_id,
int render_view_id,
const media::AudioParameters& params,
+ const std::string& output_device_id,
const std::string& input_device_id,
scoped_ptr<base::SharedMemory> shared_memory,
scoped_ptr<media::AudioOutputController::SyncReader> reader);
@@ -88,6 +89,7 @@ class AudioRendererHost::AudioEntry
AudioRendererHost::AudioEntry::AudioEntry(
AudioRendererHost* host, int stream_id, int render_view_id,
const media::AudioParameters& params,
+ const std::string& output_device_id,
const std::string& input_device_id,
scoped_ptr<base::SharedMemory> shared_memory,
scoped_ptr<media::AudioOutputController::SyncReader> reader)
@@ -95,8 +97,7 @@ AudioRendererHost::AudioEntry::AudioEntry(
stream_id_(stream_id),
render_view_id_(render_view_id),
controller_(media::AudioOutputController::Create(
- // TODO(tommi): Feed in the proper output device id.
- host->audio_manager_, this, params, std::string(),
+ host->audio_manager_, this, params, output_device_id,
input_device_id, reader.get())),
shared_memory_(shared_memory.Pass()),
reader_(reader.Pass()) {
@@ -303,10 +304,16 @@ void AudioRendererHost::OnCreateStream(
// When the |input_channels| is valid, clients are trying to create a unified
// IO stream which opens an input device mapping to the |session_id|.
- std::string input_device_id;
+ // Initialize the |output_device_id| to an empty string which indicates that
+ // the default device should be used. If a StreamDeviceInfo instance was found
+ // though, then we use the matched output device.
+ std::string input_device_id, output_device_id;
+ const StreamDeviceInfo* info = media_stream_manager_->
+ audio_input_device_manager()->GetOpenedDeviceInfoById(session_id);
+ if (info)
+ output_device_id = info->device.matched_output_device_id;
+
if (input_channels > 0) {
- const StreamDeviceInfo* info = media_stream_manager_->
- audio_input_device_manager()->GetOpenedDeviceInfoById(session_id);
if (!info) {
SendErrorMessage(stream_id);
DLOG(WARNING) << "No permission has been granted to input stream with "
@@ -348,8 +355,8 @@ void AudioRendererHost::OnCreateStream(
media_observer->OnCreatingAudioStream(render_process_id_, render_view_id);
scoped_ptr<AudioEntry> entry(new AudioEntry(
- this, stream_id, render_view_id, params, input_device_id,
- shared_memory.Pass(),
+ this, stream_id, render_view_id, params, output_device_id,
+ input_device_id, shared_memory.Pass(),
reader.PassAs<media::AudioOutputController::SyncReader>()));
if (mirroring_manager_) {
mirroring_manager_->AddDiverter(

Powered by Google App Engine
This is Rietveld 408576698