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

Side by Side Diff: media/audio/audio_output_proxy_unittest.cc

Issue 13390010: Fix a couple bugs with OSX audio buffer size selection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unittests. Created 7 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
« no previous file with comments | « no previous file | media/audio/audio_output_resampler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "media/audio/audio_output_dispatcher_impl.h" 10 #include "media/audio/audio_output_dispatcher_impl.h"
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 EXPECT_TRUE(proxy->Open()); 621 EXPECT_TRUE(proxy->Open());
622 proxy->Close(); 622 proxy->Close();
623 WaitForCloseTimer(kTestCloseDelayMs); 623 WaitForCloseTimer(kTestCloseDelayMs);
624 } 624 }
625 625
626 // Simulate failures to open both the low latency and the fallback high latency 626 // Simulate failures to open both the low latency and the fallback high latency
627 // stream and ensure AudioOutputResampler falls back to a fake stream. 627 // stream and ensure AudioOutputResampler falls back to a fake stream.
628 TEST_F(AudioOutputResamplerTest, HighLatencyFallbackFailed) { 628 TEST_F(AudioOutputResamplerTest, HighLatencyFallbackFailed) {
629 MockAudioOutputStream okay_stream(&manager_, params_); 629 MockAudioOutputStream okay_stream(&manager_, params_);
630 630
631 // Only Windows has a high latency output driver that is not the same as the low
632 // latency path.
633 #if defined(OS_WIN)
634 static const int kFallbackCount = 2;
635 #else
636 static const int kFallbackCount = 1;
637 #endif
631 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) 638 EXPECT_CALL(manager(), MakeAudioOutputStream(_))
632 .Times(2) 639 .Times(kFallbackCount)
633 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL))); 640 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL)));
634 641
635 // To prevent shared memory issues the sample rate and buffer size should 642 // To prevent shared memory issues the sample rate and buffer size should
636 // match the input stream parameters. 643 // match the input stream parameters.
637 EXPECT_CALL(manager(), MakeAudioOutputStream(AllOf( 644 EXPECT_CALL(manager(), MakeAudioOutputStream(AllOf(
638 testing::Property(&AudioParameters::format, AudioParameters::AUDIO_FAKE), 645 testing::Property(&AudioParameters::format, AudioParameters::AUDIO_FAKE),
639 testing::Property(&AudioParameters::sample_rate, params_.sample_rate()), 646 testing::Property(&AudioParameters::sample_rate, params_.sample_rate()),
640 testing::Property( 647 testing::Property(
641 &AudioParameters::frames_per_buffer, params_.frames_per_buffer())))) 648 &AudioParameters::frames_per_buffer, params_.frames_per_buffer()))))
642 .Times(1) 649 .Times(1)
643 .WillOnce(Return(&okay_stream)); 650 .WillOnce(Return(&okay_stream));
644 EXPECT_CALL(okay_stream, Open()) 651 EXPECT_CALL(okay_stream, Open())
645 .WillOnce(Return(true)); 652 .WillOnce(Return(true));
646 EXPECT_CALL(okay_stream, Close()) 653 EXPECT_CALL(okay_stream, Close())
647 .Times(1); 654 .Times(1);
648 655
649 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_); 656 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_);
650 EXPECT_TRUE(proxy->Open()); 657 EXPECT_TRUE(proxy->Open());
651 proxy->Close(); 658 proxy->Close();
652 WaitForCloseTimer(kTestCloseDelayMs); 659 WaitForCloseTimer(kTestCloseDelayMs);
653 } 660 }
654 661
655 // Simulate failures to open both the low latency, the fallback high latency 662 // Simulate failures to open both the low latency, the fallback high latency
656 // stream, and the fake audio output stream and ensure AudioOutputResampler 663 // stream, and the fake audio output stream and ensure AudioOutputResampler
657 // terminates normally. 664 // terminates normally.
658 TEST_F(AudioOutputResamplerTest, AllFallbackFailed) { 665 TEST_F(AudioOutputResamplerTest, AllFallbackFailed) {
666 // Only Windows has a high latency output driver that is not the same as the low
667 // latency path.
668 #if defined(OS_WIN)
669 static const int kFallbackCount = 3;
670 #else
671 static const int kFallbackCount = 2;
672 #endif
659 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) 673 EXPECT_CALL(manager(), MakeAudioOutputStream(_))
660 .Times(3) 674 .Times(kFallbackCount)
661 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL))); 675 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL)));
662 676
663 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_); 677 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_);
664 EXPECT_FALSE(proxy->Open()); 678 EXPECT_FALSE(proxy->Open());
665 proxy->Close(); 679 proxy->Close();
666 WaitForCloseTimer(kTestCloseDelayMs); 680 WaitForCloseTimer(kTestCloseDelayMs);
667 } 681 }
668 682
669 // Simulate an eventual OpenStream() failure; i.e. successful OpenStream() calls 683 // Simulate an eventual OpenStream() failure; i.e. successful OpenStream() calls
670 // eventually followed by one which fails; root cause of http://crbug.com/150619 684 // eventually followed by one which fails; root cause of http://crbug.com/150619
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 WaitForCloseTimer(kTestCloseDelayMs); 747 WaitForCloseTimer(kTestCloseDelayMs);
734 EXPECT_TRUE(stream1.stop_called()); 748 EXPECT_TRUE(stream1.stop_called());
735 EXPECT_TRUE(stream1.start_called()); 749 EXPECT_TRUE(stream1.start_called());
736 EXPECT_TRUE(stream2.stop_called()); 750 EXPECT_TRUE(stream2.stop_called());
737 EXPECT_TRUE(stream2.start_called()); 751 EXPECT_TRUE(stream2.start_called());
738 EXPECT_FALSE(stream3.stop_called()); 752 EXPECT_FALSE(stream3.stop_called());
739 EXPECT_FALSE(stream3.start_called()); 753 EXPECT_FALSE(stream3.start_called());
740 } 754 }
741 755
742 } // namespace media 756 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_output_resampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698