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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const ::media::AudioBus& data() { | 172 const ::media::AudioBus& data() { |
173 CHECK(data_); | 173 CHECK(data_); |
174 return *data_; | 174 return *data_; |
175 } | 175 } |
176 float multiplier() const { return multiplier_; } | 176 float multiplier() const { return multiplier_; } |
177 | 177 |
178 private: | 178 private: |
179 void DoGetResampledData(::media::AudioBus* dest, int frames) { | 179 void DoGetResampledData(::media::AudioBus* dest, int frames) { |
180 CHECK(dest); | 180 CHECK(dest); |
181 CHECK_GE(dest->frames(), frames); | 181 CHECK_GE(dest->frames(), frames); |
182 if (data_) | 182 if (data_) { |
183 data_->CopyPartialFramesTo(0, frames, 0, dest); | 183 data_->CopyPartialFramesTo(0, frames, 0, dest); |
| 184 } else { |
| 185 dest->ZeroFramesPartial(0, frames); |
| 186 } |
184 } | 187 } |
185 | 188 |
186 void DoPrepareToDelete(const OnReadyToDeleteCb& delete_cb) { | 189 void DoPrepareToDelete(const OnReadyToDeleteCb& delete_cb) { |
187 deleting_ = true; | 190 deleting_ = true; |
188 delete_cb.Run(this); | 191 delete_cb.Run(this); |
189 } | 192 } |
190 | 193 |
191 bool paused_; | 194 bool paused_; |
192 int samples_per_second_; | 195 int samples_per_second_; |
193 int max_read_size_; | 196 int max_read_size_; |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 | 592 |
590 input->SetMaxReadSize(1024); | 593 input->SetMaxReadSize(1024); |
591 EXPECT_CALL(*input, GetResampledData(_, 1024)); | 594 EXPECT_CALL(*input, GetResampledData(_, 1024)); |
592 EXPECT_CALL(*input, AfterWriteFrames(_)); | 595 EXPECT_CALL(*input, AfterWriteFrames(_)); |
593 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, 1024)).Times(1); | 596 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, 1024)).Times(1); |
594 mixer->WriteFramesForTest(); | 597 mixer->WriteFramesForTest(); |
595 } | 598 } |
596 | 599 |
597 } // namespace media | 600 } // namespace media |
598 } // namespace chromecast | 601 } // namespace chromecast |
OLD | NEW |