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

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

Issue 1538463002: Revert of Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 <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
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, 106 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override {
107 uint32_t total_bytes_delay,
108 uint32_t frames_skipped) override {
109 // Store time difference between two successive callbacks in an array. 107 // Store time difference between two successive callbacks in an array.
110 // These values will be written to a file in the destructor. 108 // These values will be written to a file in the destructor.
111 const base::TimeTicks now_time = base::TimeTicks::Now(); 109 const base::TimeTicks now_time = base::TimeTicks::Now();
112 const int diff = (now_time - previous_call_time_).InMilliseconds(); 110 const int diff = (now_time - previous_call_time_).InMilliseconds();
113 previous_call_time_ = now_time; 111 previous_call_time_ = now_time;
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 }
118 116
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 AudioOutputStreamWrapper aosw(audio_manager.get()); 375 AudioOutputStreamWrapper aosw(audio_manager.get());
378 AudioOutputStream* aos = aosw.Create(); 376 AudioOutputStream* aos = aosw.Create();
379 EXPECT_TRUE(aos->Open()); 377 EXPECT_TRUE(aos->Open());
380 378
381 // Derive the expected size in bytes of each packet. 379 // Derive the expected size in bytes of each packet.
382 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * 380 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() *
383 (aosw.bits_per_sample() / 8); 381 (aosw.bits_per_sample() / 8);
384 382
385 // Wait for the first callback and verify its parameters. Ignore any 383 // Wait for the first callback and verify its parameters. Ignore any
386 // subsequent callbacks that might arrive. 384 // subsequent callbacks that might arrive.
387 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) 385 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet)))
388 .WillOnce(DoAll(QuitLoop(loop.task_runner()), 386 .WillOnce(DoAll(QuitLoop(loop.task_runner()),
389 Return(aosw.samples_per_packet()))) 387 Return(aosw.samples_per_packet())))
390 .WillRepeatedly(Return(0)); 388 .WillRepeatedly(Return(0));
391 389
392 aos->Start(&source); 390 aos->Start(&source);
393 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 391 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
394 TestTimeouts::action_timeout()); 392 TestTimeouts::action_timeout());
395 loop.Run(); 393 loop.Run();
396 aos->Stop(); 394 aos->Stop();
397 aos->Close(); 395 aos->Close();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // using the minimum buffer size at 48kHz sample rate. 569 // using the minimum buffer size at 48kHz sample rate.
572 AudioOutputStreamWrapper aosw(audio_manager.get()); 570 AudioOutputStreamWrapper aosw(audio_manager.get());
573 AudioOutputStream* aos = aosw.Create(48000, 160); 571 AudioOutputStream* aos = aosw.Create(48000, 160);
574 EXPECT_TRUE(aos->Open()); 572 EXPECT_TRUE(aos->Open());
575 573
576 // Derive the expected size in bytes of each packet. 574 // Derive the expected size in bytes of each packet.
577 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * 575 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() *
578 (aosw.bits_per_sample() / 8); 576 (aosw.bits_per_sample() / 8);
579 577
580 // Wait for the first callback and verify its parameters. 578 // Wait for the first callback and verify its parameters.
581 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) 579 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet)))
582 .WillOnce(DoAll(QuitLoop(loop.task_runner()), 580 .WillOnce(DoAll(QuitLoop(loop.task_runner()),
583 Return(aosw.samples_per_packet()))) 581 Return(aosw.samples_per_packet())))
584 .WillRepeatedly(Return(aosw.samples_per_packet())); 582 .WillRepeatedly(Return(aosw.samples_per_packet()));
585 583
586 aos->Start(&source); 584 aos->Start(&source);
587 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 585 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
588 TestTimeouts::action_timeout()); 586 TestTimeouts::action_timeout());
589 loop.Run(); 587 loop.Run();
590 aos->Stop(); 588 aos->Stop();
591 aos->Close(); 589 aos->Close();
(...skipping 13 matching lines...) Expand all
605 // using the minimum buffer size at 44.1kHz sample rate. 603 // using the minimum buffer size at 44.1kHz sample rate.
606 AudioOutputStreamWrapper aosw(audio_manager.get()); 604 AudioOutputStreamWrapper aosw(audio_manager.get());
607 AudioOutputStream* aos = aosw.Create(44100, 160); 605 AudioOutputStream* aos = aosw.Create(44100, 160);
608 EXPECT_TRUE(aos->Open()); 606 EXPECT_TRUE(aos->Open());
609 607
610 // Derive the expected size in bytes of each packet. 608 // Derive the expected size in bytes of each packet.
611 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * 609 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() *
612 (aosw.bits_per_sample() / 8); 610 (aosw.bits_per_sample() / 8);
613 611
614 // Wait for the first callback and verify its parameters. 612 // Wait for the first callback and verify its parameters.
615 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) 613 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet)))
616 .WillOnce(DoAll(QuitLoop(loop.task_runner()), 614 .WillOnce(DoAll(QuitLoop(loop.task_runner()),
617 Return(aosw.samples_per_packet()))) 615 Return(aosw.samples_per_packet())))
618 .WillRepeatedly(Return(aosw.samples_per_packet())); 616 .WillRepeatedly(Return(aosw.samples_per_packet()));
619 617
620 aos->Start(&source); 618 aos->Start(&source);
621 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 619 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
622 TestTimeouts::action_timeout()); 620 TestTimeouts::action_timeout());
623 loop.Run(); 621 loop.Run();
624 aos->Stop(); 622 aos->Stop();
625 aos->Close(); 623 aos->Close();
626 } 624 }
627 625
628 } // namespace media 626 } // 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