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, OnMoreData(_, 0)) | 647 EXPECT_CALL(mock_callback, |
| 648 OnMoreData(_, AllOf( |
| 649 Field(&AudioBuffersState::pending_bytes, 0), |
| 650 Field(&AudioBuffersState::hardware_delay_bytes, 0)))) |
648 .WillOnce(DoAll(ClearBuffer(), Return(kTestFramesPerPacket / 2))); | 651 .WillOnce(DoAll(ClearBuffer(), Return(kTestFramesPerPacket / 2))); |
649 | 652 |
650 bool source_exhausted; | 653 bool source_exhausted; |
651 test_stream->set_source_callback(&mock_callback); | 654 test_stream->set_source_callback(&mock_callback); |
652 test_stream->packet_size_ = kTestPacketSize; | 655 test_stream->packet_size_ = kTestPacketSize; |
653 test_stream->BufferPacket(&source_exhausted); | 656 test_stream->BufferPacket(&source_exhausted); |
654 | 657 |
655 EXPECT_EQ(kTestPacketSize / 2, test_stream->buffer_->forward_bytes()); | 658 EXPECT_EQ(kTestPacketSize / 2, test_stream->buffer_->forward_bytes()); |
656 EXPECT_FALSE(source_exhausted); | 659 EXPECT_FALSE(source_exhausted); |
657 test_stream->Close(); | 660 test_stream->Close(); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 | 855 |
853 // TODO(ajwong): Find a way to test whether or not another task has been | 856 // TODO(ajwong): Find a way to test whether or not another task has been |
854 // posted so we can verify that the Alsa code will indeed break the task | 857 // posted so we can verify that the Alsa code will indeed break the task |
855 // posting loop. | 858 // posting loop. |
856 | 859 |
857 test_stream->TransitionTo(AlsaPcmOutputStream::kIsClosed); | 860 test_stream->TransitionTo(AlsaPcmOutputStream::kIsClosed); |
858 test_stream->Close(); | 861 test_stream->Close(); |
859 } | 862 } |
860 | 863 |
861 } // namespace media | 864 } // namespace media |
OLD | NEW |