diff options
author | justinlin@chromium.org <justinlin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 17:58:09 +0000 |
---|---|---|
committer | justinlin@chromium.org <justinlin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 17:58:09 +0000 |
commit | 6e37ba8c76c2240ec96bb95096cfe33e9c41eda6 (patch) | |
tree | 9006c83d118e5cde850fac75f8545a2caa024f8f /content/renderer | |
parent | 9faccc4fecfc865078149ae258aa53452831ec9b (diff) | |
download | chromium_src-6e37ba8c76c2240ec96bb95096cfe33e9c41eda6.zip chromium_src-6e37ba8c76c2240ec96bb95096cfe33e9c41eda6.tar.gz chromium_src-6e37ba8c76c2240ec96bb95096cfe33e9c41eda6.tar.bz2 |
Revert 203427 "Hook up the device selection to the WebAudio live..."
Possibly caused content_browsertests to fail on Mac.
> 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.
>
>
> 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://chromiumcodereview.appspot.com/15721002
TBR=xians@chromium.org
Review URL: https://codereview.chromium.org/15725013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
8 files changed, 31 insertions, 41 deletions
diff --git a/content/renderer/media/audio_message_filter.cc b/content/renderer/media/audio_message_filter.cc index 4523f01..1cb5352 100644 --- a/content/renderer/media/audio_message_filter.cc +++ b/content/renderer/media/audio_message_filter.cc @@ -25,8 +25,7 @@ class AudioMessageFilter::AudioOutputIPCImpl // media::AudioOutputIPC implementation. virtual void CreateStream(media::AudioOutputIPCDelegate* delegate, - const media::AudioParameters& params, - int session_id) OVERRIDE; + const media::AudioParameters& params) OVERRIDE; virtual void PlayStream() OVERRIDE; virtual void PauseStream() OVERRIDE; virtual void CloseStream() OVERRIDE; @@ -76,14 +75,13 @@ scoped_ptr<media::AudioOutputIPC> AudioMessageFilter::CreateAudioOutputIPC( void AudioMessageFilter::AudioOutputIPCImpl::CreateStream( media::AudioOutputIPCDelegate* delegate, - const media::AudioParameters& params, - int session_id) { + const media::AudioParameters& params) { 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_, session_id, params)); + stream_id_, render_view_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 fa8823f..81db84e 100644 --- a/content/renderer/media/audio_message_filter_unittest.cc +++ b/content/renderer/media/audio_message_filter_unittest.cc @@ -79,8 +79,7 @@ TEST(AudioMessageFilterTest, Basic) { MockAudioDelegate delegate; const scoped_ptr<media::AudioOutputIPC> ipc = filter->CreateAudioOutputIPC(kRenderViewId); - static const int kSessionId = 0; - ipc->CreateStream(&delegate, media::AudioParameters(), kSessionId); + ipc->CreateStream(&delegate, media::AudioParameters()); static const int kStreamId = 1; EXPECT_EQ(&delegate, filter->delegates_.Lookup(kStreamId)); @@ -129,9 +128,8 @@ TEST(AudioMessageFilterTest, Delegates) { filter->CreateAudioOutputIPC(kRenderViewId); const scoped_ptr<media::AudioOutputIPC> ipc2 = filter->CreateAudioOutputIPC(kRenderViewId); - static const int kSessionId = 0; - ipc1->CreateStream(&delegate1, media::AudioParameters(), kSessionId); - ipc2->CreateStream(&delegate2, media::AudioParameters(), kSessionId); + ipc1->CreateStream(&delegate1, media::AudioParameters()); + ipc2->CreateStream(&delegate2, media::AudioParameters()); 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 fa307dd..7f2de52 100644 --- a/content/renderer/media/media_stream_impl.cc +++ b/content/renderer/media/media_stream_impl.cc @@ -91,8 +91,7 @@ void CreateWebKitSourceVector( UTF8ToUTF16(devices[i].device.name)); webkit_sources[i].setExtraData( new content::MediaStreamSourceExtraData(devices[i], webkit_sources[i])); - webkit_sources[i].setDeviceId(UTF8ToUTF16( - base::IntToString(devices[i].session_id))); + webkit_sources[i].setDeviceId(UTF8ToUTF16(devices[i].device.id.c_str())); } } diff --git a/content/renderer/media/renderer_webaudiodevice_impl.cc b/content/renderer/media/renderer_webaudiodevice_impl.cc index b088b4e..43a4a61 100644 --- a/content/renderer/media/renderer_webaudiodevice_impl.cc +++ b/content/renderer/media/renderer_webaudiodevice_impl.cc @@ -22,11 +22,9 @@ namespace content { RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl( const media::AudioParameters& params, - WebAudioDevice::RenderCallback* callback, - int session_id) + WebAudioDevice::RenderCallback* callback) : params_(params), - client_callback_(callback), - session_id_(session_id) { + client_callback_(callback) { DCHECK(client_callback_); } @@ -53,7 +51,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_->InitializeUnifiedStream(params_, this, session_id_); + output_device_->Initialize(params_, this); 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 5a8161f..23a46ab 100644 --- a/content/renderer/media/renderer_webaudiodevice_impl.h +++ b/content/renderer/media/renderer_webaudiodevice_impl.h @@ -23,8 +23,7 @@ class RendererWebAudioDeviceImpl public media::AudioRendererSink::RenderCallback { public: RendererWebAudioDeviceImpl(const media::AudioParameters& params, - WebKit::WebAudioDevice::RenderCallback* callback, - int session_id); + WebKit::WebAudioDevice::RenderCallback* callback); virtual ~RendererWebAudioDeviceImpl(); // WebKit::WebAudioDevice implementation. @@ -55,9 +54,6 @@ 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 960d0d0..e740a59 100644 --- a/content/renderer/media/webrtc_audio_device_impl.h +++ b/content/renderer/media/webrtc_audio_device_impl.h @@ -24,11 +24,13 @@ // 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 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 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. // // Usage example: // @@ -37,7 +39,7 @@ // { // scoped_refptr<WebRtcAudioDeviceImpl> external_adm; // external_adm = new WebRtcAudioDeviceImpl(); -// external_adm->SetSessionId(session_id); +// external_adm->SetSessionId(1); // 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 05600dd..e53dd6d 100644 --- a/content/renderer/pepper/pepper_platform_audio_output_impl.cc +++ b/content/renderer/pepper/pepper_platform_audio_output_impl.cc @@ -138,9 +138,8 @@ 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, kSessionId); + ipc_->CreateStream(this, params); } void PepperPlatformAudioOutputImpl::StartPlaybackOnIOThread() { diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index 4cf27f0..133bfc2 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.cc +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc @@ -10,7 +10,6 @@ #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,6 +680,16 @@ 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. @@ -716,21 +725,12 @@ 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, session_id); + return new RendererWebAudioDeviceImpl(params, callback); } //------------------------------------------------------------------------------ |