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

Side by Side Diff: content/renderer/pepper/pepper_platform_audio_input_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: Link to crbug from TODO comments. Enforced ownership transfer using scoped_ptr. 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_input_impl.h" 5 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "content/common/child_process.h" 11 #include "content/common/child_process.h"
12 #include "content/common/media/audio_messages.h" 12 #include "content/common/media/audio_messages.h"
13 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" 13 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
14 #include "content/renderer/render_thread_impl.h" 14 #include "content/renderer/render_thread_impl.h"
15 #include "media/audio/audio_manager_base.h" 15 #include "media/audio/audio_manager_base.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 // static 19 // static
20 PepperPlatformAudioInputImpl* PepperPlatformAudioInputImpl::Create( 20 PepperPlatformAudioInputImpl* PepperPlatformAudioInputImpl::Create(
21 int render_view_id,
21 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, 22 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
22 const std::string& device_id, 23 const std::string& device_id,
23 int sample_rate, 24 int sample_rate,
24 int frames_per_buffer, 25 int frames_per_buffer,
25 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) { 26 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) {
26 scoped_refptr<PepperPlatformAudioInputImpl> audio_input( 27 scoped_refptr<PepperPlatformAudioInputImpl> audio_input(
27 new PepperPlatformAudioInputImpl()); 28 new PepperPlatformAudioInputImpl(render_view_id));
28 if (audio_input->Initialize(plugin_delegate, device_id, sample_rate, 29 if (audio_input->Initialize(plugin_delegate, device_id, sample_rate,
29 frames_per_buffer, client)) { 30 frames_per_buffer, client)) {
30 // Balanced by Release invoked in 31 // Balanced by Release invoked in
31 // PepperPlatformAudioInputImpl::ShutDownOnIOThread(). 32 // PepperPlatformAudioInputImpl::ShutDownOnIOThread().
32 return audio_input.release(); 33 return audio_input.release();
33 } 34 }
34 return NULL; 35 return NULL;
35 } 36 }
36 37
37 void PepperPlatformAudioInputImpl::StartCapture() { 38 void PepperPlatformAudioInputImpl::StartCapture() {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 FROM_HERE, 114 FROM_HERE,
114 base::Bind(&PepperPlatformAudioInputImpl::NotifyStreamCreationFailed, 115 base::Bind(&PepperPlatformAudioInputImpl::NotifyStreamCreationFailed,
115 this)); 116 this));
116 } else { 117 } else {
117 // We will be notified by OnStreamCreated(). 118 // We will be notified by OnStreamCreated().
118 ipc_->CreateStream(stream_id_, params_, device_id, false); 119 ipc_->CreateStream(stream_id_, params_, device_id, false);
119 } 120 }
120 } 121 }
121 122
122 void PepperPlatformAudioInputImpl::OnIPCClosed() { 123 void PepperPlatformAudioInputImpl::OnIPCClosed() {
123 ipc_ = NULL; 124 ipc_.reset();
124 } 125 }
125 126
126 PepperPlatformAudioInputImpl::~PepperPlatformAudioInputImpl() { 127 PepperPlatformAudioInputImpl::~PepperPlatformAudioInputImpl() {
127 // Make sure we have been shut down. Warning: this may happen on the I/O 128 // Make sure we have been shut down. Warning: this may happen on the I/O
128 // thread! 129 // thread!
129 // Although these members should be accessed on a specific thread (either the 130 // Although these members should be accessed on a specific thread (either the
130 // main thread or the I/O thread), it should be fine to examine their value 131 // main thread or the I/O thread), it should be fine to examine their value
131 // here. 132 // here.
132 DCHECK_EQ(0, stream_id_); 133 DCHECK_EQ(0, stream_id_);
133 DCHECK(!client_); 134 DCHECK(!client_);
134 DCHECK(label_.empty()); 135 DCHECK(label_.empty());
135 DCHECK(shutdown_called_); 136 DCHECK(shutdown_called_);
136 } 137 }
137 138
138 PepperPlatformAudioInputImpl::PepperPlatformAudioInputImpl() 139 PepperPlatformAudioInputImpl::PepperPlatformAudioInputImpl(int render_view_id)
139 : client_(NULL), 140 : client_(NULL),
140 stream_id_(0), 141 stream_id_(0),
141 main_message_loop_proxy_(base::MessageLoopProxy::current()), 142 main_message_loop_proxy_(base::MessageLoopProxy::current()),
142 shutdown_called_(false) { 143 shutdown_called_(false) {
143 ipc_ = RenderThreadImpl::current()->audio_input_message_filter(); 144 ipc_ = RenderThreadImpl::current()->audio_input_message_filter()->
145 CreateAudioInputIPC(render_view_id);
scherkus (not reviewing) 2012/10/18 05:17:35 fix indent
miu 2012/10/18 05:28:18 Done.
144 } 146 }
145 147
146 bool PepperPlatformAudioInputImpl::Initialize( 148 bool PepperPlatformAudioInputImpl::Initialize(
147 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, 149 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
148 const std::string& device_id, 150 const std::string& device_id,
149 int sample_rate, 151 int sample_rate,
150 int frames_per_buffer, 152 int frames_per_buffer,
151 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) { 153 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) {
152 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); 154 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread());
153 155
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 275 }
274 276
275 void PepperPlatformAudioInputImpl::NotifyStreamCreationFailed() { 277 void PepperPlatformAudioInputImpl::NotifyStreamCreationFailed() {
276 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); 278 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread());
277 279
278 if (client_) 280 if (client_)
279 client_->StreamCreationFailed(); 281 client_->StreamCreationFailed();
280 } 282 }
281 283
282 } // namespace content 284 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698