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

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

Issue 314713002: Modifies AudioInputCallback::OnData and use media::AudioBus instead of plain byte vector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 <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(_, _, _, _))
36 .WillByDefault(InvokeWithoutArgs(&data_pushed_, 36 .WillByDefault(InvokeWithoutArgs(&data_pushed_,
37 &base::WaitableEvent::Signal)); 37 &base::WaitableEvent::Signal));
38 } 38 }
39 39
40 virtual ~MockInputCallback() {} 40 virtual ~MockInputCallback() {}
41 41
42 MOCK_METHOD5(OnData, void(AudioInputStream* stream, const uint8* data, 42 MOCK_METHOD4(OnData, void(AudioInputStream* stream, const AudioBus* source,
43 uint32 size, uint32 hardware_delay_bytes, 43 uint32 hardware_delay_bytes,
44 double volume)); 44 double volume));
45 MOCK_METHOD1(OnError, void(AudioInputStream* stream)); 45 MOCK_METHOD1(OnError, void(AudioInputStream* stream));
46 46
47 void WaitForDataPushes() { 47 void WaitForDataPushes() {
48 for (int i = 0; i < 3; ++i) { 48 for (int i = 0; i < 3; ++i) {
49 data_pushed_.Wait(); 49 data_pushed_.Wait();
50 } 50 }
51 } 51 }
52 52
53 private: 53 private:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 void Create() { 107 void Create() {
108 const bool worker_is_separate_thread = GetParam(); 108 const bool worker_is_separate_thread = GetParam();
109 stream_ = new VirtualAudioInputStream( 109 stream_ = new VirtualAudioInputStream(
110 kParams, GetWorkerTaskRunner(worker_is_separate_thread), 110 kParams, GetWorkerTaskRunner(worker_is_separate_thread),
111 base::Bind(&base::DeletePointer<VirtualAudioInputStream>)); 111 base::Bind(&base::DeletePointer<VirtualAudioInputStream>));
112 stream_->Open(); 112 stream_->Open();
113 } 113 }
114 114
115 void Start() { 115 void Start() {
116 EXPECT_CALL(input_callback_, OnData(_, NotNull(), _, _, _)) 116 EXPECT_CALL(input_callback_, OnData(_, NotNull(), _, _))
117 .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,
(...skipping 210 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
« media/audio/alsa/alsa_input.cc ('K') | « media/audio/virtual_audio_input_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698