OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 | 157 |
158 private: | 158 private: |
159 int width_; | 159 int width_; |
160 int height_; | 160 int height_; |
161 scoped_ptr<TransportDIB> dib_; | 161 scoped_ptr<TransportDIB> dib_; |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(PlatformImage2DImpl); | 163 DISALLOW_COPY_AND_ASSIGN(PlatformImage2DImpl); |
164 }; | 164 }; |
165 | 165 |
166 | |
167 class PlatformAudioImpl | 166 class PlatformAudioImpl |
168 : public webkit::ppapi::PluginDelegate::PlatformAudio, | 167 : public webkit::ppapi::PluginDelegate::PlatformAudio, |
169 public AudioMessageFilter::Delegate, | 168 public AudioMessageFilter::Delegate, |
170 public base::RefCountedThreadSafe<PlatformAudioImpl> { | 169 public base::RefCountedThreadSafe<PlatformAudioImpl> { |
171 public: | 170 public: |
172 PlatformAudioImpl() | 171 PlatformAudioImpl() |
173 : client_(NULL), stream_id_(0), | 172 : client_(NULL), stream_id_(0), |
174 main_message_loop_proxy_(base::MessageLoopProxy::current()) { | 173 main_message_loop_proxy_(base::MessageLoopProxy::current()) { |
175 filter_ = RenderThreadImpl::current()->audio_message_filter(); | 174 filter_ = RenderThreadImpl::current()->audio_message_filter(); |
176 } | 175 } |
177 | 176 |
178 virtual ~PlatformAudioImpl() { | 177 virtual ~PlatformAudioImpl() { |
179 // Make sure we have been shut down. Warning: this will usually happen on | 178 // Make sure we have been shut down. Warning: this will usually happen on |
180 // the I/O thread! | 179 // the I/O thread! |
181 DCHECK_EQ(0, stream_id_); | 180 DCHECK_EQ(0, stream_id_); |
182 DCHECK(!client_); | 181 DCHECK(!client_); |
183 } | 182 } |
184 | 183 |
185 // Initialize this audio context. StreamCreated() will be called when the | 184 // Initialize this audio context. StreamCreated() will be called when the |
186 // stream is created. | 185 // stream is created. |
187 bool Initialize(uint32_t sample_rate, uint32_t sample_count, | 186 bool Initialize(uint32_t sample_rate, uint32_t sample_count, |
188 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); | 187 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); |
189 | 188 |
190 // PlatformAudio implementation (called on main thread). | 189 // PlatformAudio implementation (called on main thread). |
191 virtual bool StartPlayback(); | 190 virtual bool StartPlayback() OVERRIDE; |
192 virtual bool StopPlayback(); | 191 virtual bool StopPlayback() OVERRIDE; |
193 virtual void ShutDown(); | 192 virtual void ShutDown() OVERRIDE; |
194 | 193 |
195 private: | 194 private: |
196 // I/O thread backends to above functions. | 195 // I/O thread backends to above functions. |
197 void InitializeOnIOThread(const AudioParameters& params); | 196 void InitializeOnIOThread(const AudioParameters& params); |
198 void StartPlaybackOnIOThread(); | 197 void StartPlaybackOnIOThread(); |
199 void StopPlaybackOnIOThread(); | 198 void StopPlaybackOnIOThread(); |
200 void ShutDownOnIOThread(); | 199 void ShutDownOnIOThread(); |
201 | 200 |
202 virtual void OnRequestPacket(AudioBuffersState buffers_state) { | 201 virtual void OnRequestPacket(AudioBuffersState buffers_state) OVERRIDE { |
203 LOG(FATAL) << "Should never get OnRequestPacket in PlatformAudioImpl"; | 202 LOG(FATAL) << "Should never get OnRequestPacket in PlatformAudioImpl"; |
204 } | 203 } |
205 | 204 |
206 virtual void OnStateChanged(AudioStreamState state) {} | 205 virtual void OnStateChanged(AudioStreamState state) OVERRIDE {} |
207 | 206 |
208 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length) { | 207 virtual void OnCreated(base::SharedMemoryHandle handle, |
| 208 uint32 length) OVERRIDE { |
209 LOG(FATAL) << "Should never get OnCreated in PlatformAudioImpl"; | 209 LOG(FATAL) << "Should never get OnCreated in PlatformAudioImpl"; |
210 } | 210 } |
211 | 211 |
212 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 212 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
213 base::SyncSocket::Handle socket_handle, | 213 base::SyncSocket::Handle socket_handle, |
214 uint32 length); | 214 uint32 length) OVERRIDE; |
215 | 215 |
216 virtual void OnVolume(double volume) {} | 216 virtual void OnVolume(double volume) OVERRIDE {} |
217 | 217 |
218 // The client to notify when the stream is created. THIS MUST ONLY BE | 218 // The client to notify when the stream is created. THIS MUST ONLY BE |
219 // ACCESSED ON THE MAIN THREAD. | 219 // ACCESSED ON THE MAIN THREAD. |
220 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client_; | 220 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client_; |
221 | 221 |
222 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE | 222 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE |
223 // I/O thread except to send messages and get the message loop. | 223 // I/O thread except to send messages and get the message loop. |
224 scoped_refptr<AudioMessageFilter> filter_; | 224 scoped_refptr<AudioMessageFilter> filter_; |
225 | 225 |
226 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | 226 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 DCHECK(!client_); | 355 DCHECK(!client_); |
356 } | 356 } |
357 | 357 |
358 // Initialize this audio context. StreamCreated() will be called when the | 358 // Initialize this audio context. StreamCreated() will be called when the |
359 // stream is created. | 359 // stream is created. |
360 bool Initialize( | 360 bool Initialize( |
361 uint32_t sample_rate, uint32_t sample_count, | 361 uint32_t sample_rate, uint32_t sample_count, |
362 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); | 362 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); |
363 | 363 |
364 // PlatformAudio implementation (called on main thread). | 364 // PlatformAudio implementation (called on main thread). |
365 virtual bool StartCapture(); | 365 virtual bool StartCapture() OVERRIDE; |
366 virtual bool StopCapture(); | 366 virtual bool StopCapture() OVERRIDE; |
367 virtual void ShutDown(); | 367 virtual void ShutDown() OVERRIDE; |
368 | 368 |
369 private: | 369 private: |
370 // I/O thread backends to above functions. | 370 // I/O thread backends to above functions. |
371 void InitializeOnIOThread(const AudioParameters& params); | 371 void InitializeOnIOThread(const AudioParameters& params); |
372 void StartCaptureOnIOThread(); | 372 void StartCaptureOnIOThread(); |
373 void StopCaptureOnIOThread(); | 373 void StopCaptureOnIOThread(); |
374 void ShutDownOnIOThread(); | 374 void ShutDownOnIOThread(); |
375 | 375 |
376 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 376 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
377 base::SyncSocket::Handle socket_handle, | 377 base::SyncSocket::Handle socket_handle, |
378 uint32 length); | 378 uint32 length) OVERRIDE; |
379 | 379 |
380 virtual void OnVolume(double volume) {} | 380 virtual void OnVolume(double volume) OVERRIDE {} |
381 | 381 |
382 virtual void OnStateChanged(AudioStreamState state) {} | 382 virtual void OnStateChanged(AudioStreamState state) OVERRIDE {} |
383 | 383 |
384 virtual void OnDeviceReady(int index) {} | 384 virtual void OnDeviceReady(int index) OVERRIDE {} |
385 | 385 |
386 // The client to notify when the stream is created. THIS MUST ONLY BE | 386 // The client to notify when the stream is created. THIS MUST ONLY BE |
387 // ACCESSED ON THE MAIN THREAD. | 387 // ACCESSED ON THE MAIN THREAD. |
388 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client_; | 388 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client_; |
389 | 389 |
390 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE | 390 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE |
391 // I/O thread except to send messages and get the message loop. | 391 // I/O thread except to send messages and get the message loop. |
392 scoped_refptr<AudioInputMessageFilter> filter_; | 392 scoped_refptr<AudioInputMessageFilter> filter_; |
393 | 393 |
394 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | 394 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD |
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1937 if (!context) | 1937 if (!context) |
1938 return NULL; | 1938 return NULL; |
1939 if (!context->makeContextCurrent() || context->isContextLost()) | 1939 if (!context->makeContextCurrent() || context->isContextLost()) |
1940 return NULL; | 1940 return NULL; |
1941 | 1941 |
1942 RendererGLContext* parent_context = context->context(); | 1942 RendererGLContext* parent_context = context->context(); |
1943 if (!parent_context) | 1943 if (!parent_context) |
1944 return NULL; | 1944 return NULL; |
1945 return parent_context; | 1945 return parent_context; |
1946 } | 1946 } |
OLD | NEW |