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

Side by Side Diff: media/renderers/audio_renderer_impl_unittest.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: Fix issues from rebase Created 3 years, 7 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
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 "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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 sink_ = new FakeAudioRendererSink(hardware_params_); 156 sink_ = new FakeAudioRendererSink(hardware_params_);
157 renderer_.reset(new AudioRendererImpl( 157 renderer_.reset(new AudioRendererImpl(
158 message_loop_.task_runner(), sink_.get(), 158 message_loop_.task_runner(), sink_.get(),
159 base::Bind(&AudioRendererImplTest::CreateAudioDecoderForTest, 159 base::Bind(&AudioRendererImplTest::CreateAudioDecoderForTest,
160 base::Unretained(this)), 160 base::Unretained(this)),
161 &media_log_)); 161 &media_log_));
162 testing::Mock::VerifyAndClearExpectations(&demuxer_stream_); 162 testing::Mock::VerifyAndClearExpectations(&demuxer_stream_);
163 ConfigureDemuxerStream(true); 163 ConfigureDemuxerStream(true);
164 } 164 }
165 165
166 // Reconfigures a demuxer stream using a given config.
167 void ConfigureChangeDemuxerStream(const AudioDecoderConfig& audio_config) {
168 demuxer_stream_.set_audio_decoder_config(audio_config);
169 ConfigureDemuxerStream(true);
170 }
171
166 // RendererClient implementation. 172 // RendererClient implementation.
167 MOCK_METHOD1(OnError, void(PipelineStatus)); 173 MOCK_METHOD1(OnError, void(PipelineStatus));
168 void OnEnded() override { 174 void OnEnded() override {
169 CHECK(!ended_); 175 CHECK(!ended_);
170 ended_ = true; 176 ended_ = true;
171 } 177 }
172 void OnStatisticsUpdate(const PipelineStatistics& stats) override { 178 void OnStatisticsUpdate(const PipelineStatistics& stats) override {
173 last_statistics_.audio_memory_usage += stats.audio_memory_usage; 179 last_statistics_.audio_memory_usage += stats.audio_memory_usage;
174 } 180 }
175 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); 181 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState));
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 DeliverBuffer(DecodeStatus::OK, buffer); 678 DeliverBuffer(DecodeStatus::OK, buffer);
673 679
674 // All channels should now be enabled. 680 // All channels should now be enabled.
675 mask = channel_mask(); 681 mask = channel_mask();
676 EXPECT_FALSE(mask.empty()); 682 EXPECT_FALSE(mask.empty());
677 ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels())); 683 ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels()));
678 for (int ch = 0; ch < hw_params.channels(); ++ch) 684 for (int ch = 0; ch < hw_params.channels(); ++ch)
679 ASSERT_TRUE(mask[ch]); 685 ASSERT_TRUE(mask[ch]);
680 } 686 }
681 687
688 // Verify that the proper channel mask is configured when downmixing is applied
689 // to the input with discrete layout. The default hardware layout is stereo.
690 TEST_F(AudioRendererImplTest, ChannelMask_DownmixDiscreteLayout) {
691 int audio_channels = 9;
692
693 AudioDecoderConfig audio_config(
694 kCodecOpus, kSampleFormat, CHANNEL_LAYOUT_DISCRETE,
695 kInputSamplesPerSecond, EmptyExtraData(), Unencrypted());
696 audio_config.SetChannelsForDiscrete(audio_channels);
697 ConfigureChangeDemuxerStream(audio_config);
698
699 // Renderer supports discrete layout only if the sink_ is a web audio source
700 // with discrete layout as well.
701 AudioParameters sink_params(AudioParameters::AUDIO_PCM_LOW_LATENCY,
702 CHANNEL_LAYOUT_DISCRETE, kOutputSamplesPerSecond,
703 SampleFormatToBytesPerChannel(kSampleFormat) * 8,
704 1024);
705 sink_params.set_channels_for_discrete(audio_channels);
706 ConfigureBasicRenderer(sink_params);
707
708 Initialize();
709 std::vector<bool> mask = channel_mask();
710 EXPECT_FALSE(mask.empty());
711 ASSERT_EQ(mask.size(), static_cast<size_t>(audio_channels));
712 for (int ch = 0; ch < audio_channels; ++ch)
713 ASSERT_TRUE(mask[ch]);
714 }
715
682 TEST_F(AudioRendererImplTest, Underflow_Flush) { 716 TEST_F(AudioRendererImplTest, Underflow_Flush) {
683 Initialize(); 717 Initialize();
684 Preroll(); 718 Preroll();
685 StartTicking(); 719 StartTicking();
686 720
687 // Force underflow. 721 // Force underflow.
688 EXPECT_TRUE(ConsumeBufferedData(frames_buffered())); 722 EXPECT_TRUE(ConsumeBufferedData(frames_buffered()));
689 WaitForPendingRead(); 723 WaitForPendingRead();
690 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); 724 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING));
691 EXPECT_FALSE(ConsumeBufferedData(OutputFrames(1))); 725 EXPECT_FALSE(ConsumeBufferedData(OutputFrames(1)));
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 // Advance far enough that we shouldn't be clamped to current time (tested 1128 // Advance far enough that we shouldn't be clamped to current time (tested
1095 // already above). 1129 // already above).
1096 tick_clock_->Advance(kOneSecond); 1130 tick_clock_->Advance(kOneSecond);
1097 EXPECT_EQ( 1131 EXPECT_EQ(
1098 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), 1132 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value),
1099 CurrentMediaWallClockTime(&is_time_moving)); 1133 CurrentMediaWallClockTime(&is_time_moving));
1100 EXPECT_TRUE(is_time_moving); 1134 EXPECT_TRUE(is_time_moving);
1101 } 1135 }
1102 1136
1103 } // namespace media 1137 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698