| 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_platform_audio_input.h" | 5 #include "content/renderer/pepper/pepper_platform_audio_input.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 client_ = NULL; | 72 client_ = NULL; |
| 73 io_task_runner_->PostTask( | 73 io_task_runner_->PostTask( |
| 74 FROM_HERE, | 74 FROM_HERE, |
| 75 base::Bind(&PepperPlatformAudioInput::ShutDownOnIOThread, this)); | 75 base::Bind(&PepperPlatformAudioInput::ShutDownOnIOThread, this)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void PepperPlatformAudioInput::OnStreamCreated( | 78 void PepperPlatformAudioInput::OnStreamCreated( |
| 79 base::SharedMemoryHandle handle, | 79 base::SharedMemoryHandle handle, |
| 80 base::SyncSocket::Handle socket_handle, | 80 base::SyncSocket::Handle socket_handle, |
| 81 int length, | 81 int length, |
| 82 int total_segments) { | 82 int total_segments, |
| 83 bool initially_muted) { |
| 83 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
| 84 DCHECK(handle.IsValid()); | 85 DCHECK(handle.IsValid()); |
| 85 DCHECK(socket_handle); | 86 DCHECK(socket_handle); |
| 86 #else | 87 #else |
| 87 DCHECK(base::SharedMemory::IsHandleValid(handle)); | 88 DCHECK(base::SharedMemory::IsHandleValid(handle)); |
| 88 DCHECK_NE(-1, socket_handle); | 89 DCHECK_NE(-1, socket_handle); |
| 89 #endif | 90 #endif |
| 90 DCHECK(length); | 91 DCHECK(length); |
| 91 // TODO(yzshen): Make use of circular buffer scheme. crbug.com/181449. | 92 // TODO(yzshen): Make use of circular buffer scheme. crbug.com/181449. |
| 92 DCHECK_EQ(1, total_segments); | 93 DCHECK_EQ(1, total_segments); |
| 93 | 94 |
| 94 if (base::ThreadTaskRunnerHandle::Get().get() != main_task_runner_.get()) { | 95 if (base::ThreadTaskRunnerHandle::Get().get() != main_task_runner_.get()) { |
| 95 // If shutdown has occurred, |client_| will be NULL and the handles will be | 96 // If shutdown has occurred, |client_| will be NULL and the handles will be |
| 96 // cleaned up on the main thread. | 97 // cleaned up on the main thread. |
| 97 main_task_runner_->PostTask( | 98 main_task_runner_->PostTask( |
| 98 FROM_HERE, base::Bind(&PepperPlatformAudioInput::OnStreamCreated, this, | 99 FROM_HERE, |
| 99 handle, socket_handle, length, total_segments)); | 100 base::Bind(&PepperPlatformAudioInput::OnStreamCreated, this, handle, |
| 101 socket_handle, length, total_segments, initially_muted)); |
| 100 } else { | 102 } else { |
| 101 // Must dereference the client only on the main thread. Shutdown may have | 103 // Must dereference the client only on the main thread. Shutdown may have |
| 102 // occurred while the request was in-flight, so we need to NULL check. | 104 // occurred while the request was in-flight, so we need to NULL check. |
| 103 if (client_) { | 105 if (client_) { |
| 104 client_->StreamCreated(handle, length, socket_handle); | 106 client_->StreamCreated(handle, length, socket_handle); |
| 105 } else { | 107 } else { |
| 106 // Clean up the handles. | 108 // Clean up the handles. |
| 107 base::SyncSocket temp_socket(socket_handle); | 109 base::SyncSocket temp_socket(socket_handle); |
| 108 base::SharedMemory temp_shared_memory(handle, false); | 110 base::SharedMemory temp_shared_memory(handle, false); |
| 109 } | 111 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 PepperMediaDeviceManager* PepperPlatformAudioInput::GetMediaDeviceManager() { | 278 PepperMediaDeviceManager* PepperPlatformAudioInput::GetMediaDeviceManager() { |
| 277 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 279 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 278 | 280 |
| 279 RenderFrameImpl* const render_frame = | 281 RenderFrameImpl* const render_frame = |
| 280 RenderFrameImpl::FromRoutingID(render_frame_id_); | 282 RenderFrameImpl::FromRoutingID(render_frame_id_); |
| 281 return render_frame ? | 283 return render_frame ? |
| 282 PepperMediaDeviceManager::GetForRenderFrame(render_frame).get() : NULL; | 284 PepperMediaDeviceManager::GetForRenderFrame(render_frame).get() : NULL; |
| 283 } | 285 } |
| 284 | 286 |
| 285 } // namespace content | 287 } // namespace content |
| OLD | NEW |