PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.43k stars 295 forks source link

25+ seconds of delay before callback function starts with RaspberryPi4 #656

Open josephernest opened 2 years ago

josephernest commented 2 years ago

When using Portaudio (via the sounddevice Python module which calls Portaudio) with a Raspberry Pi 4, there is a 25-30 seconds delay before the callback function even starts.

Here is a short-example, the AudioCallback function starts only after 25-30 seconds.

sd = sounddevice.OutputStream(device=AUDIO_DEVICE_ID, blocksize=512, samplerate=44100, channels=2, 
                                                    dtype='int16', callback=AudioCallback)
sd.start()

It has already been confirmed by a few different people here: https://github.com/spatialaudio/python-sounddevice/issues/327

I have found reports of this with other wrapper libraries around Portaudio than sounddevice, so this is not linked to sounddevice itself, but more probably RPi + Portaudio.

Do you have any idea what could be the cause?

Other interesting read: https://listserv.cuit.columbia.edu/scripts/wa.exe?A2=2103B&L=PORTAUDIO&D=0&S=b&P=292768

RossBencina commented 2 years ago

Could you please clarify whether the delay occurs during Pa_OpenStream or Pa_StartStream?

josephernest commented 2 years ago

Seems solved with

apt update 
apt install raspberrypi-kernel

Would be cool if someone can confirm :)