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

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

Issue 2689483006: Switch browser side audio capture path to use base time primitives. (Closed)
Patch Set: Bloop Created 3 years, 10 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
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <list> 7 #include <list>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 19 matching lines...) Expand all
30 namespace { 30 namespace {
31 31
32 const AudioParameters kParams( 32 const AudioParameters kParams(
33 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, 8000, 8, 10); 33 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, 8000, 8, 10);
34 34
35 class MockInputCallback : public AudioInputStream::AudioInputCallback { 35 class MockInputCallback : public AudioInputStream::AudioInputCallback {
36 public: 36 public:
37 MockInputCallback() 37 MockInputCallback()
38 : data_pushed_(base::WaitableEvent::ResetPolicy::AUTOMATIC, 38 : data_pushed_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
39 base::WaitableEvent::InitialState::NOT_SIGNALED) { 39 base::WaitableEvent::InitialState::NOT_SIGNALED) {
40 ON_CALL(*this, OnData(_, _, _, _)).WillByDefault( 40 ON_CALL(*this, OnData(_, _, _, _, _))
41 InvokeWithoutArgs(&data_pushed_, &base::WaitableEvent::Signal)); 41 .WillByDefault(
42 InvokeWithoutArgs(&data_pushed_, &base::WaitableEvent::Signal));
42 } 43 }
43 44
44 virtual ~MockInputCallback() {} 45 virtual ~MockInputCallback() {}
45 46
46 MOCK_METHOD4(OnData, 47 MOCK_METHOD5(OnData,
47 void(AudioInputStream* stream, 48 void(AudioInputStream* stream,
48 const AudioBus* source, 49 const AudioBus* source,
49 uint32_t hardware_delay_bytes, 50 base::TimeDelta delay,
51 base::TimeTicks delay_timestamp,
50 double volume)); 52 double volume));
51 MOCK_METHOD1(OnError, void(AudioInputStream* stream)); 53 MOCK_METHOD1(OnError, void(AudioInputStream* stream));
52 54
53 void WaitForDataPushes() { 55 void WaitForDataPushes() {
54 for (int i = 0; i < 3; ++i) { 56 for (int i = 0; i < 3; ++i) {
55 data_pushed_.Wait(); 57 data_pushed_.Wait();
56 } 58 }
57 } 59 }
58 60
59 private: 61 private:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 120
119 void Create() { 121 void Create() {
120 const bool worker_is_separate_thread = GetParam(); 122 const bool worker_is_separate_thread = GetParam();
121 stream_ = new VirtualAudioInputStream( 123 stream_ = new VirtualAudioInputStream(
122 kParams, GetWorkerTaskRunner(worker_is_separate_thread), 124 kParams, GetWorkerTaskRunner(worker_is_separate_thread),
123 base::Bind(&base::DeletePointer<VirtualAudioInputStream>)); 125 base::Bind(&base::DeletePointer<VirtualAudioInputStream>));
124 stream_->Open(); 126 stream_->Open();
125 } 127 }
126 128
127 void Start() { 129 void Start() {
128 EXPECT_CALL(input_callback_, OnData(_, NotNull(), _, _)).Times(AtLeast(1)); 130 EXPECT_CALL(input_callback_, OnData(_, NotNull(), _, _, _))
131 .Times(AtLeast(1));
129 132
130 ASSERT_TRUE(stream_); 133 ASSERT_TRUE(stream_);
131 stream_->Start(&input_callback_); 134 stream_->Start(&input_callback_);
132 } 135 }
133 136
134 void CreateAndStartOneOutputStream() { 137 void CreateAndStartOneOutputStream() {
135 ASSERT_TRUE(stream_); 138 ASSERT_TRUE(stream_);
136 AudioOutputStream* const output_stream = new VirtualAudioOutputStream( 139 AudioOutputStream* const output_stream = new VirtualAudioOutputStream(
137 kParams, 140 kParams,
138 stream_, 141 stream_,
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 352 }
350 RUN_ON_AUDIO_THREAD(Close); 353 RUN_ON_AUDIO_THREAD(Close);
351 WaitUntilClosed(); 354 WaitUntilClosed();
352 } 355 }
353 356
354 INSTANTIATE_TEST_CASE_P(SingleVersusMultithreaded, 357 INSTANTIATE_TEST_CASE_P(SingleVersusMultithreaded,
355 VirtualAudioInputStreamTest, 358 VirtualAudioInputStreamTest,
356 ::testing::Values(false, true)); 359 ::testing::Values(false, true));
357 360
358 } // namespace media 361 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698