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 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
10 #include "media/audio/audio_output_ipc.h" | 11 #include "media/audio/audio_output_ipc.h" |
11 #include "webkit/plugins/ppapi/plugin_delegate.h" | 12 #include "webkit/plugins/ppapi/plugin_delegate.h" |
12 | 13 |
13 namespace media { | 14 namespace media { |
14 class AudioParameters; | 15 class AudioParameters; |
15 } | 16 } |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class MessageLoopProxy; | 19 class MessageLoopProxy; |
19 } | 20 } |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 class AudioMessageFilter; | |
24 | |
25 class PepperPlatformAudioOutputImpl | 24 class PepperPlatformAudioOutputImpl |
26 : public webkit::ppapi::PluginDelegate::PlatformAudioOutput, | 25 : public webkit::ppapi::PluginDelegate::PlatformAudioOutput, |
27 public media::AudioOutputIPCDelegate, | 26 public media::AudioOutputIPCDelegate, |
28 public base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl> { | 27 public base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl> { |
29 public: | 28 public: |
30 // Factory function, returns NULL on failure. StreamCreated() will be called | 29 // Factory function, returns NULL on failure. StreamCreated() will be called |
31 // when the stream is created. | 30 // when the stream is created. |
32 static PepperPlatformAudioOutputImpl* Create( | 31 static PepperPlatformAudioOutputImpl* Create( |
33 int sample_rate, | 32 int sample_rate, |
34 int frames_per_buffer, | 33 int frames_per_buffer, |
(...skipping 12 matching lines...) Expand all Loading... |
47 base::SyncSocket::Handle socket_handle, | 46 base::SyncSocket::Handle socket_handle, |
48 int length) OVERRIDE; | 47 int length) OVERRIDE; |
49 virtual void OnIPCClosed() OVERRIDE; | 48 virtual void OnIPCClosed() OVERRIDE; |
50 | 49 |
51 protected: | 50 protected: |
52 virtual ~PepperPlatformAudioOutputImpl(); | 51 virtual ~PepperPlatformAudioOutputImpl(); |
53 | 52 |
54 private: | 53 private: |
55 friend class base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl>; | 54 friend class base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl>; |
56 | 55 |
57 PepperPlatformAudioOutputImpl(); | 56 explicit PepperPlatformAudioOutputImpl(int source_render_view_id); |
58 | 57 |
59 bool Initialize( | 58 bool Initialize( |
60 int sample_rate, | 59 int sample_rate, |
61 int frames_per_buffer, | 60 int frames_per_buffer, |
62 int source_render_view_id, | |
63 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client); | 61 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client); |
64 | 62 |
65 // I/O thread backends to above functions. | 63 // I/O thread backends to above functions. |
66 void InitializeOnIOThread(const media::AudioParameters& params, | 64 void InitializeOnIOThread(const media::AudioParameters& params); |
67 int source_render_view_id); | |
68 void StartPlaybackOnIOThread(); | 65 void StartPlaybackOnIOThread(); |
69 void StopPlaybackOnIOThread(); | 66 void StopPlaybackOnIOThread(); |
70 void ShutDownOnIOThread(); | 67 void ShutDownOnIOThread(); |
71 | 68 |
72 // The client to notify when the stream is created. THIS MUST ONLY BE | 69 // The client to notify when the stream is created. THIS MUST ONLY BE |
73 // ACCESSED ON THE MAIN THREAD. | 70 // ACCESSED ON THE MAIN THREAD. |
74 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client_; | 71 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client_; |
75 | 72 |
76 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE | 73 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE |
77 // I/O thread except to send messages and get the message loop. | 74 // I/O thread except to send messages and get the message loop. |
78 scoped_refptr<AudioMessageFilter> ipc_; | 75 scoped_ptr<media::AudioOutputIPC> ipc_; |
79 | 76 |
80 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | 77 // True while the stream is live (i.e., between the Create and Close audio |
81 // or else you could race with the initialize function which sets it. | 78 // IPCs). THIS MUST ONLY BE ACCESSED ON THE I/O THREAD or else you could race |
82 int32 stream_id_; | 79 // with the initialize function which sets it. |
| 80 bool stream_created_; |
83 | 81 |
84 base::MessageLoopProxy* main_message_loop_proxy_; | 82 base::MessageLoopProxy* main_message_loop_proxy_; |
85 | 83 |
86 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioOutputImpl); | 84 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioOutputImpl); |
87 }; | 85 }; |
88 | 86 |
89 } // namespace content | 87 } // namespace content |
90 | 88 |
91 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ | 89 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ |
OLD | NEW |