Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: webkit/glue/plugins/pepper_audio.h

Issue 5202002: changes for proxy audio (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/simple_thread.h" 11 #include "base/simple_thread.h"
12 #include "base/sync_socket.h" 12 #include "base/sync_socket.h"
13 #include "ppapi/c/dev/ppb_audio_dev.h" 13 #include "ppapi/c/dev/ppb_audio_dev.h"
14 #include "ppapi/c/dev/ppb_audio_config_dev.h" 14 #include "ppapi/c/dev/ppb_audio_config_dev.h"
15 #include "ppapi/c/dev/ppb_audio_trusted_dev.h" 15 #include "ppapi/c/dev/ppb_audio_trusted_dev.h"
16 #include "ppapi/c/pp_completion_callback.h"
16 #include "webkit/glue/plugins/pepper_plugin_delegate.h" 17 #include "webkit/glue/plugins/pepper_plugin_delegate.h"
17 #include "webkit/glue/plugins/pepper_plugin_instance.h" 18 #include "webkit/glue/plugins/pepper_plugin_instance.h"
18 #include "webkit/glue/plugins/pepper_plugin_module.h" 19 #include "webkit/glue/plugins/pepper_plugin_module.h"
19 #include "webkit/glue/plugins/pepper_resource.h" 20 #include "webkit/glue/plugins/pepper_resource.h"
20 21
21 namespace pepper { 22 namespace pepper {
22 23
23 class PluginInstance; 24 class PluginInstance;
24 class PluginModule; 25 class PluginModule;
25 26
(...skipping 13 matching lines...) Expand all
39 virtual AudioConfig* AsAudioConfig(); 40 virtual AudioConfig* AsAudioConfig();
40 41
41 PP_AudioSampleRate_Dev sample_rate_; 42 PP_AudioSampleRate_Dev sample_rate_;
42 uint32_t sample_frame_count_; 43 uint32_t sample_frame_count_;
43 }; 44 };
44 45
45 class Audio : public Resource, 46 class Audio : public Resource,
46 public PluginDelegate::PlatformAudio::Client, 47 public PluginDelegate::PlatformAudio::Client,
47 public base::DelegateSimpleThread::Delegate { 48 public base::DelegateSimpleThread::Delegate {
48 public: 49 public:
49 explicit Audio(PluginModule* module); 50 explicit Audio(PluginModule* module, PP_Instance instance_id);
50 virtual ~Audio(); 51 virtual ~Audio();
51 52
52 static const PPB_Audio_Dev* GetInterface(); 53 static const PPB_Audio_Dev* GetInterface();
53 static const PPB_AudioTrusted_Dev* GetTrustedInterface(); 54 static const PPB_AudioTrusted_Dev* GetTrustedInterface();
54 55
55 bool Init(PluginDelegate* plugin_delegate, PP_Resource config_id, 56 bool Init(PluginDelegate* plugin_delegate,
56 PPB_Audio_Callback callback, void* user_data); 57 PP_Resource config_id,
58 PPB_Audio_Callback user_callback, void* user_data);
59
60 int32_t OpenTrusted(PluginDelegate* plugin_delegate,
61 PP_Resource config_id,
62 PP_CompletionCallback create_callback);
63
64 void CloseTrusted();
57 65
58 PP_Resource GetCurrentConfiguration() { 66 PP_Resource GetCurrentConfiguration() {
59 return config_->GetReference(); 67 return config_->GetReference();
60 } 68 }
61 69
70 PP_Instance pp_instance() {
71 return pp_instance_;
72 }
73
74 int32_t GetSyncSocket(int* sync_socket);
75
76 int32_t GetSharedMemory(uint64_t* shm_handle, int32_t* shm_size);
77
62 bool StartPlayback(); 78 bool StartPlayback();
63 79
64 bool StopPlayback(); 80 bool StopPlayback();
65 81
66 // Resource override. 82 // Resource override.
67 virtual Audio* AsAudio(); 83 virtual Audio* AsAudio();
68 84
69 private: 85 private:
70 // pepper::PluginDelegate::PlatformAudio::Client implementation. 86 // pepper::PluginDelegate::PlatformAudio::Client implementation.
71 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, 87 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
72 size_t shared_memory_size_, 88 size_t shared_memory_size_,
73 base::SyncSocket::Handle socket); 89 base::SyncSocket::Handle socket);
74 // End of pepper::PluginDelegate::PlatformAudio::Client implementation. 90 // End of pepper::PluginDelegate::PlatformAudio::Client implementation.
75 91
76 // Audio thread. DelegateSimpleThread::Delegate implementation. 92 // Audio thread. DelegateSimpleThread::Delegate implementation.
77 virtual void Run(); 93 virtual void Run();
78 // End of DelegateSimpleThread::Delegate implementation. 94 // End of DelegateSimpleThread::Delegate implementation.
79 95
80 // True if playing the stream. 96 // True if playing the stream.
81 bool playing_; 97 bool playing_;
82 98
83 // AudioConfig used for creating this Audio object. 99 // AudioConfig used for creating this Audio object.
84 scoped_refptr<AudioConfig> config_; 100 scoped_refptr<AudioConfig> config_;
85 101
102 // Instance id
103 PP_Instance pp_instance_;
104
86 // PluginDelegate audio object that we delegate audio IPC through. 105 // PluginDelegate audio object that we delegate audio IPC through.
87 scoped_ptr<PluginDelegate::PlatformAudio> audio_; 106 PluginDelegate::PlatformAudio* audio_;
88 107
89 // Socket used to notify us when audio is ready to accept new samples. This 108 // Socket used to notify us when audio is ready to accept new samples. This
90 // pointer is created in StreamCreated(). 109 // pointer is created in StreamCreated().
91 scoped_ptr<base::SyncSocket> socket_; 110 scoped_ptr<base::SyncSocket> socket_;
92 111
93 // Sample buffer in shared memory. This pointer is created in 112 // Sample buffer in shared memory. This pointer is created in
94 // StreamCreated(). The memory is only mapped when the audio thread is 113 // StreamCreated(). The memory is only mapped when the audio thread is
95 // created. 114 // created.
96 scoped_ptr<base::SharedMemory> shared_memory_; 115 scoped_ptr<base::SharedMemory> shared_memory_;
97 116
98 // The size of the sample buffer in bytes. 117 // The size of the sample buffer in bytes.
99 size_t shared_memory_size_; 118 size_t shared_memory_size_;
100 119
120 // OS specific shared memory handle.
121 uint64_t shared_memory_handle_;
122
101 // When the callback is set, this thread is spawned for calling it. 123 // When the callback is set, this thread is spawned for calling it.
102 scoped_ptr<base::DelegateSimpleThread> audio_thread_; 124 scoped_ptr<base::DelegateSimpleThread> audio_thread_;
103 125
104 // Callback to call when audio is ready to accept new samples. 126 // Callback to call when audio is ready to accept new samples.
105 volatile PPB_Audio_Callback callback_; 127 volatile PPB_Audio_Callback callback_;
106 128
107 // User data pointer passed verbatim to the callback function. 129 // User data pointer passed verbatim to the callback function.
108 void* user_data_; 130 void* user_data_;
131
132 // Is a create callback pending to fire?
133 bool create_callback_pending_;
134
135 // Trusted callback invoked from StreamCreated.
136 PP_CompletionCallback create_callback_;
109 }; 137 };
110 138
111 } // namespace pepper 139 } // namespace pepper
112 140
113 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ 141 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_
114
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698