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

Side by Side 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 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/media/renderer_audio_output_device.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h"
9 #include "content/renderer/media/audio_message_filter.h"
10
11 namespace content {
12
13 RendererAudioOutputDevice::RendererAudioOutputDevice(
14 AudioMessageFilter* message_filter,
15 const scoped_refptr<base::MessageLoopProxy>& io_loop)
16 : AudioOutputDevice(message_filter, io_loop),
17 source_render_view_id_(MSG_ROUTING_NONE),
18 is_after_stream_created_(false) {
19 }
20
21 RendererAudioOutputDevice::~RendererAudioOutputDevice() {}
22
23 void RendererAudioOutputDevice::Start() {
24 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
25 message_loop()->PostTask(FROM_HERE,
26 base::Bind(&RendererAudioOutputDevice::OnStart, this));
27 }
28
29 void RendererAudioOutputDevice::Stop() {
30 AudioOutputDevice::Stop();
31 message_loop()->PostTask(FROM_HERE,
32 base::Bind(&RendererAudioOutputDevice::OnStop, this));
33 }
34
35 void RendererAudioOutputDevice::SetSourceRenderView(int render_view_id) {
36 message_loop()->PostTask(FROM_HERE,
37 base::Bind(&RendererAudioOutputDevice::OnSourceChange, this,
38 render_view_id));
39 }
40
41 void RendererAudioOutputDevice::OnStart() {
42 is_after_stream_created_ = true;
43 OnSourceChange(source_render_view_id_);
44 }
45
46 void RendererAudioOutputDevice::OnStop() {
47 is_after_stream_created_ = false;
48 }
49
50 void RendererAudioOutputDevice::OnSourceChange(int render_view_id) {
51 source_render_view_id_ = render_view_id;
52 if (is_after_stream_created_ && source_render_view_id_ != MSG_ROUTING_NONE) {
53 AudioMessageFilter* const filter =
54 static_cast<AudioMessageFilter*>(audio_output_ipc());
55 if (filter)
56 filter->AssociateStreamWithProducer(stream_id(), source_render_view_id_);
57 }
58 }
59
60 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698