| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/filters/audio_renderer_base.h" | 5 #include "media/filters/audio_renderer_base.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 // Create a callback so our algorithm can request more reads. | 98 // Create a callback so our algorithm can request more reads. |
| 99 AudioRendererAlgorithmBase::RequestReadCallback* cb = | 99 AudioRendererAlgorithmBase::RequestReadCallback* cb = |
| 100 NewCallback(this, &AudioRendererBase::ScheduleRead_Locked); | 100 NewCallback(this, &AudioRendererBase::ScheduleRead_Locked); |
| 101 | 101 |
| 102 // Construct the algorithm. | 102 // Construct the algorithm. |
| 103 algorithm_.reset(new AudioRendererAlgorithmOLA()); | 103 algorithm_.reset(new AudioRendererAlgorithmOLA()); |
| 104 | 104 |
| 105 // Initialize our algorithm with media properties, initial playback rate, | 105 // Initialize our algorithm with media properties, initial playback rate, |
| 106 // and a callback to request more reads from the data source. | 106 // and a callback to request more reads from the data source. |
| 107 AudioDecoderConfig config = decoder_->config(); | 107 ChannelLayout channel_layout = decoder_->channel_layout(); |
| 108 algorithm_->Initialize(ChannelLayoutToChannelCount(config.channel_layout), | 108 int channels = ChannelLayoutToChannelCount(channel_layout); |
| 109 config.sample_rate, | 109 int bits_per_channel = decoder_->bits_per_channel(); |
| 110 config.bits_per_channel, | 110 int sample_rate = decoder_->sample_rate(); |
| 111 0.0f, | 111 algorithm_->Initialize(channels, sample_rate, bits_per_channel, 0.0f, cb); |
| 112 cb); | |
| 113 | 112 |
| 114 // Give the subclass an opportunity to initialize itself. | 113 // Give the subclass an opportunity to initialize itself. |
| 115 if (!OnInitialize(config)) { | 114 if (!OnInitialize(bits_per_channel, channel_layout, sample_rate)) { |
| 116 host()->SetError(PIPELINE_ERROR_INITIALIZATION_FAILED); | 115 host()->SetError(PIPELINE_ERROR_INITIALIZATION_FAILED); |
| 117 callback->Run(); | 116 callback->Run(); |
| 118 return; | 117 return; |
| 119 } | 118 } |
| 120 | 119 |
| 121 // Finally, execute the start callback. | 120 // Finally, execute the start callback. |
| 122 state_ = kPaused; | 121 state_ = kPaused; |
| 123 callback->Run(); | 122 callback->Run(); |
| 124 } | 123 } |
| 125 | 124 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 248 |
| 250 void AudioRendererBase::SetPlaybackRate(float playback_rate) { | 249 void AudioRendererBase::SetPlaybackRate(float playback_rate) { |
| 251 algorithm_->set_playback_rate(playback_rate); | 250 algorithm_->set_playback_rate(playback_rate); |
| 252 } | 251 } |
| 253 | 252 |
| 254 float AudioRendererBase::GetPlaybackRate() { | 253 float AudioRendererBase::GetPlaybackRate() { |
| 255 return algorithm_->playback_rate(); | 254 return algorithm_->playback_rate(); |
| 256 } | 255 } |
| 257 | 256 |
| 258 } // namespace media | 257 } // namespace media |
| OLD | NEW |