| 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/renderers/audio_renderer_impl.h" | 5 #include "media/renderers/audio_renderer_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 DeliverBuffer(DecodeStatus::OK, buffer); | 672 DeliverBuffer(DecodeStatus::OK, buffer); |
| 673 | 673 |
| 674 // All channels should now be enabled. | 674 // All channels should now be enabled. |
| 675 mask = channel_mask(); | 675 mask = channel_mask(); |
| 676 EXPECT_FALSE(mask.empty()); | 676 EXPECT_FALSE(mask.empty()); |
| 677 ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels())); | 677 ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels())); |
| 678 for (int ch = 0; ch < hw_params.channels(); ++ch) | 678 for (int ch = 0; ch < hw_params.channels(); ++ch) |
| 679 ASSERT_TRUE(mask[ch]); | 679 ASSERT_TRUE(mask[ch]); |
| 680 } | 680 } |
| 681 | 681 |
| 682 // Verify that the proper channel mask is configured when downmixing is applied |
| 683 // to the input with discrete layout. The default hardware layout is stereo. |
| 684 TEST_F(AudioRendererImplTest, ChannelMask_DownmixDiscreteLayout) { |
| 685 int audio_channels = 9; |
| 686 |
| 687 AudioDecoderConfig audio_config( |
| 688 kCodecOpus, kSampleFormat, CHANNEL_LAYOUT_DISCRETE, |
| 689 kInputSamplesPerSecond, EmptyExtraData(), Unencrypted()); |
| 690 audio_config.SetChannelsForDiscrete(audio_channels); |
| 691 demuxer_stream_.set_audio_decoder_config(audio_config); |
| 692 ConfigureDemuxerStream(true); |
| 693 |
| 694 // Fake an attached webaudio client. |
| 695 sink_->SetIsOptimizedForHardwareParameters(false); |
| 696 |
| 697 Initialize(); |
| 698 std::vector<bool> mask = channel_mask(); |
| 699 EXPECT_FALSE(mask.empty()); |
| 700 ASSERT_EQ(mask.size(), static_cast<size_t>(audio_channels)); |
| 701 for (int ch = 0; ch < audio_channels; ++ch) |
| 702 ASSERT_TRUE(mask[ch]); |
| 703 } |
| 704 |
| 682 TEST_F(AudioRendererImplTest, Underflow_Flush) { | 705 TEST_F(AudioRendererImplTest, Underflow_Flush) { |
| 683 Initialize(); | 706 Initialize(); |
| 684 Preroll(); | 707 Preroll(); |
| 685 StartTicking(); | 708 StartTicking(); |
| 686 | 709 |
| 687 // Force underflow. | 710 // Force underflow. |
| 688 EXPECT_TRUE(ConsumeBufferedData(frames_buffered())); | 711 EXPECT_TRUE(ConsumeBufferedData(frames_buffered())); |
| 689 WaitForPendingRead(); | 712 WaitForPendingRead(); |
| 690 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); | 713 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); |
| 691 EXPECT_FALSE(ConsumeBufferedData(OutputFrames(1))); | 714 EXPECT_FALSE(ConsumeBufferedData(OutputFrames(1))); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 // Advance far enough that we shouldn't be clamped to current time (tested | 1117 // Advance far enough that we shouldn't be clamped to current time (tested |
| 1095 // already above). | 1118 // already above). |
| 1096 tick_clock_->Advance(kOneSecond); | 1119 tick_clock_->Advance(kOneSecond); |
| 1097 EXPECT_EQ( | 1120 EXPECT_EQ( |
| 1098 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), | 1121 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), |
| 1099 CurrentMediaWallClockTime(&is_time_moving)); | 1122 CurrentMediaWallClockTime(&is_time_moving)); |
| 1100 EXPECT_TRUE(is_time_moving); | 1123 EXPECT_TRUE(is_time_moving); |
| 1101 } | 1124 } |
| 1102 | 1125 |
| 1103 } // namespace media | 1126 } // namespace media |
| OLD | NEW |