napframework / nap

NAP Framework source code
https://nap-framework.tech
Mozilla Public License 2.0
403 stars 23 forks source link

Enable real time scheduling (ALSA) #54

Open cklosters opened 4 hours ago

cklosters commented 4 hours ago

When going over the ALSA docs for portaudio I noticed you have to explicitly enable real time scheduling:

Of particular importance is PaAlsa_EnableRealtimeScheduling, which allows ALSA to run at a high priority to prevent ordinary processes on the system from preempting audio playback. Without this, low latency audio playback will be irregular and will contain frequent drop-outs. If this is turned on by the stream is started, the audio callback thread will be created with the FIFO scheduling policy, which is suitable for realtime operation.

We should turn it on, because it's (implicitly?) enabled on all other platforms according to @stijnvanbeek - resulting in less frequent drop-outs, although me personally have not noticed any.

lshoek commented 2 hours ago

I did actually notice lots of stutter yesterday when running the audiovisual demo (PR) in Release on Ubuntu 22 with audio playback routed to the front output of my system. I will try to see if this makes any difference on my end.

cklosters commented 1 hour ago

I did actually notice lots of stutter yesterday when running the audiovisual demo (PR) in Release on Ubuntu 22 with audio playback routed to the front output of my system. I will try to see if this makes any difference on my end.

Ok, sounds good. To avoid any confusion: I removed libjack as a dependency for the release of 0.7.5 because it's not default (installed) with Ubuntu 24.04. I don't think that's what you used in the past (default often isn't jack) but good to know. Also: You might want to use a Low-Latency Kernel (Ubuntu Studio). and benchmark with and without the PaAlsa_EnableRealtimeScheduling enabled.