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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/win/scoped_co_mem.h" | 8 #include "base/win/scoped_co_mem.h" |
9 #include "base/win/scoped_com_initializer.h" | 9 #include "base/win/scoped_com_initializer.h" |
10 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 329 |
330 ScopedComPtr<IAudioClient> client; | 330 ScopedComPtr<IAudioClient> client; |
331 client = CoreAudioUtil::CreateDefaultClient(eRender, eConsole); | 331 client = CoreAudioUtil::CreateDefaultClient(eRender, eConsole); |
332 EXPECT_TRUE(client.get()); | 332 EXPECT_TRUE(client.get()); |
333 | 333 |
334 WAVEFORMATPCMEX format; | 334 WAVEFORMATPCMEX format; |
335 EXPECT_TRUE( | 335 EXPECT_TRUE( |
336 SUCCEEDED(CoreAudioUtil::GetSharedModeMixFormat(client.get(), &format))); | 336 SUCCEEDED(CoreAudioUtil::GetSharedModeMixFormat(client.get(), &format))); |
337 | 337 |
338 // Perform a shared-mode initialization without event-driven buffer handling. | 338 // Perform a shared-mode initialization without event-driven buffer handling. |
339 uint32 endpoint_buffer_size = 0; | 339 uint32_t endpoint_buffer_size = 0; |
340 HRESULT hr = CoreAudioUtil::SharedModeInitialize(client.get(), &format, NULL, | 340 HRESULT hr = CoreAudioUtil::SharedModeInitialize(client.get(), &format, NULL, |
341 &endpoint_buffer_size, NULL); | 341 &endpoint_buffer_size, NULL); |
342 EXPECT_TRUE(SUCCEEDED(hr)); | 342 EXPECT_TRUE(SUCCEEDED(hr)); |
343 EXPECT_GT(endpoint_buffer_size, 0u); | 343 EXPECT_GT(endpoint_buffer_size, 0u); |
344 | 344 |
345 // It is only possible to create a client once. | 345 // It is only possible to create a client once. |
346 hr = CoreAudioUtil::SharedModeInitialize(client.get(), &format, NULL, | 346 hr = CoreAudioUtil::SharedModeInitialize(client.get(), &format, NULL, |
347 &endpoint_buffer_size, NULL); | 347 &endpoint_buffer_size, NULL); |
348 EXPECT_FALSE(SUCCEEDED(hr)); | 348 EXPECT_FALSE(SUCCEEDED(hr)); |
349 EXPECT_EQ(hr, AUDCLNT_E_ALREADY_INITIALIZED); | 349 EXPECT_EQ(hr, AUDCLNT_E_ALREADY_INITIALIZED); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 EXPECT_TRUE(SUCCEEDED(hr)); | 385 EXPECT_TRUE(SUCCEEDED(hr)); |
386 EXPECT_GT(endpoint_buffer_size, 0u); | 386 EXPECT_GT(endpoint_buffer_size, 0u); |
387 } | 387 } |
388 | 388 |
389 TEST_F(CoreAudioUtilWinTest, CreateRenderAndCaptureClients) { | 389 TEST_F(CoreAudioUtilWinTest, CreateRenderAndCaptureClients) { |
390 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); | 390 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); |
391 | 391 |
392 EDataFlow data[] = {eRender, eCapture}; | 392 EDataFlow data[] = {eRender, eCapture}; |
393 | 393 |
394 WAVEFORMATPCMEX format; | 394 WAVEFORMATPCMEX format; |
395 uint32 endpoint_buffer_size = 0; | 395 uint32_t endpoint_buffer_size = 0; |
396 | 396 |
397 for (size_t i = 0; i < arraysize(data); ++i) { | 397 for (size_t i = 0; i < arraysize(data); ++i) { |
398 ScopedComPtr<IAudioClient> client; | 398 ScopedComPtr<IAudioClient> client; |
399 ScopedComPtr<IAudioRenderClient> render_client; | 399 ScopedComPtr<IAudioRenderClient> render_client; |
400 ScopedComPtr<IAudioCaptureClient> capture_client; | 400 ScopedComPtr<IAudioCaptureClient> capture_client; |
401 | 401 |
402 client = CoreAudioUtil::CreateDefaultClient(data[i], eConsole); | 402 client = CoreAudioUtil::CreateDefaultClient(data[i], eConsole); |
403 EXPECT_TRUE(client.get()); | 403 EXPECT_TRUE(client.get()); |
404 EXPECT_TRUE(SUCCEEDED( | 404 EXPECT_TRUE(SUCCEEDED( |
405 CoreAudioUtil::GetSharedModeMixFormat(client.get(), &format))); | 405 CoreAudioUtil::GetSharedModeMixFormat(client.get(), &format))); |
(...skipping 27 matching lines...) Expand all Loading... |
433 | 433 |
434 TEST_F(CoreAudioUtilWinTest, FillRenderEndpointBufferWithSilence) { | 434 TEST_F(CoreAudioUtilWinTest, FillRenderEndpointBufferWithSilence) { |
435 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); | 435 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); |
436 | 436 |
437 // Create default clients using the default mixing format for shared mode. | 437 // Create default clients using the default mixing format for shared mode. |
438 ScopedComPtr<IAudioClient> client( | 438 ScopedComPtr<IAudioClient> client( |
439 CoreAudioUtil::CreateDefaultClient(eRender, eConsole)); | 439 CoreAudioUtil::CreateDefaultClient(eRender, eConsole)); |
440 EXPECT_TRUE(client.get()); | 440 EXPECT_TRUE(client.get()); |
441 | 441 |
442 WAVEFORMATPCMEX format; | 442 WAVEFORMATPCMEX format; |
443 uint32 endpoint_buffer_size = 0; | 443 uint32_t endpoint_buffer_size = 0; |
444 EXPECT_TRUE( | 444 EXPECT_TRUE( |
445 SUCCEEDED(CoreAudioUtil::GetSharedModeMixFormat(client.get(), &format))); | 445 SUCCEEDED(CoreAudioUtil::GetSharedModeMixFormat(client.get(), &format))); |
446 CoreAudioUtil::SharedModeInitialize(client.get(), &format, NULL, | 446 CoreAudioUtil::SharedModeInitialize(client.get(), &format, NULL, |
447 &endpoint_buffer_size, NULL); | 447 &endpoint_buffer_size, NULL); |
448 EXPECT_GT(endpoint_buffer_size, 0u); | 448 EXPECT_GT(endpoint_buffer_size, 0u); |
449 | 449 |
450 ScopedComPtr<IAudioRenderClient> render_client( | 450 ScopedComPtr<IAudioRenderClient> render_client( |
451 CoreAudioUtil::CreateRenderClient(client.get())); | 451 CoreAudioUtil::CreateRenderClient(client.get())); |
452 EXPECT_TRUE(render_client.get()); | 452 EXPECT_TRUE(render_client.get()); |
453 | 453 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 499 } |
500 | 500 |
501 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { | 501 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { |
502 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); | 502 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); |
503 | 503 |
504 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); | 504 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); |
505 EXPECT_FALSE(default_device_id.empty()); | 505 EXPECT_FALSE(default_device_id.empty()); |
506 } | 506 } |
507 | 507 |
508 } // namespace media | 508 } // namespace media |
OLD | NEW |