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_impl.h" | 5 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 int sample_rate, | 113 int sample_rate, |
114 int frames_per_buffer, | 114 int frames_per_buffer, |
115 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { | 115 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { |
116 DCHECK(client); | 116 DCHECK(client); |
117 // Make sure we don't call init more than once. | 117 // Make sure we don't call init more than once. |
118 DCHECK_EQ(0, stream_id_); | 118 DCHECK_EQ(0, stream_id_); |
119 | 119 |
120 client_ = client; | 120 client_ = client; |
121 | 121 |
122 media::AudioParameters::Format format; | 122 media::AudioParameters::Format format; |
123 const int kMaxFramesForLowLatency = 2400; | 123 const int kMaxFramesForLowLatency = 2047; |
124 // Use the low latency back end if the client request is compatible, and | 124 // Use the low latency back end if the client request is compatible, and |
125 // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY. | 125 // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY. |
126 if (sample_rate == audio_hardware::GetOutputSampleRate() && | 126 if (sample_rate == audio_hardware::GetOutputSampleRate() && |
127 frames_per_buffer <= kMaxFramesForLowLatency && | 127 frames_per_buffer <= kMaxFramesForLowLatency && |
128 frames_per_buffer % audio_hardware::GetOutputBufferSize() == 0) { | 128 frames_per_buffer % audio_hardware::GetOutputBufferSize() == 0) { |
129 format = media::AudioParameters::AUDIO_PCM_LOW_LATENCY; | 129 format = media::AudioParameters::AUDIO_PCM_LOW_LATENCY; |
130 } else { | 130 } else { |
131 format = media::AudioParameters::AUDIO_PCM_LINEAR; | 131 format = media::AudioParameters::AUDIO_PCM_LINEAR; |
132 } | 132 } |
133 | 133 |
(...skipping 30 matching lines...) Expand all Loading... |
164 | 164 |
165 ipc_->CloseStream(stream_id_); | 165 ipc_->CloseStream(stream_id_); |
166 ipc_->RemoveDelegate(stream_id_); | 166 ipc_->RemoveDelegate(stream_id_); |
167 stream_id_ = 0; | 167 stream_id_ = 0; |
168 | 168 |
169 Release(); // Release for the delegate, balances out the reference taken in | 169 Release(); // Release for the delegate, balances out the reference taken in |
170 // PepperPluginDelegateImpl::CreateAudio. | 170 // PepperPluginDelegateImpl::CreateAudio. |
171 } | 171 } |
172 | 172 |
173 } // namespace content | 173 } // namespace content |
OLD | NEW |