OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chromecast/media/cma/backend/alsa/audio_decoder_alsa.h" | 5 #include "chromecast/media/cma/backend/alsa/audio_decoder_alsa.h" |
6 | 6 |
7 #include <time.h> | 7 #include <time.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 pending_output_frames_ = kNoPendingOutput; | 101 pending_output_frames_ = kNoPendingOutput; |
102 | 102 |
103 last_mixer_delay_.timestamp_microseconds = kInvalidTimestamp; | 103 last_mixer_delay_.timestamp_microseconds = kInvalidTimestamp; |
104 last_mixer_delay_.delay_microseconds = 0; | 104 last_mixer_delay_.delay_microseconds = 0; |
105 } | 105 } |
106 | 106 |
107 bool AudioDecoderAlsa::Start(int64_t start_pts) { | 107 bool AudioDecoderAlsa::Start(int64_t start_pts) { |
108 TRACE_FUNCTION_ENTRY0(); | 108 TRACE_FUNCTION_ENTRY0(); |
109 current_pts_ = start_pts; | 109 current_pts_ = start_pts; |
110 DCHECK(IsValidConfig(config_)); | 110 DCHECK(IsValidConfig(config_)); |
111 mixer_input_.reset(new StreamMixerAlsaInput(this, config_.samples_per_second, | 111 mixer_input_.reset(new StreamMixerAlsaInput( |
112 backend_->Primary(), | 112 this, config_.samples_per_second, backend_->Primary())); |
113 backend_->DeviceId())); | |
114 mixer_input_->SetVolumeMultiplier(volume_multiplier_); | 113 mixer_input_->SetVolumeMultiplier(volume_multiplier_); |
115 // Create decoder_ if necessary. This can happen if Stop() was called, and | 114 // Create decoder_ if necessary. This can happen if Stop() was called, and |
116 // SetConfig() was not called since then. | 115 // SetConfig() was not called since then. |
117 if (!decoder_) { | 116 if (!decoder_) { |
118 CreateDecoder(); | 117 CreateDecoder(); |
119 } | 118 } |
120 if (!rate_shifter_) { | 119 if (!rate_shifter_) { |
121 CreateRateShifter(config_.samples_per_second); | 120 CreateRateShifter(config_.samples_per_second); |
122 } | 121 } |
123 return true; | 122 return true; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 (config.samples_per_second != config_.samples_per_second); | 222 (config.samples_per_second != config_.samples_per_second); |
224 | 223 |
225 if (!rate_shifter_ || changed_sample_rate) { | 224 if (!rate_shifter_ || changed_sample_rate) { |
226 CreateRateShifter(config.samples_per_second); | 225 CreateRateShifter(config.samples_per_second); |
227 } | 226 } |
228 | 227 |
229 if (mixer_input_ && changed_sample_rate) { | 228 if (mixer_input_ && changed_sample_rate) { |
230 // Destroy the old input first to ensure that the mixer output sample rate | 229 // Destroy the old input first to ensure that the mixer output sample rate |
231 // is updated. | 230 // is updated. |
232 mixer_input_.reset(); | 231 mixer_input_.reset(); |
233 mixer_input_.reset(new StreamMixerAlsaInput(this, config.samples_per_second, | 232 mixer_input_.reset(new StreamMixerAlsaInput( |
234 backend_->Primary(), | 233 this, config.samples_per_second, backend_->Primary())); |
235 backend_->DeviceId())); | |
236 mixer_input_->SetVolumeMultiplier(volume_multiplier_); | 234 mixer_input_->SetVolumeMultiplier(volume_multiplier_); |
237 pending_output_frames_ = kNoPendingOutput; | 235 pending_output_frames_ = kNoPendingOutput; |
238 } | 236 } |
239 | 237 |
240 config_ = config; | 238 config_ = config; |
241 decoder_.reset(); | 239 decoder_.reset(); |
242 CreateDecoder(); | 240 CreateDecoder(); |
243 | 241 |
244 if (pending_buffer_complete_ && changed_sample_rate) { | 242 if (pending_buffer_complete_ && changed_sample_rate) { |
245 pending_buffer_complete_ = false; | 243 pending_buffer_complete_ = false; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 TRACE_FUNCTION_ENTRY0(); | 527 TRACE_FUNCTION_ENTRY0(); |
530 DCHECK(task_runner_->BelongsToCurrentThread()); | 528 DCHECK(task_runner_->BelongsToCurrentThread()); |
531 if (error != MixerError::kInputIgnored) | 529 if (error != MixerError::kInputIgnored) |
532 LOG(ERROR) << "Mixer error occurred."; | 530 LOG(ERROR) << "Mixer error occurred."; |
533 mixer_error_ = true; | 531 mixer_error_ = true; |
534 delegate_->OnDecoderError(); | 532 delegate_->OnDecoderError(); |
535 } | 533 } |
536 | 534 |
537 } // namespace media | 535 } // namespace media |
538 } // namespace chromecast | 536 } // namespace chromecast |
OLD | NEW |