Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: chromecast/media/cma/backend/alsa/stream_mixer_alsa.cc

Issue 2342913002: [Chromecast] Don't DCHECK the result of snd_pcm_status_get_avail (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 base::Bind(&StreamMixerAlsa::WriteFrames, base::Unretained(this))); 757 base::Bind(&StreamMixerAlsa::WriteFrames, base::Unretained(this)));
758 } 758 }
759 } 759 }
760 760
761 bool StreamMixerAlsa::TryWriteFrames() { 761 bool StreamMixerAlsa::TryWriteFrames() {
762 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); 762 DCHECK(mixer_task_runner_->BelongsToCurrentThread());
763 if (state_ != kStateNormalPlayback) { 763 if (state_ != kStateNormalPlayback) {
764 return false; 764 return false;
765 } 765 }
766 766
767 const int min_frames_in_buffer =
768 output_samples_per_second_ * kMinBufferedDataMs / 1000;
767 int chunk_size = output_samples_per_second_ * kMaxWriteSizeMs / 1000; 769 int chunk_size = output_samples_per_second_ * kMaxWriteSizeMs / 1000;
768 std::vector<InputQueue*> active_inputs; 770 std::vector<InputQueue*> active_inputs;
769 for (auto&& input : inputs_) { 771 for (auto&& input : inputs_) {
770 int read_size = input->MaxReadSize(); 772 int read_size = input->MaxReadSize();
771 if (read_size > 0) { 773 if (read_size > 0) {
772 active_inputs.push_back(input.get()); 774 active_inputs.push_back(input.get());
773 chunk_size = std::min(chunk_size, read_size); 775 chunk_size = std::min(chunk_size, read_size);
774 } else if (input->primary()) { 776 } else if (input->primary()) {
775 if (alsa_->PcmStatus(pcm_, pcm_status_) != 0) { 777 if (alsa_->PcmStatus(pcm_, pcm_status_) != 0) {
776 LOG(ERROR) << "Failed to get status"; 778 LOG(ERROR) << "Failed to get status";
777 return false; 779 return false;
778 } 780 }
779 781
780 const int min_frames_in_buffer =
781 output_samples_per_second_ * kMinBufferedDataMs / 1000;
782 int frames_in_buffer = 782 int frames_in_buffer =
783 alsa_buffer_size_ - alsa_->PcmStatusGetAvail(pcm_status_); 783 alsa_buffer_size_ - alsa_->PcmStatusGetAvail(pcm_status_);
784 DCHECK_GE(frames_in_buffer, 0);
785 if (alsa_->PcmStatusGetState(pcm_status_) == SND_PCM_STATE_XRUN || 784 if (alsa_->PcmStatusGetState(pcm_status_) == SND_PCM_STATE_XRUN ||
786 frames_in_buffer < min_frames_in_buffer) { 785 frames_in_buffer < min_frames_in_buffer) {
787 // If there has been (or soon will be) an underrun, continue without the 786 // If there has been (or soon will be) an underrun, continue without the
788 // empty primary input stream. 787 // empty primary input stream.
789 continue; 788 continue;
790 } 789 }
791 790
792 // A primary input cannot provide any data, so wait until later. 791 // A primary input cannot provide any data, so wait until later.
793 retry_write_frames_timer_->Start( 792 retry_write_frames_timer_->Start(
794 FROM_HERE, base::TimeDelta::FromMilliseconds(kMinBufferedDataMs / 2), 793 FROM_HERE, base::TimeDelta::FromMilliseconds(kMinBufferedDataMs / 2),
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 DCHECK(std::find(loopback_observers_.begin(), loopback_observers_.end(), 942 DCHECK(std::find(loopback_observers_.begin(), loopback_observers_.end(),
944 observer) != loopback_observers_.end()); 943 observer) != loopback_observers_.end());
945 loopback_observers_.erase(std::remove(loopback_observers_.begin(), 944 loopback_observers_.erase(std::remove(loopback_observers_.begin(),
946 loopback_observers_.end(), observer), 945 loopback_observers_.end(), observer),
947 loopback_observers_.end()); 946 loopback_observers_.end());
948 observer->OnRemoved(); 947 observer->OnRemoved();
949 } 948 }
950 949
951 } // namespace media 950 } // namespace media
952 } // namespace chromecast 951 } // namespace chromecast
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698