summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-03 11:09:05 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-03 11:09:05 +0000
commit2372e96427d128a67ada47547bd1826276a0e62a (patch)
tree7b19533629dc2188b186e14a54f592168d994df7 /content/renderer
parentc5ab76dfd2e6fd9e84f67e7223fa5dad80919853 (diff)
downloadchromium_src-2372e96427d128a67ada47547bd1826276a0e62a.zip
chromium_src-2372e96427d128a67ada47547bd1826276a0e62a.tar.gz
chromium_src-2372e96427d128a67ada47547bd1826276a0e62a.tar.bz2
Try relanding this CL, the original CL passed the try bots but failed the mac 10.7 bot because the oroginal CL queried the device info while there is no device on the bot.
Hook up the device selection to the WebAudio live audio. WebAudio live audio needs to pass the session_id to the browser process so that Chrome can open the correct input device for unitfied IO. This CL looks big because it touches quite some interfaces from the render to the browser. But the change is simple and basically adding a session_id/device_id to the classes. All the changes some together and it is very hard to break it down. It also makes the media output code more similar to the media input code as well, and it will be easier to merge them for the future. TBR=henrika@chormium.org BUG=147327 TEST=http://chromium.googlecode.com/svn/trunk/samples/audio/visualizer-live.html Change the device using the camera icon on the right of the omnibox, then reload. Verify the sound is coming from the correct input device. Review URL: https://codereview.chromium.org/15979015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203695 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/media/audio_message_filter.cc8
-rw-r--r--content/renderer/media/audio_message_filter_unittest.cc8
-rw-r--r--content/renderer/media/media_stream_impl.cc3
-rw-r--r--content/renderer/media/renderer_webaudiodevice_impl.cc8
-rw-r--r--content/renderer/media/renderer_webaudiodevice_impl.h6
-rw-r--r--content/renderer/media/webrtc_audio_device_impl.h14
-rw-r--r--content/renderer/pepper/pepper_platform_audio_output_impl.cc3
-rw-r--r--content/renderer/renderer_webkitplatformsupport_impl.cc22
8 files changed, 41 insertions, 31 deletions
diff --git a/content/renderer/media/audio_message_filter.cc b/content/renderer/media/audio_message_filter.cc
index 1cb5352..4523f01 100644
--- a/content/renderer/media/audio_message_filter.cc
+++ b/content/renderer/media/audio_message_filter.cc
@@ -25,7 +25,8 @@ class AudioMessageFilter::AudioOutputIPCImpl
// media::AudioOutputIPC implementation.
virtual void CreateStream(media::AudioOutputIPCDelegate* delegate,
- const media::AudioParameters& params) OVERRIDE;
+ const media::AudioParameters& params,
+ int session_id) OVERRIDE;
virtual void PlayStream() OVERRIDE;
virtual void PauseStream() OVERRIDE;
virtual void CloseStream() OVERRIDE;
@@ -75,13 +76,14 @@ scoped_ptr<media::AudioOutputIPC> AudioMessageFilter::CreateAudioOutputIPC(
void AudioMessageFilter::AudioOutputIPCImpl::CreateStream(
media::AudioOutputIPCDelegate* delegate,
- const media::AudioParameters& params) {
+ const media::AudioParameters& params,
+ int session_id) {
DCHECK(filter_->io_message_loop_->BelongsToCurrentThread());
DCHECK(delegate);
DCHECK_EQ(stream_id_, kStreamIDNotSet);
stream_id_ = filter_->delegates_.Add(delegate);
filter_->Send(new AudioHostMsg_CreateStream(
- stream_id_, render_view_id_, params));
+ stream_id_, render_view_id_, session_id, params));
}
void AudioMessageFilter::AudioOutputIPCImpl::PlayStream() {
diff --git a/content/renderer/media/audio_message_filter_unittest.cc b/content/renderer/media/audio_message_filter_unittest.cc
index 81db84e..fa8823f 100644
--- a/content/renderer/media/audio_message_filter_unittest.cc
+++ b/content/renderer/media/audio_message_filter_unittest.cc
@@ -79,7 +79,8 @@ TEST(AudioMessageFilterTest, Basic) {
MockAudioDelegate delegate;
const scoped_ptr<media::AudioOutputIPC> ipc =
filter->CreateAudioOutputIPC(kRenderViewId);
- ipc->CreateStream(&delegate, media::AudioParameters());
+ static const int kSessionId = 0;
+ ipc->CreateStream(&delegate, media::AudioParameters(), kSessionId);
static const int kStreamId = 1;
EXPECT_EQ(&delegate, filter->delegates_.Lookup(kStreamId));
@@ -128,8 +129,9 @@ TEST(AudioMessageFilterTest, Delegates) {
filter->CreateAudioOutputIPC(kRenderViewId);
const scoped_ptr<media::AudioOutputIPC> ipc2 =
filter->CreateAudioOutputIPC(kRenderViewId);
- ipc1->CreateStream(&delegate1, media::AudioParameters());
- ipc2->CreateStream(&delegate2, media::AudioParameters());
+ static const int kSessionId = 0;
+ ipc1->CreateStream(&delegate1, media::AudioParameters(), kSessionId);
+ ipc2->CreateStream(&delegate2, media::AudioParameters(), kSessionId);
static const int kStreamId1 = 1;
static const int kStreamId2 = 2;
EXPECT_EQ(&delegate1, filter->delegates_.Lookup(kStreamId1));
diff --git a/content/renderer/media/media_stream_impl.cc b/content/renderer/media/media_stream_impl.cc
index 20277b8..08d4edf 100644
--- a/content/renderer/media/media_stream_impl.cc
+++ b/content/renderer/media/media_stream_impl.cc
@@ -91,7 +91,8 @@ void CreateWebKitSourceVector(
UTF8ToUTF16(devices[i].device.name));
webkit_sources[i].setExtraData(
new content::MediaStreamSourceExtraData(devices[i], webkit_sources[i]));
- webkit_sources[i].setDeviceId(UTF8ToUTF16(devices[i].device.id.c_str()));
+ webkit_sources[i].setDeviceId(UTF8ToUTF16(
+ base::IntToString(devices[i].session_id)));
}
}
diff --git a/content/renderer/media/renderer_webaudiodevice_impl.cc b/content/renderer/media/renderer_webaudiodevice_impl.cc
index 3b08159..cb2ba7d 100644
--- a/content/renderer/media/renderer_webaudiodevice_impl.cc
+++ b/content/renderer/media/renderer_webaudiodevice_impl.cc
@@ -22,9 +22,11 @@ namespace content {
RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl(
const media::AudioParameters& params,
- WebAudioDevice::RenderCallback* callback)
+ WebAudioDevice::RenderCallback* callback,
+ int session_id)
: params_(params),
- client_callback_(callback) {
+ client_callback_(callback),
+ session_id_(session_id) {
DCHECK(client_callback_);
}
@@ -51,7 +53,7 @@ void RendererWebAudioDeviceImpl::start() {
web_view ? RenderViewImpl::FromWebView(web_view) : NULL;
output_device_ = AudioDeviceFactory::NewOutputDevice(
render_view ? render_view->routing_id() : MSG_ROUTING_NONE);
- output_device_->Initialize(params_, this);
+ output_device_->InitializeUnifiedStream(params_, this, session_id_);
output_device_->Start();
// Note: Default behavior is to auto-play on start.
}
diff --git a/content/renderer/media/renderer_webaudiodevice_impl.h b/content/renderer/media/renderer_webaudiodevice_impl.h
index 23a46ab..5a8161f 100644
--- a/content/renderer/media/renderer_webaudiodevice_impl.h
+++ b/content/renderer/media/renderer_webaudiodevice_impl.h
@@ -23,7 +23,8 @@ class RendererWebAudioDeviceImpl
public media::AudioRendererSink::RenderCallback {
public:
RendererWebAudioDeviceImpl(const media::AudioParameters& params,
- WebKit::WebAudioDevice::RenderCallback* callback);
+ WebKit::WebAudioDevice::RenderCallback* callback,
+ int session_id);
virtual ~RendererWebAudioDeviceImpl();
// WebKit::WebAudioDevice implementation.
@@ -54,6 +55,9 @@ class RendererWebAudioDeviceImpl
// When non-NULL, we are started. When NULL, we are stopped.
scoped_refptr<media::AudioOutputDevice> output_device_;
+ // ID to allow browser to select the correct input device for unified IO.
+ int session_id_;
+
DISALLOW_COPY_AND_ASSIGN(RendererWebAudioDeviceImpl);
};
diff --git a/content/renderer/media/webrtc_audio_device_impl.h b/content/renderer/media/webrtc_audio_device_impl.h
index e740a59..960d0d0 100644
--- a/content/renderer/media/webrtc_audio_device_impl.h
+++ b/content/renderer/media/webrtc_audio_device_impl.h
@@ -24,13 +24,11 @@
// webrtc::AudioDeviceModule which makes it possible for a user (e.g. webrtc::
// VoiceEngine) to register this class as an external AudioDeviceModule (ADM).
// Then WebRtcAudioDeviceImpl::SetSessionId() needs to be called to set the
-// session id that tells which device to use. The user can either get the
-// session id from the MediaStream or use a value of 1 (AudioInputDeviceManager
-// ::kFakeOpenSessionId), the later will open the default device without going
-// through the MediaStream. The user can then call WebRtcAudioDeviceImpl::
-// StartPlayout() and WebRtcAudioDeviceImpl::StartRecording() from the render
-// process to initiate and start audio rendering and capturing in the browser
-// process. IPC is utilized to set up the media streams.
+// session id that tells which device to use. The user can then call
+// WebRtcAudioDeviceImpl::StartPlayout() and
+// WebRtcAudioDeviceImpl::StartRecording() from the render process to initiate
+// and start audio rendering and capturing in the browser process. IPC is
+// utilized to set up the media streams.
//
// Usage example:
//
@@ -39,7 +37,7 @@
// {
// scoped_refptr<WebRtcAudioDeviceImpl> external_adm;
// external_adm = new WebRtcAudioDeviceImpl();
-// external_adm->SetSessionId(1);
+// external_adm->SetSessionId(session_id);
// VoiceEngine* voe = VoiceEngine::Create();
// VoEBase* base = VoEBase::GetInterface(voe);
// base->Init(external_adm);
diff --git a/content/renderer/pepper/pepper_platform_audio_output_impl.cc b/content/renderer/pepper/pepper_platform_audio_output_impl.cc
index e53dd6d..05600dd 100644
--- a/content/renderer/pepper/pepper_platform_audio_output_impl.cc
+++ b/content/renderer/pepper/pepper_platform_audio_output_impl.cc
@@ -138,8 +138,9 @@ void PepperPlatformAudioOutputImpl::InitializeOnIOThread(
const media::AudioParameters& params) {
DCHECK(ChildProcess::current()->io_message_loop_proxy()->
BelongsToCurrentThread());
+ const int kSessionId = 0;
if (ipc_)
- ipc_->CreateStream(this, params);
+ ipc_->CreateStream(this, params, kSessionId);
}
void PepperPlatformAudioOutputImpl::StartPlaybackOnIOThread() {
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 4efc1fa..f0b7910 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -10,6 +10,7 @@
#include "base/metrics/histogram.h"
#include "base/platform_file.h"
#include "base/shared_memory.h"
+#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "content/common/database_util.h"
#include "content/common/file_utilities_messages.h"
@@ -681,16 +682,6 @@ RendererWebKitPlatformSupportImpl::createAudioDevice(
double sample_rate,
WebAudioDevice::RenderCallback* callback,
const WebKit::WebString& input_device_id) {
- if (input_device_id != "default") {
- // Only allow audio input if we know for sure that WebKit is giving us the
- // "default" input device.
- // TODO(crogers): add support for non-default audio input devices when
- // using synchronized audio I/O in WebAudio.
- if (input_channels > 0)
- DLOG(WARNING) << "createAudioDevice(): request for audio input ignored";
- input_channels = 0;
- }
-
// The |channels| does not exactly identify the channel layout of the
// device. The switch statement below assigns a best guess to the channel
// layout based on number of channels.
@@ -726,12 +717,21 @@ RendererWebKitPlatformSupportImpl::createAudioDevice(
layout = media::CHANNEL_LAYOUT_STEREO;
}
+ int session_id = 0;
+ if (input_device_id.isNull() ||
+ !base::StringToInt(UTF16ToUTF8(input_device_id), &session_id)) {
+ if (input_channels > 0)
+ DLOG(WARNING) << "createAudioDevice(): request for audio input ignored";
+
+ input_channels = 0;
+ }
+
media::AudioParameters params(
media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
layout, input_channels,
static_cast<int>(sample_rate), 16, buffer_size);
- return new RendererWebAudioDeviceImpl(params, callback);
+ return new RendererWebAudioDeviceImpl(params, callback, session_id);
}
//------------------------------------------------------------------------------