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 "content/renderer/media/audio_message_filter.h" | 10 #include "content/renderer/media/audio_message_filter.h" |
11 #include "webkit/plugins/ppapi/plugin_delegate.h" | 11 #include "webkit/plugins/ppapi/plugin_delegate.h" |
12 | 12 |
13 struct AudioParameters; | 13 class AudioParameters; |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class MessageLoopProxy; | 16 class MessageLoopProxy; |
17 } | 17 } |
18 | 18 |
19 class PepperPlatformAudioOutputImpl | 19 class PepperPlatformAudioOutputImpl |
20 : public webkit::ppapi::PluginDelegate::PlatformAudioOutput, | 20 : public webkit::ppapi::PluginDelegate::PlatformAudioOutput, |
21 public AudioMessageFilter::Delegate, | 21 public AudioMessageFilter::Delegate, |
22 public base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl> { | 22 public base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl> { |
23 public: | 23 public: |
24 virtual ~PepperPlatformAudioOutputImpl(); | 24 virtual ~PepperPlatformAudioOutputImpl(); |
25 | 25 |
26 // Factory function, returns NULL on failure. StreamCreated() will be called | 26 // Factory function, returns NULL on failure. StreamCreated() will be called |
27 // when the stream is created. | 27 // when the stream is created. |
28 static PepperPlatformAudioOutputImpl* Create( | 28 static PepperPlatformAudioOutputImpl* Create( |
29 uint32_t sample_rate, | 29 int sample_rate, |
30 uint32_t sample_count, | 30 int frames_per_buffer, |
31 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); | 31 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); |
32 | 32 |
33 // PlatformAudioOutput implementation (called on main thread). | 33 // PlatformAudioOutput implementation (called on main thread). |
34 virtual bool StartPlayback() OVERRIDE; | 34 virtual bool StartPlayback() OVERRIDE; |
35 virtual bool StopPlayback() OVERRIDE; | 35 virtual bool StopPlayback() OVERRIDE; |
36 virtual void ShutDown() OVERRIDE; | 36 virtual void ShutDown() OVERRIDE; |
37 | 37 |
38 private: | 38 private: |
39 PepperPlatformAudioOutputImpl(); | 39 PepperPlatformAudioOutputImpl(); |
40 | 40 |
41 bool Initialize( | 41 bool Initialize( |
42 uint32_t sample_rate, | 42 int sample_rate, |
43 uint32_t sample_count, | 43 int frames_per_buffer, |
44 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); | 44 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); |
45 | 45 |
46 // I/O thread backends to above functions. | 46 // I/O thread backends to above functions. |
47 void InitializeOnIOThread(const AudioParameters& params); | 47 void InitializeOnIOThread(const AudioParameters& params); |
48 void StartPlaybackOnIOThread(); | 48 void StartPlaybackOnIOThread(); |
49 void StopPlaybackOnIOThread(); | 49 void StopPlaybackOnIOThread(); |
50 void ShutDownOnIOThread(); | 50 void ShutDownOnIOThread(); |
51 | 51 |
52 // AudioMessageFilter::Delegate. | 52 // AudioMessageFilter::Delegate. |
53 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; | 53 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
66 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | 66 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD |
67 // or else you could race with the initialize function which sets it. | 67 // or else you could race with the initialize function which sets it. |
68 int32 stream_id_; | 68 int32 stream_id_; |
69 | 69 |
70 base::MessageLoopProxy* main_message_loop_proxy_; | 70 base::MessageLoopProxy* main_message_loop_proxy_; |
71 | 71 |
72 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioOutputImpl); | 72 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioOutputImpl); |
73 }; | 73 }; |
74 | 74 |
75 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ | 75 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ |
OLD | NEW |