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

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

Issue 5202002: changes for proxy audio (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.cc
===================================================================
--- webkit/glue/plugins/pepper_audio.cc (revision 66651)
+++ webkit/glue/plugins/pepper_audio.cc (working copy)
@@ -5,8 +5,8 @@
#include "webkit/glue/plugins/pepper_audio.h"
#include "base/logging.h"
-#include "ppapi/c/dev/ppb_audio_dev.h"
-#include "ppapi/c/dev/ppb_audio_trusted_dev.h"
+#include "third_party/ppapi/c/dev/ppb_audio_dev.h"
+#include "third_party/ppapi/c/dev/ppb_audio_trusted_dev.h"
#include "webkit/glue/plugins/pepper_common.h"
namespace pepper {
@@ -77,13 +77,14 @@
// PPB_Audio -------------------------------------------------------------------
PP_Resource Create(PP_Instance instance_id, PP_Resource config_id,
- PPB_Audio_Callback callback, void* user_data) {
+ PPB_Audio_Callback user_callback, void* user_data) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance)
return 0;
// TODO(neb): Require callback to be present for untrusted plugins.
scoped_refptr<Audio> audio(new Audio(instance->module()));
- if (!audio->Init(instance->delegate(), config_id, callback, user_data))
+ if (!audio->Init(instance->delegate(), instance_id, config_id,
+ user_callback, user_data, NULL))
return 0;
return audio->GetReference();
}
@@ -118,19 +119,20 @@
// PPB_AudioTrusted ------------------------------------------------------------
-PP_Resource GetBuffer(PP_Resource audio_id) {
- // TODO(neb): Implement me!
- return 0;
+PP_Resource CreateTrusted(PP_Instance instance_id, PP_Resource config_id,
+ PPB_AudioTrusted_Callback created) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return 0;
+ scoped_refptr<Audio> audio(new Audio(instance->module()));
+ if (!audio->Init(instance->delegate(), instance_id, config_id,
+ NULL, NULL, created))
darin (slow to review) 2010/11/19 17:45:39 nit: please indent so the start of the arguments a
+ return 0;
+ return audio->GetReference();
}
-int GetOSDescriptor(PP_Resource audio_id) {
- // TODO(neb): Implement me!
- return -1;
-}
-
const PPB_AudioTrusted_Dev ppb_audiotrusted = {
- &GetBuffer,
- &GetOSDescriptor
+ &CreateTrusted
};
} // namespace
@@ -168,16 +170,20 @@
Audio::Audio(PluginModule* module)
: Resource(module),
playing_(false),
+ pp_instance_(0),
+ audio_(NULL),
socket_(NULL),
shared_memory_(NULL),
shared_memory_size_(0),
callback_(NULL),
- user_data_(NULL) {
+ user_data_(NULL),
+ create_callback_(NULL) {
}
Audio::~Audio() {
// Calling ShutDown() makes sure StreamCreated cannot be called anymore.
audio_->ShutDown();
+ audio_ = NULL;
// Closing the socket causes the thread to exit - wait for it.
socket_->Close();
if (audio_thread_.get()) {
@@ -199,19 +205,24 @@
return this;
}
-bool Audio::Init(PluginDelegate* plugin_delegate, PP_Resource config_id,
- PPB_Audio_Callback callback, void* user_data) {
- CHECK(!audio_.get());
+bool Audio::Init(PluginDelegate* plugin_delegate,
+ PP_Instance instance_id,
+ PP_Resource config_id,
+ PPB_Audio_Callback callback, void* user_data,
+ PPB_AudioTrusted_Callback create_callback) {
+ CHECK(!audio_);
config_ = Resource::GetAs<AudioConfig>(config_id);
if (!config_)
return false;
+ pp_instance_ = instance_id;
callback_ = callback;
user_data_ = user_data;
- // When the stream is created, we'll get called back in StreamCreated().
- audio_.reset(plugin_delegate->CreateAudio(config_->sample_rate(),
- config_->sample_frame_count(),
- this));
- return audio_.get() != NULL;
+ create_callback_ = create_callback;
+ // When the stream is created, we'll get called back on StreamCreated().
+ audio_ = plugin_delegate->CreateAudio(config_->sample_rate(),
+ config_->sample_frame_count(),
+ this);
+ return audio_ != NULL;
}
bool Audio::StartPlayback() {
@@ -249,7 +260,19 @@
socket_.reset(new base::SyncSocket(socket_handle));
shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false));
shared_memory_size_ = shared_memory_size;
-
+ // Trusted side of proxy can specify a callback to recieve handles on.
+ if (create_callback_) {
+#if OS_LINUX || OS_MAC
+ int64_t shm_handle = static_cast<int64_t>(shared_memory_handle.fd);
+#elif OS_WIN
+ int64_T shm_handle = static_cast<int64_t>(shared_memory_handle);
+#else
+ #error "Unknown OS"
darin (slow to review) 2010/11/19 17:45:39 nit: indent by 4 spaces like the other branches?
+#endif
+ create_callback_(pp_instance_, GetReference(), shm_handle,
+ shared_memory_size, static_cast<int64_t>(socket_handle));
darin (slow to review) 2010/11/19 17:45:39 nit: align the arguments so they all start at the
+ }
+ // Recurring callback to fill audio buffers.
if (callback_) {
shared_memory_->Map(shared_memory_size_);
// In common case StartPlayback() was called before StreamCreated().

Powered by Google App Engine
This is Rietveld 408576698