We faced a critical bug that happened occasionally when user plug in a microphone device and we need to switch to that device.
In those cases, ma_device_init were ok, but ma_device_start never returned, . Log callback showed "[WASAPI] Failed to start internal capture device."
Our lead engineer found that:
ma_device_start sends pDevice->wakeupEvent and then wait for pDevice->startEvent
ma_worker_thread calls ma_device_start__wasapi via callbacks.onDeviceStart
if ma_device_start__wasapi failed, ma_worker_thread will store the result to pDevice->workResult loop back to the start and wait for pDevice->wakeupEvent again.
In this case, ma_device_start will wait forever. We temporarily patched ma_worker_thread to notify pDevice->startEvent so that ma_device_start will return when internal start function fails.
if (startResult != MA_SUCCESS) {
pDevice->workResult = startResult;
ma_event_signal(&pDevice->startEvent);
continue; /* Failed to start. Loop back to the start and wait for something to happen (pDevice->wakeupEvent). */
}
Please let me know if what we are doing are correct or not.
We faced a critical bug that happened occasionally when user plug in a microphone device and we need to switch to that device.
In those cases, ma_device_init were ok, but ma_device_start never returned, . Log callback showed "[WASAPI] Failed to start internal capture device."
Our lead engineer found that:
In this case, ma_device_start will wait forever. We temporarily patched ma_worker_thread to notify pDevice->startEvent so that ma_device_start will return when internal start function fails.
Please let me know if what we are doing are correct or not.
Thank you very much for miniaudio.
Best,