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 "media/audio/audio_output_resampler.h" | 5 #include "media/audio/audio_output_resampler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 } | 125 } |
126 | 126 |
127 // Include bits per channel differences. | 127 // Include bits per channel differences. |
128 io_ratio_ *= static_cast<double>(params_.bits_per_sample()) / | 128 io_ratio_ *= static_cast<double>(params_.bits_per_sample()) / |
129 output_params_.bits_per_sample(); | 129 output_params_.bits_per_sample(); |
130 | 130 |
131 // Include channel count differences. | 131 // Include channel count differences. |
132 io_ratio_ *= static_cast<double>(params_.channels()) / | 132 io_ratio_ *= static_cast<double>(params_.channels()) / |
133 output_params_.channels(); | 133 output_params_.channels(); |
134 | 134 |
135 // We allow the clients to set the buffer size for low latency path. | |
136 if (output_params_.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY && | |
137 params_.frames_per_buffer() != output_params_.frames_per_buffer()) { | |
scherkus (not reviewing)
2012/09/17 16:27:23
doesn't this essentially disable the FIFO when sam
no longer working on chromium
2012/09/17 21:56:28
True, we should not do this.
| |
138 output_params_.Reset(output_params_.format(), | |
139 output_params_.channel_layout(), | |
140 output_params_.sample_rate(), | |
141 output_params_.bits_per_sample(), | |
142 params_.frames_per_buffer()); | |
143 } | |
144 | |
135 // Since the resampler / output device may want a different buffer size than | 145 // Since the resampler / output device may want a different buffer size than |
136 // the caller asked for, we need to use a FIFO to ensure that both sides | 146 // the caller asked for, we need to use a FIFO to ensure that both sides |
137 // read in chunk sizes they're configured for. | 147 // read in chunk sizes they're configured for. |
138 if (params_.sample_rate() != output_params_.sample_rate() || | 148 if (params_.sample_rate() != output_params_.sample_rate() || |
139 params_.frames_per_buffer() != output_params_.frames_per_buffer()) { | 149 params_.frames_per_buffer() != output_params_.frames_per_buffer()) { |
140 DVLOG(1) << "Rebuffering from " << params_.frames_per_buffer() | 150 DVLOG(1) << "Rebuffering from " << params_.frames_per_buffer() |
141 << " to " << output_params_.frames_per_buffer(); | 151 << " to " << output_params_.frames_per_buffer(); |
142 audio_fifo_.reset(new AudioPullFifo( | 152 audio_fifo_.reset(new AudioPullFifo( |
143 params_.channels(), params_.frames_per_buffer(), base::Bind( | 153 params_.channels(), params_.frames_per_buffer(), base::Bind( |
144 &AudioOutputResampler::SourceCallback_Locked, | 154 &AudioOutputResampler::SourceCallback_Locked, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 source_callback_->OnError(stream, code); | 326 source_callback_->OnError(stream, code); |
317 } | 327 } |
318 | 328 |
319 void AudioOutputResampler::WaitTillDataReady() { | 329 void AudioOutputResampler::WaitTillDataReady() { |
320 base::AutoLock auto_lock(source_lock_); | 330 base::AutoLock auto_lock(source_lock_); |
321 if (source_callback_ && !outstanding_audio_bytes_) | 331 if (source_callback_ && !outstanding_audio_bytes_) |
322 source_callback_->WaitTillDataReady(); | 332 source_callback_->WaitTillDataReady(); |
323 } | 333 } |
324 | 334 |
325 } // namespace media | 335 } // namespace media |
OLD | NEW |