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

Side by Side Diff: media/filters/audio_renderer_algorithm_unittest.cc

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 // The format of these tests are to enqueue a known amount of data and then 5 // The format of these tests are to enqueue a known amount of data and then
6 // request the exact amount we expect in order to dequeue the known amount of 6 // request the exact amount we expect in order to dequeue the known amount of
7 // data. This ensures that for any rate we are consuming input data at the 7 // data. This ensures that for any rate we are consuming input data at the
8 // correct rate. We always pass in a very large destination buffer with the 8 // correct rate. We always pass in a very large destination buffer with the
9 // expectation that FillBuffer() will fill as much as it can but no more. 9 // expectation that FillBuffer() will fill as much as it can but no more.
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void FillAlgorithmQueue() { 105 void FillAlgorithmQueue() {
106 // The value of the data is meaningless; we just want non-zero data to 106 // The value of the data is meaningless; we just want non-zero data to
107 // differentiate it from muted data. 107 // differentiate it from muted data.
108 scoped_refptr<AudioBuffer> buffer; 108 scoped_refptr<AudioBuffer> buffer;
109 while (!algorithm_.IsQueueFull()) { 109 while (!algorithm_.IsQueueFull()) {
110 switch (sample_format_) { 110 switch (sample_format_) {
111 case kSampleFormatU8: 111 case kSampleFormatU8:
112 buffer = MakeAudioBuffer<uint8_t>( 112 buffer = MakeAudioBuffer<uint8_t>(
113 sample_format_, channel_layout_, 113 sample_format_, channel_layout_,
114 ChannelLayoutToChannelCount(channel_layout_), samples_per_second_, 114 ChannelLayoutToChannelCount(channel_layout_), samples_per_second_,
115 1, 1, kFrameSize, kNoTimestamp()); 115 1, 1, kFrameSize, kNoTimestamp);
116 break; 116 break;
117 case kSampleFormatS16: 117 case kSampleFormatS16:
118 buffer = MakeAudioBuffer<int16_t>( 118 buffer = MakeAudioBuffer<int16_t>(
119 sample_format_, channel_layout_, 119 sample_format_, channel_layout_,
120 ChannelLayoutToChannelCount(channel_layout_), samples_per_second_, 120 ChannelLayoutToChannelCount(channel_layout_), samples_per_second_,
121 1, 1, kFrameSize, kNoTimestamp()); 121 1, 1, kFrameSize, kNoTimestamp);
122 break; 122 break;
123 case kSampleFormatS32: 123 case kSampleFormatS32:
124 buffer = MakeAudioBuffer<int32_t>( 124 buffer = MakeAudioBuffer<int32_t>(
125 sample_format_, channel_layout_, 125 sample_format_, channel_layout_,
126 ChannelLayoutToChannelCount(channel_layout_), samples_per_second_, 126 ChannelLayoutToChannelCount(channel_layout_), samples_per_second_,
127 1, 1, kFrameSize, kNoTimestamp()); 127 1, 1, kFrameSize, kNoTimestamp);
128 break; 128 break;
129 default: 129 default:
130 NOTREACHED() << "Unrecognized format " << sample_format_; 130 NOTREACHED() << "Unrecognized format " << sample_format_;
131 } 131 }
132 algorithm_.EnqueueBuffer(buffer); 132 algorithm_.EnqueueBuffer(buffer);
133 frames_enqueued_ += kFrameSize; 133 frames_enqueued_ += kFrameSize;
134 } 134 }
135 } 135 }
136 136
137 bool VerifyAudioData(AudioBus* bus, int offset, int frames, float value) { 137 bool VerifyAudioData(AudioBus* bus, int offset, int frames, float value) {
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 const int frames_filled = 681 const int frames_filled =
682 algorithm_.FillBuffer(bus.get(), kHalfSize, kHalfSize, kMutedRates[i]); 682 algorithm_.FillBuffer(bus.get(), kHalfSize, kHalfSize, kMutedRates[i]);
683 ASSERT_EQ(kHalfSize, frames_filled); 683 ASSERT_EQ(kHalfSize, frames_filled);
684 ASSERT_FALSE(VerifyAudioData(bus.get(), 0, kHalfSize, 0)); 684 ASSERT_FALSE(VerifyAudioData(bus.get(), 0, kHalfSize, 0));
685 ASSERT_TRUE(VerifyAudioData(bus.get(), kHalfSize, kHalfSize, 0)); 685 ASSERT_TRUE(VerifyAudioData(bus.get(), kHalfSize, kHalfSize, 0));
686 FillAlgorithmQueue(); 686 FillAlgorithmQueue();
687 } 687 }
688 } 688 }
689 689
690 } // namespace media 690 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698