| OLD | NEW |
| 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/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 size_t elements_written = 0; | 96 size_t elements_written = 0; |
| 97 while (elements_written < elements_to_write_) { | 97 while (elements_written < elements_to_write_) { |
| 98 fprintf(text_file_, "%d\n", delta_times_[elements_written]); | 98 fprintf(text_file_, "%d\n", delta_times_[elements_written]); |
| 99 ++elements_written; | 99 ++elements_written; |
| 100 } | 100 } |
| 101 | 101 |
| 102 base::CloseFile(text_file_); | 102 base::CloseFile(text_file_); |
| 103 } | 103 } |
| 104 | 104 |
| 105 // AudioOutputStream::AudioSourceCallback implementation. | 105 // AudioOutputStream::AudioSourceCallback implementation. |
| 106 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override { | 106 int OnMoreData(AudioBus* audio_bus, |
| 107 uint32_t total_bytes_delay, |
| 108 uint32_t frames_skipped) override { |
| 107 // Store time difference between two successive callbacks in an array. | 109 // Store time difference between two successive callbacks in an array. |
| 108 // These values will be written to a file in the destructor. | 110 // These values will be written to a file in the destructor. |
| 109 const base::TimeTicks now_time = base::TimeTicks::Now(); | 111 const base::TimeTicks now_time = base::TimeTicks::Now(); |
| 110 const int diff = (now_time - previous_call_time_).InMilliseconds(); | 112 const int diff = (now_time - previous_call_time_).InMilliseconds(); |
| 111 previous_call_time_ = now_time; | 113 previous_call_time_ = now_time; |
| 112 if (elements_to_write_ < kMaxDeltaSamples) { | 114 if (elements_to_write_ < kMaxDeltaSamples) { |
| 113 delta_times_[elements_to_write_] = diff; | 115 delta_times_[elements_to_write_] = diff; |
| 114 ++elements_to_write_; | 116 ++elements_to_write_; |
| 115 } | 117 } |
| 116 | 118 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 AudioOutputStreamWrapper aosw(audio_manager.get()); | 377 AudioOutputStreamWrapper aosw(audio_manager.get()); |
| 376 AudioOutputStream* aos = aosw.Create(); | 378 AudioOutputStream* aos = aosw.Create(); |
| 377 EXPECT_TRUE(aos->Open()); | 379 EXPECT_TRUE(aos->Open()); |
| 378 | 380 |
| 379 // Derive the expected size in bytes of each packet. | 381 // Derive the expected size in bytes of each packet. |
| 380 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * | 382 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * |
| 381 (aosw.bits_per_sample() / 8); | 383 (aosw.bits_per_sample() / 8); |
| 382 | 384 |
| 383 // Wait for the first callback and verify its parameters. Ignore any | 385 // Wait for the first callback and verify its parameters. Ignore any |
| 384 // subsequent callbacks that might arrive. | 386 // subsequent callbacks that might arrive. |
| 385 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet))) | 387 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) |
| 386 .WillOnce(DoAll(QuitLoop(loop.task_runner()), | 388 .WillOnce(DoAll(QuitLoop(loop.task_runner()), |
| 387 Return(aosw.samples_per_packet()))) | 389 Return(aosw.samples_per_packet()))) |
| 388 .WillRepeatedly(Return(0)); | 390 .WillRepeatedly(Return(0)); |
| 389 | 391 |
| 390 aos->Start(&source); | 392 aos->Start(&source); |
| 391 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 393 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 392 TestTimeouts::action_timeout()); | 394 TestTimeouts::action_timeout()); |
| 393 loop.Run(); | 395 loop.Run(); |
| 394 aos->Stop(); | 396 aos->Stop(); |
| 395 aos->Close(); | 397 aos->Close(); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 // using the minimum buffer size at 48kHz sample rate. | 571 // using the minimum buffer size at 48kHz sample rate. |
| 570 AudioOutputStreamWrapper aosw(audio_manager.get()); | 572 AudioOutputStreamWrapper aosw(audio_manager.get()); |
| 571 AudioOutputStream* aos = aosw.Create(48000, 160); | 573 AudioOutputStream* aos = aosw.Create(48000, 160); |
| 572 EXPECT_TRUE(aos->Open()); | 574 EXPECT_TRUE(aos->Open()); |
| 573 | 575 |
| 574 // Derive the expected size in bytes of each packet. | 576 // Derive the expected size in bytes of each packet. |
| 575 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * | 577 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * |
| 576 (aosw.bits_per_sample() / 8); | 578 (aosw.bits_per_sample() / 8); |
| 577 | 579 |
| 578 // Wait for the first callback and verify its parameters. | 580 // Wait for the first callback and verify its parameters. |
| 579 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet))) | 581 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) |
| 580 .WillOnce(DoAll(QuitLoop(loop.task_runner()), | 582 .WillOnce(DoAll(QuitLoop(loop.task_runner()), |
| 581 Return(aosw.samples_per_packet()))) | 583 Return(aosw.samples_per_packet()))) |
| 582 .WillRepeatedly(Return(aosw.samples_per_packet())); | 584 .WillRepeatedly(Return(aosw.samples_per_packet())); |
| 583 | 585 |
| 584 aos->Start(&source); | 586 aos->Start(&source); |
| 585 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 587 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 586 TestTimeouts::action_timeout()); | 588 TestTimeouts::action_timeout()); |
| 587 loop.Run(); | 589 loop.Run(); |
| 588 aos->Stop(); | 590 aos->Stop(); |
| 589 aos->Close(); | 591 aos->Close(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 603 // using the minimum buffer size at 44.1kHz sample rate. | 605 // using the minimum buffer size at 44.1kHz sample rate. |
| 604 AudioOutputStreamWrapper aosw(audio_manager.get()); | 606 AudioOutputStreamWrapper aosw(audio_manager.get()); |
| 605 AudioOutputStream* aos = aosw.Create(44100, 160); | 607 AudioOutputStream* aos = aosw.Create(44100, 160); |
| 606 EXPECT_TRUE(aos->Open()); | 608 EXPECT_TRUE(aos->Open()); |
| 607 | 609 |
| 608 // Derive the expected size in bytes of each packet. | 610 // Derive the expected size in bytes of each packet. |
| 609 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * | 611 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * |
| 610 (aosw.bits_per_sample() / 8); | 612 (aosw.bits_per_sample() / 8); |
| 611 | 613 |
| 612 // Wait for the first callback and verify its parameters. | 614 // Wait for the first callback and verify its parameters. |
| 613 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet))) | 615 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) |
| 614 .WillOnce(DoAll(QuitLoop(loop.task_runner()), | 616 .WillOnce(DoAll(QuitLoop(loop.task_runner()), |
| 615 Return(aosw.samples_per_packet()))) | 617 Return(aosw.samples_per_packet()))) |
| 616 .WillRepeatedly(Return(aosw.samples_per_packet())); | 618 .WillRepeatedly(Return(aosw.samples_per_packet())); |
| 617 | 619 |
| 618 aos->Start(&source); | 620 aos->Start(&source); |
| 619 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 621 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 620 TestTimeouts::action_timeout()); | 622 TestTimeouts::action_timeout()); |
| 621 loop.Run(); | 623 loop.Run(); |
| 622 aos->Stop(); | 624 aos->Stop(); |
| 623 aos->Close(); | 625 aos->Close(); |
| 624 } | 626 } |
| 625 | 627 |
| 626 } // namespace media | 628 } // namespace media |
| OLD | NEW |