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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 int sample_rate, | 106 int sample_rate, |
107 int frames_per_buffer, | 107 int frames_per_buffer, |
108 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { | 108 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { |
109 DCHECK(client); | 109 DCHECK(client); |
110 // Make sure we don't call init more than once. | 110 // Make sure we don't call init more than once. |
111 DCHECK_EQ(0, stream_id_); | 111 DCHECK_EQ(0, stream_id_); |
112 | 112 |
113 client_ = client; | 113 client_ = client; |
114 | 114 |
115 media::AudioParameters::Format format; | 115 media::AudioParameters::Format format; |
116 const int kMaxFramesForLowLatency = 2048; | 116 const int kMaxFramesForLowLatency = 2400; |
117 // Use the low latency back end if the client request is compatible, and | 117 // Use the low latency back end if the client request is compatible, and |
118 // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY. | 118 // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY. |
119 if (sample_rate == audio_hardware::GetOutputSampleRate() && | 119 if (sample_rate == audio_hardware::GetOutputSampleRate() && |
120 frames_per_buffer <= kMaxFramesForLowLatency && | 120 frames_per_buffer <= kMaxFramesForLowLatency && |
121 frames_per_buffer % audio_hardware::GetOutputBufferSize() == 0) { | 121 frames_per_buffer % audio_hardware::GetOutputBufferSize() == 0) { |
122 format = media::AudioParameters::AUDIO_PCM_LOW_LATENCY; | 122 format = media::AudioParameters::AUDIO_PCM_LOW_LATENCY; |
123 } else { | 123 } else { |
124 format = media::AudioParameters::AUDIO_PCM_LINEAR; | 124 format = media::AudioParameters::AUDIO_PCM_LINEAR; |
125 } | 125 } |
126 | 126 |
(...skipping 30 matching lines...) Expand all Loading... |
157 | 157 |
158 filter_->Send(new AudioHostMsg_CloseStream(stream_id_)); | 158 filter_->Send(new AudioHostMsg_CloseStream(stream_id_)); |
159 filter_->RemoveDelegate(stream_id_); | 159 filter_->RemoveDelegate(stream_id_); |
160 stream_id_ = 0; | 160 stream_id_ = 0; |
161 | 161 |
162 Release(); // Release for the delegate, balances out the reference taken in | 162 Release(); // Release for the delegate, balances out the reference taken in |
163 // PepperPluginDelegateImpl::CreateAudio. | 163 // PepperPluginDelegateImpl::CreateAudio. |
164 } | 164 } |
165 | 165 |
166 } // namespace content | 166 } // namespace content |
OLD | NEW |