| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( | 111 mixer_input_.reset(new StreamMixerAlsaInput( |
| 112 this, config_.samples_per_second, backend_->Primary())); | 112 this, config_.samples_per_second, backend_->Primary(), backend_->Name())); |
| 113 mixer_input_->SetVolumeMultiplier(volume_multiplier_); | 113 mixer_input_->SetVolumeMultiplier(volume_multiplier_); |
| 114 // 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 |
| 115 // SetConfig() was not called since then. | 115 // SetConfig() was not called since then. |
| 116 if (!decoder_) { | 116 if (!decoder_) { |
| 117 CreateDecoder(); | 117 CreateDecoder(); |
| 118 } | 118 } |
| 119 if (!rate_shifter_) { | 119 if (!rate_shifter_) { |
| 120 CreateRateShifter(config_.samples_per_second); | 120 CreateRateShifter(config_.samples_per_second); |
| 121 } | 121 } |
| 122 return true; | 122 return true; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 (config.samples_per_second != config_.samples_per_second); | 222 (config.samples_per_second != config_.samples_per_second); |
| 223 | 223 |
| 224 if (!rate_shifter_ || changed_sample_rate) { | 224 if (!rate_shifter_ || changed_sample_rate) { |
| 225 CreateRateShifter(config.samples_per_second); | 225 CreateRateShifter(config.samples_per_second); |
| 226 } | 226 } |
| 227 | 227 |
| 228 if (mixer_input_ && changed_sample_rate) { | 228 if (mixer_input_ && changed_sample_rate) { |
| 229 // 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 |
| 230 // is updated. | 230 // is updated. |
| 231 mixer_input_.reset(); | 231 mixer_input_.reset(); |
| 232 mixer_input_.reset(new StreamMixerAlsaInput( | 232 mixer_input_.reset(new StreamMixerAlsaInput(this, config.samples_per_second, |
| 233 this, config.samples_per_second, backend_->Primary())); | 233 backend_->Primary(), |
| 234 backend_->Name())); |
| 234 mixer_input_->SetVolumeMultiplier(volume_multiplier_); | 235 mixer_input_->SetVolumeMultiplier(volume_multiplier_); |
| 235 pending_output_frames_ = kNoPendingOutput; | 236 pending_output_frames_ = kNoPendingOutput; |
| 236 } | 237 } |
| 237 | 238 |
| 238 config_ = config; | 239 config_ = config; |
| 239 decoder_.reset(); | 240 decoder_.reset(); |
| 240 CreateDecoder(); | 241 CreateDecoder(); |
| 241 | 242 |
| 242 if (pending_buffer_complete_ && changed_sample_rate) { | 243 if (pending_buffer_complete_ && changed_sample_rate) { |
| 243 pending_buffer_complete_ = false; | 244 pending_buffer_complete_ = false; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 TRACE_FUNCTION_ENTRY0(); | 528 TRACE_FUNCTION_ENTRY0(); |
| 528 DCHECK(task_runner_->BelongsToCurrentThread()); | 529 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 529 if (error != MixerError::kInputIgnored) | 530 if (error != MixerError::kInputIgnored) |
| 530 LOG(ERROR) << "Mixer error occurred."; | 531 LOG(ERROR) << "Mixer error occurred."; |
| 531 mixer_error_ = true; | 532 mixer_error_ = true; |
| 532 delegate_->OnDecoderError(); | 533 delegate_->OnDecoderError(); |
| 533 } | 534 } |
| 534 | 535 |
| 535 } // namespace media | 536 } // namespace media |
| 536 } // namespace chromecast | 537 } // namespace chromecast |
| OLD | NEW |