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

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: Restored AudioDeviceFactory. Created new RendererAudioOutputDevice. 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..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() {

Powered by Google App Engine
This is Rietveld 408576698