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_platform_audio_output_dev.h" | 5 #include "content/renderer/pepper/pepper_platform_audio_output_dev.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" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "content/child/child_process.h" | 15 #include "content/child/child_process.h" |
16 #include "content/common/content_constants_internal.h" | 16 #include "content/common/content_constants_internal.h" |
17 #include "content/common/media/audio_messages.h" | 17 #include "content/renderer/media/audio_ipc_factory.h" |
18 #include "content/renderer/media/audio_message_filter.h" | |
19 #include "content/renderer/pepper/audio_helper.h" | 18 #include "content/renderer/pepper/audio_helper.h" |
20 #include "content/renderer/pepper/pepper_audio_output_host.h" | 19 #include "content/renderer/pepper/pepper_audio_output_host.h" |
21 #include "content/renderer/pepper/pepper_media_device_manager.h" | 20 #include "content/renderer/pepper/pepper_media_device_manager.h" |
22 #include "content/renderer/render_frame_impl.h" | 21 #include "content/renderer/render_frame_impl.h" |
23 #include "content/renderer/render_thread_impl.h" | |
24 #include "media/audio/audio_device_description.h" | 22 #include "media/audio/audio_device_description.h" |
25 #include "ppapi/shared_impl/ppb_audio_config_shared.h" | 23 #include "ppapi/shared_impl/ppb_audio_config_shared.h" |
26 | 24 |
| 25 namespace { |
| 26 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 27 const int64_t kMaxAuthorizationTimeoutMs = 4000; |
| 28 #else |
| 29 const int64_t kMaxAuthorizationTimeoutMs = 0; // No timeout. |
| 30 #endif |
| 31 } |
| 32 |
27 namespace content { | 33 namespace content { |
28 | 34 |
29 // static | 35 // static |
30 PepperPlatformAudioOutputDev* PepperPlatformAudioOutputDev::Create( | 36 PepperPlatformAudioOutputDev* PepperPlatformAudioOutputDev::Create( |
31 int render_frame_id, | 37 int render_frame_id, |
32 const std::string& device_id, | 38 const std::string& device_id, |
33 const GURL& document_url, | 39 const GURL& document_url, |
34 int sample_rate, | 40 int sample_rate, |
35 int frames_per_buffer, | 41 int frames_per_buffer, |
36 PepperAudioOutputHost* client) { | 42 PepperAudioOutputHost* client) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 PepperAudioOutputHost* client) { | 253 PepperAudioOutputHost* client) { |
248 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 254 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
249 | 255 |
250 RenderFrameImpl* const render_frame = | 256 RenderFrameImpl* const render_frame = |
251 RenderFrameImpl::FromRoutingID(render_frame_id_); | 257 RenderFrameImpl::FromRoutingID(render_frame_id_); |
252 if (!render_frame || !client) | 258 if (!render_frame || !client) |
253 return false; | 259 return false; |
254 | 260 |
255 client_ = client; | 261 client_ = client; |
256 | 262 |
257 RenderThreadImpl* const render_thread = RenderThreadImpl::current(); | 263 ipc_ = AudioIPCFactory::get()->CreateAudioOutputIPC(render_frame_id_); |
258 ipc_ = render_thread->audio_message_filter()->CreateAudioOutputIPC( | |
259 render_frame_id_); | |
260 CHECK(ipc_); | 264 CHECK(ipc_); |
261 | 265 |
262 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 266 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
263 media::CHANNEL_LAYOUT_STEREO, sample_rate, | 267 media::CHANNEL_LAYOUT_STEREO, sample_rate, |
264 ppapi::kBitsPerAudioOutputSample, frames_per_buffer); | 268 ppapi::kBitsPerAudioOutputSample, frames_per_buffer); |
265 | 269 |
266 io_task_runner_->PostTask( | 270 io_task_runner_->PostTask( |
267 FROM_HERE, | 271 FROM_HERE, |
268 base::Bind(&PepperPlatformAudioOutputDev::CreateStreamOnIOThread, this, | 272 base::Bind(&PepperPlatformAudioOutputDev::CreateStreamOnIOThread, this, |
269 params_)); | 273 params_)); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 401 } |
398 | 402 |
399 void PepperPlatformAudioOutputDev::NotifyStreamCreationFailed() { | 403 void PepperPlatformAudioOutputDev::NotifyStreamCreationFailed() { |
400 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 404 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
401 | 405 |
402 if (client_) | 406 if (client_) |
403 client_->StreamCreationFailed(); | 407 client_->StreamCreationFailed(); |
404 } | 408 } |
405 | 409 |
406 } // namespace content | 410 } // namespace content |
OLD | NEW |