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/stream_mixer_alsa.h" | 5 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <utility> | 10 #include <utility> |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 pcm_, | 338 pcm_, |
339 pcm_hw_params_, | 339 pcm_hw_params_, |
340 &unsigned_output_samples_per_second, | 340 &unsigned_output_samples_per_second, |
341 kAlsaDirDontCare); | 341 kAlsaDirDontCare); |
342 if (requested_rate != unsigned_output_samples_per_second) { | 342 if (requested_rate != unsigned_output_samples_per_second) { |
343 LOG(ERROR) << "Requested sample rate (" << requested_rate | 343 LOG(ERROR) << "Requested sample rate (" << requested_rate |
344 << " Hz) does not match the actual sample rate (" | 344 << " Hz) does not match the actual sample rate (" |
345 << unsigned_output_samples_per_second | 345 << unsigned_output_samples_per_second |
346 << " Hz). This may lead to lower audio quality."; | 346 << " Hz). This may lead to lower audio quality."; |
347 } | 347 } |
| 348 LOG(INFO) << "Sample rate changed from " << output_samples_per_second_ |
| 349 << " to " << unsigned_output_samples_per_second; |
348 output_samples_per_second_ = | 350 output_samples_per_second_ = |
349 static_cast<int>(unsigned_output_samples_per_second); | 351 static_cast<int>(unsigned_output_samples_per_second); |
350 | 352 |
351 snd_pcm_uframes_t requested_buffer_size = alsa_buffer_size_; | 353 snd_pcm_uframes_t requested_buffer_size = alsa_buffer_size_; |
352 RETURN_ERROR_CODE(PcmHwParamsSetBufferSizeNear, pcm_, pcm_hw_params_, | 354 RETURN_ERROR_CODE(PcmHwParamsSetBufferSizeNear, pcm_, pcm_hw_params_, |
353 &alsa_buffer_size_); | 355 &alsa_buffer_size_); |
354 if (requested_buffer_size != alsa_buffer_size_) { | 356 if (requested_buffer_size != alsa_buffer_size_) { |
355 LOG(ERROR) << "Requested buffer size (" << requested_buffer_size | 357 LOG(ERROR) << "Requested buffer size (" << requested_buffer_size |
356 << " frames) does not match the actual buffer size (" | 358 << " frames) does not match the actual buffer size (" |
357 << alsa_buffer_size_ | 359 << alsa_buffer_size_ |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 rendering_delay_.timestamp_microseconds = | 760 rendering_delay_.timestamp_microseconds = |
759 TimespecToMicroseconds(status_timestamp); | 761 TimespecToMicroseconds(status_timestamp); |
760 snd_pcm_sframes_t delay_frames = alsa_->PcmStatusGetDelay(pcm_status_); | 762 snd_pcm_sframes_t delay_frames = alsa_->PcmStatusGetDelay(pcm_status_); |
761 rendering_delay_.delay_microseconds = static_cast<int64_t>(delay_frames) * | 763 rendering_delay_.delay_microseconds = static_cast<int64_t>(delay_frames) * |
762 base::Time::kMicrosecondsPerSecond / | 764 base::Time::kMicrosecondsPerSecond / |
763 output_samples_per_second_; | 765 output_samples_per_second_; |
764 } | 766 } |
765 | 767 |
766 } // namespace media | 768 } // namespace media |
767 } // namespace chromecast | 769 } // namespace chromecast |
OLD | NEW |