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 16 matching lines...) Expand all Loading... |
27 TRACE_EVENT2("cma", __FUNCTION__, #arg1, arg1, #arg2, arg2) | 27 TRACE_EVENT2("cma", __FUNCTION__, #arg1, arg1, #arg2, arg2) |
28 | 28 |
29 namespace chromecast { | 29 namespace chromecast { |
30 namespace media { | 30 namespace media { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 const CastAudioDecoder::OutputFormat kDecoderSampleFormat = | 34 const CastAudioDecoder::OutputFormat kDecoderSampleFormat = |
35 CastAudioDecoder::kOutputPlanarFloat; | 35 CastAudioDecoder::kOutputPlanarFloat; |
36 | 36 |
37 const int kInvalidSampleRate = -1; | |
38 const int64_t kInvalidDelayTimestamp = std::numeric_limits<int64_t>::min(); | 37 const int64_t kInvalidDelayTimestamp = std::numeric_limits<int64_t>::min(); |
39 | 38 |
40 AudioDecoderAlsa::RenderingDelay kInvalidRenderingDelay() { | 39 AudioDecoderAlsa::RenderingDelay kInvalidRenderingDelay() { |
41 AudioDecoderAlsa::RenderingDelay delay; | 40 AudioDecoderAlsa::RenderingDelay delay; |
42 delay.timestamp_microseconds = kInvalidDelayTimestamp; | 41 delay.timestamp_microseconds = kInvalidDelayTimestamp; |
43 delay.delay_microseconds = 0; | 42 delay.delay_microseconds = 0; |
44 return delay; | 43 return delay; |
45 } | 44 } |
46 | 45 |
47 } // namespace | 46 } // namespace |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 last_known_delay_.timestamp_microseconds = kInvalidDelayTimestamp; | 85 last_known_delay_.timestamp_microseconds = kInvalidDelayTimestamp; |
87 return false; | 86 return false; |
88 } | 87 } |
89 last_known_delay_.delay_microseconds = 0; | 88 last_known_delay_.delay_microseconds = 0; |
90 return true; | 89 return true; |
91 } | 90 } |
92 | 91 |
93 bool AudioDecoderAlsa::Start(int64_t start_pts) { | 92 bool AudioDecoderAlsa::Start(int64_t start_pts) { |
94 TRACE_FUNCTION_ENTRY0(); | 93 TRACE_FUNCTION_ENTRY0(); |
95 current_pts_ = start_pts; | 94 current_pts_ = start_pts; |
96 DCHECK_NE(config_.samples_per_second, kInvalidSampleRate); | 95 DCHECK(IsValidConfig(config_)); |
97 mixer_input_.reset(new StreamMixerAlsaInput( | 96 mixer_input_.reset(new StreamMixerAlsaInput( |
98 this, config_.samples_per_second, backend_->Primary())); | 97 this, config_.samples_per_second, backend_->Primary())); |
99 mixer_input_->SetVolumeMultiplier(volume_multiplier_); | 98 mixer_input_->SetVolumeMultiplier(volume_multiplier_); |
100 // Create decoder_ if necessary. This can happen if Stop() was called, and | 99 // Create decoder_ if necessary. This can happen if Stop() was called, and |
101 // SetConfig() was not called since then. | 100 // SetConfig() was not called since then. |
102 if (!decoder_) | 101 if (!decoder_) |
103 CreateDecoder(); | 102 CreateDecoder(); |
104 return true; | 103 return true; |
105 } | 104 } |
106 | 105 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 void AudioDecoderAlsa::OnMixerError() { | 289 void AudioDecoderAlsa::OnMixerError() { |
291 TRACE_FUNCTION_ENTRY0(); | 290 TRACE_FUNCTION_ENTRY0(); |
292 DCHECK(task_runner_->BelongsToCurrentThread()); | 291 DCHECK(task_runner_->BelongsToCurrentThread()); |
293 LOG(ERROR) << "Mixer error occured."; | 292 LOG(ERROR) << "Mixer error occured."; |
294 error_ = true; | 293 error_ = true; |
295 delegate_->OnDecoderError(); | 294 delegate_->OnDecoderError(); |
296 } | 295 } |
297 | 296 |
298 } // namespace media | 297 } // namespace media |
299 } // namespace chromecast | 298 } // namespace chromecast |
OLD | NEW |