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/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "base/win/scoped_co_mem.h" |
7 #include "base/win/scoped_com_initializer.h" | 9 #include "base/win/scoped_com_initializer.h" |
8 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
9 #include "media/audio/win/core_audio_util_win.h" | 11 #include "media/audio/win/core_audio_util_win.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 using base::win::ScopedCOMInitializer; | 15 using base::win::ScopedCOMInitializer; |
14 | 16 |
15 namespace media { | 17 namespace media { |
16 | 18 |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // Fill it up with zeros and verify that the buffer is full. | 470 // Fill it up with zeros and verify that the buffer is full. |
469 // It is not possible to verify that the actual data consists of zeros | 471 // It is not possible to verify that the actual data consists of zeros |
470 // since we can't access data that has already been sent to the endpoint | 472 // since we can't access data that has already been sent to the endpoint |
471 // buffer. | 473 // buffer. |
472 EXPECT_TRUE(CoreAudioUtil::FillRenderEndpointBufferWithSilence( | 474 EXPECT_TRUE(CoreAudioUtil::FillRenderEndpointBufferWithSilence( |
473 client, render_client)); | 475 client, render_client)); |
474 client->GetCurrentPadding(&num_queued_frames); | 476 client->GetCurrentPadding(&num_queued_frames); |
475 EXPECT_EQ(num_queued_frames, endpoint_buffer_size); | 477 EXPECT_EQ(num_queued_frames, endpoint_buffer_size); |
476 } | 478 } |
477 | 479 |
478 // | 480 // This test can only succeed on a machine that has audio hardware |
| 481 // that has both input and output devices. Currently this is the case |
| 482 // with our test bots and the CanRunAudioTest() method should make sure |
| 483 // that the test won't run in unsupported environments, but be warned. |
| 484 TEST_F(CoreAudioUtilWinTest, GetMatchingOutputDeviceID) { |
| 485 if (!CanRunAudioTest()) |
| 486 return; |
| 487 |
| 488 bool found_a_pair = false; |
| 489 |
| 490 ScopedComPtr<IMMDeviceEnumerator> enumerator( |
| 491 CoreAudioUtil::CreateDeviceEnumerator()); |
| 492 ASSERT_TRUE(enumerator); |
| 493 |
| 494 // Enumerate all active input and output devices and fetch the ID of |
| 495 // the associated device. |
| 496 ScopedComPtr<IMMDeviceCollection> collection; |
| 497 ASSERT_TRUE(SUCCEEDED(enumerator->EnumAudioEndpoints(eCapture, |
| 498 DEVICE_STATE_ACTIVE, collection.Receive()))); |
| 499 UINT count = 0; |
| 500 collection->GetCount(&count); |
| 501 for (UINT i = 0; i < count && !found_a_pair; ++i) { |
| 502 ScopedComPtr<IMMDevice> device; |
| 503 collection->Item(i, device.Receive()); |
| 504 base::win::ScopedCoMem<WCHAR> wide_id; |
| 505 device->GetId(&wide_id); |
| 506 std::string id; |
| 507 WideToUTF8(wide_id, wcslen(wide_id), &id); |
| 508 found_a_pair = !CoreAudioUtil::GetMatchingOutputDeviceID(id).empty(); |
| 509 } |
| 510 |
| 511 EXPECT_TRUE(found_a_pair); |
| 512 } |
479 | 513 |
480 } // namespace media | 514 } // namespace media |
OLD | NEW |