Commit 97633937 authored by Ghislain MARY's avatar Ghislain MARY

Improve sound card detection and used specified sound card on Windows 10.

parent b4be757d
......@@ -417,19 +417,27 @@ public:
DefaultId = MediaDevice::GetDefaultAudioRenderId(AudioDeviceRole::Communications);
}
AddOrUpdateCard(DefaultId, DefaultName, _dc);
Concurrency::task<DeviceInformationCollection^> enumOperation(DeviceInformation::FindAllAsync(_dc));
enumOperation.then([this](DeviceInformationCollection^ DeviceInfoCollection) {
if ((DeviceInfoCollection == nullptr) || (DeviceInfoCollection->Size == 0)) {
ms_error("mswasapi: No audio device found");
} else {
try {
for (unsigned int i = 0; i < DeviceInfoCollection->Size; i++) {
DeviceInformation^ deviceInfo = DeviceInfoCollection->GetAt(i);
AddOrUpdateCard(deviceInfo->Id, deviceInfo->Name, _dc);
Windows::Foundation::IAsyncOperation<DeviceInformationCollection^>^ op = DeviceInformation::FindAllAsync(_dc);
op->Completed = ref new Windows::Foundation::AsyncOperationCompletedHandler<DeviceInformationCollection^>(
[this](Windows::Foundation::IAsyncOperation<DeviceInformationCollection^>^ asyncOp, Windows::Foundation::AsyncStatus asyncStatus) {
if (asyncStatus == Windows::Foundation::AsyncStatus::Completed) {
DeviceInformationCollection^ deviceInfoCollection = asyncOp->GetResults();
if ((deviceInfoCollection == nullptr) || (deviceInfoCollection->Size == 0)) {
ms_error("mswasapi: No audio device found");
}
else {
try {
for (unsigned int i = 0; i < deviceInfoCollection->Size; i++) {
DeviceInformation^ deviceInfo = deviceInfoCollection->GetAt(i);
AddOrUpdateCard(deviceInfo->Id, deviceInfo->Name, _dc);
}
}
catch (Platform::Exception^ e) {
ms_error("mswaspi: Error of audio device detection");
}
} catch (Platform::Exception^ e) {
ms_error("mswaspi: Error of audio device detection");
}
} else {
ms_error("mswasapi: DeviceInformation::FindAllAsync failed");
}
SetEvent(_DetectEvent);
});
......
......@@ -86,7 +86,7 @@ void MSWASAPIReader::init(LPCWSTR id)
#if defined(MS2_WINDOWS_UNIVERSAL)
ComPtr<IActivateAudioInterfaceAsyncOperation> asyncOp;
mCaptureId = MediaDevice::GetDefaultAudioCaptureId(AudioDeviceRole::Communications);
mCaptureId = ref new Platform::String(id);
if (mCaptureId == nullptr) {
ms_error("Could not get the CaptureID of the MSWASAPI audio input interface");
goto error;
......
......@@ -84,7 +84,7 @@ void MSWASAPIWriter::init(LPCWSTR id) {
#if defined(MS2_WINDOWS_UNIVERSAL)
IActivateAudioInterfaceAsyncOperation *asyncOp;
mRenderId = MediaDevice::GetDefaultAudioRenderId(AudioDeviceRole::Communications);
mRenderId = ref new Platform::String(id);
if (mRenderId == nullptr) {
ms_error("Could not get the RenderID of the MSWASAPI audio output interface");
goto error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment