| 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 "media/audio/win/audio_low_latency_output_win.h" | 5 #include "media/audio/win/audio_low_latency_output_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <mmsystem.h> | 8 #include <mmsystem.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 fprintf(text_file_, "%d\n", delta_times_[elements_written]); | 101 fprintf(text_file_, "%d\n", delta_times_[elements_written]); |
| 102 ++elements_written; | 102 ++elements_written; |
| 103 } | 103 } |
| 104 | 104 |
| 105 base::CloseFile(text_file_); | 105 base::CloseFile(text_file_); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // AudioOutputStream::AudioSourceCallback implementation. | 108 // AudioOutputStream::AudioSourceCallback implementation. |
| 109 int OnMoreData(AudioBus* audio_bus, | 109 int OnMoreData(AudioBus* audio_bus, |
| 110 uint32_t total_bytes_delay, | 110 uint32_t total_bytes_delay, |
| 111 uint32_t frames_skipped) override { | 111 uint32_t frames_skipped, |
| 112 const AudioTimestamp& output_timestamp) override { |
| 112 // Store time difference between two successive callbacks in an array. | 113 // Store time difference between two successive callbacks in an array. |
| 113 // These values will be written to a file in the destructor. | 114 // These values will be written to a file in the destructor. |
| 114 const base::TimeTicks now_time = base::TimeTicks::Now(); | 115 const base::TimeTicks now_time = base::TimeTicks::Now(); |
| 115 const int diff = (now_time - previous_call_time_).InMilliseconds(); | 116 const int diff = (now_time - previous_call_time_).InMilliseconds(); |
| 116 previous_call_time_ = now_time; | 117 previous_call_time_ = now_time; |
| 117 if (elements_to_write_ < kMaxDeltaSamples) { | 118 if (elements_to_write_ < kMaxDeltaSamples) { |
| 118 delta_times_[elements_to_write_] = diff; | 119 delta_times_[elements_to_write_] = diff; |
| 119 ++elements_to_write_; | 120 ++elements_to_write_; |
| 120 } | 121 } |
| 121 | 122 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 AudioOutputStreamWrapper aosw(audio_manager_.get()); | 388 AudioOutputStreamWrapper aosw(audio_manager_.get()); |
| 388 AudioOutputStream* aos = aosw.Create(); | 389 AudioOutputStream* aos = aosw.Create(); |
| 389 EXPECT_TRUE(aos->Open()); | 390 EXPECT_TRUE(aos->Open()); |
| 390 | 391 |
| 391 // Derive the expected size in bytes of each packet. | 392 // Derive the expected size in bytes of each packet. |
| 392 uint32_t bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * | 393 uint32_t bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * |
| 393 (aosw.bits_per_sample() / 8); | 394 (aosw.bits_per_sample() / 8); |
| 394 | 395 |
| 395 // Wait for the first callback and verify its parameters. Ignore any | 396 // Wait for the first callback and verify its parameters. Ignore any |
| 396 // subsequent callbacks that might arrive. | 397 // subsequent callbacks that might arrive. |
| 397 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) | 398 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0, |
| 399 AudioTimestamp())) |
| 398 .WillOnce(DoAll(QuitLoop(message_loop_.task_runner()), | 400 .WillOnce(DoAll(QuitLoop(message_loop_.task_runner()), |
| 399 Return(aosw.samples_per_packet()))) | 401 Return(aosw.samples_per_packet()))) |
| 400 .WillRepeatedly(Return(0)); | 402 .WillRepeatedly(Return(0)); |
| 401 | 403 |
| 402 aos->Start(&source); | 404 aos->Start(&source); |
| 403 message_loop_.PostDelayedTask(FROM_HERE, | 405 message_loop_.PostDelayedTask(FROM_HERE, |
| 404 base::MessageLoop::QuitWhenIdleClosure(), | 406 base::MessageLoop::QuitWhenIdleClosure(), |
| 405 TestTimeouts::action_timeout()); | 407 TestTimeouts::action_timeout()); |
| 406 message_loop_.Run(); | 408 message_loop_.Run(); |
| 407 aos->Stop(); | 409 aos->Stop(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 // using the minimum buffer size at 48kHz sample rate. | 579 // using the minimum buffer size at 48kHz sample rate. |
| 578 AudioOutputStreamWrapper aosw(audio_manager_.get()); | 580 AudioOutputStreamWrapper aosw(audio_manager_.get()); |
| 579 AudioOutputStream* aos = aosw.Create(48000, 160); | 581 AudioOutputStream* aos = aosw.Create(48000, 160); |
| 580 EXPECT_TRUE(aos->Open()); | 582 EXPECT_TRUE(aos->Open()); |
| 581 | 583 |
| 582 // Derive the expected size in bytes of each packet. | 584 // Derive the expected size in bytes of each packet. |
| 583 uint32_t bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * | 585 uint32_t bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * |
| 584 (aosw.bits_per_sample() / 8); | 586 (aosw.bits_per_sample() / 8); |
| 585 | 587 |
| 586 // Wait for the first callback and verify its parameters. | 588 // Wait for the first callback and verify its parameters. |
| 587 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) | 589 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0, |
| 590 AudioTimestamp())) |
| 588 .WillOnce(DoAll(QuitLoop(message_loop_.task_runner()), | 591 .WillOnce(DoAll(QuitLoop(message_loop_.task_runner()), |
| 589 Return(aosw.samples_per_packet()))) | 592 Return(aosw.samples_per_packet()))) |
| 590 .WillRepeatedly(Return(aosw.samples_per_packet())); | 593 .WillRepeatedly(Return(aosw.samples_per_packet())); |
| 591 | 594 |
| 592 aos->Start(&source); | 595 aos->Start(&source); |
| 593 message_loop_.PostDelayedTask(FROM_HERE, | 596 message_loop_.PostDelayedTask(FROM_HERE, |
| 594 base::MessageLoop::QuitWhenIdleClosure(), | 597 base::MessageLoop::QuitWhenIdleClosure(), |
| 595 TestTimeouts::action_timeout()); | 598 TestTimeouts::action_timeout()); |
| 596 message_loop_.Run(); | 599 message_loop_.Run(); |
| 597 aos->Stop(); | 600 aos->Stop(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 610 // using the minimum buffer size at 44.1kHz sample rate. | 613 // using the minimum buffer size at 44.1kHz sample rate. |
| 611 AudioOutputStreamWrapper aosw(audio_manager_.get()); | 614 AudioOutputStreamWrapper aosw(audio_manager_.get()); |
| 612 AudioOutputStream* aos = aosw.Create(44100, 160); | 615 AudioOutputStream* aos = aosw.Create(44100, 160); |
| 613 EXPECT_TRUE(aos->Open()); | 616 EXPECT_TRUE(aos->Open()); |
| 614 | 617 |
| 615 // Derive the expected size in bytes of each packet. | 618 // Derive the expected size in bytes of each packet. |
| 616 uint32_t bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * | 619 uint32_t bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * |
| 617 (aosw.bits_per_sample() / 8); | 620 (aosw.bits_per_sample() / 8); |
| 618 | 621 |
| 619 // Wait for the first callback and verify its parameters. | 622 // Wait for the first callback and verify its parameters. |
| 620 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) | 623 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0, |
| 624 AudioTimestamp())) |
| 621 .WillOnce(DoAll(QuitLoop(message_loop_.task_runner()), | 625 .WillOnce(DoAll(QuitLoop(message_loop_.task_runner()), |
| 622 Return(aosw.samples_per_packet()))) | 626 Return(aosw.samples_per_packet()))) |
| 623 .WillRepeatedly(Return(aosw.samples_per_packet())); | 627 .WillRepeatedly(Return(aosw.samples_per_packet())); |
| 624 | 628 |
| 625 aos->Start(&source); | 629 aos->Start(&source); |
| 626 message_loop_.PostDelayedTask(FROM_HERE, | 630 message_loop_.PostDelayedTask(FROM_HERE, |
| 627 base::MessageLoop::QuitWhenIdleClosure(), | 631 base::MessageLoop::QuitWhenIdleClosure(), |
| 628 TestTimeouts::action_timeout()); | 632 TestTimeouts::action_timeout()); |
| 629 message_loop_.Run(); | 633 message_loop_.Run(); |
| 630 aos->Stop(); | 634 aos->Stop(); |
| 631 aos->Close(); | 635 aos->Close(); |
| 632 } | 636 } |
| 633 | 637 |
| 634 } // namespace media | 638 } // namespace media |
| OLD | NEW |