| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/audio/audio_output_controller.h" | 8 #include "media/audio/audio_output_controller.h" |
| 9 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
| 10 #include "ppapi/c/ppb_audio.h" | 10 #include "ppapi/c/ppb_audio.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 using ppapi::thunk::PPB_AudioConfig_API; | 23 using ppapi::thunk::PPB_AudioConfig_API; |
| 24 using ppapi::TrackedCallback; | 24 using ppapi::TrackedCallback; |
| 25 | 25 |
| 26 namespace webkit { | 26 namespace webkit { |
| 27 namespace ppapi { | 27 namespace ppapi { |
| 28 | 28 |
| 29 // PPB_Audio_Impl -------------------------------------------------------------- | 29 // PPB_Audio_Impl -------------------------------------------------------------- |
| 30 | 30 |
| 31 PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance) | 31 PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance) |
| 32 : Resource(::ppapi::OBJECT_IS_IMPL, instance), | 32 : Resource(::ppapi::OBJECT_IS_IMPL, instance), |
| 33 audio_(NULL) { | 33 audio_(NULL), |
| 34 sample_frame_count_(0) { |
| 34 } | 35 } |
| 35 | 36 |
| 36 PPB_Audio_Impl::~PPB_Audio_Impl() { | 37 PPB_Audio_Impl::~PPB_Audio_Impl() { |
| 37 // Calling ShutDown() makes sure StreamCreated cannot be called anymore and | 38 // Calling ShutDown() makes sure StreamCreated cannot be called anymore and |
| 38 // releases the audio data associated with the pointer. Note however, that | 39 // releases the audio data associated with the pointer. Note however, that |
| 39 // until ShutDown returns, StreamCreated may still be called. This will be | 40 // until ShutDown returns, StreamCreated may still be called. This will be |
| 40 // OK since we'll just immediately clean up the data it stored later in this | 41 // OK since we'll just immediately clean up the data it stored later in this |
| 41 // destructor. | 42 // destructor. |
| 42 if (audio_) { | 43 if (audio_) { |
| 43 audio_->ShutDown(); | 44 audio_->ShutDown(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 74 | 75 |
| 75 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 76 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 76 if (!plugin_delegate) | 77 if (!plugin_delegate) |
| 77 return false; | 78 return false; |
| 78 | 79 |
| 79 // When the stream is created, we'll get called back on StreamCreated(). | 80 // When the stream is created, we'll get called back on StreamCreated(). |
| 80 CHECK(!audio_); | 81 CHECK(!audio_); |
| 81 audio_ = plugin_delegate->CreateAudioOutput( | 82 audio_ = plugin_delegate->CreateAudioOutput( |
| 82 enter.object()->GetSampleRate(), enter.object()->GetSampleFrameCount(), | 83 enter.object()->GetSampleRate(), enter.object()->GetSampleFrameCount(), |
| 83 this); | 84 this); |
| 85 sample_frame_count_ = enter.object()->GetSampleFrameCount(); |
| 84 return audio_ != NULL; | 86 return audio_ != NULL; |
| 85 } | 87 } |
| 86 | 88 |
| 87 PP_Resource PPB_Audio_Impl::GetCurrentConfig() { | 89 PP_Resource PPB_Audio_Impl::GetCurrentConfig() { |
| 88 // AddRef on behalf of caller, while keeping a ref for ourselves. | 90 // AddRef on behalf of caller, while keeping a ref for ourselves. |
| 89 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(config_); | 91 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(config_); |
| 90 return config_; | 92 return config_; |
| 91 } | 93 } |
| 92 | 94 |
| 93 PP_Bool PPB_Audio_Impl::StartPlayback() { | 95 PP_Bool PPB_Audio_Impl::StartPlayback() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, | 148 int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, |
| 147 uint32_t* shm_size) { | 149 uint32_t* shm_size) { |
| 148 return GetSharedMemoryImpl(shm_handle, shm_size); | 150 return GetSharedMemoryImpl(shm_handle, shm_size); |
| 149 } | 151 } |
| 150 | 152 |
| 151 void PPB_Audio_Impl::OnSetStreamInfo( | 153 void PPB_Audio_Impl::OnSetStreamInfo( |
| 152 base::SharedMemoryHandle shared_memory_handle, | 154 base::SharedMemoryHandle shared_memory_handle, |
| 153 size_t shared_memory_size, | 155 size_t shared_memory_size, |
| 154 base::SyncSocket::Handle socket_handle) { | 156 base::SyncSocket::Handle socket_handle) { |
| 155 SetStreamInfo(pp_instance(), shared_memory_handle, shared_memory_size, | 157 SetStreamInfo(pp_instance(), shared_memory_handle, shared_memory_size, |
| 156 socket_handle); | 158 socket_handle, sample_frame_count_); |
| 157 } | 159 } |
| 158 | 160 |
| 159 } // namespace ppapi | 161 } // namespace ppapi |
| 160 } // namespace webkit | 162 } // namespace webkit |
| OLD | NEW |