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

Unified Diff: webkit/plugins/ppapi/ppb_audio_impl.cc

Issue 8138008: Implementation of ppapi audio. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 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/plugins/ppapi/ppb_audio_impl.cc
===================================================================
--- webkit/plugins/ppapi/ppb_audio_impl.cc (revision 103964)
+++ webkit/plugins/ppapi/ppb_audio_impl.cc (working copy)
@@ -28,10 +28,7 @@
PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance)
: Resource(instance),
- audio_(NULL),
- create_callback_pending_(false),
- shared_memory_size_for_create_callback_(0) {
- create_callback_ = PP_MakeCompletionCallback(NULL, NULL);
+ audio_(NULL) {
}
PPB_Audio_Impl::~PPB_Audio_Impl() {
@@ -44,13 +41,6 @@
audio_->ShutDown();
audio_ = NULL;
}
-
- // If the completion callback hasn't fired yet, do so here
- // with an error condition.
- if (create_callback_pending_) {
- PP_RunCompletionCallback(&create_callback_, PP_ERROR_ABORTED);
- create_callback_pending_ = false;
- }
}
// static
@@ -141,68 +131,33 @@
// At this point, we are guaranteeing ownership of the completion
// callback. Audio promises to fire the completion callback
// once and only once.
- create_callback_ = create_callback;
- create_callback_pending_ = true;
+ SetCallbackInfo(true, create_callback);
+
return PP_OK_COMPLETIONPENDING;
}
int32_t PPB_Audio_Impl::GetSyncSocket(int* sync_socket) {
- if (socket_for_create_callback_.get()) {
-#if defined(OS_POSIX)
- *sync_socket = socket_for_create_callback_->handle();
-#elif defined(OS_WIN)
- *sync_socket = reinterpret_cast<int>(socket_for_create_callback_->handle());
-#else
- #error "Platform not supported."
-#endif
- return PP_OK;
- }
- return PP_ERROR_FAILED;
+ return AudioHelper::GetSyncSocket(sync_socket);
}
-int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, uint32_t* shm_size) {
- if (shared_memory_for_create_callback_.get()) {
-#if defined(OS_POSIX)
- *shm_handle = shared_memory_for_create_callback_->handle().fd;
-#elif defined(OS_WIN)
- *shm_handle = reinterpret_cast<int>(
- shared_memory_for_create_callback_->handle());
-#else
- #error "Platform not supported."
-#endif
- *shm_size = shared_memory_size_for_create_callback_;
- return PP_OK;
- }
- return PP_ERROR_FAILED;
+int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle,
+ uint32_t* shm_size) {
viettrungluu 2011/11/08 00:41:54 indentation
+ return AudioHelper::GetSharedMemory(shm_handle, shm_size);
}
-void PPB_Audio_Impl::StreamCreated(
- base::SharedMemoryHandle shared_memory_handle,
- size_t shared_memory_size,
- base::SyncSocket::Handle socket_handle) {
- if (create_callback_pending_) {
- // Trusted side of proxy can specify a callback to recieve handles. In
- // this case we don't need to map any data or start the thread since it
- // will be handled by the proxy.
- shared_memory_for_create_callback_.reset(
- new base::SharedMemory(shared_memory_handle, false));
- shared_memory_size_for_create_callback_ = shared_memory_size;
- socket_for_create_callback_.reset(new base::SyncSocket(socket_handle));
-
- PP_RunCompletionCallback(&create_callback_, 0);
- create_callback_pending_ = false;
-
- // It might be nice to close the handles here to free up some system
- // resources, but we can't since there's a race condition. The handles must
- // be valid until they're sent over IPC, which is done from the I/O thread
- // which will often get done after this code executes. We could do
- // something more elaborate like an ACK from the plugin or post a task to
- // the I/O thread and back, but this extra complexity doesn't seem worth it
- // just to clean up these handles faster.
- } else {
+void PPB_Audio_Impl::OnSetStreamInfo(
+ base::SharedMemoryHandle shared_memory_handle,
+ size_t shared_memory_size,
+ base::SyncSocket::Handle socket_handle) {
SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle);
- }
}
+void PPB_Audio_Impl::StreamCreated(
+ base::SharedMemoryHandle shared_memory_handle,
viettrungluu 2011/11/08 00:41:54 indentation
+ size_t shared_memory_size,
+ base::SyncSocket::Handle socket_handle) {
+ StreamCreated_(shared_memory_handle, shared_memory_size, socket_handle);
+}
+
} // namespace ppapi
} // namespace webkit

Powered by Google App Engine
This is Rietveld 408576698