Skip to content

Conversation

MrGuim
Copy link

@MrGuim MrGuim commented Oct 8, 2025

In the audio thread of asynchronous backends, the following condition keeps the for loop running while it waits for a new operation in the queue.

if (ma_context_is_backend_asynchronous(ma_device_get_context(pDevice))) {
    continue;   /* <-- This just makes the audio thread wait for a new operation to arrive, like an uninit or stop. */
}

You should then stop the backend when a MA_DEVICE_OP_STOP operation is queued rather than only triggering a signal.

for (;;) {
    // You will be waiting again for a new operation to be queued.
    result = ma_device_op_queue_next(&pDevice->opQueue, MA_BLOCKING_MODE_BLOCKING, &pOp); 
    if (result != MA_SUCCESS) {
        break;
    }

    if (pOp->type == MA_DEVICE_OP_UNINIT) {
        ...
    } else if (pOp->type == MA_DEVICE_OP_START) {
        ...
    } else if (pOp->type == MA_DEVICE_OP_STOP) {
        // <-- You should handle the stop operation here and not only send a signal.
        ma_device_op_do_stop(pDevice, pOp->pCompletionEvent);
    }
}

I might be missing something about how the backend interaction works, but I don't see where the backend is being stopped elsewhere

@mackron
Copy link
Owner

mackron commented Oct 9, 2025

Thanks. Just acknowledging that I've seen this. Will report back when I get a chance to properly review this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants