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

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

Issue 11359196: Associate audio streams with their source/destination RenderView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Consolidate construct/init/destruct code in AudioOutputDeviceTest. Created 8 years, 1 month 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/renderer/media/renderer_webaudiodevice_impl.cc
diff --git a/content/renderer/media/renderer_webaudiodevice_impl.cc b/content/renderer/media/renderer_webaudiodevice_impl.cc
index 4c72e8ca65b3631bd80edc93927ba4bef49519a1..283b2fb66c3727b7fbef0452ca58be341316c368 100644
--- a/content/renderer/media/renderer_webaudiodevice_impl.cc
+++ b/content/renderer/media/renderer_webaudiodevice_impl.cc
@@ -6,11 +6,17 @@
#include "base/command_line.h"
#include "base/logging.h"
-#include "content/renderer/media/audio_device_factory.h"
+#include "content/renderer/media/audio_message_filter.h"
+#include "content/renderer/render_thread_impl.h"
+#include "content/renderer/render_view_impl.h"
#include "media/base/media_switches.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
using WebKit::WebAudioDevice;
+using WebKit::WebFrame;
using WebKit::WebVector;
+using WebKit::WebView;
namespace content {
@@ -19,7 +25,9 @@ RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl(
WebAudioDevice::RenderCallback* callback)
: is_running_(false),
client_callback_(callback) {
- audio_device_ = AudioDeviceFactory::NewOutputDevice();
+ audio_device_ = new media::AudioOutputDevice(
+ RenderThreadImpl::current()->audio_message_filter(),
+ RenderThreadImpl::current()->GetIOMessageLoopProxy());
// TODO(crogers): remove once we properly handle input device selection.
// https://code.google.com/p/chromium/issues/detail?id=147327
@@ -39,6 +47,24 @@ RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() {
void RendererWebAudioDeviceImpl::start() {
if (!is_running_) {
+ // Assumption: This method is being invoked within a V8 call stack. CHECKs
+ // will fail in the call to frameForCurrentContext() otherwise.
+ //
+ // Therefore, we can perform look-ups to determine which RenderView is
+ // starting the audio device. The reason for all this is because the
+ // creator of the WebAudio objects might not be the actual source of the
+ // audio (e.g., an extension creates a object that is passed and used within
+ // a page).
+ WebFrame* const web_frame = WebFrame::frameForCurrentContext();
+ WebView* const web_view = web_frame ? web_frame->view() : NULL;
+ RenderViewImpl* const render_view =
+ web_view ? RenderViewImpl::FromWebView(web_view) : NULL;
+ if (render_view) {
+ RenderThreadImpl::current()->audio_message_filter()->
+ AssociateStreamWithProducer(audio_device_->stream_id(),
+ render_view->routing_id());
+ }
+
audio_device_->Start();
is_running_ = true;
}

Powered by Google App Engine
This is Rietveld 408576698