| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "webkit/plugins/ppapi/ppb_audio_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_audio_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
| 9 #include "ppapi/c/ppb_audio.h" | 9 #include "ppapi/c/ppb_audio.h" |
| 10 #include "ppapi/c/ppb_audio_config.h" | 10 #include "ppapi/c/ppb_audio_config.h" |
| 11 #include "ppapi/c/trusted/ppb_audio_trusted.h" | 11 #include "ppapi/c/trusted/ppb_audio_trusted.h" |
| 12 #include "ppapi/shared_impl/resource_tracker.h" | 12 #include "ppapi/shared_impl/resource_tracker.h" |
| 13 #include "ppapi/thunk/enter.h" | 13 #include "ppapi/thunk/enter.h" |
| 14 #include "ppapi/thunk/ppb_audio_config_api.h" | 14 #include "ppapi/thunk/ppb_audio_config_api.h" |
| 15 #include "ppapi/thunk/thunk.h" | 15 #include "ppapi/thunk/thunk.h" |
| 16 #include "webkit/plugins/ppapi/common.h" | 16 #include "webkit/plugins/ppapi/common.h" |
| 17 #include "webkit/plugins/ppapi/resource_helper.h" | 17 #include "webkit/plugins/ppapi/resource_helper.h" |
| 18 | 18 |
| 19 using ppapi::PpapiGlobals; | 19 using ppapi::PpapiGlobals; |
| 20 using ppapi::thunk::EnterResourceNoLock; | 20 using ppapi::thunk::EnterResourceNoLock; |
| 21 using ppapi::thunk::PPB_Audio_API; | 21 using ppapi::thunk::PPB_Audio_API; |
| 22 using ppapi::thunk::PPB_AudioConfig_API; | 22 using ppapi::thunk::PPB_AudioConfig_API; |
| 23 using ppapi::TrackedCallback; |
| 23 | 24 |
| 24 namespace webkit { | 25 namespace webkit { |
| 25 namespace ppapi { | 26 namespace ppapi { |
| 26 | 27 |
| 27 // PPB_Audio_Impl -------------------------------------------------------------- | 28 // PPB_Audio_Impl -------------------------------------------------------------- |
| 28 | 29 |
| 29 PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance) | 30 PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance) |
| 30 : Resource(instance), | 31 : Resource(instance), |
| 31 audio_(NULL) { | 32 audio_(NULL) { |
| 32 } | 33 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 DCHECK(!audio_); | 125 DCHECK(!audio_); |
| 125 audio_ = plugin_delegate->CreateAudio(enter.object()->GetSampleRate(), | 126 audio_ = plugin_delegate->CreateAudio(enter.object()->GetSampleRate(), |
| 126 enter.object()->GetSampleFrameCount(), | 127 enter.object()->GetSampleFrameCount(), |
| 127 this); | 128 this); |
| 128 if (!audio_) | 129 if (!audio_) |
| 129 return PP_ERROR_FAILED; | 130 return PP_ERROR_FAILED; |
| 130 | 131 |
| 131 // At this point, we are guaranteeing ownership of the completion | 132 // At this point, we are guaranteeing ownership of the completion |
| 132 // callback. Audio promises to fire the completion callback | 133 // callback. Audio promises to fire the completion callback |
| 133 // once and only once. | 134 // once and only once. |
| 134 SetCallbackInfo(true, create_callback); | 135 SetCreateCallback(new TrackedCallback(this, create_callback)); |
| 135 | 136 |
| 136 return PP_OK_COMPLETIONPENDING; | 137 return PP_OK_COMPLETIONPENDING; |
| 137 } | 138 } |
| 138 | 139 |
| 139 int32_t PPB_Audio_Impl::GetSyncSocket(int* sync_socket) { | 140 int32_t PPB_Audio_Impl::GetSyncSocket(int* sync_socket) { |
| 140 return GetSyncSocketImpl(sync_socket); | 141 return GetSyncSocketImpl(sync_socket); |
| 141 } | 142 } |
| 142 | 143 |
| 143 int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, | 144 int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, |
| 144 uint32_t* shm_size) { | 145 uint32_t* shm_size) { |
| 145 return GetSharedMemoryImpl(shm_handle, shm_size); | 146 return GetSharedMemoryImpl(shm_handle, shm_size); |
| 146 } | 147 } |
| 147 | 148 |
| 148 void PPB_Audio_Impl::OnSetStreamInfo( | 149 void PPB_Audio_Impl::OnSetStreamInfo( |
| 149 base::SharedMemoryHandle shared_memory_handle, | 150 base::SharedMemoryHandle shared_memory_handle, |
| 150 size_t shared_memory_size, | 151 size_t shared_memory_size, |
| 151 base::SyncSocket::Handle socket_handle) { | 152 base::SyncSocket::Handle socket_handle) { |
| 152 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); | 153 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); |
| 153 } | 154 } |
| 154 | 155 |
| 155 } // namespace ppapi | 156 } // namespace ppapi |
| 156 } // namespace webkit | 157 } // namespace webkit |
| OLD | NEW |