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

Side by Side Diff: media/audio/linux/alsa_output_unittest.cc

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright years Created 8 years, 9 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 | « media/audio/linux/alsa_output.cc ('k') | media/audio/linux/audio_manager_linux.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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/stringprintf.h" 6 #include "base/stringprintf.h"
7 #include "media/audio/linux/alsa_output.h" 7 #include "media/audio/linux/alsa_output.h"
8 #include "media/audio/linux/alsa_wrapper.h" 8 #include "media/audio/linux/alsa_wrapper.h"
9 #include "media/audio/linux/audio_manager_linux.h" 9 #include "media/audio/linux/audio_manager_linux.h"
10 #include "media/base/data_buffer.h" 10 #include "media/base/data_buffer.h"
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 AlsaPcmOutputStream::kDefaultDevice, 651 AlsaPcmOutputStream::kDefaultDevice,
652 kSurround40, kSurround50, kSurround51, 652 kSurround40, kSurround50, kSurround51,
653 kSurround70, kSurround71, 653 kSurround70, kSurround71,
654 AlsaPcmOutputStream::kDefaultDevice }; 654 AlsaPcmOutputStream::kDefaultDevice };
655 bool kExpectedDownmix[] = { false, false, false, false, false, true, 655 bool kExpectedDownmix[] = { false, false, false, false, false, true,
656 false, false, false, false }; 656 false, false, false, false };
657 ChannelLayout kExpectedLayouts[] = { CHANNEL_LAYOUT_NONE, 657 ChannelLayout kExpectedLayouts[] = { CHANNEL_LAYOUT_NONE,
658 CHANNEL_LAYOUT_MONO, 658 CHANNEL_LAYOUT_MONO,
659 CHANNEL_LAYOUT_STEREO, 659 CHANNEL_LAYOUT_STEREO,
660 CHANNEL_LAYOUT_SURROUND, 660 CHANNEL_LAYOUT_SURROUND,
661 CHANNEL_LAYOUT_4POINT0, 661 CHANNEL_LAYOUT_4_0,
662 CHANNEL_LAYOUT_5POINT0, 662 CHANNEL_LAYOUT_5_0,
663 CHANNEL_LAYOUT_5POINT1, 663 CHANNEL_LAYOUT_5_1,
664 CHANNEL_LAYOUT_7POINT0, 664 CHANNEL_LAYOUT_7_0,
665 CHANNEL_LAYOUT_7POINT1 }; 665 CHANNEL_LAYOUT_7_1 };
666 666
667 667
668 for (int i = 1; i < 9; ++i) { 668 for (int i = 1; i < 9; ++i) {
669 if (i == 3 || i == 4 || i == 5) // invalid number of channels 669 if (i == 3 || i == 4 || i == 5) // invalid number of channels
670 continue; 670 continue;
671 SCOPED_TRACE(base::StringPrintf("Attempting %d Channel", i)); 671 SCOPED_TRACE(base::StringPrintf("Attempting %d Channel", i));
672 672
673 // Hints will only be grabbed for channel numbers that have non-default 673 // Hints will only be grabbed for channel numbers that have non-default
674 // devices associated with them. 674 // devices associated with them.
675 if (kExpectedDeviceName[i] != AlsaPcmOutputStream::kDefaultDevice) { 675 if (kExpectedDeviceName[i] != AlsaPcmOutputStream::kDefaultDevice) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 InSequence s; 739 InSequence s;
740 EXPECT_CALL(mock_alsa_wrapper_, PcmOpen(_, StrEq(first_try.c_str()), _, _)) 740 EXPECT_CALL(mock_alsa_wrapper_, PcmOpen(_, StrEq(first_try.c_str()), _, _))
741 .WillOnce(Return(kTestFailedErrno)); 741 .WillOnce(Return(kTestFailedErrno));
742 EXPECT_CALL(mock_alsa_wrapper_, PcmOpen(_, StrEq(second_try.c_str()), _, _)) 742 EXPECT_CALL(mock_alsa_wrapper_, PcmOpen(_, StrEq(second_try.c_str()), _, _))
743 .WillOnce(Return(kTestFailedErrno)); 743 .WillOnce(Return(kTestFailedErrno));
744 EXPECT_CALL(mock_alsa_wrapper_, PcmOpen(_, StrEq(third_try.c_str()), _, _)) 744 EXPECT_CALL(mock_alsa_wrapper_, PcmOpen(_, StrEq(third_try.c_str()), _, _))
745 .WillOnce(Return(kTestFailedErrno)); 745 .WillOnce(Return(kTestFailedErrno));
746 EXPECT_CALL(mock_alsa_wrapper_, PcmOpen(_, StrEq(fourth_try.c_str()), _, _)) 746 EXPECT_CALL(mock_alsa_wrapper_, PcmOpen(_, StrEq(fourth_try.c_str()), _, _))
747 .WillOnce(Return(kTestFailedErrno)); 747 .WillOnce(Return(kTestFailedErrno));
748 748
749 AlsaPcmOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_5POINT0); 749 AlsaPcmOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_5_0);
750 EXPECT_FALSE(test_stream->AutoSelectDevice(5)); 750 EXPECT_FALSE(test_stream->AutoSelectDevice(5));
751 test_stream->Close(); 751 test_stream->Close();
752 } 752 }
753 753
754 TEST_F(AlsaPcmOutputStreamTest, AutoSelectDevice_HintFail) { 754 TEST_F(AlsaPcmOutputStreamTest, AutoSelectDevice_HintFail) {
755 // Should get |kDefaultDevice|, and force a 2-channel downmix on a failure to 755 // Should get |kDefaultDevice|, and force a 2-channel downmix on a failure to
756 // enumerate devices. 756 // enumerate devices.
757 EXPECT_CALL(mock_alsa_wrapper_, DeviceNameHint(_, _, _)) 757 EXPECT_CALL(mock_alsa_wrapper_, DeviceNameHint(_, _, _))
758 .WillRepeatedly(Return(kTestFailedErrno)); 758 .WillRepeatedly(Return(kTestFailedErrno));
759 EXPECT_CALL(mock_alsa_wrapper_, 759 EXPECT_CALL(mock_alsa_wrapper_,
760 PcmOpen(_, StrEq(AlsaPcmOutputStream::kDefaultDevice), _, _)) 760 PcmOpen(_, StrEq(AlsaPcmOutputStream::kDefaultDevice), _, _))
761 .WillOnce(DoAll(SetArgumentPointee<0>(kFakeHandle), Return(0))); 761 .WillOnce(DoAll(SetArgumentPointee<0>(kFakeHandle), Return(0)));
762 EXPECT_CALL(mock_alsa_wrapper_, 762 EXPECT_CALL(mock_alsa_wrapper_,
763 PcmSetParams(kFakeHandle, _, _, 2, _, _, _)) 763 PcmSetParams(kFakeHandle, _, _, 2, _, _, _))
764 .WillOnce(Return(0)); 764 .WillOnce(Return(0));
765 EXPECT_CALL(mock_alsa_wrapper_, StrError(kTestFailedErrno)) 765 EXPECT_CALL(mock_alsa_wrapper_, StrError(kTestFailedErrno))
766 .WillOnce(Return(kDummyMessage)); 766 .WillOnce(Return(kDummyMessage));
767 767
768 AlsaPcmOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_5POINT0); 768 AlsaPcmOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_5_0);
769 EXPECT_TRUE(test_stream->AutoSelectDevice(5)); 769 EXPECT_TRUE(test_stream->AutoSelectDevice(5));
770 EXPECT_TRUE(test_stream->should_downmix_); 770 EXPECT_TRUE(test_stream->should_downmix_);
771 test_stream->Close(); 771 test_stream->Close();
772 } 772 }
773 773
774 TEST_F(AlsaPcmOutputStreamTest, BufferPacket_StopStream) { 774 TEST_F(AlsaPcmOutputStreamTest, BufferPacket_StopStream) {
775 AlsaPcmOutputStream* test_stream = CreateStream(kTestChannelLayout); 775 AlsaPcmOutputStream* test_stream = CreateStream(kTestChannelLayout);
776 InitBuffer(test_stream); 776 InitBuffer(test_stream);
777 test_stream->stop_stream_ = true; 777 test_stream->stop_stream_ = true;
778 bool source_exhausted; 778 bool source_exhausted;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 test_stream->stop_stream_ = true; 817 test_stream->stop_stream_ = true;
818 test_stream->ScheduleNextWrite(true); 818 test_stream->ScheduleNextWrite(true);
819 819
820 // TODO(ajwong): Find a way to test whether or not another task has been 820 // TODO(ajwong): Find a way to test whether or not another task has been
821 // posted so we can verify that the Alsa code will indeed break the task 821 // posted so we can verify that the Alsa code will indeed break the task
822 // posting loop. 822 // posting loop.
823 823
824 test_stream->TransitionTo(AlsaPcmOutputStream::kIsClosed); 824 test_stream->TransitionTo(AlsaPcmOutputStream::kIsClosed);
825 test_stream->Close(); 825 test_stream->Close();
826 } 826 }
OLDNEW
« no previous file with comments | « media/audio/linux/alsa_output.cc ('k') | media/audio/linux/audio_manager_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698