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

Side by Side Diff: content/renderer/pepper/pepper_platform_audio_output_impl.cc

Issue 11166002: Plumb render view ID from audio-related code in renderer through IPCs to AudioRendererHost in brows… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add plumbing for input side as well. Created 8 years, 2 months 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" 5 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "content/common/child_process.h" 12 #include "content/common/child_process.h"
13 #include "content/common/media/audio_messages.h" 13 #include "content/common/media/audio_messages.h"
14 #include "content/renderer/media/audio_hardware.h" 14 #include "content/renderer/media/audio_hardware.h"
15 #include "content/renderer/media/audio_message_filter.h" 15 #include "content/renderer/media/audio_message_filter.h"
16 #include "content/renderer/render_thread_impl.h" 16 #include "content/renderer/render_thread_impl.h"
17 #include "media/base/media_switches.h" 17 #include "media/base/media_switches.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 // static 21 // static
22 PepperPlatformAudioOutputImpl* PepperPlatformAudioOutputImpl::Create( 22 PepperPlatformAudioOutputImpl* PepperPlatformAudioOutputImpl::Create(
23 int render_view_id,
23 int sample_rate, 24 int sample_rate,
24 int frames_per_buffer, 25 int frames_per_buffer,
25 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { 26 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) {
26 scoped_refptr<PepperPlatformAudioOutputImpl> audio_output( 27 scoped_refptr<PepperPlatformAudioOutputImpl> audio_output(
27 new PepperPlatformAudioOutputImpl()); 28 new PepperPlatformAudioOutputImpl(render_view_id));
28 if (audio_output->Initialize(sample_rate, frames_per_buffer, client)) { 29 if (audio_output->Initialize(sample_rate, frames_per_buffer, client)) {
29 // Balanced by Release invoked in 30 // Balanced by Release invoked in
30 // PepperPlatformAudioOutputImpl::ShutDownOnIOThread(). 31 // PepperPlatformAudioOutputImpl::ShutDownOnIOThread().
31 return audio_output.release(); 32 return audio_output.release();
32 } 33 }
33 return NULL; 34 return NULL;
34 } 35 }
35 36
36 bool PepperPlatformAudioOutputImpl::StartPlayback() { 37 bool PepperPlatformAudioOutputImpl::StartPlayback() {
37 if (ipc_) { 38 if (ipc_.get()) {
tommi (sloooow) - chröme 2012/10/17 18:40:06 nit: I don't think we need to call .get() like thi
miu 2012/10/17 20:10:44 Done.
38 ChildProcess::current()->io_message_loop()->PostTask( 39 ChildProcess::current()->io_message_loop()->PostTask(
39 FROM_HERE, 40 FROM_HERE,
40 base::Bind(&PepperPlatformAudioOutputImpl::StartPlaybackOnIOThread, 41 base::Bind(&PepperPlatformAudioOutputImpl::StartPlaybackOnIOThread,
41 this)); 42 this));
42 return true; 43 return true;
43 } 44 }
44 return false; 45 return false;
45 } 46 }
46 47
47 bool PepperPlatformAudioOutputImpl::StopPlayback() { 48 bool PepperPlatformAudioOutputImpl::StopPlayback() {
48 if (ipc_) { 49 if (ipc_.get()) {
49 ChildProcess::current()->io_message_loop()->PostTask( 50 ChildProcess::current()->io_message_loop()->PostTask(
50 FROM_HERE, 51 FROM_HERE,
51 base::Bind(&PepperPlatformAudioOutputImpl::StopPlaybackOnIOThread, 52 base::Bind(&PepperPlatformAudioOutputImpl::StopPlaybackOnIOThread,
52 this)); 53 this));
53 return true; 54 return true;
54 } 55 }
55 return false; 56 return false;
56 } 57 }
57 58
58 void PepperPlatformAudioOutputImpl::ShutDown() { 59 void PepperPlatformAudioOutputImpl::ShutDown() {
(...skipping 28 matching lines...) Expand all
87 if (client_) 88 if (client_)
88 client_->StreamCreated(handle, length, socket_handle); 89 client_->StreamCreated(handle, length, socket_handle);
89 } else { 90 } else {
90 main_message_loop_proxy_->PostTask(FROM_HERE, 91 main_message_loop_proxy_->PostTask(FROM_HERE,
91 base::Bind(&PepperPlatformAudioOutputImpl::OnStreamCreated, this, 92 base::Bind(&PepperPlatformAudioOutputImpl::OnStreamCreated, this,
92 handle, socket_handle, length)); 93 handle, socket_handle, length));
93 } 94 }
94 } 95 }
95 96
96 void PepperPlatformAudioOutputImpl::OnIPCClosed() { 97 void PepperPlatformAudioOutputImpl::OnIPCClosed() {
97 ipc_ = NULL; 98 ipc_.reset();
98 } 99 }
99 100
100 PepperPlatformAudioOutputImpl::~PepperPlatformAudioOutputImpl() { 101 PepperPlatformAudioOutputImpl::~PepperPlatformAudioOutputImpl() {
101 // Make sure we have been shut down. Warning: this will usually happen on 102 // Make sure we have been shut down. Warning: this will usually happen on
102 // the I/O thread! 103 // the I/O thread!
103 DCHECK_EQ(0, stream_id_); 104 DCHECK_EQ(0, stream_id_);
104 DCHECK(!client_); 105 DCHECK(!client_);
105 } 106 }
106 107
107 PepperPlatformAudioOutputImpl::PepperPlatformAudioOutputImpl() 108 PepperPlatformAudioOutputImpl::PepperPlatformAudioOutputImpl(int render_view_id)
108 : client_(NULL), 109 : client_(NULL),
109 stream_id_(0), 110 stream_id_(0),
110 main_message_loop_proxy_(base::MessageLoopProxy::current()) { 111 main_message_loop_proxy_(base::MessageLoopProxy::current()) {
111 ipc_ = RenderThreadImpl::current()->audio_message_filter(); 112 ipc_.reset(RenderThreadImpl::current()->audio_message_filter()->
113 CreateAudioOutputIPC(render_view_id));
112 } 114 }
113 115
114 bool PepperPlatformAudioOutputImpl::Initialize( 116 bool PepperPlatformAudioOutputImpl::Initialize(
115 int sample_rate, 117 int sample_rate,
116 int frames_per_buffer, 118 int frames_per_buffer,
117 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { 119 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) {
118 DCHECK(client); 120 DCHECK(client);
119 // Make sure we don't call init more than once. 121 // Make sure we don't call init more than once.
120 DCHECK_EQ(0, stream_id_); 122 DCHECK_EQ(0, stream_id_);
121 123
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 174
173 ipc_->CloseStream(stream_id_); 175 ipc_->CloseStream(stream_id_);
174 ipc_->RemoveDelegate(stream_id_); 176 ipc_->RemoveDelegate(stream_id_);
175 stream_id_ = 0; 177 stream_id_ = 0;
176 178
177 Release(); // Release for the delegate, balances out the reference taken in 179 Release(); // Release for the delegate, balances out the reference taken in
178 // PepperPluginDelegateImpl::CreateAudio. 180 // PepperPluginDelegateImpl::CreateAudio.
179 } 181 }
180 182
181 } // namespace content 183 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698