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

Side by Side Diff: media/audio/win/audio_low_latency_output_win_unittest.cc

Issue 10184011: Remove unused parameter "stream" from all variants of OnMoreData(). (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 8 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 <windows.h> 5 #include <windows.h>
6 #include <mmsystem.h> 6 #include <mmsystem.h>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 MATCHER_P(HasValidDelay, value, "") { 47 MATCHER_P(HasValidDelay, value, "") {
48 // It is difficult to come up with a perfect test condition for the delay 48 // It is difficult to come up with a perfect test condition for the delay
49 // estimation. For now, verify that the produced output delay is always 49 // estimation. For now, verify that the produced output delay is always
50 // larger than the selected buffer size. 50 // larger than the selected buffer size.
51 return arg.hardware_delay_bytes > value.hardware_delay_bytes; 51 return arg.hardware_delay_bytes > value.hardware_delay_bytes;
52 } 52 }
53 53
54 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { 54 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback {
55 public: 55 public:
56 MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, 56 MOCK_METHOD3(OnMoreData, uint32(uint8* dest,
57 uint8* dest,
58 uint32 max_size, 57 uint32 max_size,
59 AudioBuffersState buffers_state)); 58 AudioBuffersState buffers_state));
60 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); 59 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code));
61 }; 60 };
62 61
63 // This audio source implementation should be used for manual tests only since 62 // This audio source implementation should be used for manual tests only since
64 // it takes about 20 seconds to play out a file. 63 // it takes about 20 seconds to play out a file.
65 class ReadFromFileAudioSource : public AudioOutputStream::AudioSourceCallback { 64 class ReadFromFileAudioSource : public AudioOutputStream::AudioSourceCallback {
66 public: 65 public:
67 explicit ReadFromFileAudioSource(const std::string& name) 66 explicit ReadFromFileAudioSource(const std::string& name)
(...skipping 28 matching lines...) Expand all
96 size_t elements_written = 0; 95 size_t elements_written = 0;
97 while (elements_written < elements_to_write_) { 96 while (elements_written < elements_to_write_) {
98 fprintf(text_file_, "%d\n", delta_times_[elements_written]); 97 fprintf(text_file_, "%d\n", delta_times_[elements_written]);
99 ++elements_written; 98 ++elements_written;
100 } 99 }
101 100
102 file_util::CloseFile(text_file_); 101 file_util::CloseFile(text_file_);
103 } 102 }
104 103
105 // AudioOutputStream::AudioSourceCallback implementation. 104 // AudioOutputStream::AudioSourceCallback implementation.
106 virtual uint32 OnMoreData(AudioOutputStream* stream, 105 virtual uint32 OnMoreData(uint8* dest,
107 uint8* dest,
108 uint32 max_size, 106 uint32 max_size,
109 AudioBuffersState buffers_state) { 107 AudioBuffersState buffers_state) {
110 // Store time difference between two successive callbacks in an array. 108 // Store time difference between two successive callbacks in an array.
111 // These values will be written to a file in the destructor. 109 // These values will be written to a file in the destructor.
112 int diff = (base::Time::Now() - previous_call_time_).InMilliseconds(); 110 int diff = (base::Time::Now() - previous_call_time_).InMilliseconds();
113 previous_call_time_ = base::Time::Now(); 111 previous_call_time_ = base::Time::Now();
114 if (elements_to_write_ < kMaxDeltaSamples) { 112 if (elements_to_write_ < kMaxDeltaSamples) {
115 delta_times_[elements_to_write_] = diff; 113 delta_times_[elements_to_write_] = diff;
116 ++elements_to_write_; 114 ++elements_to_write_;
117 } 115 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 EXPECT_TRUE(aos->Open()); 391 EXPECT_TRUE(aos->Open());
394 392
395 // Derive the expected size in bytes of each packet. 393 // Derive the expected size in bytes of each packet.
396 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * 394 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() *
397 (aosw.bits_per_sample() / 8); 395 (aosw.bits_per_sample() / 8);
398 396
399 // Set up expected minimum delay estimation. 397 // Set up expected minimum delay estimation.
400 AudioBuffersState state(0, bytes_per_packet); 398 AudioBuffersState state(0, bytes_per_packet);
401 399
402 // Wait for the first callback and verify its parameters. 400 // Wait for the first callback and verify its parameters.
403 EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, 401 EXPECT_CALL(source, OnMoreData(NotNull(), bytes_per_packet,
404 HasValidDelay(state))) 402 HasValidDelay(state)))
405 .WillOnce( 403 .WillOnce(
406 DoAll( 404 DoAll(
407 InvokeWithoutArgs( 405 InvokeWithoutArgs(
408 CreateFunctor(&QuitMessageLoop, proxy.get())), 406 CreateFunctor(&QuitMessageLoop, proxy.get())),
409 Return(bytes_per_packet))); 407 Return(bytes_per_packet)));
410 408
411 aos->Start(&source); 409 aos->Start(&source);
412 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), 410 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(),
413 TestTimeouts::action_timeout()); 411 TestTimeouts::action_timeout());
(...skipping 21 matching lines...) Expand all
435 EXPECT_TRUE(aos->Open()); 433 EXPECT_TRUE(aos->Open());
436 434
437 // Derive the expected size in bytes of each packet. 435 // Derive the expected size in bytes of each packet.
438 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * 436 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() *
439 (aosw.bits_per_sample() / 8); 437 (aosw.bits_per_sample() / 8);
440 438
441 // Set up expected minimum delay estimation. 439 // Set up expected minimum delay estimation.
442 AudioBuffersState state(0, bytes_per_packet); 440 AudioBuffersState state(0, bytes_per_packet);
443 441
444 // Wait for the first callback and verify its parameters. 442 // Wait for the first callback and verify its parameters.
445 EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, 443 EXPECT_CALL(source, OnMoreData(NotNull(), bytes_per_packet,
446 HasValidDelay(state))) 444 HasValidDelay(state)))
447 .WillOnce( 445 .WillOnce(
448 DoAll( 446 DoAll(
449 InvokeWithoutArgs( 447 InvokeWithoutArgs(
450 CreateFunctor(&QuitMessageLoop, proxy.get())), 448 CreateFunctor(&QuitMessageLoop, proxy.get())),
451 Return(bytes_per_packet))); 449 Return(bytes_per_packet)));
452 450
453 aos->Start(&source); 451 aos->Start(&source);
454 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), 452 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(),
455 TestTimeouts::action_timeout()); 453 TestTimeouts::action_timeout());
(...skipping 25 matching lines...) Expand all
481 aos->Close(); 479 aos->Close();
482 return; 480 return;
483 } 481 }
484 // Derive the expected size in bytes of each packet. 482 // Derive the expected size in bytes of each packet.
485 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * 483 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() *
486 (aosw.bits_per_sample() / 8); 484 (aosw.bits_per_sample() / 8);
487 485
488 // Set up expected minimum delay estimation. 486 // Set up expected minimum delay estimation.
489 AudioBuffersState state(0, bytes_per_packet); 487 AudioBuffersState state(0, bytes_per_packet);
490 488
491 EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, 489 EXPECT_CALL(source, OnMoreData(NotNull(), bytes_per_packet,
492 HasValidDelay(state))) 490 HasValidDelay(state)))
493 .WillOnce( 491 .WillOnce(
494 DoAll( 492 DoAll(
495 InvokeWithoutArgs( 493 InvokeWithoutArgs(
496 CreateFunctor(&QuitMessageLoop, proxy.get())), 494 CreateFunctor(&QuitMessageLoop, proxy.get())),
497 Return(bytes_per_packet))); 495 Return(bytes_per_packet)));
498 496
499 aos->Start(&source); 497 aos->Start(&source);
500 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), 498 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(),
501 TestTimeouts::action_timeout()); 499 TestTimeouts::action_timeout());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 aos->Start(&file_source); 540 aos->Start(&file_source);
543 base::PlatformThread::Sleep( 541 base::PlatformThread::Sleep(
544 base::TimeDelta::FromMilliseconds(kFileDurationMs)); 542 base::TimeDelta::FromMilliseconds(kFileDurationMs));
545 aos->Stop(); 543 aos->Stop();
546 544
547 LOG(INFO) << ">> File playout has stopped."; 545 LOG(INFO) << ">> File playout has stopped.";
548 aos->Close(); 546 aos->Close();
549 } 547 }
550 548
551 } // namespace media 549 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/audio_low_latency_output_win.cc ('k') | media/audio/win/audio_output_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698