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
3 // found in the LICENSE file.
8 #include "base/basictypes.h"
9 #include "base/environment.h"
10 #include "base/files/file_util.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/path_service.h"
14 #include "base/test/test_timeouts.h"
15 #include "base/time/time.h"
16 #include "base/win/scoped_com_initializer.h"
17 #include "media/audio/audio_io.h"
18 #include "media/audio/audio_manager.h"
19 #include "media/audio/audio_unittest_util.h"
20 #include "media/audio/mock_audio_source_callback.h"
21 #include "media/audio/win/audio_low_latency_output_win.h"
22 #include "media/audio/win/core_audio_util_win.h"
23 #include "media/base/decoder_buffer.h"
24 #include "media/base/seekable_buffer.h"
25 #include "media/base/test_data_util.h"
26 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gmock_mutant.h"
28 #include "testing/gtest/include/gtest/gtest.h"
31 using ::testing::AnyNumber
;
32 using ::testing::AtLeast
;
33 using ::testing::Between
;
34 using ::testing::CreateFunctor
;
35 using ::testing::DoAll
;
37 using ::testing::InvokeWithoutArgs
;
38 using ::testing::NotNull
;
39 using ::testing::Return
;
40 using base::win::ScopedCOMInitializer
;
44 static const char kSpeechFile_16b_s_48k
[] = "speech_16b_stereo_48kHz.raw";
45 static const char kSpeechFile_16b_s_44k
[] = "speech_16b_stereo_44kHz.raw";
46 static const size_t kFileDurationMs
= 20000;
47 static const size_t kNumFileSegments
= 2;
48 static const int kBitsPerSample
= 16;
49 static const size_t kMaxDeltaSamples
= 1000;
50 static const char kDeltaTimeMsFileName
[] = "delta_times_ms.txt";
52 MATCHER_P(HasValidDelay
, value
, "") {
53 // It is difficult to come up with a perfect test condition for the delay
54 // estimation. For now, verify that the produced output delay is always
55 // larger than the selected buffer size.
59 // Used to terminate a loop from a different thread than the loop belongs to.
60 // |loop| should be a MessageLoopProxy.
61 ACTION_P(QuitLoop
, loop
) {
62 loop
->PostTask(FROM_HERE
, base::MessageLoop::QuitClosure());
65 // This audio source implementation should be used for manual tests only since
66 // it takes about 20 seconds to play out a file.
67 class ReadFromFileAudioSource
: public AudioOutputStream::AudioSourceCallback
{
69 explicit ReadFromFileAudioSource(const std::string
& name
)
71 previous_call_time_(base::TimeTicks::Now()),
73 elements_to_write_(0) {
74 // Reads a test file from media/test/data directory.
75 file_
= ReadTestDataFile(name
);
77 // Creates an array that will store delta times between callbacks.
78 // The content of this array will be written to a text file at
79 // destruction and can then be used for off-line analysis of the exact
80 // timing of callbacks. The text file will be stored in media/test/data.
81 delta_times_
.reset(new int[kMaxDeltaSamples
]);
84 virtual ~ReadFromFileAudioSource() {
85 // Get complete file path to output file in directory containing
86 // media_unittests.exe.
87 base::FilePath file_name
;
88 EXPECT_TRUE(PathService::Get(base::DIR_EXE
, &file_name
));
89 file_name
= file_name
.AppendASCII(kDeltaTimeMsFileName
);
91 EXPECT_TRUE(!text_file_
);
92 text_file_
= base::OpenFile(file_name
, "wt");
93 DLOG_IF(ERROR
, !text_file_
) << "Failed to open log file.";
95 // Write the array which contains delta times to a text file.
96 size_t elements_written
= 0;
97 while (elements_written
< elements_to_write_
) {
98 fprintf(text_file_
, "%d\n", delta_times_
[elements_written
]);
102 base::CloseFile(text_file_
);
105 // AudioOutputStream::AudioSourceCallback implementation.
106 virtual int OnMoreData(AudioBus
* audio_bus
,
107 uint32 total_bytes_delay
) {
108 // Store time difference between two successive callbacks in an array.
109 // These values will be written to a file in the destructor.
110 const base::TimeTicks now_time
= base::TimeTicks::Now();
111 const int diff
= (now_time
- previous_call_time_
).InMilliseconds();
112 previous_call_time_
= now_time
;
113 if (elements_to_write_
< kMaxDeltaSamples
) {
114 delta_times_
[elements_to_write_
] = diff
;
115 ++elements_to_write_
;
119 audio_bus
->frames() * audio_bus
->channels() * kBitsPerSample
/ 8;
121 // Use samples read from a data file and fill up the audio buffer
122 // provided to us in the callback.
123 if (pos_
+ static_cast<int>(max_size
) > file_size())
124 max_size
= file_size() - pos_
;
125 int frames
= max_size
/ (audio_bus
->channels() * kBitsPerSample
/ 8);
127 audio_bus
->FromInterleaved(
128 file_
->data() + pos_
, frames
, kBitsPerSample
/ 8);
134 virtual void OnError(AudioOutputStream
* stream
) {}
136 int file_size() { return file_
->data_size(); }
139 scoped_refptr
<DecoderBuffer
> file_
;
140 scoped_ptr
<int[]> delta_times_
;
142 base::TimeTicks previous_call_time_
;
144 size_t elements_to_write_
;
147 static bool ExclusiveModeIsEnabled() {
148 return (WASAPIAudioOutputStream::GetShareMode() ==
149 AUDCLNT_SHAREMODE_EXCLUSIVE
);
152 static bool HasCoreAudioAndOutputDevices(AudioManager
* audio_man
) {
153 // The low-latency (WASAPI-based) version requires Windows Vista or higher.
154 // TODO(henrika): note that we use Wave today to query the number of
155 // existing output devices.
156 return CoreAudioUtil::IsSupported() && audio_man
->HasAudioOutputDevices();
159 // Convenience method which creates a default AudioOutputStream object but
160 // also allows the user to modify the default settings.
161 class AudioOutputStreamWrapper
{
163 explicit AudioOutputStreamWrapper(AudioManager
* audio_manager
)
164 : audio_man_(audio_manager
),
165 format_(AudioParameters::AUDIO_PCM_LOW_LATENCY
),
166 bits_per_sample_(kBitsPerSample
) {
167 AudioParameters preferred_params
;
168 EXPECT_TRUE(SUCCEEDED(CoreAudioUtil::GetPreferredAudioParameters(
169 eRender
, eConsole
, &preferred_params
)));
170 channel_layout_
= preferred_params
.channel_layout();
171 sample_rate_
= preferred_params
.sample_rate();
172 samples_per_packet_
= preferred_params
.frames_per_buffer();
175 ~AudioOutputStreamWrapper() {}
177 // Creates AudioOutputStream object using default parameters.
178 AudioOutputStream
* Create() {
179 return CreateOutputStream();
182 // Creates AudioOutputStream object using non-default parameters where the
183 // frame size is modified.
184 AudioOutputStream
* Create(int samples_per_packet
) {
185 samples_per_packet_
= samples_per_packet
;
186 return CreateOutputStream();
189 // Creates AudioOutputStream object using non-default parameters where the
190 // sample rate and frame size are modified.
191 AudioOutputStream
* Create(int sample_rate
, int samples_per_packet
) {
192 sample_rate_
= sample_rate
;
193 samples_per_packet_
= samples_per_packet
;
194 return CreateOutputStream();
197 AudioParameters::Format
format() const { return format_
; }
198 int channels() const { return ChannelLayoutToChannelCount(channel_layout_
); }
199 int bits_per_sample() const { return bits_per_sample_
; }
200 int sample_rate() const { return sample_rate_
; }
201 int samples_per_packet() const { return samples_per_packet_
; }
204 AudioOutputStream
* CreateOutputStream() {
205 AudioOutputStream
* aos
= audio_man_
->MakeAudioOutputStream(
206 AudioParameters(format_
, channel_layout_
, sample_rate_
,
207 bits_per_sample_
, samples_per_packet_
),
213 AudioManager
* audio_man_
;
214 AudioParameters::Format format_
;
215 ChannelLayout channel_layout_
;
216 int bits_per_sample_
;
218 int samples_per_packet_
;
221 // Convenience method which creates a default AudioOutputStream object.
222 static AudioOutputStream
* CreateDefaultAudioOutputStream(
223 AudioManager
* audio_manager
) {
224 AudioOutputStreamWrapper
aosw(audio_manager
);
225 AudioOutputStream
* aos
= aosw
.Create();
229 // Verify that we can retrieve the current hardware/mixing sample rate
230 // for the default audio device.
231 // TODO(henrika): modify this test when we support full device enumeration.
232 TEST(WASAPIAudioOutputStreamTest
, HardwareSampleRate
) {
233 // Skip this test in exclusive mode since the resulting rate is only utilized
234 // for shared mode streams.
235 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
236 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()) &&
237 ExclusiveModeIsEnabled());
239 // Default device intended for games, system notification sounds,
240 // and voice commands.
241 int fs
= static_cast<int>(
242 WASAPIAudioOutputStream::HardwareSampleRate(std::string()));
246 // Test Create(), Close() calling sequence.
247 TEST(WASAPIAudioOutputStreamTest
, CreateAndClose
) {
248 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
249 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()));
250 AudioOutputStream
* aos
= CreateDefaultAudioOutputStream(audio_manager
.get());
254 // Test Open(), Close() calling sequence.
255 TEST(WASAPIAudioOutputStreamTest
, OpenAndClose
) {
256 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
257 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()));
258 AudioOutputStream
* aos
= CreateDefaultAudioOutputStream(audio_manager
.get());
259 EXPECT_TRUE(aos
->Open());
263 // Test Open(), Start(), Close() calling sequence.
264 TEST(WASAPIAudioOutputStreamTest
, OpenStartAndClose
) {
265 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
266 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()));
267 AudioOutputStream
* aos
= CreateDefaultAudioOutputStream(audio_manager
.get());
268 EXPECT_TRUE(aos
->Open());
269 MockAudioSourceCallback source
;
270 EXPECT_CALL(source
, OnError(aos
))
276 // Test Open(), Start(), Stop(), Close() calling sequence.
277 TEST(WASAPIAudioOutputStreamTest
, OpenStartStopAndClose
) {
278 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
279 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()));
280 AudioOutputStream
* aos
= CreateDefaultAudioOutputStream(audio_manager
.get());
281 EXPECT_TRUE(aos
->Open());
282 MockAudioSourceCallback source
;
283 EXPECT_CALL(source
, OnError(aos
))
290 // Test SetVolume(), GetVolume()
291 TEST(WASAPIAudioOutputStreamTest
, Volume
) {
292 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
293 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()));
294 AudioOutputStream
* aos
= CreateDefaultAudioOutputStream(audio_manager
.get());
296 // Initial volume should be full volume (1.0).
298 aos
->GetVolume(&volume
);
299 EXPECT_EQ(1.0, volume
);
301 // Verify some valid volume settings.
303 aos
->GetVolume(&volume
);
304 EXPECT_EQ(0.0, volume
);
307 aos
->GetVolume(&volume
);
308 EXPECT_EQ(0.5, volume
);
311 aos
->GetVolume(&volume
);
312 EXPECT_EQ(1.0, volume
);
314 // Ensure that invalid volume setting have no effect.
316 aos
->GetVolume(&volume
);
317 EXPECT_EQ(1.0, volume
);
319 aos
->SetVolume(-0.5);
320 aos
->GetVolume(&volume
);
321 EXPECT_EQ(1.0, volume
);
326 // Test some additional calling sequences.
327 TEST(WASAPIAudioOutputStreamTest
, MiscCallingSequences
) {
328 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
329 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()));
331 AudioOutputStream
* aos
= CreateDefaultAudioOutputStream(audio_manager
.get());
332 WASAPIAudioOutputStream
* waos
= static_cast<WASAPIAudioOutputStream
*>(aos
);
334 // Open(), Open() is a valid calling sequence (second call does nothing).
335 EXPECT_TRUE(aos
->Open());
336 EXPECT_TRUE(aos
->Open());
338 MockAudioSourceCallback source
;
340 // Start(), Start() is a valid calling sequence (second call does nothing).
342 EXPECT_TRUE(waos
->started());
344 EXPECT_TRUE(waos
->started());
346 // Stop(), Stop() is a valid calling sequence (second call does nothing).
348 EXPECT_FALSE(waos
->started());
350 EXPECT_FALSE(waos
->started());
352 // Start(), Stop(), Start(), Stop().
354 EXPECT_TRUE(waos
->started());
356 EXPECT_FALSE(waos
->started());
358 EXPECT_TRUE(waos
->started());
360 EXPECT_FALSE(waos
->started());
365 // Use preferred packet size and verify that rendering starts.
366 TEST(WASAPIAudioOutputStreamTest
, ValidPacketSize
) {
367 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
368 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()));
370 base::MessageLoopForUI loop
;
371 MockAudioSourceCallback source
;
373 // Create default WASAPI output stream which plays out in stereo using
374 // the shared mixing rate. The default buffer size is 10ms.
375 AudioOutputStreamWrapper
aosw(audio_manager
.get());
376 AudioOutputStream
* aos
= aosw
.Create();
377 EXPECT_TRUE(aos
->Open());
379 // Derive the expected size in bytes of each packet.
380 uint32 bytes_per_packet
= aosw
.channels() * aosw
.samples_per_packet() *
381 (aosw
.bits_per_sample() / 8);
383 // Wait for the first callback and verify its parameters.
384 EXPECT_CALL(source
, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet
)))
386 QuitLoop(loop
.message_loop_proxy()),
387 Return(aosw
.samples_per_packet())));
390 loop
.PostDelayedTask(FROM_HERE
, base::MessageLoop::QuitClosure(),
391 TestTimeouts::action_timeout());
397 // This test is intended for manual tests and should only be enabled
398 // when it is required to play out data from a local PCM file.
399 // By default, GTest will print out YOU HAVE 1 DISABLED TEST.
400 // To include disabled tests in test execution, just invoke the test program
401 // with --gtest_also_run_disabled_tests or set the GTEST_ALSO_RUN_DISABLED_TESTS
402 // environment variable to a value greater than 0.
403 // The test files are approximately 20 seconds long.
404 TEST(WASAPIAudioOutputStreamTest
, DISABLED_ReadFromStereoFile
) {
405 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
406 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()));
408 AudioOutputStreamWrapper
aosw(audio_manager
.get());
409 AudioOutputStream
* aos
= aosw
.Create();
410 EXPECT_TRUE(aos
->Open());
412 std::string file_name
;
413 if (aosw
.sample_rate() == 48000) {
414 file_name
= kSpeechFile_16b_s_48k
;
415 } else if (aosw
.sample_rate() == 44100) {
416 file_name
= kSpeechFile_16b_s_44k
;
417 } else if (aosw
.sample_rate() == 96000) {
418 // Use 48kHz file at 96kHz as well. Will sound like Donald Duck.
419 file_name
= kSpeechFile_16b_s_48k
;
421 FAIL() << "This test supports 44.1, 48kHz and 96kHz only.";
424 ReadFromFileAudioSource
file_source(file_name
);
426 DVLOG(0) << "File name : " << file_name
.c_str();
427 DVLOG(0) << "Sample rate : " << aosw
.sample_rate();
428 DVLOG(0) << "Bits per sample: " << aosw
.bits_per_sample();
429 DVLOG(0) << "#channels : " << aosw
.channels();
430 DVLOG(0) << "File size : " << file_source
.file_size();
431 DVLOG(0) << "#file segments : " << kNumFileSegments
;
432 DVLOG(0) << ">> Listen to the stereo file while playing...";
434 for (int i
= 0; i
< kNumFileSegments
; i
++) {
435 // Each segment will start with a short (~20ms) block of zeros, hence
436 // some short glitches might be heard in this test if kNumFileSegments
437 // is larger than one. The exact length of the silence period depends on
438 // the selected sample rate.
439 aos
->Start(&file_source
);
440 base::PlatformThread::Sleep(
441 base::TimeDelta::FromMilliseconds(kFileDurationMs
/ kNumFileSegments
));
445 DVLOG(0) << ">> Stereo file playout has stopped.";
449 // Verify that we can open the output stream in exclusive mode using a
450 // certain set of audio parameters and a sample rate of 48kHz.
451 // The expected outcomes of each setting in this test has been derived
452 // manually using log outputs (--v=1).
453 TEST(WASAPIAudioOutputStreamTest
, ExclusiveModeBufferSizesAt48kHz
) {
454 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
455 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()) &&
456 ExclusiveModeIsEnabled());
458 AudioOutputStreamWrapper
aosw(audio_manager
.get());
460 // 10ms @ 48kHz shall work.
461 // Note that, this is the same size as we can use for shared-mode streaming
462 // but here the endpoint buffer delay is only 10ms instead of 20ms.
463 AudioOutputStream
* aos
= aosw
.Create(48000, 480);
464 EXPECT_TRUE(aos
->Open());
467 // 5ms @ 48kHz does not work due to misalignment.
468 // This test will propose an aligned buffer size of 5.3333ms.
469 // Note that we must call Close() even is Open() fails since Close() also
470 // deletes the object and we want to create a new object in the next test.
471 aos
= aosw
.Create(48000, 240);
472 EXPECT_FALSE(aos
->Open());
475 // 5.3333ms @ 48kHz should work (see test above).
476 aos
= aosw
.Create(48000, 256);
477 EXPECT_TRUE(aos
->Open());
480 // 2.6667ms is smaller than the minimum supported size (=3ms).
481 aos
= aosw
.Create(48000, 128);
482 EXPECT_FALSE(aos
->Open());
485 // 3ms does not correspond to an aligned buffer size.
486 // This test will propose an aligned buffer size of 3.3333ms.
487 aos
= aosw
.Create(48000, 144);
488 EXPECT_FALSE(aos
->Open());
491 // 3.3333ms @ 48kHz <=> smallest possible buffer size we can use.
492 aos
= aosw
.Create(48000, 160);
493 EXPECT_TRUE(aos
->Open());
497 // Verify that we can open the output stream in exclusive mode using a
498 // certain set of audio parameters and a sample rate of 44.1kHz.
499 // The expected outcomes of each setting in this test has been derived
500 // manually using log outputs (--v=1).
501 TEST(WASAPIAudioOutputStreamTest
, ExclusiveModeBufferSizesAt44kHz
) {
502 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
503 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()) &&
504 ExclusiveModeIsEnabled());
506 AudioOutputStreamWrapper
aosw(audio_manager
.get());
508 // 10ms @ 44.1kHz does not work due to misalignment.
509 // This test will propose an aligned buffer size of 10.1587ms.
510 AudioOutputStream
* aos
= aosw
.Create(44100, 441);
511 EXPECT_FALSE(aos
->Open());
514 // 10.1587ms @ 44.1kHz shall work (see test above).
515 aos
= aosw
.Create(44100, 448);
516 EXPECT_TRUE(aos
->Open());
519 // 5.8050ms @ 44.1 should work.
520 aos
= aosw
.Create(44100, 256);
521 EXPECT_TRUE(aos
->Open());
524 // 4.9887ms @ 44.1kHz does not work to misalignment.
525 // This test will propose an aligned buffer size of 5.0794ms.
526 // Note that we must call Close() even is Open() fails since Close() also
527 // deletes the object and we want to create a new object in the next test.
528 aos
= aosw
.Create(44100, 220);
529 EXPECT_FALSE(aos
->Open());
532 // 5.0794ms @ 44.1kHz shall work (see test above).
533 aos
= aosw
.Create(44100, 224);
534 EXPECT_TRUE(aos
->Open());
537 // 2.9025ms is smaller than the minimum supported size (=3ms).
538 aos
= aosw
.Create(44100, 132);
539 EXPECT_FALSE(aos
->Open());
542 // 3.01587ms is larger than the minimum size but is not aligned.
543 // This test will propose an aligned buffer size of 3.6281ms.
544 aos
= aosw
.Create(44100, 133);
545 EXPECT_FALSE(aos
->Open());
548 // 3.6281ms @ 44.1kHz <=> smallest possible buffer size we can use.
549 aos
= aosw
.Create(44100, 160);
550 EXPECT_TRUE(aos
->Open());
554 // Verify that we can open and start the output stream in exclusive mode at
555 // the lowest possible delay at 48kHz.
556 TEST(WASAPIAudioOutputStreamTest
, ExclusiveModeMinBufferSizeAt48kHz
) {
557 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
558 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager
.get()) &&
559 ExclusiveModeIsEnabled());
561 base::MessageLoopForUI loop
;
562 MockAudioSourceCallback source
;
564 // Create exclusive-mode WASAPI output stream which plays out in stereo
565 // using the minimum buffer size at 48kHz sample rate.
566 AudioOutputStreamWrapper
aosw(audio_manager
.get());
567 AudioOutputStream
* aos
= aosw
.Create(48000, 160);
568 EXPECT_TRUE(aos
->Open());
570 // Derive the expected size in bytes of each packet.
571 uint32 bytes_per_packet
= aosw
.channels() * aosw
.samples_per_packet() *
572 (aosw
.bits_per_sample() / 8);
574 // Wait for the first callback and verify its parameters.
575 EXPECT_CALL(source
, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet
)))
577 QuitLoop(loop
.message_loop_proxy()),
578 Return(aosw
.samples_per_packet())))
579 .WillRepeatedly(Return(aosw
.samples_per_packet()));
582 loop
.PostDelayedTask(FROM_HERE
, base::MessageLoop::QuitClosure(),
583 TestTimeouts::action_timeout());
589 // Verify that we can open and start the output stream in exclusive mode at
590 // the lowest possible delay at 44.1kHz.
591 TEST(WASAPIAudioOutputStreamTest
, ExclusiveModeMinBufferSizeAt44kHz
) {
592 ABORT_AUDIO_TEST_IF_NOT(ExclusiveModeIsEnabled());
593 scoped_ptr
<AudioManager
> audio_manager(AudioManager::CreateForTesting());
595 base::MessageLoopForUI loop
;
596 MockAudioSourceCallback source
;
598 // Create exclusive-mode WASAPI output stream which plays out in stereo
599 // using the minimum buffer size at 44.1kHz sample rate.
600 AudioOutputStreamWrapper
aosw(audio_manager
.get());
601 AudioOutputStream
* aos
= aosw
.Create(44100, 160);
602 EXPECT_TRUE(aos
->Open());
604 // Derive the expected size in bytes of each packet.
605 uint32 bytes_per_packet
= aosw
.channels() * aosw
.samples_per_packet() *
606 (aosw
.bits_per_sample() / 8);
608 // Wait for the first callback and verify its parameters.
609 EXPECT_CALL(source
, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet
)))
611 QuitLoop(loop
.message_loop_proxy()),
612 Return(aosw
.samples_per_packet())))
613 .WillRepeatedly(Return(aosw
.samples_per_packet()));
616 loop
.PostDelayedTask(FROM_HERE
, base::MessageLoop::QuitClosure(),
617 TestTimeouts::action_timeout());