Commit 1ceecebb authored by David Reid's avatar David Reid

WASAPI: Add some debug output for WASAPI and automatic stream routing.

Public issue https://github.com/mackron/miniaudio/issues/258
parent bd80a409
...@@ -13564,23 +13564,32 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMM ...@@ -13564,23 +13564,32 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMM
static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, LPCWSTR pDefaultDeviceID) static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, LPCWSTR pDefaultDeviceID)
{ {
#ifdef MA_DEBUG_OUTPUT #ifdef MA_DEBUG_OUTPUT
/*printf("IMMNotificationClient_OnDefaultDeviceChanged(dataFlow=%d, role=%d, pDefaultDeviceID=%S)\n", dataFlow, role, (pDefaultDeviceID != NULL) ? pDefaultDeviceID : L"(NULL)");*/ printf("IMMNotificationClient_OnDefaultDeviceChanged(dataFlow=%d, role=%d, pDefaultDeviceID=%S)\n", dataFlow, role, (pDefaultDeviceID != NULL) ? pDefaultDeviceID : L"(NULL)");
#endif #endif
/* We only ever use the eConsole role in miniaudio. */ /* We only ever use the eConsole role in miniaudio. */
if (role != ma_eConsole) { if (role != ma_eConsole) {
return S_OK; #ifdef MA_DEBUG_OUTPUT
printf("[WASAPI] Stream rerouting: role != eConsole\n");
#endif
/*return S_OK;*/
} }
/* We only care about devices with the same data flow and role as the current device. */ /* We only care about devices with the same data flow and role as the current device. */
if ((pThis->pDevice->type == ma_device_type_playback && dataFlow != ma_eRender) || if ((pThis->pDevice->type == ma_device_type_playback && dataFlow != ma_eRender) ||
(pThis->pDevice->type == ma_device_type_capture && dataFlow != ma_eCapture)) { (pThis->pDevice->type == ma_device_type_capture && dataFlow != ma_eCapture)) {
#ifdef MA_DEBUG_OUTPUT
printf("[WASAPI] Stream rerouting abandoned because dataFlow does match device type.\n");
#endif
return S_OK; return S_OK;
} }
/* Don't do automatic stream routing if we're not allowed. */ /* Don't do automatic stream routing if we're not allowed. */
if ((dataFlow == ma_eRender && pThis->pDevice->wasapi.allowPlaybackAutoStreamRouting == MA_FALSE) || if ((dataFlow == ma_eRender && pThis->pDevice->wasapi.allowPlaybackAutoStreamRouting == MA_FALSE) ||
(dataFlow == ma_eCapture && pThis->pDevice->wasapi.allowCaptureAutoStreamRouting == MA_FALSE)) { (dataFlow == ma_eCapture && pThis->pDevice->wasapi.allowCaptureAutoStreamRouting == MA_FALSE)) {
#ifdef MA_DEBUG_OUTPUT
printf("[WASAPI] Stream rerouting abandoned because automatic stream routing has been disabled by the device config.\n");
#endif
return S_OK; return S_OK;
} }
...@@ -13591,6 +13600,9 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged ...@@ -13591,6 +13600,9 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged
*/ */
if ((dataFlow == ma_eRender && pThis->pDevice->playback.shareMode == ma_share_mode_exclusive) || if ((dataFlow == ma_eRender && pThis->pDevice->playback.shareMode == ma_share_mode_exclusive) ||
(dataFlow == ma_eCapture && pThis->pDevice->capture.shareMode == ma_share_mode_exclusive)) { (dataFlow == ma_eCapture && pThis->pDevice->capture.shareMode == ma_share_mode_exclusive)) {
#ifdef MA_DEBUG_OUTPUT
printf("[WASAPI] Stream rerouting abandoned because the device shared mode is exclusive.\n");
#endif
return S_OK; return S_OK;
} }
...@@ -15113,12 +15125,15 @@ static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type de ...@@ -15113,12 +15125,15 @@ static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type de
} }
#ifdef MA_DEBUG_OUTPUT #ifdef MA_DEBUG_OUTPUT
printf("=== CHANGING DEVICE ===\n"); printf("=== CHANGING DEVICE ===\n");
#endif #endif
result = ma_device_reinit__wasapi(pDevice, deviceType); result = ma_device_reinit__wasapi(pDevice, deviceType);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
#ifdef MA_DEBUG_OUTPUT
printf("[WASAPI] Reinitializing device after route change failed.\n");
#endif
return result; return result;
} }
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