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 <devicetopology.h> | 7 #include <devicetopology.h> |
8 #include <dxdiag.h> | 8 #include <dxdiag.h> |
9 #include <functiondiscoverykeys_devpkey.h> | 9 #include <functiondiscoverykeys_devpkey.h> |
10 #include <objbase.h> | 10 #include <objbase.h> |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 // Fetching the controller device id could be as simple as fetching the value | 370 // Fetching the controller device id could be as simple as fetching the value |
371 // of the "{B3F8FA53-0004-438E-9003-51A46E139BFC},2" property in the property | 371 // of the "{B3F8FA53-0004-438E-9003-51A46E139BFC},2" property in the property |
372 // store of the |device|, but that key isn't defined in any header and | 372 // store of the |device|, but that key isn't defined in any header and |
373 // according to MS should not be relied upon. | 373 // according to MS should not be relied upon. |
374 // So, instead, we go deeper, look at the device topology and fetch the | 374 // So, instead, we go deeper, look at the device topology and fetch the |
375 // PKEY_Device_InstanceId of the associated physical audio device. | 375 // PKEY_Device_InstanceId of the associated physical audio device. |
376 ScopedComPtr<IDeviceTopology> topology; | 376 ScopedComPtr<IDeviceTopology> topology; |
377 ScopedComPtr<IConnector> connector; | 377 ScopedComPtr<IConnector> connector; |
378 ScopedCoMem<WCHAR> filter_id; | 378 ScopedCoMem<WCHAR> filter_id; |
379 if (FAILED(device->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, | 379 if (FAILED(device->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, |
380 topology.ReceiveVoid())) || | 380 &topology)) || |
381 // For our purposes checking the first connected device should be enough | 381 // For our purposes checking the first connected device should be enough |
382 // and if there are cases where there are more than one device connected | 382 // and if there are cases where there are more than one device connected |
383 // we're not sure how to handle that anyway. So we pass 0. | 383 // we're not sure how to handle that anyway. So we pass 0. |
384 FAILED(topology->GetConnector(0, connector.Receive())) || | 384 FAILED(topology->GetConnector(0, connector.Receive())) || |
385 FAILED(connector->GetDeviceIdConnectedTo(&filter_id))) { | 385 FAILED(connector->GetDeviceIdConnectedTo(&filter_id))) { |
386 DLOG(ERROR) << "Failed to get the device identifier of the audio device"; | 386 DLOG(ERROR) << "Failed to get the device identifier of the audio device"; |
387 return std::string(); | 387 return std::string(); |
388 } | 388 } |
389 | 389 |
390 // Now look at the properties of the connected device node and fetch the | 390 // Now look at the properties of the connected device node and fetch the |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 } | 506 } |
507 | 507 |
508 ScopedComPtr<IAudioClient> CoreAudioUtil::CreateClient( | 508 ScopedComPtr<IAudioClient> CoreAudioUtil::CreateClient( |
509 IMMDevice* audio_device) { | 509 IMMDevice* audio_device) { |
510 // Creates and activates an IAudioClient COM object given the selected | 510 // Creates and activates an IAudioClient COM object given the selected |
511 // endpoint device. | 511 // endpoint device. |
512 ScopedComPtr<IAudioClient> audio_client; | 512 ScopedComPtr<IAudioClient> audio_client; |
513 HRESULT hr = audio_device->Activate(__uuidof(IAudioClient), | 513 HRESULT hr = audio_device->Activate(__uuidof(IAudioClient), |
514 CLSCTX_INPROC_SERVER, | 514 CLSCTX_INPROC_SERVER, |
515 NULL, | 515 NULL, |
516 audio_client.ReceiveVoid()); | 516 &audio_client); |
517 DVLOG_IF(1, FAILED(hr)) << "IMMDevice::Activate: " << std::hex << hr; | 517 DVLOG_IF(1, FAILED(hr)) << "IMMDevice::Activate: " << std::hex << hr; |
518 return audio_client; | 518 return audio_client; |
519 } | 519 } |
520 | 520 |
521 ScopedComPtr<IAudioClient> CoreAudioUtil::CreateDefaultClient( | 521 ScopedComPtr<IAudioClient> CoreAudioUtil::CreateDefaultClient( |
522 EDataFlow data_flow, ERole role) { | 522 EDataFlow data_flow, ERole role) { |
523 ScopedComPtr<IMMDevice> default_device(CreateDefaultDevice(data_flow, role)); | 523 ScopedComPtr<IMMDevice> default_device(CreateDefaultDevice(data_flow, role)); |
524 return (default_device.Get() ? CreateClient(default_device.Get()) | 524 return (default_device.Get() ? CreateClient(default_device.Get()) |
525 : ScopedComPtr<IAudioClient>()); | 525 : ScopedComPtr<IAudioClient>()); |
526 } | 526 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 return ScopedComPtr<IAudioRenderClient>(); | 836 return ScopedComPtr<IAudioRenderClient>(); |
837 } | 837 } |
838 return audio_render_client; | 838 return audio_render_client; |
839 } | 839 } |
840 | 840 |
841 ScopedComPtr<IAudioCaptureClient> CoreAudioUtil::CreateCaptureClient( | 841 ScopedComPtr<IAudioCaptureClient> CoreAudioUtil::CreateCaptureClient( |
842 IAudioClient* client) { | 842 IAudioClient* client) { |
843 // Get access to the IAudioCaptureClient interface. This interface | 843 // Get access to the IAudioCaptureClient interface. This interface |
844 // enables us to read input data from a capturing endpoint buffer. | 844 // enables us to read input data from a capturing endpoint buffer. |
845 ScopedComPtr<IAudioCaptureClient> audio_capture_client; | 845 ScopedComPtr<IAudioCaptureClient> audio_capture_client; |
846 HRESULT hr = client->GetService(__uuidof(IAudioCaptureClient), | 846 HRESULT hr = client->GetService(IID_PPV_ARGS(&audio_capture_client)); |
847 audio_capture_client.ReceiveVoid()); | |
848 if (FAILED(hr)) { | 847 if (FAILED(hr)) { |
849 DVLOG(1) << "IAudioClient::GetService: " << std::hex << hr; | 848 DVLOG(1) << "IAudioClient::GetService: " << std::hex << hr; |
850 return ScopedComPtr<IAudioCaptureClient>(); | 849 return ScopedComPtr<IAudioCaptureClient>(); |
851 } | 850 } |
852 return audio_capture_client; | 851 return audio_capture_client; |
853 } | 852 } |
854 | 853 |
855 bool CoreAudioUtil::FillRenderEndpointBufferWithSilence( | 854 bool CoreAudioUtil::FillRenderEndpointBufferWithSilence( |
856 IAudioClient* client, IAudioRenderClient* render_client) { | 855 IAudioClient* client, IAudioRenderClient* render_client) { |
857 UINT32 endpoint_buffer_size = 0; | 856 UINT32 endpoint_buffer_size = 0; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 | 919 |
921 if (variant.type() == VT_BSTR && variant.ptr()->bstrVal) { | 920 if (variant.type() == VT_BSTR && variant.ptr()->bstrVal) { |
922 base::WideToUTF8(variant.ptr()->bstrVal, wcslen(variant.ptr()->bstrVal), | 921 base::WideToUTF8(variant.ptr()->bstrVal, wcslen(variant.ptr()->bstrVal), |
923 driver_version); | 922 driver_version); |
924 } | 923 } |
925 | 924 |
926 return true; | 925 return true; |
927 } | 926 } |
928 | 927 |
929 } // namespace media | 928 } // namespace media |
OLD | NEW |