atomically read queue_stored

This commit is contained in:
derselbst 2017-08-25 21:16:37 +02:00 committed by derselbst
parent 680fcf1f88
commit 0bf4873ab2

View file

@ -67,9 +67,11 @@ int fluid_rvoice_eventhandler_dispatch_count(fluid_rvoice_eventhandler_t*);
static FLUID_INLINE void
fluid_rvoice_eventhandler_flush(fluid_rvoice_eventhandler_t* handler)
{
if (handler->queue_stored > 0) {
fluid_ringbuffer_next_inptr(handler->queue, handler->queue_stored);
handler->queue_stored = 0;
int queue_stored = fluid_atomic_int_get(&handler->queue_stored);
if (queue_stored > 0) {
fluid_atomic_int_set(&handler->queue_stored, 0);
fluid_ringbuffer_next_inptr(handler->queue, queue_stored);
}
}
@ -103,11 +105,15 @@ static FLUID_INLINE void
fluid_rvoice_eventhandler_add_rvoice(fluid_rvoice_eventhandler_t* handler,
fluid_rvoice_t* rvoice)
{
if (handler->is_threadsafe)
/* always queue events. without it we may run into timing issues, when events are being dispatched
* via the sampletimers, without actually rendering it.
*/
// if (handler->is_threadsafe)
fluid_rvoice_eventhandler_push_ptr(handler, fluid_rvoice_mixer_add_voice,
handler->mixer, rvoice);
else
fluid_rvoice_mixer_add_voice(handler->mixer, rvoice);
// else
// fluid_rvoice_mixer_add_voice(handler->mixer, rvoice);
}