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/common/pepper_file_util.h" | 9 #include "content/common/pepper_file_util.h" |
10 #include "content/renderer/pepper/pepper_media_device_manager.h" | 10 #include "content/renderer/pepper/pepper_media_device_manager.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 void PepperAudioInputHost::StreamCreated( | 62 void PepperAudioInputHost::StreamCreated( |
63 base::SharedMemoryHandle shared_memory_handle, | 63 base::SharedMemoryHandle shared_memory_handle, |
64 size_t shared_memory_size, | 64 size_t shared_memory_size, |
65 base::SyncSocket::Handle socket) { | 65 base::SyncSocket::Handle socket) { |
66 OnOpenComplete(PP_OK, shared_memory_handle, shared_memory_size, socket); | 66 OnOpenComplete(PP_OK, shared_memory_handle, shared_memory_size, socket); |
67 } | 67 } |
68 | 68 |
69 void PepperAudioInputHost::StreamCreationFailed() { | 69 void PepperAudioInputHost::StreamCreationFailed() { |
70 OnOpenComplete(PP_ERROR_FAILED, | 70 OnOpenComplete(PP_ERROR_FAILED, base::SharedMemoryHandle(), 0, |
71 base::SharedMemory::NULLHandle(), | |
72 0, | |
73 base::SyncSocket::kInvalidHandle); | 71 base::SyncSocket::kInvalidHandle); |
74 } | 72 } |
75 | 73 |
76 int32_t PepperAudioInputHost::OnOpen(ppapi::host::HostMessageContext* context, | 74 int32_t PepperAudioInputHost::OnOpen(ppapi::host::HostMessageContext* context, |
77 const std::string& device_id, | 75 const std::string& device_id, |
78 PP_AudioSampleRate sample_rate, | 76 PP_AudioSampleRate sample_rate, |
79 uint32_t sample_frame_count) { | 77 uint32_t sample_frame_count) { |
80 if (open_context_.is_valid()) | 78 if (open_context_.is_valid()) |
81 return PP_ERROR_INPROGRESS; | 79 return PP_ERROR_INPROGRESS; |
82 if (audio_input_) | 80 if (audio_input_) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 135 } |
138 | 136 |
139 ppapi::proxy::SerializedHandle serialized_socket_handle( | 137 ppapi::proxy::SerializedHandle serialized_socket_handle( |
140 ppapi::proxy::SerializedHandle::SOCKET); | 138 ppapi::proxy::SerializedHandle::SOCKET); |
141 ppapi::proxy::SerializedHandle serialized_shared_memory_handle( | 139 ppapi::proxy::SerializedHandle serialized_shared_memory_handle( |
142 ppapi::proxy::SerializedHandle::SHARED_MEMORY); | 140 ppapi::proxy::SerializedHandle::SHARED_MEMORY); |
143 | 141 |
144 if (result == PP_OK) { | 142 if (result == PP_OK) { |
145 IPC::PlatformFileForTransit temp_socket = | 143 IPC::PlatformFileForTransit temp_socket = |
146 IPC::InvalidPlatformFileForTransit(); | 144 IPC::InvalidPlatformFileForTransit(); |
147 base::SharedMemoryHandle temp_shmem = base::SharedMemory::NULLHandle(); | 145 base::SharedMemoryHandle temp_shmem; |
148 result = GetRemoteHandles( | 146 result = GetRemoteHandles( |
149 scoped_socket, scoped_shared_memory, &temp_socket, &temp_shmem); | 147 scoped_socket, scoped_shared_memory, &temp_socket, &temp_shmem); |
150 | 148 |
151 serialized_socket_handle.set_socket(temp_socket); | 149 serialized_socket_handle.set_socket(temp_socket); |
152 serialized_shared_memory_handle.set_shmem(temp_shmem, shared_memory_size); | 150 serialized_shared_memory_handle.set_shmem(temp_shmem, shared_memory_size); |
153 } | 151 } |
154 | 152 |
155 // Send all the values, even on error. This simplifies some of our cleanup | 153 // Send all the values, even on error. This simplifies some of our cleanup |
156 // code since the handles will be in the other process and could be | 154 // code since the handles will be in the other process and could be |
157 // inconvenient to clean up. Our IPC code will automatically handle this for | 155 // inconvenient to clean up. Our IPC code will automatically handle this for |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 SendOpenReply(PP_ERROR_ABORTED); | 190 SendOpenReply(PP_ERROR_ABORTED); |
193 } | 191 } |
194 | 192 |
195 void PepperAudioInputHost::SendOpenReply(int32_t result) { | 193 void PepperAudioInputHost::SendOpenReply(int32_t result) { |
196 open_context_.params.set_result(result); | 194 open_context_.params.set_result(result); |
197 host()->SendReply(open_context_, PpapiPluginMsg_AudioInput_OpenReply()); | 195 host()->SendReply(open_context_, PpapiPluginMsg_AudioInput_OpenReply()); |
198 open_context_ = ppapi::host::ReplyMessageContext(); | 196 open_context_ = ppapi::host::ReplyMessageContext(); |
199 } | 197 } |
200 | 198 |
201 } // namespace content | 199 } // namespace content |
OLD | NEW |