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

Side by Side Diff: media/audio/win/core_audio_util_win_unittest.cc

Issue 12918026: Adds support for CoreAudioUtil::IsChannelLayoutSupported() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 7 years, 8 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/win/core_audio_util_win.cc ('k') | no next file » | 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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/synchronization/waitable_event.h" 6 #include "base/synchronization/waitable_event.h"
7 #include "base/win/scoped_com_initializer.h" 7 #include "base/win/scoped_com_initializer.h"
8 #include "base/win/scoped_handle.h" 8 #include "base/win/scoped_handle.h"
9 #include "media/audio/win/core_audio_util_win.h" 9 #include "media/audio/win/core_audio_util_win.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 WAVEFORMATPCMEX format; 225 WAVEFORMATPCMEX format;
226 EXPECT_TRUE(SUCCEEDED(CoreAudioUtil::GetSharedModeMixFormat(client, 226 EXPECT_TRUE(SUCCEEDED(CoreAudioUtil::GetSharedModeMixFormat(client,
227 &format))); 227 &format)));
228 EXPECT_GE(format.Format.nChannels, 1); 228 EXPECT_GE(format.Format.nChannels, 1);
229 EXPECT_GE(format.Format.nSamplesPerSec, 8000u); 229 EXPECT_GE(format.Format.nSamplesPerSec, 8000u);
230 EXPECT_GE(format.Format.wBitsPerSample, 16); 230 EXPECT_GE(format.Format.wBitsPerSample, 16);
231 EXPECT_GE(format.Samples.wValidBitsPerSample, 16); 231 EXPECT_GE(format.Samples.wValidBitsPerSample, 16);
232 EXPECT_EQ(format.Format.wFormatTag, WAVE_FORMAT_EXTENSIBLE); 232 EXPECT_EQ(format.Format.wFormatTag, WAVE_FORMAT_EXTENSIBLE);
233 } 233 }
234 234
235 TEST_F(CoreAudioUtilWinTest, IsChannelLayoutSupported) {
236 if (!CanRunAudioTest())
237 return;
238
239 // The preferred channel layout should always be supported. Being supported
240 // means that it is possible to initialize a shared mode stream with the
241 // particular channel layout.
242 AudioParameters mix_params;
243 HRESULT hr = CoreAudioUtil::GetPreferredAudioParameters(eRender, eConsole,
244 &mix_params);
245 EXPECT_TRUE(SUCCEEDED(hr));
246 EXPECT_TRUE(mix_params.IsValid());
247 EXPECT_TRUE(CoreAudioUtil::IsChannelLayoutSupported(
248 eRender, eConsole, mix_params.channel_layout()));
249
250 // Check if it is possible to modify the channel layout to stereo for a
251 // device which reports that it prefers to be openen up in an other
252 // channel configuration.
253 if (mix_params.channel_layout() != CHANNEL_LAYOUT_STEREO) {
254 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
255 // TODO(henrika): it might be too pessimistic to assume false as return
256 // value here.
257 EXPECT_FALSE(CoreAudioUtil::IsChannelLayoutSupported(
258 eRender, eConsole, channel_layout));
259 }
260 }
261
235 TEST_F(CoreAudioUtilWinTest, GetDevicePeriod) { 262 TEST_F(CoreAudioUtilWinTest, GetDevicePeriod) {
236 if (!CanRunAudioTest()) 263 if (!CanRunAudioTest())
237 return; 264 return;
238 265
239 EDataFlow data[] = {eRender, eCapture}; 266 EDataFlow data[] = {eRender, eCapture};
240 267
241 // Verify that the device periods are valid for the default render and 268 // Verify that the device periods are valid for the default render and
242 // capture devices. 269 // capture devices.
243 for (int i = 0; i < arraysize(data); ++i) { 270 for (int i = 0; i < arraysize(data); ++i) {
244 ScopedComPtr<IAudioClient> client; 271 ScopedComPtr<IAudioClient> client;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // buffer. 444 // buffer.
418 EXPECT_TRUE(CoreAudioUtil::FillRenderEndpointBufferWithSilence( 445 EXPECT_TRUE(CoreAudioUtil::FillRenderEndpointBufferWithSilence(
419 client, render_client)); 446 client, render_client));
420 client->GetCurrentPadding(&num_queued_frames); 447 client->GetCurrentPadding(&num_queued_frames);
421 EXPECT_EQ(num_queued_frames, endpoint_buffer_size); 448 EXPECT_EQ(num_queued_frames, endpoint_buffer_size);
422 } 449 }
423 450
424 // 451 //
425 452
426 } // namespace media 453 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/core_audio_util_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698