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

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

Issue 2344993003: [Chromecast] Fade in after a mixer input stream has skipped (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 | « chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc ('k') | 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // StreamMixerAlsa::InputQueue implementation: 144 // StreamMixerAlsa::InputQueue implementation:
145 int input_samples_per_second() const override { return samples_per_second_; } 145 int input_samples_per_second() const override { return samples_per_second_; }
146 float volume_multiplier() const override { return multiplier_; } 146 float volume_multiplier() const override { return multiplier_; }
147 bool primary() const override { return primary_; } 147 bool primary() const override { return primary_; }
148 bool IsDeleting() const override { return deleting_; } 148 bool IsDeleting() const override { return deleting_; }
149 MOCK_METHOD1(Initialize, 149 MOCK_METHOD1(Initialize,
150 void(const MediaPipelineBackendAlsa::RenderingDelay& 150 void(const MediaPipelineBackendAlsa::RenderingDelay&
151 mixer_rendering_delay)); 151 mixer_rendering_delay));
152 int MaxReadSize() override { return max_read_size_; } 152 int MaxReadSize() override { return max_read_size_; }
153 MOCK_METHOD2(GetResampledData, void(::media::AudioBus* dest, int frames)); 153 MOCK_METHOD2(GetResampledData, void(::media::AudioBus* dest, int frames));
154 MOCK_METHOD0(OnSkipped, void());
154 MOCK_METHOD1(AfterWriteFrames, 155 MOCK_METHOD1(AfterWriteFrames,
155 void(const MediaPipelineBackendAlsa::RenderingDelay& 156 void(const MediaPipelineBackendAlsa::RenderingDelay&
156 mixer_rendering_delay)); 157 mixer_rendering_delay));
157 MOCK_METHOD1(SignalError, void(StreamMixerAlsaInput::MixerError error)); 158 MOCK_METHOD1(SignalError, void(StreamMixerAlsaInput::MixerError error));
158 MOCK_METHOD1(PrepareToDelete, void(const OnReadyToDeleteCb& delete_cb)); 159 MOCK_METHOD1(PrepareToDelete, void(const OnReadyToDeleteCb& delete_cb));
159 160
160 // Setters and getters for test control. 161 // Setters and getters for test control.
161 void SetPaused(bool paused) { paused_ = paused; } 162 void SetPaused(bool paused) { paused_ = paused; }
162 void SetMaxReadSize(int max_read_size) { max_read_size_ = max_read_size; } 163 void SetMaxReadSize(int max_read_size) { max_read_size_ = max_read_size; }
163 void SetData(std::unique_ptr<::media::AudioBus> data) { 164 void SetData(std::unique_ptr<::media::AudioBus> data) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 370
370 // TODO(slan): Verify that the data is mixed properly with math. 371 // TODO(slan): Verify that the data is mixed properly with math.
371 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, 512)).Times(1); 372 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, 512)).Times(1);
372 mixer->WriteFramesForTest(); 373 mixer->WriteFramesForTest();
373 374
374 // Make two of these streams non-primary, and exhaust a non-primary stream. 375 // Make two of these streams non-primary, and exhaust a non-primary stream.
375 // All non-empty streams shall be polled for data and the mixer shall write 376 // All non-empty streams shall be polled for data and the mixer shall write
376 // to ALSA. 377 // to ALSA.
377 inputs[1]->SetPrimary(false); 378 inputs[1]->SetPrimary(false);
378 inputs[1]->SetMaxReadSize(0); 379 inputs[1]->SetMaxReadSize(0);
380 EXPECT_CALL(*inputs[1], OnSkipped());
379 inputs[2]->SetPrimary(false); 381 inputs[2]->SetPrimary(false);
380 for (auto* input : inputs) { 382 for (auto* input : inputs) {
381 if (input != inputs[1]) 383 if (input != inputs[1])
382 EXPECT_CALL(*input, GetResampledData(_, 1024)).Times(1); 384 EXPECT_CALL(*input, GetResampledData(_, 1024)).Times(1);
383 EXPECT_CALL(*input, AfterWriteFrames(_)).Times(1); 385 EXPECT_CALL(*input, AfterWriteFrames(_)).Times(1);
384 } 386 }
385 // Note that the new smallest stream shall dictate the length of the write. 387 // Note that the new smallest stream shall dictate the length of the write.
386 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, 1024)).Times(1); 388 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, 1024)).Times(1);
387 mixer->WriteFramesForTest(); 389 mixer->WriteFramesForTest();
388 390
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 649
648 // Poll the inputs for data. The first input will provide data (since the 650 // Poll the inputs for data. The first input will provide data (since the
649 // output is in an underrun condition); the second input can't provide any 651 // output is in an underrun condition); the second input can't provide any
650 // data, but AfterWriteFrames() will still be called on it so that it has the 652 // data, but AfterWriteFrames() will still be called on it so that it has the
651 // correct rendering delay. 653 // correct rendering delay.
652 const int kNumFrames = 32; 654 const int kNumFrames = 32;
653 inputs[0]->SetData(GetTestData(0)); 655 inputs[0]->SetData(GetTestData(0));
654 EXPECT_CALL(*inputs[0], GetResampledData(_, kNumFrames)); 656 EXPECT_CALL(*inputs[0], GetResampledData(_, kNumFrames));
655 EXPECT_CALL(*inputs[0], AfterWriteFrames(_)); 657 EXPECT_CALL(*inputs[0], AfterWriteFrames(_));
656 EXPECT_CALL(*inputs[1], GetResampledData(_, _)).Times(0); 658 EXPECT_CALL(*inputs[1], GetResampledData(_, _)).Times(0);
659 EXPECT_CALL(*inputs[1], OnSkipped());
657 EXPECT_CALL(*inputs[1], AfterWriteFrames(_)); 660 EXPECT_CALL(*inputs[1], AfterWriteFrames(_));
658 661
659 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, kNumFrames)).Times(1); 662 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, kNumFrames)).Times(1);
660 mixer->WriteFramesForTest(); 663 mixer->WriteFramesForTest();
661 } 664 }
662 665
663 TEST_F(StreamMixerAlsaTest, StuckStreamWithLowBuffer) { 666 TEST_F(StreamMixerAlsaTest, StuckStreamWithLowBuffer) {
664 // Create a group of input streams. 667 // Create a group of input streams.
665 std::vector<testing::StrictMock<MockInputQueue>*> inputs; 668 std::vector<testing::StrictMock<MockInputQueue>*> inputs;
666 const int kNumInputs = 2; 669 const int kNumInputs = 2;
(...skipping 14 matching lines...) Expand all
681 684
682 // Poll the inputs for data. The first input will provide data (since the 685 // Poll the inputs for data. The first input will provide data (since the
683 // output is in an low buffer condition); the second input can't provide any 686 // output is in an low buffer condition); the second input can't provide any
684 // data, but AfterWriteFrames() will still be called on it so that it has the 687 // data, but AfterWriteFrames() will still be called on it so that it has the
685 // correct rendering delay. 688 // correct rendering delay.
686 const int kNumFrames = 32; 689 const int kNumFrames = 32;
687 inputs[0]->SetData(GetTestData(0)); 690 inputs[0]->SetData(GetTestData(0));
688 EXPECT_CALL(*inputs[0], GetResampledData(_, kNumFrames)); 691 EXPECT_CALL(*inputs[0], GetResampledData(_, kNumFrames));
689 EXPECT_CALL(*inputs[0], AfterWriteFrames(_)); 692 EXPECT_CALL(*inputs[0], AfterWriteFrames(_));
690 EXPECT_CALL(*inputs[1], GetResampledData(_, _)).Times(0); 693 EXPECT_CALL(*inputs[1], GetResampledData(_, _)).Times(0);
694 EXPECT_CALL(*inputs[1], OnSkipped());
691 EXPECT_CALL(*inputs[1], AfterWriteFrames(_)); 695 EXPECT_CALL(*inputs[1], AfterWriteFrames(_));
692 696
693 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, kNumFrames)).Times(1); 697 EXPECT_CALL(*mock_alsa(), PcmWritei(_, _, kNumFrames)).Times(1);
694 mixer->WriteFramesForTest(); 698 mixer->WriteFramesForTest();
695 } 699 }
696 700
697 } // namespace media 701 } // namespace media
698 } // namespace chromecast 702 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698