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

Side by Side Diff: media/audio/virtual_audio_input_stream_unittest.cc

Issue 344583002: Modifies AudioInputCallback::OnData and use media::AudioBus instead of plain byte vector (Relanding) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added extra non-pure OnData API 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 <list> 5 #include <list>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 14 matching lines...) Expand all
25 25
26 namespace { 26 namespace {
27 27
28 const AudioParameters kParams( 28 const AudioParameters kParams(
29 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, 8000, 8, 10); 29 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, 8000, 8, 10);
30 30
31 class MockInputCallback : public AudioInputStream::AudioInputCallback { 31 class MockInputCallback : public AudioInputStream::AudioInputCallback {
32 public: 32 public:
33 MockInputCallback() 33 MockInputCallback()
34 : data_pushed_(false, false) { 34 : data_pushed_(false, false) {
35 ON_CALL(*this, OnData(_, _, _, _, _)) 35 ON_CALL(*this, OnData(_, _, _, _)).WillByDefault(
36 .WillByDefault(InvokeWithoutArgs(&data_pushed_, 36 InvokeWithoutArgs(&data_pushed_, &base::WaitableEvent::Signal));
37 &base::WaitableEvent::Signal));
38 } 37 }
39 38
40 virtual ~MockInputCallback() {} 39 virtual ~MockInputCallback() {}
41 40
42 MOCK_METHOD5(OnData, void(AudioInputStream* stream, const uint8* data, 41 MOCK_METHOD4(OnData,
43 uint32 size, uint32 hardware_delay_bytes, 42 void(AudioInputStream* stream,
44 double volume)); 43 const AudioBus* source,
44 uint32 hardware_delay_bytes,
45 double volume));
45 MOCK_METHOD1(OnError, void(AudioInputStream* stream)); 46 MOCK_METHOD1(OnError, void(AudioInputStream* stream));
46 47
47 void WaitForDataPushes() { 48 void WaitForDataPushes() {
48 for (int i = 0; i < 3; ++i) { 49 for (int i = 0; i < 3; ++i) {
49 data_pushed_.Wait(); 50 data_pushed_.Wait();
50 } 51 }
51 } 52 }
52 53
53 private: 54 private:
54 base::WaitableEvent data_pushed_; 55 base::WaitableEvent data_pushed_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 107
107 void Create() { 108 void Create() {
108 const bool worker_is_separate_thread = GetParam(); 109 const bool worker_is_separate_thread = GetParam();
109 stream_ = new VirtualAudioInputStream( 110 stream_ = new VirtualAudioInputStream(
110 kParams, GetWorkerTaskRunner(worker_is_separate_thread), 111 kParams, GetWorkerTaskRunner(worker_is_separate_thread),
111 base::Bind(&base::DeletePointer<VirtualAudioInputStream>)); 112 base::Bind(&base::DeletePointer<VirtualAudioInputStream>));
112 stream_->Open(); 113 stream_->Open();
113 } 114 }
114 115
115 void Start() { 116 void Start() {
116 EXPECT_CALL(input_callback_, OnData(_, NotNull(), _, _, _)) 117 EXPECT_CALL(input_callback_, OnData(_, NotNull(), _, _)).Times(AtLeast(1));
117 .Times(AtLeast(1));
118 118
119 ASSERT_TRUE(!!stream_); 119 ASSERT_TRUE(!!stream_);
120 stream_->Start(&input_callback_); 120 stream_->Start(&input_callback_);
121 } 121 }
122 122
123 void CreateAndStartOneOutputStream() { 123 void CreateAndStartOneOutputStream() {
124 ASSERT_TRUE(!!stream_); 124 ASSERT_TRUE(!!stream_);
125 AudioOutputStream* const output_stream = new VirtualAudioOutputStream( 125 AudioOutputStream* const output_stream = new VirtualAudioOutputStream(
126 kParams, 126 kParams,
127 stream_, 127 stream_,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 337 }
338 RUN_ON_AUDIO_THREAD(Close); 338 RUN_ON_AUDIO_THREAD(Close);
339 WaitUntilClosed(); 339 WaitUntilClosed();
340 } 340 }
341 341
342 INSTANTIATE_TEST_CASE_P(SingleVersusMultithreaded, 342 INSTANTIATE_TEST_CASE_P(SingleVersusMultithreaded,
343 VirtualAudioInputStreamTest, 343 VirtualAudioInputStreamTest,
344 ::testing::Values(false, true)); 344 ::testing::Values(false, true));
345 345
346 } // namespace media 346 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/virtual_audio_input_stream.cc ('k') | media/audio/win/audio_low_latency_input_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698