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

Unified Diff: webkit/glue/plugins/pepper_audio.h

Issue 4985001: Initial audio implementation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: webkit/glue/plugins/pepper_audio.h
===================================================================
--- webkit/glue/plugins/pepper_audio.h (revision 67884)
+++ webkit/glue/plugins/pepper_audio.h (working copy)
@@ -6,14 +6,13 @@
#define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_
#include "base/ref_counted.h"
-#include "base/scoped_ptr.h"
#include "base/shared_memory.h"
-#include "base/simple_thread.h"
#include "base/sync_socket.h"
#include "ppapi/c/dev/ppb_audio_dev.h"
#include "ppapi/c/dev/ppb_audio_config_dev.h"
#include "ppapi/c/dev/ppb_audio_trusted_dev.h"
#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/shared_impl/audio_impl.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
@@ -43,9 +42,11 @@
uint32_t sample_frame_count_;
};
+// Some of the backend functionality of this class is implemented by the
+// AudioImpl so it can be shared with the proxy.
class Audio : public Resource,
- public PluginDelegate::PlatformAudio::Client,
- public base::DelegateSimpleThread::Delegate {
+ public pp::shared_impl::AudioImpl,
+ public PluginDelegate::PlatformAudio::Client {
public:
explicit Audio(PluginModule* module, PP_Instance instance_id);
virtual ~Audio();
@@ -53,30 +54,25 @@
static const PPB_Audio_Dev* GetInterface();
static const PPB_AudioTrusted_Dev* GetTrustedInterface();
+ PP_Instance pp_instance() {
+ return pp_instance_;
+ }
+
+ // PPB_Audio implementation.
bool Init(PluginDelegate* plugin_delegate,
PP_Resource config_id,
PPB_Audio_Callback user_callback, void* user_data);
+ PP_Resource GetCurrentConfig();
+ bool StartPlayback();
+ bool StopPlayback();
+ // PPB_Audio_Trusted implementation.
int32_t Open(PluginDelegate* plugin_delegate,
PP_Resource config_id,
PP_CompletionCallback create_callback);
-
- PP_Resource GetCurrentConfiguration() {
- return config_->GetReference();
- }
-
- PP_Instance pp_instance() {
- return pp_instance_;
- }
-
int32_t GetSyncSocket(int* sync_socket);
-
int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size);
- bool StartPlayback();
-
- bool StopPlayback();
-
// Resource override.
virtual Audio* AsAudio();
@@ -85,50 +81,29 @@
virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
size_t shared_memory_size_,
base::SyncSocket::Handle socket);
- // End of pepper::PluginDelegate::PlatformAudio::Client implementation.
- // Audio thread. DelegateSimpleThread::Delegate implementation.
- virtual void Run();
- // End of DelegateSimpleThread::Delegate implementation.
-
- // True if playing the stream.
- bool playing_;
-
// AudioConfig used for creating this Audio object.
scoped_refptr<AudioConfig> config_;
- // Instance id
+ // Plugin instance that owns this audio object.
PP_Instance pp_instance_;
// PluginDelegate audio object that we delegate audio IPC through.
PluginDelegate::PlatformAudio* audio_;
- // Socket used to notify us when audio is ready to accept new samples. This
- // pointer is created in StreamCreated().
- scoped_ptr<base::SyncSocket> socket_;
-
- // Sample buffer in shared memory. This pointer is created in
- // StreamCreated(). The memory is only mapped when the audio thread is
- // created.
- scoped_ptr<base::SharedMemory> shared_memory_;
-
- // The size of the sample buffer in bytes.
- size_t shared_memory_size_;
-
- // When the callback is set, this thread is spawned for calling it.
- scoped_ptr<base::DelegateSimpleThread> audio_thread_;
-
- // Callback to call when audio is ready to accept new samples.
- volatile PPB_Audio_Callback callback_;
-
- // User data pointer passed verbatim to the callback function.
- void* user_data_;
-
// Is a create callback pending to fire?
bool create_callback_pending_;
// Trusted callback invoked from StreamCreated.
PP_CompletionCallback create_callback_;
+
+ // When a create callback is being issued, these will save the info for
+ // querying from the callback. The proxy uses this to get the handles to the
+ // other process instead of mapping them in the renderer. These will are
+ // invalid all other times.
nfullagar 2010/12/01 23:34:21 check last sentence above. "These will are..."
+ scoped_ptr<base::SharedMemory> shared_memory_for_create_callback_;
+ size_t shared_memory_size_for_create_callback_;
+ scoped_ptr<base::SyncSocket> socket_for_create_callback_;
};
} // namespace pepper

Powered by Google App Engine
This is Rietveld 408576698