OLD | NEW |
(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(); |
| 25 message_loop()->PostTask( |
| 26 FROM_HERE, |
| 27 base::Bind(&RendererAudioOutputDevice::OnStart, this)); |
| 28 } |
| 29 |
| 30 void RendererAudioOutputDevice::Stop() { |
| 31 AudioOutputDevice::Stop(); |
| 32 message_loop()->PostTask( |
| 33 FROM_HERE, |
| 34 base::Bind(&RendererAudioOutputDevice::OnStop, this)); |
| 35 } |
| 36 |
| 37 void RendererAudioOutputDevice::SetSourceRenderView(int render_view_id) { |
| 38 message_loop()->PostTask( |
| 39 FROM_HERE, |
| 40 base::Bind(&RendererAudioOutputDevice::OnSourceChange, this, |
| 41 render_view_id)); |
| 42 } |
| 43 |
| 44 void RendererAudioOutputDevice::OnStart() { |
| 45 is_after_stream_created_ = true; |
| 46 OnSourceChange(source_render_view_id_); |
| 47 } |
| 48 |
| 49 void RendererAudioOutputDevice::OnStop() { |
| 50 is_after_stream_created_ = false; |
| 51 } |
| 52 |
| 53 void RendererAudioOutputDevice::OnSourceChange(int render_view_id) { |
| 54 source_render_view_id_ = render_view_id; |
| 55 if (is_after_stream_created_ && source_render_view_id_ != MSG_ROUTING_NONE) { |
| 56 AudioMessageFilter* const filter = |
| 57 static_cast<AudioMessageFilter*>(audio_output_ipc()); |
| 58 if (filter) |
| 59 filter->AssociateStreamWithProducer(stream_id(), source_render_view_id_); |
| 60 } |
| 61 } |
| 62 |
| 63 } // namespace content |
OLD | NEW |