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

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

Issue 2870263002: Rename ScopedComPtr::Receive to ScopedComPtr::GetAddressOf (Closed)
Patch Set: Rebase to 2a6f440 Created 3 years, 7 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
« no previous file with comments | « media/audio/win/core_audio_util_win.cc ('k') | media/audio/win/device_enumeration_win.cc » ('j') | 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 "media/audio/win/core_audio_util_win.h" 5 #include "media/audio/win/core_audio_util_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 ScopedComPtr<IMMDeviceEnumerator> enumerator( 153 ScopedComPtr<IMMDeviceEnumerator> enumerator(
154 CoreAudioUtil::CreateDeviceEnumerator()); 154 CoreAudioUtil::CreateDeviceEnumerator());
155 ASSERT_TRUE(enumerator.Get()); 155 ASSERT_TRUE(enumerator.Get());
156 156
157 // Enumerate all active input and output devices and fetch the ID of 157 // Enumerate all active input and output devices and fetch the ID of
158 // the associated device. 158 // the associated device.
159 EDataFlow flows[] = { eRender , eCapture }; 159 EDataFlow flows[] = { eRender , eCapture };
160 for (size_t i = 0; i < arraysize(flows); ++i) { 160 for (size_t i = 0; i < arraysize(flows); ++i) {
161 ScopedComPtr<IMMDeviceCollection> collection; 161 ScopedComPtr<IMMDeviceCollection> collection;
162 ASSERT_TRUE(SUCCEEDED(enumerator->EnumAudioEndpoints(flows[i], 162 ASSERT_TRUE(SUCCEEDED(enumerator->EnumAudioEndpoints(
163 DEVICE_STATE_ACTIVE, collection.Receive()))); 163 flows[i], DEVICE_STATE_ACTIVE, collection.GetAddressOf())));
164 UINT count = 0; 164 UINT count = 0;
165 collection->GetCount(&count); 165 collection->GetCount(&count);
166 for (UINT j = 0; j < count; ++j) { 166 for (UINT j = 0; j < count; ++j) {
167 ScopedComPtr<IMMDevice> device; 167 ScopedComPtr<IMMDevice> device;
168 collection->Item(j, device.Receive()); 168 collection->Item(j, device.GetAddressOf());
169 std::string controller_id( 169 std::string controller_id(
170 CoreAudioUtil::GetAudioControllerID(device.Get(), enumerator.Get())); 170 CoreAudioUtil::GetAudioControllerID(device.Get(), enumerator.Get()));
171 EXPECT_FALSE(controller_id.empty()); 171 EXPECT_FALSE(controller_id.empty());
172 } 172 }
173 } 173 }
174 } 174 }
175 175
176 TEST_F(CoreAudioUtilWinTest, GetFriendlyName) { 176 TEST_F(CoreAudioUtilWinTest, GetFriendlyName) {
177 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); 177 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable());
178 178
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 478
479 bool found_a_pair = false; 479 bool found_a_pair = false;
480 480
481 ScopedComPtr<IMMDeviceEnumerator> enumerator( 481 ScopedComPtr<IMMDeviceEnumerator> enumerator(
482 CoreAudioUtil::CreateDeviceEnumerator()); 482 CoreAudioUtil::CreateDeviceEnumerator());
483 ASSERT_TRUE(enumerator.Get()); 483 ASSERT_TRUE(enumerator.Get());
484 484
485 // Enumerate all active input and output devices and fetch the ID of 485 // Enumerate all active input and output devices and fetch the ID of
486 // the associated device. 486 // the associated device.
487 ScopedComPtr<IMMDeviceCollection> collection; 487 ScopedComPtr<IMMDeviceCollection> collection;
488 ASSERT_TRUE(SUCCEEDED(enumerator->EnumAudioEndpoints(eCapture, 488 ASSERT_TRUE(SUCCEEDED(enumerator->EnumAudioEndpoints(
489 DEVICE_STATE_ACTIVE, collection.Receive()))); 489 eCapture, DEVICE_STATE_ACTIVE, collection.GetAddressOf())));
490 UINT count = 0; 490 UINT count = 0;
491 collection->GetCount(&count); 491 collection->GetCount(&count);
492 for (UINT i = 0; i < count && !found_a_pair; ++i) { 492 for (UINT i = 0; i < count && !found_a_pair; ++i) {
493 ScopedComPtr<IMMDevice> device; 493 ScopedComPtr<IMMDevice> device;
494 collection->Item(i, device.Receive()); 494 collection->Item(i, device.GetAddressOf());
495 base::win::ScopedCoMem<WCHAR> wide_id; 495 base::win::ScopedCoMem<WCHAR> wide_id;
496 device->GetId(&wide_id); 496 device->GetId(&wide_id);
497 std::string id; 497 std::string id;
498 base::WideToUTF8(wide_id, wcslen(wide_id), &id); 498 base::WideToUTF8(wide_id, wcslen(wide_id), &id);
499 found_a_pair = !CoreAudioUtil::GetMatchingOutputDeviceID(id).empty(); 499 found_a_pair = !CoreAudioUtil::GetMatchingOutputDeviceID(id).empty();
500 } 500 }
501 501
502 EXPECT_TRUE(found_a_pair); 502 EXPECT_TRUE(found_a_pair);
503 } 503 }
504 504
505 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) { 505 TEST_F(CoreAudioUtilWinTest, GetDefaultOutputDeviceID) {
506 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); 506 ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable());
507 507
508 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID()); 508 std::string default_device_id(CoreAudioUtil::GetDefaultOutputDeviceID());
509 EXPECT_FALSE(default_device_id.empty()); 509 EXPECT_FALSE(default_device_id.empty());
510 } 510 }
511 511
512 } // namespace media 512 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/core_audio_util_win.cc ('k') | media/audio/win/device_enumeration_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698