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

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

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Pass target playout time to AudioSourceCallback::OnMoreData. Created 4 years, 4 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 "media/audio/audio_output_controller.h" 5 #include "media/audio/audio_output_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/environment.h" 12 #include "base/environment.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/test/test_message_loop.h" 19 #include "base/test/test_message_loop.h"
20 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
21 #include "base/time/time.h"
21 #include "media/audio/audio_device_description.h" 22 #include "media/audio/audio_device_description.h"
22 #include "media/audio/audio_source_diverter.h" 23 #include "media/audio/audio_source_diverter.h"
23 #include "media/base/audio_bus.h" 24 #include "media/base/audio_bus.h"
24 #include "media/base/audio_parameters.h" 25 #include "media/base/audio_parameters.h"
25 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
27 28
28 using ::testing::_; 29 using ::testing::_;
29 using ::testing::AtLeast; 30 using ::testing::AtLeast;
30 using ::testing::DoAll; 31 using ::testing::DoAll;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 194
194 void StartDuplicating(MockAudioPushSink* sink) { 195 void StartDuplicating(MockAudioPushSink* sink) {
195 controller_->StartDuplicating(sink); 196 controller_->StartDuplicating(sink);
196 base::RunLoop().RunUntilIdle(); 197 base::RunLoop().RunUntilIdle();
197 } 198 }
198 199
199 void ReadDivertedAudioData() { 200 void ReadDivertedAudioData() {
200 std::unique_ptr<AudioBus> dest = AudioBus::Create(params_); 201 std::unique_ptr<AudioBus> dest = AudioBus::Create(params_);
201 ASSERT_TRUE(mock_stream_.callback()); 202 ASSERT_TRUE(mock_stream_.callback());
202 const int frames_read = 203 const int frames_read =
203 mock_stream_.callback()->OnMoreData(dest.get(), 0, 0); 204 mock_stream_.callback()->OnMoreData(base::TimeTicks(), 0, dest.get());
chcunningham 2016/07/29 01:21:09 Now?
jameswest 2016/08/26 02:08:47 Done.
204 EXPECT_LT(0, frames_read); 205 EXPECT_LT(0, frames_read);
205 EXPECT_EQ(kBufferNonZeroData, dest->channel(0)[0]); 206 EXPECT_EQ(kBufferNonZeroData, dest->channel(0)[0]);
206 } 207 }
207 208
208 void ReadDuplicatedAudioData(const std::vector<MockAudioPushSink*>& sinks) { 209 void ReadDuplicatedAudioData(const std::vector<MockAudioPushSink*>& sinks) {
209 for (size_t i = 0; i < sinks.size(); i++) { 210 for (size_t i = 0; i < sinks.size(); i++) {
210 EXPECT_CALL(*sinks[i], OnDataCheck(kBufferNonZeroData)); 211 EXPECT_CALL(*sinks[i], OnDataCheck(kBufferNonZeroData));
211 } 212 }
212 213
213 std::unique_ptr<AudioBus> dest = AudioBus::Create(params_); 214 std::unique_ptr<AudioBus> dest = AudioBus::Create(params_);
214 215
215 // It is this OnMoreData() call that triggers |sink|'s OnData(). 216 // It is this OnMoreData() call that triggers |sink|'s OnData().
216 const int frames_read = controller_->OnMoreData(dest.get(), 0, 0); 217 const int frames_read =
218 controller_->OnMoreData(base::TimeTicks(), 0, dest.get());
chcunningham 2016/07/29 01:21:09 Now?
jameswest 2016/08/26 02:08:47 Done.
217 219
218 EXPECT_LT(0, frames_read); 220 EXPECT_LT(0, frames_read);
219 EXPECT_EQ(kBufferNonZeroData, dest->channel(0)[0]); 221 EXPECT_EQ(kBufferNonZeroData, dest->channel(0)[0]);
220 222
221 base::RunLoop().RunUntilIdle(); 223 base::RunLoop().RunUntilIdle();
222 } 224 }
223 225
224 void Revert(bool was_playing) { 226 void Revert(bool was_playing) {
225 if (was_playing) { 227 if (was_playing) {
226 // Expect the handler to receive one OnPlaying() call as a result of the 228 // Expect the handler to receive one OnPlaying() call as a result of the
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 // Switching device would trigger a read, and in turn it would trigger a push 428 // Switching device would trigger a read, and in turn it would trigger a push
427 // to sink. 429 // to sink.
428 EXPECT_CALL(mock_sink, OnDataCheck(kBufferNonZeroData)); 430 EXPECT_CALL(mock_sink, OnDataCheck(kBufferNonZeroData));
429 SwitchDevice(false); 431 SwitchDevice(false);
430 432
431 StopDuplicating(&mock_sink); 433 StopDuplicating(&mock_sink);
432 Close(); 434 Close();
433 } 435 }
434 436
435 } // namespace media 437 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698