OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 class Audio : public Resource, | 45 class Audio : public Resource, |
46 public PluginDelegate::PlatformAudio::Client, | 46 public PluginDelegate::PlatformAudio::Client, |
47 public base::DelegateSimpleThread::Delegate { | 47 public base::DelegateSimpleThread::Delegate { |
48 public: | 48 public: |
49 explicit Audio(PluginModule* module); | 49 explicit Audio(PluginModule* module); |
50 virtual ~Audio(); | 50 virtual ~Audio(); |
51 | 51 |
52 static const PPB_Audio_Dev* GetInterface(); | 52 static const PPB_Audio_Dev* GetInterface(); |
53 static const PPB_AudioTrusted_Dev* GetTrustedInterface(); | 53 static const PPB_AudioTrusted_Dev* GetTrustedInterface(); |
54 | 54 |
55 bool Init(PluginDelegate* plugin_delegate, PP_Resource config_id, | 55 bool Init(PluginDelegate* plugin_delegate, |
56 PPB_Audio_Callback callback, void* user_data); | 56 PP_Instance instance_id, |
| 57 PP_Resource config_id, |
| 58 PPB_Audio_Callback user_callback, void* user_data, |
| 59 PPB_AudioTrusted_Callback created); |
57 | 60 |
58 PP_Resource GetCurrentConfiguration() { | 61 PP_Resource GetCurrentConfiguration() { |
59 return config_->GetReference(); | 62 return config_->GetReference(); |
60 } | 63 } |
61 | 64 |
62 bool StartPlayback(); | 65 bool StartPlayback(); |
63 | 66 |
64 bool StopPlayback(); | 67 bool StopPlayback(); |
65 | 68 |
66 // Resource override. | 69 // Resource override. |
67 virtual Audio* AsAudio(); | 70 virtual Audio* AsAudio(); |
68 | 71 |
69 private: | 72 private: |
70 // pepper::PluginDelegate::PlatformAudio::Client implementation. | 73 // pepper::PluginDelegate::PlatformAudio::Client implementation. |
71 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, | 74 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
72 size_t shared_memory_size_, | 75 size_t shared_memory_size_, |
73 base::SyncSocket::Handle socket); | 76 base::SyncSocket::Handle socket); |
74 // End of pepper::PluginDelegate::PlatformAudio::Client implementation. | 77 // End of pepper::PluginDelegate::PlatformAudio::Client implementation. |
75 | 78 |
76 // Audio thread. DelegateSimpleThread::Delegate implementation. | 79 // Audio thread. DelegateSimpleThread::Delegate implementation. |
77 virtual void Run(); | 80 virtual void Run(); |
78 // End of DelegateSimpleThread::Delegate implementation. | 81 // End of DelegateSimpleThread::Delegate implementation. |
79 | 82 |
80 // True if playing the stream. | 83 // True if playing the stream. |
81 bool playing_; | 84 bool playing_; |
82 | 85 |
83 // AudioConfig used for creating this Audio object. | 86 // AudioConfig used for creating this Audio object. |
84 scoped_refptr<AudioConfig> config_; | 87 scoped_refptr<AudioConfig> config_; |
85 | 88 |
| 89 // Instance id |
| 90 PP_Instance pp_instance_; |
| 91 |
86 // PluginDelegate audio object that we delegate audio IPC through. | 92 // PluginDelegate audio object that we delegate audio IPC through. |
87 scoped_ptr<PluginDelegate::PlatformAudio> audio_; | 93 PluginDelegate::PlatformAudio* audio_; |
88 | 94 |
89 // Socket used to notify us when audio is ready to accept new samples. This | 95 // Socket used to notify us when audio is ready to accept new samples. This |
90 // pointer is created in StreamCreated(). | 96 // pointer is created in StreamCreated(). |
91 scoped_ptr<base::SyncSocket> socket_; | 97 scoped_ptr<base::SyncSocket> socket_; |
92 | 98 |
93 // Sample buffer in shared memory. This pointer is created in | 99 // Sample buffer in shared memory. This pointer is created in |
94 // StreamCreated(). The memory is only mapped when the audio thread is | 100 // StreamCreated(). The memory is only mapped when the audio thread is |
95 // created. | 101 // created. |
96 scoped_ptr<base::SharedMemory> shared_memory_; | 102 scoped_ptr<base::SharedMemory> shared_memory_; |
97 | 103 |
98 // The size of the sample buffer in bytes. | 104 // The size of the sample buffer in bytes. |
99 size_t shared_memory_size_; | 105 size_t shared_memory_size_; |
100 | 106 |
101 // When the callback is set, this thread is spawned for calling it. | 107 // When the callback is set, this thread is spawned for calling it. |
102 scoped_ptr<base::DelegateSimpleThread> audio_thread_; | 108 scoped_ptr<base::DelegateSimpleThread> audio_thread_; |
103 | 109 |
104 // Callback to call when audio is ready to accept new samples. | 110 // Callback to call when audio is ready to accept new samples. |
105 volatile PPB_Audio_Callback callback_; | 111 volatile PPB_Audio_Callback callback_; |
106 | 112 |
107 // User data pointer passed verbatim to the callback function. | 113 // User data pointer passed verbatim to the callback function. |
108 void* user_data_; | 114 void* user_data_; |
| 115 |
| 116 // Trusted callback invoked from StreamCreated. |
| 117 PPB_AudioTrusted_Callback create_callback_; |
109 }; | 118 }; |
110 | 119 |
111 } // namespace pepper | 120 } // namespace pepper |
112 | 121 |
113 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ | 122 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ |
114 | 123 |
OLD | NEW |