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

Side by Side Diff: trunk/src/media/audio/cras/cras_input_unittest.cc

Issue 335343004: Revert 277794 "Modifies AudioInputCallback::OnData and use media..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "media/audio/cras/audio_manager_cras.h" 10 #include "media/audio/cras/audio_manager_cras.h"
(...skipping 10 matching lines...) Expand all
21 using testing::_; 21 using testing::_;
22 using testing::AtLeast; 22 using testing::AtLeast;
23 using testing::Ge; 23 using testing::Ge;
24 using testing::InvokeWithoutArgs; 24 using testing::InvokeWithoutArgs;
25 using testing::StrictMock; 25 using testing::StrictMock;
26 26
27 namespace media { 27 namespace media {
28 28
29 class MockAudioInputCallback : public AudioInputStream::AudioInputCallback { 29 class MockAudioInputCallback : public AudioInputStream::AudioInputCallback {
30 public: 30 public:
31 MOCK_METHOD4(OnData, void( 31 MOCK_METHOD5(OnData, void(
32 AudioInputStream*, const AudioBus*, uint32, double)); 32 AudioInputStream*, const uint8*, uint32, uint32, double));
33 MOCK_METHOD1(OnError, void(AudioInputStream*)); 33 MOCK_METHOD1(OnError, void(AudioInputStream*));
34 }; 34 };
35 35
36 class MockAudioManagerCrasInput : public AudioManagerCras { 36 class MockAudioManagerCrasInput : public AudioManagerCras {
37 public: 37 public:
38 MockAudioManagerCrasInput() : AudioManagerCras(&fake_audio_log_factory_) {} 38 MockAudioManagerCrasInput() : AudioManagerCras(&fake_audio_log_factory_) {}
39 39
40 // We need to override this function in order to skip checking the number 40 // We need to override this function in order to skip checking the number
41 // of active output streams. It is because the number of active streams 41 // of active output streams. It is because the number of active streams
42 // is managed inside MakeAudioInputStream, and we don't use 42 // is managed inside MakeAudioInputStream, and we don't use
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 unsigned int duration_ms) { 78 unsigned int duration_ms) {
79 CrasInputStream* test_stream = new CrasInputStream( 79 CrasInputStream* test_stream = new CrasInputStream(
80 params, mock_manager_.get(), AudioManagerBase::kDefaultDeviceId); 80 params, mock_manager_.get(), AudioManagerBase::kDefaultDeviceId);
81 81
82 ASSERT_TRUE(test_stream->Open()); 82 ASSERT_TRUE(test_stream->Open());
83 83
84 // Allow 8 frames variance for SRC in the callback. Different numbers of 84 // Allow 8 frames variance for SRC in the callback. Different numbers of
85 // samples can be provided when doing non-integer SRC. For example 85 // samples can be provided when doing non-integer SRC. For example
86 // converting from 192k to 44.1k is a ratio of 4.35 to 1. 86 // converting from 192k to 44.1k is a ratio of 4.35 to 1.
87 MockAudioInputCallback mock_callback; 87 MockAudioInputCallback mock_callback;
88 unsigned int expected_size = (kTestFramesPerPacket - 8) *
89 params.channels() *
90 params.bits_per_sample() / 8;
91
88 base::WaitableEvent event(false, false); 92 base::WaitableEvent event(false, false);
89 93
90 EXPECT_CALL(mock_callback, 94 EXPECT_CALL(mock_callback,
91 OnData(test_stream, _, _, _)) 95 OnData(test_stream, _, Ge(expected_size), _, _))
92 .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal)); 96 .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal));
93 97
94 test_stream->Start(&mock_callback); 98 test_stream->Start(&mock_callback);
95 99
96 // Wait for samples to be captured. 100 // Wait for samples to be captured.
97 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); 101 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout()));
98 102
99 test_stream->Stop(); 103 test_stream->Stop();
100 test_stream->Close(); 104 test_stream->Close();
101 } 105 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 AudioParameters params_stereo(kTestFormat, 211 AudioParameters params_stereo(kTestFormat,
208 CHANNEL_LAYOUT_STEREO, 212 CHANNEL_LAYOUT_STEREO,
209 rates[i], 213 rates[i],
210 kTestBitsPerSample, 214 kTestBitsPerSample,
211 kTestFramesPerPacket); 215 kTestFramesPerPacket);
212 CaptureSomeFrames(params_stereo, kTestCaptureDurationMs); 216 CaptureSomeFrames(params_stereo, kTestCaptureDurationMs);
213 } 217 }
214 } 218 }
215 219
216 } // namespace media 220 } // namespace media
OLDNEW
« no previous file with comments | « trunk/src/media/audio/cras/cras_input.cc ('k') | trunk/src/media/audio/fake_audio_input_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698