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

Unified Diff: content/renderer/media/renderer_audio_output_device.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_audio_output_device.cc
diff --git a/content/renderer/media/renderer_audio_output_device.cc b/content/renderer/media/renderer_audio_output_device.cc
new file mode 100644
index 0000000000000000000000000000000000000000..23dfa6d4168ae38efc4ff2a4eb94fa09766288bc
--- /dev/null
+++ b/content/renderer/media/renderer_audio_output_device.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/media/renderer_audio_output_device.h"
+
+#include "base/bind.h"
+#include "base/message_loop_proxy.h"
+#include "content/renderer/media/audio_message_filter.h"
+
+namespace content {
+
+RendererAudioOutputDevice::RendererAudioOutputDevice(
+ AudioMessageFilter* message_filter,
+ const scoped_refptr<base::MessageLoopProxy>& io_loop)
+ : AudioOutputDevice(message_filter, io_loop),
+ source_render_view_id_(MSG_ROUTING_NONE),
+ is_after_stream_created_(false) {
+}
+
+RendererAudioOutputDevice::~RendererAudioOutputDevice() {}
+
+void RendererAudioOutputDevice::Start() {
+ AudioOutputDevice::Start();
scherkus (not reviewing) 2012/11/30 22:09:43 q: should we DCHECK() here / in OnStart() that sou
miu 2012/12/01 00:40:17 It's valid to not be set. In fact, it's valid to
+ message_loop()->PostTask(FROM_HERE,
+ base::Bind(&RendererAudioOutputDevice::OnStart, this));
+}
+
+void RendererAudioOutputDevice::Stop() {
+ AudioOutputDevice::Stop();
+ message_loop()->PostTask(FROM_HERE,
+ base::Bind(&RendererAudioOutputDevice::OnStop, this));
+}
+
+void RendererAudioOutputDevice::SetSourceRenderView(int render_view_id) {
+ message_loop()->PostTask(FROM_HERE,
+ base::Bind(&RendererAudioOutputDevice::OnSourceChange, this,
+ render_view_id));
+}
+
+void RendererAudioOutputDevice::OnStart() {
+ is_after_stream_created_ = true;
+ OnSourceChange(source_render_view_id_);
+}
+
+void RendererAudioOutputDevice::OnStop() {
+ is_after_stream_created_ = false;
+}
+
+void RendererAudioOutputDevice::OnSourceChange(int render_view_id) {
+ source_render_view_id_ = render_view_id;
+ if (is_after_stream_created_ && source_render_view_id_ != MSG_ROUTING_NONE) {
+ AudioMessageFilter* const filter =
+ static_cast<AudioMessageFilter*>(audio_output_ipc());
+ if (filter)
+ filter->AssociateStreamWithProducer(stream_id(), source_render_view_id_);
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698