| 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/pepper_audio_input_host.h" | 5 #include "content/renderer/pepper/pepper_audio_input_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
| 10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (instance) | 87 if (instance) |
| 88 return instance->delegate(); | 88 return instance->delegate(); |
| 89 return NULL; | 89 return NULL; |
| 90 } | 90 } |
| 91 | 91 |
| 92 int32_t PepperAudioInputHost::OnOpen( | 92 int32_t PepperAudioInputHost::OnOpen( |
| 93 ppapi::host::HostMessageContext* context, | 93 ppapi::host::HostMessageContext* context, |
| 94 const std::string& device_id, | 94 const std::string& device_id, |
| 95 PP_AudioSampleRate sample_rate, | 95 PP_AudioSampleRate sample_rate, |
| 96 uint32_t sample_frame_count) { | 96 uint32_t sample_frame_count) { |
| 97 if (open_context_.get()) | 97 if (open_context_) |
| 98 return PP_ERROR_INPROGRESS; | 98 return PP_ERROR_INPROGRESS; |
| 99 if (audio_input_) | 99 if (audio_input_) |
| 100 return PP_ERROR_FAILED; | 100 return PP_ERROR_FAILED; |
| 101 | 101 |
| 102 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate(); | 102 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate(); |
| 103 if (!plugin_delegate) | 103 if (!plugin_delegate) |
| 104 return PP_ERROR_FAILED; | 104 return PP_ERROR_FAILED; |
| 105 | 105 |
| 106 // When it is done, we'll get called back on StreamCreated() or | 106 // When it is done, we'll get called back on StreamCreated() or |
| 107 // StreamCreationFailed(). | 107 // StreamCreationFailed(). |
| (...skipping 28 matching lines...) Expand all Loading... |
| 136 | 136 |
| 137 void PepperAudioInputHost::OnOpenComplete( | 137 void PepperAudioInputHost::OnOpenComplete( |
| 138 int32_t result, | 138 int32_t result, |
| 139 base::SharedMemoryHandle shared_memory_handle, | 139 base::SharedMemoryHandle shared_memory_handle, |
| 140 size_t shared_memory_size, | 140 size_t shared_memory_size, |
| 141 base::SyncSocket::Handle socket_handle) { | 141 base::SyncSocket::Handle socket_handle) { |
| 142 // Make sure the handles are cleaned up. | 142 // Make sure the handles are cleaned up. |
| 143 base::SyncSocket scoped_socket(socket_handle); | 143 base::SyncSocket scoped_socket(socket_handle); |
| 144 base::SharedMemory scoped_shared_memory(shared_memory_handle, false); | 144 base::SharedMemory scoped_shared_memory(shared_memory_handle, false); |
| 145 | 145 |
| 146 if (!open_context_.get()) { | 146 if (!open_context_) { |
| 147 NOTREACHED(); | 147 NOTREACHED(); |
| 148 return; | 148 return; |
| 149 } | 149 } |
| 150 | 150 |
| 151 ppapi::proxy::SerializedHandle serialized_socket_handle( | 151 ppapi::proxy::SerializedHandle serialized_socket_handle( |
| 152 ppapi::proxy::SerializedHandle::SOCKET); | 152 ppapi::proxy::SerializedHandle::SOCKET); |
| 153 ppapi::proxy::SerializedHandle serialized_shared_memory_handle( | 153 ppapi::proxy::SerializedHandle serialized_shared_memory_handle( |
| 154 ppapi::proxy::SerializedHandle::SHARED_MEMORY); | 154 ppapi::proxy::SerializedHandle::SHARED_MEMORY); |
| 155 | 155 |
| 156 if (result == PP_OK) { | 156 if (result == PP_OK) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return PP_OK; | 201 return PP_OK; |
| 202 } | 202 } |
| 203 | 203 |
| 204 void PepperAudioInputHost::Close() { | 204 void PepperAudioInputHost::Close() { |
| 205 if (!audio_input_) | 205 if (!audio_input_) |
| 206 return; | 206 return; |
| 207 | 207 |
| 208 audio_input_->ShutDown(); | 208 audio_input_->ShutDown(); |
| 209 audio_input_ = NULL; | 209 audio_input_ = NULL; |
| 210 | 210 |
| 211 if (open_context_.get()) { | 211 if (open_context_) { |
| 212 open_context_->params.set_result(PP_ERROR_ABORTED); | 212 open_context_->params.set_result(PP_ERROR_ABORTED); |
| 213 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); | 213 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); |
| 214 open_context_.reset(); | 214 open_context_.reset(); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace content | 218 } // namespace content |
| 219 | 219 |
| OLD | NEW |