Skip to content

FlexASIO never waits for ASIOOutputReady() #180

@dechamps

Description

@dechamps

While reviewing some FlexASIO code I stumbled upon this:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions