| 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_output.h" | 5 #include "content/renderer/pepper/pepper_platform_audio_output.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 "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/child/child_process.h" | 13 #include "content/child/child_process.h" |
| 14 #include "content/common/media/audio_messages.h" | 14 #include "content/renderer/media/audio_ipc_factory.h" |
| 15 #include "content/renderer/media/audio_message_filter.h" | |
| 16 #include "content/renderer/pepper/audio_helper.h" | 15 #include "content/renderer/pepper/audio_helper.h" |
| 17 #include "content/renderer/render_thread_impl.h" | |
| 18 #include "ppapi/shared_impl/ppb_audio_config_shared.h" | 16 #include "ppapi/shared_impl/ppb_audio_config_shared.h" |
| 19 | 17 |
| 20 namespace content { | 18 namespace content { |
| 21 | 19 |
| 22 // static | 20 // static |
| 23 PepperPlatformAudioOutput* PepperPlatformAudioOutput::Create( | 21 PepperPlatformAudioOutput* PepperPlatformAudioOutput::Create( |
| 24 int sample_rate, | 22 int sample_rate, |
| 25 int frames_per_buffer, | 23 int frames_per_buffer, |
| 26 int source_render_frame_id, | 24 int source_render_frame_id, |
| 27 AudioHelper* client) { | 25 AudioHelper* client) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 io_task_runner_(ChildProcess::current()->io_task_runner()) { | 125 io_task_runner_(ChildProcess::current()->io_task_runner()) { |
| 128 } | 126 } |
| 129 | 127 |
| 130 bool PepperPlatformAudioOutput::Initialize(int sample_rate, | 128 bool PepperPlatformAudioOutput::Initialize(int sample_rate, |
| 131 int frames_per_buffer, | 129 int frames_per_buffer, |
| 132 int source_render_frame_id, | 130 int source_render_frame_id, |
| 133 AudioHelper* client) { | 131 AudioHelper* client) { |
| 134 DCHECK(client); | 132 DCHECK(client); |
| 135 client_ = client; | 133 client_ = client; |
| 136 | 134 |
| 137 RenderThreadImpl* const render_thread = RenderThreadImpl::current(); | 135 ipc_ = AudioIPCFactory::get()->CreateAudioOutputIPC(source_render_frame_id); |
| 138 ipc_ = render_thread->audio_message_filter()->CreateAudioOutputIPC( | |
| 139 source_render_frame_id); | |
| 140 CHECK(ipc_); | 136 CHECK(ipc_); |
| 141 | 137 |
| 142 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 138 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 143 media::CHANNEL_LAYOUT_STEREO, | 139 media::CHANNEL_LAYOUT_STEREO, |
| 144 sample_rate, | 140 sample_rate, |
| 145 ppapi::kBitsPerAudioOutputSample, | 141 ppapi::kBitsPerAudioOutputSample, |
| 146 frames_per_buffer); | 142 frames_per_buffer); |
| 147 | 143 |
| 148 io_task_runner_->PostTask( | 144 io_task_runner_->PostTask( |
| 149 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::InitializeOnIOThread, | 145 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::InitializeOnIOThread, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 return; | 180 return; |
| 185 | 181 |
| 186 ipc_->CloseStream(); | 182 ipc_->CloseStream(); |
| 187 ipc_.reset(); | 183 ipc_.reset(); |
| 188 | 184 |
| 189 Release(); // Release for the delegate, balances out the reference taken in | 185 Release(); // Release for the delegate, balances out the reference taken in |
| 190 // PepperPlatformAudioOutput::Create. | 186 // PepperPlatformAudioOutput::Create. |
| 191 } | 187 } |
| 192 | 188 |
| 193 } // namespace content | 189 } // namespace content |
| OLD | NEW |