OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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_output_host.h" | 5 #include "content/renderer/pepper/pepper_audio_output_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_audio_controller.h" | 10 #include "content/renderer/pepper/pepper_audio_controller.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 void PepperAudioOutputHost::StreamCreated( | 81 void PepperAudioOutputHost::StreamCreated( |
82 base::SharedMemoryHandle shared_memory_handle, | 82 base::SharedMemoryHandle shared_memory_handle, |
83 size_t shared_memory_size, | 83 size_t shared_memory_size, |
84 base::SyncSocket::Handle socket) { | 84 base::SyncSocket::Handle socket) { |
85 OnOpenComplete(PP_OK, shared_memory_handle, shared_memory_size, socket); | 85 OnOpenComplete(PP_OK, shared_memory_handle, shared_memory_size, socket); |
86 } | 86 } |
87 | 87 |
88 void PepperAudioOutputHost::StreamCreationFailed() { | 88 void PepperAudioOutputHost::StreamCreationFailed() { |
89 OnOpenComplete(PP_ERROR_FAILED, base::SharedMemory::NULLHandle(), 0, | 89 OnOpenComplete(PP_ERROR_FAILED, base::SharedMemoryHandle(), 0, |
90 base::SyncSocket::kInvalidHandle); | 90 base::SyncSocket::kInvalidHandle); |
91 } | 91 } |
92 | 92 |
93 void PepperAudioOutputHost::SetVolume(double volume) { | 93 void PepperAudioOutputHost::SetVolume(double volume) { |
94 if (audio_output_) | 94 if (audio_output_) |
95 audio_output_->SetVolume(volume); | 95 audio_output_->SetVolume(volume); |
96 } | 96 } |
97 | 97 |
98 int32_t PepperAudioOutputHost::OnOpen(ppapi::host::HostMessageContext* context, | 98 int32_t PepperAudioOutputHost::OnOpen(ppapi::host::HostMessageContext* context, |
99 const std::string& device_id, | 99 const std::string& device_id, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 175 } |
176 | 176 |
177 ppapi::proxy::SerializedHandle serialized_socket_handle( | 177 ppapi::proxy::SerializedHandle serialized_socket_handle( |
178 ppapi::proxy::SerializedHandle::SOCKET); | 178 ppapi::proxy::SerializedHandle::SOCKET); |
179 ppapi::proxy::SerializedHandle serialized_shared_memory_handle( | 179 ppapi::proxy::SerializedHandle serialized_shared_memory_handle( |
180 ppapi::proxy::SerializedHandle::SHARED_MEMORY); | 180 ppapi::proxy::SerializedHandle::SHARED_MEMORY); |
181 | 181 |
182 if (result == PP_OK) { | 182 if (result == PP_OK) { |
183 IPC::PlatformFileForTransit temp_socket = | 183 IPC::PlatformFileForTransit temp_socket = |
184 IPC::InvalidPlatformFileForTransit(); | 184 IPC::InvalidPlatformFileForTransit(); |
185 base::SharedMemoryHandle temp_shmem = base::SharedMemory::NULLHandle(); | 185 base::SharedMemoryHandle temp_shmem; |
186 result = GetRemoteHandles(scoped_socket, scoped_shared_memory, &temp_socket, | 186 result = GetRemoteHandles(scoped_socket, scoped_shared_memory, &temp_socket, |
187 &temp_shmem); | 187 &temp_shmem); |
188 | 188 |
189 serialized_socket_handle.set_socket(temp_socket); | 189 serialized_socket_handle.set_socket(temp_socket); |
190 serialized_shared_memory_handle.set_shmem(temp_shmem, shared_memory_size); | 190 serialized_shared_memory_handle.set_shmem(temp_shmem, shared_memory_size); |
191 } | 191 } |
192 | 192 |
193 // Send all the values, even on error. This simplifies some of our cleanup | 193 // Send all the values, even on error. This simplifies some of our cleanup |
194 // code since the handles will be in the other process and could be | 194 // code since the handles will be in the other process and could be |
195 // inconvenient to clean up. Our IPC code will automatically handle this for | 195 // inconvenient to clean up. Our IPC code will automatically handle this for |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 256 |
257 PepperPluginInstanceImpl* instance = static_cast<PepperPluginInstanceImpl*>( | 257 PepperPluginInstanceImpl* instance = static_cast<PepperPluginInstanceImpl*>( |
258 PepperPluginInstance::Get(pp_instance())); | 258 PepperPluginInstance::Get(pp_instance())); |
259 if (instance) | 259 if (instance) |
260 instance->audio_controller().AddInstance(this); | 260 instance->audio_controller().AddInstance(this); |
261 | 261 |
262 audio_output_->StartPlayback(); | 262 audio_output_->StartPlayback(); |
263 } | 263 } |
264 | 264 |
265 } // namespace content | 265 } // namespace content |
OLD | NEW |