-
Notifications
You must be signed in to change notification settings - Fork 96
FlexASIO never waits for ASIOOutputReady() #180
Description
While reviewing some FlexASIO code I stumbled upon this:
FlexASIO/src/flexasio/FlexASIO/flexasio.cpp
Lines 998 to 1003 in 57e14e8
| std::unique_lock outputReadyLock(outputReadyMutex); | |
| if (!outputReady) { | |
| if (IsLoggingEnabled()) Log() << "Waiting for the ASIO Host Application to signal OutputReady"; | |
| outputReadyCondition.wait(outputReadyLock, [&] { return outputReady; }); | |
| outputReady = false; | |
| } |
I suspect this is subtly wrong. With this code outputReady only gets reset if it happened to get set after we started waiting for the condition. If outputReady was already true before we entered this block, then it will stay true forever. That doesn't seem right. The reset should happen unconditionally.
The consequence of outputReady being stuck at true is that ASIO output buffers will be transferred to PortAudio before the ASIO host application is done writing them, leading to corrupted audio output.
One reason why this went unnoticed until now is probably because this only has consequences in ASIO Host Applications that support OutputReady and return from bufferSwitch before they call it. I suspect such applications are rare.