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

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

Issue 16256018: Update content/ to use WeakPtr<T>::get() instead of implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix incorrectly modified code Created 7 years, 6 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"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 bool PepperPlatformAudioInputImpl::Initialize( 131 bool PepperPlatformAudioInputImpl::Initialize(
132 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, 132 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
133 const std::string& device_id, 133 const std::string& device_id,
134 int sample_rate, 134 int sample_rate,
135 int frames_per_buffer, 135 int frames_per_buffer,
136 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) { 136 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) {
137 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); 137 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread());
138 138
139 if (!plugin_delegate || !client) 139 if (!plugin_delegate.get() || !client)
140 return false; 140 return false;
141 141
142 ipc_ = RenderThreadImpl::current()->audio_input_message_filter()-> 142 ipc_ = RenderThreadImpl::current()->audio_input_message_filter()->
143 CreateAudioInputIPC(plugin_delegate->GetRoutingID()); 143 CreateAudioInputIPC(plugin_delegate->GetRoutingID());
144 144
145 plugin_delegate_ = plugin_delegate; 145 plugin_delegate_ = plugin_delegate;
146 client_ = client; 146 client_ = client;
147 147
148 params_.Reset(media::AudioParameters::AUDIO_PCM_LINEAR, 148 params_.Reset(media::AudioParameters::AUDIO_PCM_LINEAR,
149 media::CHANNEL_LAYOUT_MONO, 1, 0, 149 media::CHANNEL_LAYOUT_MONO, 1, 0,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 Release(); // Release for the delegate, balances out the reference taken in 202 Release(); // Release for the delegate, balances out the reference taken in
203 // PepperPluginDelegateImpl::CreateAudioInput. 203 // PepperPluginDelegateImpl::CreateAudioInput.
204 } 204 }
205 205
206 void PepperPlatformAudioInputImpl::OnDeviceOpened(int request_id, 206 void PepperPlatformAudioInputImpl::OnDeviceOpened(int request_id,
207 bool succeeded, 207 bool succeeded,
208 const std::string& label) { 208 const std::string& label) {
209 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); 209 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread());
210 210
211 if (succeeded && plugin_delegate_) { 211 if (succeeded && plugin_delegate_.get()) {
212 DCHECK(!label.empty()); 212 DCHECK(!label.empty());
213 label_ = label; 213 label_ = label;
214 214
215 if (client_) { 215 if (client_) {
216 int session_id = plugin_delegate_->GetSessionID( 216 int session_id = plugin_delegate_->GetSessionID(
217 PP_DEVICETYPE_DEV_AUDIOCAPTURE, label); 217 PP_DEVICETYPE_DEV_AUDIOCAPTURE, label);
218 ChildProcess::current()->io_message_loop()->PostTask( 218 ChildProcess::current()->io_message_loop()->PostTask(
219 FROM_HERE, 219 FROM_HERE,
220 base::Bind(&PepperPlatformAudioInputImpl::InitializeOnIOThread, 220 base::Bind(&PepperPlatformAudioInputImpl::InitializeOnIOThread,
221 this, session_id)); 221 this, session_id));
222 } else { 222 } else {
223 // Shutdown has occurred. 223 // Shutdown has occurred.
224 CloseDevice(); 224 CloseDevice();
225 } 225 }
226 } else { 226 } else {
227 NotifyStreamCreationFailed(); 227 NotifyStreamCreationFailed();
228 } 228 }
229 } 229 }
230 230
231 void PepperPlatformAudioInputImpl::CloseDevice() { 231 void PepperPlatformAudioInputImpl::CloseDevice() {
232 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); 232 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread());
233 233
234 if (plugin_delegate_ && !label_.empty()) { 234 if (plugin_delegate_.get() && !label_.empty()) {
235 plugin_delegate_->CloseDevice(label_); 235 plugin_delegate_->CloseDevice(label_);
236 label_.clear(); 236 label_.clear();
237 } 237 }
238 } 238 }
239 239
240 void PepperPlatformAudioInputImpl::NotifyStreamCreationFailed() { 240 void PepperPlatformAudioInputImpl::NotifyStreamCreationFailed() {
241 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); 241 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread());
242 242
243 if (client_) 243 if (client_)
244 client_->StreamCreationFailed(); 244 client_->StreamCreationFailed();
245 } 245 }
246 246
247 } // namespace content 247 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_file_chooser_host.cc ('k') | content/renderer/pepper/pepper_platform_video_capture_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698