OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "media/audio/alsa/alsa_output.h" | 6 #include "media/audio/alsa/alsa_output.h" |
7 #include "media/audio/alsa/alsa_wrapper.h" | 7 #include "media/audio/alsa/alsa_wrapper.h" |
8 #include "media/audio/alsa/audio_manager_alsa.h" | 8 #include "media/audio/alsa/audio_manager_alsa.h" |
9 #include "media/audio/fake_audio_log_factory.h" | 9 #include "media/audio/fake_audio_log_factory.h" |
10 #include "media/audio/mock_audio_source_callback.h" | 10 #include "media/audio/mock_audio_source_callback.h" |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 AlsaPcmOutputStream* test_stream = CreateStream(kTestChannelLayout); | 637 AlsaPcmOutputStream* test_stream = CreateStream(kTestChannelLayout); |
638 InitBuffer(test_stream); | 638 InitBuffer(test_stream); |
639 test_stream->buffer_->Clear(); | 639 test_stream->buffer_->Clear(); |
640 | 640 |
641 // If ALSA has underrun then we should assume a delay of zero. | 641 // If ALSA has underrun then we should assume a delay of zero. |
642 MockAudioSourceCallback mock_callback; | 642 MockAudioSourceCallback mock_callback; |
643 EXPECT_CALL(mock_alsa_wrapper_, PcmState(_)) | 643 EXPECT_CALL(mock_alsa_wrapper_, PcmState(_)) |
644 .WillOnce(Return(SND_PCM_STATE_XRUN)); | 644 .WillOnce(Return(SND_PCM_STATE_XRUN)); |
645 EXPECT_CALL(mock_alsa_wrapper_, PcmAvailUpdate(_)) | 645 EXPECT_CALL(mock_alsa_wrapper_, PcmAvailUpdate(_)) |
646 .WillRepeatedly(Return(0)); // Buffer is full. | 646 .WillRepeatedly(Return(0)); // Buffer is full. |
647 EXPECT_CALL(mock_callback, | 647 EXPECT_CALL(mock_callback, OnMoreData(_, 0)) |
648 OnMoreData(_, AllOf( | |
649 Field(&AudioBuffersState::pending_bytes, 0), | |
650 Field(&AudioBuffersState::hardware_delay_bytes, 0)))) | |
651 .WillOnce(DoAll(ClearBuffer(), Return(kTestFramesPerPacket / 2))); | 648 .WillOnce(DoAll(ClearBuffer(), Return(kTestFramesPerPacket / 2))); |
652 | 649 |
653 bool source_exhausted; | 650 bool source_exhausted; |
654 test_stream->set_source_callback(&mock_callback); | 651 test_stream->set_source_callback(&mock_callback); |
655 test_stream->packet_size_ = kTestPacketSize; | 652 test_stream->packet_size_ = kTestPacketSize; |
656 test_stream->BufferPacket(&source_exhausted); | 653 test_stream->BufferPacket(&source_exhausted); |
657 | 654 |
658 EXPECT_EQ(kTestPacketSize / 2, test_stream->buffer_->forward_bytes()); | 655 EXPECT_EQ(kTestPacketSize / 2, test_stream->buffer_->forward_bytes()); |
659 EXPECT_FALSE(source_exhausted); | 656 EXPECT_FALSE(source_exhausted); |
660 test_stream->Close(); | 657 test_stream->Close(); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 | 852 |
856 // TODO(ajwong): Find a way to test whether or not another task has been | 853 // TODO(ajwong): Find a way to test whether or not another task has been |
857 // posted so we can verify that the Alsa code will indeed break the task | 854 // posted so we can verify that the Alsa code will indeed break the task |
858 // posting loop. | 855 // posting loop. |
859 | 856 |
860 test_stream->TransitionTo(AlsaPcmOutputStream::kIsClosed); | 857 test_stream->TransitionTo(AlsaPcmOutputStream::kIsClosed); |
861 test_stream->Close(); | 858 test_stream->Close(); |
862 } | 859 } |
863 | 860 |
864 } // namespace media | 861 } // namespace media |
OLD | NEW |