OLD | NEW |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 int length) { | 67 int length) { |
68 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
69 DCHECK(handle); | 69 DCHECK(handle); |
70 DCHECK(socket_handle); | 70 DCHECK(socket_handle); |
71 #else | 71 #else |
72 DCHECK_NE(-1, handle.fd); | 72 DCHECK_NE(-1, handle.fd); |
73 DCHECK_NE(-1, socket_handle); | 73 DCHECK_NE(-1, socket_handle); |
74 #endif | 74 #endif |
75 DCHECK(length); | 75 DCHECK(length); |
76 | 76 |
77 if (base::MessageLoopProxy::current() != main_message_loop_proxy_) { | 77 if (base::MessageLoopProxy::current().get() != main_message_loop_proxy_) { |
78 // No need to check |shutdown_called_| here. If shutdown has occurred, | 78 // No need to check |shutdown_called_| here. If shutdown has occurred, |
79 // |client_| will be NULL and the handles will be cleaned up on the main | 79 // |client_| will be NULL and the handles will be cleaned up on the main |
80 // thread. | 80 // thread. |
81 main_message_loop_proxy_->PostTask( | 81 main_message_loop_proxy_->PostTask( |
82 FROM_HERE, | 82 FROM_HERE, |
83 base::Bind(&PepperPlatformAudioInputImpl::OnStreamCreated, this, | 83 base::Bind(&PepperPlatformAudioInputImpl::OnStreamCreated, this, |
84 handle, socket_handle, length)); | 84 handle, socket_handle, length)); |
85 } else { | 85 } else { |
86 // Must dereference the client only on the main thread. Shutdown may have | 86 // Must dereference the client only on the main thread. Shutdown may have |
87 // occurred while the request was in-flight, so we need to NULL check. | 87 // occurred while the request was in-flight, so we need to NULL check. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // here. | 131 // here. |
132 DCHECK_EQ(0, stream_id_); | 132 DCHECK_EQ(0, stream_id_); |
133 DCHECK(!client_); | 133 DCHECK(!client_); |
134 DCHECK(label_.empty()); | 134 DCHECK(label_.empty()); |
135 DCHECK(shutdown_called_); | 135 DCHECK(shutdown_called_); |
136 } | 136 } |
137 | 137 |
138 PepperPlatformAudioInputImpl::PepperPlatformAudioInputImpl() | 138 PepperPlatformAudioInputImpl::PepperPlatformAudioInputImpl() |
139 : client_(NULL), | 139 : client_(NULL), |
140 stream_id_(0), | 140 stream_id_(0), |
141 main_message_loop_proxy_(base::MessageLoopProxy::current()), | 141 main_message_loop_proxy_(base::MessageLoopProxy::current().get()), |
142 shutdown_called_(false) { | 142 shutdown_called_(false) { |
143 ipc_ = RenderThreadImpl::current()->audio_input_message_filter(); | 143 ipc_ = RenderThreadImpl::current()->audio_input_message_filter(); |
144 } | 144 } |
145 | 145 |
146 bool PepperPlatformAudioInputImpl::Initialize( | 146 bool PepperPlatformAudioInputImpl::Initialize( |
147 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, | 147 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, |
148 const std::string& device_id, | 148 const std::string& device_id, |
149 int sample_rate, | 149 int sample_rate, |
150 int frames_per_buffer, | 150 int frames_per_buffer, |
151 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) { | 151 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client) { |
152 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); | 152 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } | 273 } |
274 | 274 |
275 void PepperPlatformAudioInputImpl::NotifyStreamCreationFailed() { | 275 void PepperPlatformAudioInputImpl::NotifyStreamCreationFailed() { |
276 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); | 276 DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); |
277 | 277 |
278 if (client_) | 278 if (client_) |
279 client_->StreamCreationFailed(); | 279 client_->StreamCreationFailed(); |
280 } | 280 } |
281 | 281 |
282 } // namespace content | 282 } // namespace content |
OLD | NEW |