| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 unsigned int duration_ms) { | 95 unsigned int duration_ms) { |
| 96 CrasInputStream* test_stream = new CrasInputStream( | 96 CrasInputStream* test_stream = new CrasInputStream( |
| 97 params, mock_manager_.get(), AudioDeviceDescription::kDefaultDeviceId); | 97 params, mock_manager_.get(), AudioDeviceDescription::kDefaultDeviceId); |
| 98 | 98 |
| 99 ASSERT_TRUE(test_stream->Open()); | 99 ASSERT_TRUE(test_stream->Open()); |
| 100 | 100 |
| 101 // Allow 8 frames variance for SRC in the callback. Different numbers of | 101 // Allow 8 frames variance for SRC in the callback. Different numbers of |
| 102 // samples can be provided when doing non-integer SRC. For example | 102 // samples can be provided when doing non-integer SRC. For example |
| 103 // converting from 192k to 44.1k is a ratio of 4.35 to 1. | 103 // converting from 192k to 44.1k is a ratio of 4.35 to 1. |
| 104 MockAudioInputCallback mock_callback; | 104 MockAudioInputCallback mock_callback; |
| 105 base::WaitableEvent event(false, false); | 105 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 106 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 106 | 107 |
| 107 EXPECT_CALL(mock_callback, OnData(test_stream, _, _, _)) | 108 EXPECT_CALL(mock_callback, OnData(test_stream, _, _, _)) |
| 108 .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal)); | 109 .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal)); |
| 109 | 110 |
| 110 test_stream->Start(&mock_callback); | 111 test_stream->Start(&mock_callback); |
| 111 | 112 |
| 112 // Wait for samples to be captured. | 113 // Wait for samples to be captured. |
| 113 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); | 114 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); |
| 114 | 115 |
| 115 test_stream->Stop(); | 116 test_stream->Stop(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 223 |
| 223 TEST_F(CrasInputStreamTest, CaptureLoopback) { | 224 TEST_F(CrasInputStreamTest, CaptureLoopback) { |
| 224 CrasInputStream* test_stream = | 225 CrasInputStream* test_stream = |
| 225 CreateStream(CHANNEL_LAYOUT_STEREO, kTestFramesPerPacket, | 226 CreateStream(CHANNEL_LAYOUT_STEREO, kTestFramesPerPacket, |
| 226 AudioDeviceDescription::kLoopbackInputDeviceId); | 227 AudioDeviceDescription::kLoopbackInputDeviceId); |
| 227 EXPECT_TRUE(test_stream->Open()); | 228 EXPECT_TRUE(test_stream->Open()); |
| 228 test_stream->Close(); | 229 test_stream->Close(); |
| 229 } | 230 } |
| 230 | 231 |
| 231 } // namespace media | 232 } // namespace media |
| OLD | NEW |