| 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 "content/renderer/pepper/ppb_audio_impl.h" | 5 #include "content/renderer/pepper/ppb_audio_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/pepper/common.h" | 8 #include "content/renderer/pepper/common.h" |
| 9 #include "content/renderer/pepper/pepper_platform_audio_output.h" | 9 #include "content/renderer/pepper/pepper_platform_audio_output.h" |
| 10 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 10 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 11 #include "content/renderer/pepper/resource_helper.h" | |
| 12 #include "content/renderer/render_view_impl.h" | 11 #include "content/renderer/render_view_impl.h" |
| 13 #include "media/audio/audio_output_controller.h" | 12 #include "media/audio/audio_output_controller.h" |
| 14 #include "ppapi/c/pp_completion_callback.h" | 13 #include "ppapi/c/pp_completion_callback.h" |
| 15 #include "ppapi/c/ppb_audio.h" | 14 #include "ppapi/c/ppb_audio.h" |
| 16 #include "ppapi/c/ppb_audio_config.h" | 15 #include "ppapi/c/ppb_audio_config.h" |
| 17 #include "ppapi/shared_impl/resource_tracker.h" | 16 #include "ppapi/shared_impl/resource_tracker.h" |
| 18 #include "ppapi/thunk/enter.h" | 17 #include "ppapi/thunk/enter.h" |
| 19 #include "ppapi/thunk/ppb_audio_config_api.h" | 18 #include "ppapi/thunk/ppb_audio_config_api.h" |
| 20 #include "ppapi/thunk/thunk.h" | 19 #include "ppapi/thunk/thunk.h" |
| 21 | 20 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // Validate the config and keep a reference to it. | 66 // Validate the config and keep a reference to it. |
| 68 EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true); | 67 EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true); |
| 69 if (enter.failed()) | 68 if (enter.failed()) |
| 70 return false; | 69 return false; |
| 71 config_ = config; | 70 config_ = config; |
| 72 | 71 |
| 73 if (!callback) | 72 if (!callback) |
| 74 return false; | 73 return false; |
| 75 SetCallback(callback, user_data); | 74 SetCallback(callback, user_data); |
| 76 | 75 |
| 77 PepperPluginInstanceImpl* instance = ResourceHelper::GetPluginInstance(this); | 76 PepperPluginInstance* instance = PepperPluginInstance::Get(pp_instance()); |
| 78 if (!instance) | 77 if (!instance) |
| 79 return false; | 78 return false; |
| 80 | 79 |
| 81 // 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(). |
| 82 CHECK(!audio_); | 81 CHECK(!audio_); |
| 83 audio_ = PepperPlatformAudioOutput::Create( | 82 audio_ = PepperPlatformAudioOutput::Create( |
| 84 static_cast<int>(enter.object()->GetSampleRate()), | 83 static_cast<int>(enter.object()->GetSampleRate()), |
| 85 static_cast<int>(enter.object()->GetSampleFrameCount()), | 84 static_cast<int>(enter.object()->GetSampleFrameCount()), |
| 86 instance->GetRenderView()->GetRoutingID(), | 85 instance->GetRenderView()->GetRoutingID(), |
| 87 this); | 86 this); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 117 | 116 |
| 118 int32_t PPB_Audio_Impl::Open( | 117 int32_t PPB_Audio_Impl::Open( |
| 119 PP_Resource config, | 118 PP_Resource config, |
| 120 scoped_refptr<TrackedCallback> create_callback) { | 119 scoped_refptr<TrackedCallback> create_callback) { |
| 121 // Validate the config and keep a reference to it. | 120 // Validate the config and keep a reference to it. |
| 122 EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true); | 121 EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true); |
| 123 if (enter.failed()) | 122 if (enter.failed()) |
| 124 return PP_ERROR_FAILED; | 123 return PP_ERROR_FAILED; |
| 125 config_ = config; | 124 config_ = config; |
| 126 | 125 |
| 127 PepperPluginInstanceImpl* instance = ResourceHelper::GetPluginInstance(this); | 126 PepperPluginInstance* instance = PepperPluginInstance::Get(pp_instance()); |
| 128 if (!instance) | 127 if (!instance) |
| 129 return PP_ERROR_FAILED; | 128 return PP_ERROR_FAILED; |
| 130 | 129 |
| 131 // When the stream is created, we'll get called back on StreamCreated(). | 130 // When the stream is created, we'll get called back on StreamCreated(). |
| 132 DCHECK(!audio_); | 131 DCHECK(!audio_); |
| 133 audio_ = PepperPlatformAudioOutput::Create( | 132 audio_ = PepperPlatformAudioOutput::Create( |
| 134 static_cast<int>(enter.object()->GetSampleRate()), | 133 static_cast<int>(enter.object()->GetSampleRate()), |
| 135 static_cast<int>(enter.object()->GetSampleFrameCount()), | 134 static_cast<int>(enter.object()->GetSampleFrameCount()), |
| 136 instance->GetRenderView()->GetRoutingID(), | 135 instance->GetRenderView()->GetRoutingID(), |
| 137 this); | 136 this); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 157 | 156 |
| 158 void PPB_Audio_Impl::OnSetStreamInfo( | 157 void PPB_Audio_Impl::OnSetStreamInfo( |
| 159 base::SharedMemoryHandle shared_memory_handle, | 158 base::SharedMemoryHandle shared_memory_handle, |
| 160 size_t shared_memory_size, | 159 size_t shared_memory_size, |
| 161 base::SyncSocket::Handle socket_handle) { | 160 base::SyncSocket::Handle socket_handle) { |
| 162 SetStreamInfo(pp_instance(), shared_memory_handle, shared_memory_size, | 161 SetStreamInfo(pp_instance(), shared_memory_handle, shared_memory_size, |
| 163 socket_handle, sample_frame_count_); | 162 socket_handle, sample_frame_count_); |
| 164 } | 163 } |
| 165 | 164 |
| 166 } // namespace content | 165 } // namespace content |
| OLD | NEW |