PulseAudio delay before writeable callback called

I am currently using pulseaudio to play some audio while triggering another event that needs to happen essentially at the same time. The event is a light being turned on, ideally just need this to be visually "in sync" with the audio.

At the moment (high level) a callback is setup using pa_stream_set_write_callback() and then there is a main loop running over pa_mainloop_iterate().

The issue is there is a significant delay (~280ms) before my callback is called (i.e. the stream is writable) and this it is obvious that the audio is out of sync to the light event. Unfortunately I can't seem to find any info on this delay before the stream is writable.

Unloading the suspend-on-idle-module improved the delay from ~280ms to ~70ms. I am hoping this can be improved further (there is additional delay on top of the 70ms until sound is heard, so it is still visually noticeable).

Very high level pseudo code:

// callback - there is a delay before this is called
void streamWriteCallback(pa_stream*, size_t, void*)
    // write to stream


// setup code
pa_stream_set_write_callback(stream_, &streamWriteCallback, this);


// main loop
while (true)

Suggestions are appreciated.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum