| 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 "media/audio/win/core_audio_util_win.h" | 5 #include "media/audio/win/core_audio_util_win.h" |
| 6 | 6 |
| 7 #include <audioclient.h> | 7 #include <audioclient.h> |
| 8 #include <devicetopology.h> | 8 #include <devicetopology.h> |
| 9 #include <functiondiscoverykeys_devpkey.h> | 9 #include <functiondiscoverykeys_devpkey.h> |
| 10 | 10 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // Fetching the controller device id could be as simple as fetching the value | 352 // Fetching the controller device id could be as simple as fetching the value |
| 353 // of the "{B3F8FA53-0004-438E-9003-51A46E139BFC},2" property in the property | 353 // of the "{B3F8FA53-0004-438E-9003-51A46E139BFC},2" property in the property |
| 354 // store of the |device|, but that key isn't defined in any header and | 354 // store of the |device|, but that key isn't defined in any header and |
| 355 // according to MS should not be relied upon. | 355 // according to MS should not be relied upon. |
| 356 // So, instead, we go deeper, look at the device topology and fetch the | 356 // So, instead, we go deeper, look at the device topology and fetch the |
| 357 // PKEY_Device_InstanceId of the associated physical audio device. | 357 // PKEY_Device_InstanceId of the associated physical audio device. |
| 358 ScopedComPtr<IDeviceTopology> topology; | 358 ScopedComPtr<IDeviceTopology> topology; |
| 359 ScopedComPtr<IConnector> connector; | 359 ScopedComPtr<IConnector> connector; |
| 360 ScopedCoMem<WCHAR> filter_id; | 360 ScopedCoMem<WCHAR> filter_id; |
| 361 if (FAILED(device->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, | 361 if (FAILED(device->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, |
| 362 topology.ReceiveVoid()) || | 362 topology.ReceiveVoid())) || |
| 363 // For our purposes checking the first connected device should be enough | 363 // For our purposes checking the first connected device should be enough |
| 364 // and if there are cases where there are more than one device connected | 364 // and if there are cases where there are more than one device connected |
| 365 // we're not sure how to handle that anyway. So we pass 0. | 365 // we're not sure how to handle that anyway. So we pass 0. |
| 366 FAILED(topology->GetConnector(0, connector.Receive())) || | 366 FAILED(topology->GetConnector(0, connector.Receive())) || |
| 367 FAILED(connector->GetDeviceIdConnectedTo(&filter_id)))) { | 367 FAILED(connector->GetDeviceIdConnectedTo(&filter_id))) { |
| 368 DLOG(ERROR) << "Failed to get the device identifier of the audio device"; | 368 DLOG(ERROR) << "Failed to get the device identifier of the audio device"; |
| 369 return std::string(); | 369 return std::string(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 // Now look at the properties of the connected device node and fetch the | 372 // Now look at the properties of the connected device node and fetch the |
| 373 // instance id (PKEY_Device_InstanceId) of the device node that uniquely | 373 // instance id (PKEY_Device_InstanceId) of the device node that uniquely |
| 374 // identifies the controller. | 374 // identifies the controller. |
| 375 ScopedComPtr<IMMDevice> device_node; | 375 ScopedComPtr<IMMDevice> device_node; |
| 376 ScopedComPtr<IPropertyStore> properties; | 376 ScopedComPtr<IPropertyStore> properties; |
| 377 base::win::ScopedPropVariant instance_id; | 377 base::win::ScopedPropVariant instance_id; |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 return false; | 847 return false; |
| 848 | 848 |
| 849 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to | 849 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to |
| 850 // explicitly write silence data to the rendering buffer. | 850 // explicitly write silence data to the rendering buffer. |
| 851 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; | 851 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; |
| 852 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, | 852 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, |
| 853 AUDCLNT_BUFFERFLAGS_SILENT)); | 853 AUDCLNT_BUFFERFLAGS_SILENT)); |
| 854 } | 854 } |
| 855 | 855 |
| 856 } // namespace media | 856 } // namespace media |
| OLD | NEW |