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

Side by Side Diff: content/renderer/media/audio_renderer_mixer_manager_unittest.cc

Issue 1304973005: Refactor AudioParameters member setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cross-platform. Created 5 years, 3 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/renderer/media/audio_renderer_mixer_manager.h" 8 #include "content/renderer/media/audio_renderer_mixer_manager.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "media/audio/audio_parameters.h" 10 #include "media/audio/audio_parameters.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 kSampleRate, 127 kSampleRate,
128 kBitsPerChannel, 128 kBitsPerChannel,
129 kBufferSize); 129 kBufferSize);
130 media::AudioRendererMixer* mixer1 = GetMixer(kRenderFrameId, params1); 130 media::AudioRendererMixer* mixer1 = GetMixer(kRenderFrameId, params1);
131 ASSERT_TRUE(mixer1); 131 ASSERT_TRUE(mixer1);
132 EXPECT_EQ(mixer_count(), 1); 132 EXPECT_EQ(mixer_count(), 1);
133 133
134 // Different formats, bit depths, and buffer sizes should not result in a 134 // Different formats, bit depths, and buffer sizes should not result in a
135 // different mixer. 135 // different mixer.
136 media::AudioParameters params2(AudioParameters::AUDIO_PCM_LOW_LATENCY, 136 media::AudioParameters params2(AudioParameters::AUDIO_PCM_LOW_LATENCY,
137 kChannelLayout, 137 kChannelLayout, kSampleRate,
138 kSampleRate, 138 kBitsPerChannel * 2, kBufferSize * 2);
139 kBitsPerChannel * 2,
140 kBufferSize * 2,
141 AudioParameters::NO_EFFECTS);
142 EXPECT_EQ(mixer1, GetMixer(kRenderFrameId, params2)); 139 EXPECT_EQ(mixer1, GetMixer(kRenderFrameId, params2));
143 EXPECT_EQ(mixer_count(), 1); 140 EXPECT_EQ(mixer_count(), 1);
144 RemoveMixer(kRenderFrameId, params2); 141 RemoveMixer(kRenderFrameId, params2);
145 EXPECT_EQ(mixer_count(), 1); 142 EXPECT_EQ(mixer_count(), 1);
146 143
147 // Modify some parameters that do matter. 144 // Modify some parameters that do matter.
148 media::AudioParameters params3(AudioParameters::AUDIO_PCM_LOW_LATENCY, 145 media::AudioParameters params3(AudioParameters::AUDIO_PCM_LOW_LATENCY,
149 media::CHANNEL_LAYOUT_MONO, 146 media::CHANNEL_LAYOUT_MONO, kSampleRate * 2,
150 kSampleRate * 2, 147 kBitsPerChannel, kBufferSize);
151 kBitsPerChannel,
152 kBufferSize,
153 AudioParameters::NO_EFFECTS);
154 ASSERT_NE(params3.channel_layout(), params1.channel_layout()); 148 ASSERT_NE(params3.channel_layout(), params1.channel_layout());
155 149
156 EXPECT_NE(mixer1, GetMixer(kRenderFrameId, params3)); 150 EXPECT_NE(mixer1, GetMixer(kRenderFrameId, params3));
157 EXPECT_EQ(mixer_count(), 2); 151 EXPECT_EQ(mixer_count(), 2);
158 RemoveMixer(kRenderFrameId, params3); 152 RemoveMixer(kRenderFrameId, params3);
159 EXPECT_EQ(mixer_count(), 1); 153 EXPECT_EQ(mixer_count(), 1);
160 154
161 // Remove final mixer. 155 // Remove final mixer.
162 RemoveMixer(kRenderFrameId, params1); 156 RemoveMixer(kRenderFrameId, params1);
163 EXPECT_EQ(mixer_count(), 0); 157 EXPECT_EQ(mixer_count(), 0);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Destroying the inputs should destroy the mixers. 194 // Destroying the inputs should destroy the mixers.
201 input->Stop(); 195 input->Stop();
202 input = NULL; 196 input = NULL;
203 EXPECT_EQ(mixer_count(), 1); 197 EXPECT_EQ(mixer_count(), 1);
204 another_input->Stop(); 198 another_input->Stop();
205 another_input = NULL; 199 another_input = NULL;
206 EXPECT_EQ(mixer_count(), 0); 200 EXPECT_EQ(mixer_count(), 0);
207 } 201 }
208 202
209 } // namespace content 203 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698