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..5f5d0e71f68cfb9b6482a90fe4679777d18c878d 100644 |
--- a/content/renderer/media/renderer_webaudiodevice_impl.cc |
+++ b/content/renderer/media/renderer_webaudiodevice_impl.cc |
@@ -7,10 +7,16 @@ |
#include "base/command_line.h" |
#include "base/logging.h" |
#include "content/renderer/media/audio_device_factory.h" |
+#include "content/renderer/media/renderer_audio_output_device.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 { |
@@ -38,10 +44,26 @@ RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() { |
} |
void RendererWebAudioDeviceImpl::start() { |
- if (!is_running_) { |
- audio_device_->Start(); |
- is_running_ = true; |
+ if (is_running_) |
tommi (sloooow) - chröme
2012/11/30 06:51:31
I don't see any thread checks in this file, yet th
miu
2012/12/01 00:40:17
Done. I left thread-checking out of Render/Render
|
+ return; |
+ |
+ // 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) { |
+ audio_device_->SetSourceRenderView(render_view->routing_id()); |
} |
+ |
+ audio_device_->Start(); |
+ is_running_ = true; |
} |
void RendererWebAudioDeviceImpl::stop() { |