From 1c15cf650254acf26cc1f5ae5b53be3f183e7b57 Mon Sep 17 00:00:00 2001 From: David Reid Date: Tue, 14 May 2024 07:48:53 +1000 Subject: [PATCH] WASAPI: Fix a regression where incorrect device info is retrieved. --- miniaudio.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/miniaudio.h b/miniaudio.h index 82356a8c..ad2a7bf7 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -42388,6 +42388,17 @@ MA_API ma_result ma_device_get_info(ma_device* pDevice, ma_device_type type, ma_ if (type == ma_device_type_playback) { return ma_context_get_device_info(pDevice->pContext, type, pDevice->playback.pID, pDeviceInfo); } else { + /* + Here we're getting the capture side, which is the branch we'll be entering for a loopback + device, since loopback is capturing. However, if the device is using the default device ID, + it won't get the correct information because it'll think we're asking for the default + capture device, where in fact for loopback we want the default *playback* device. We'll do + a bit of a hack here to make sure we get the correct info. + */ + if (pDevice->type == ma_device_type_loopback && pDevice->capture.pID == NULL) { + type = ma_device_type_playback; + } + return ma_context_get_device_info(pDevice->pContext, type, pDevice->capture.pID, pDeviceInfo); } }