Audio is delayed through laptop's speakers, but it's fine without any delay when headphones plugged in

Here is what I just noticed; if a youtube video is playing in the background, (meaning, if the sound device is already initialized and activated by a youtube video currently playing in the background), there is no audio delay at all when I play an audio file that reads, “I am just happy to be back”.

The audio delay happens for the initial second or so when the audio device needs to start to play a youtube video or an audio file. When you’re done watching the youtube video or listening to the audio file, it appears that the sound device is deactivated or put on idle again. So, I’m assuming, every time you play anything with audio, the audio device needs to be activated or initialized again and it’s not ready yet.

Is there a way to make sure the audio device is always on and is not deactivated or put on idle when it’s not in use?

Default configuration of PulseAudio includes module-suspend-on-idle that automatically suspends audio devices when no audio is playing

Try unloading the module temporarily:

pactl unload-module module-suspend-on-idle

If that works, module can be permanently disabled:

sudo sed -i '/load-module module-suspend-on-idle/s/^/#/' /etc/pulse/default.pa

If that does not work, use module-sine to generate a constant low-frequency tone
and set volume to 1%

pactl load-module module-sine frequency=10;
pactl set-sink-input-volume $(LANG=C pactl list sink-inputs | grep -B 1 "Driver: module-sine.c" | grep Input | sed 's/[^0-9]//g') 1%
2 Likes

Unfortunately, none of the suggestions seem to make any difference.

Has no one done this?

https://wiki.archlinux.org/title/PipeWire#Noticeable_audio_delay_or_audible_pop/crack_when_starting_playback

Or possibly power saving settings such as here

https://wiki.archlinux.org/title/Power_management#Audio

1 Like

I’m using PulseAudio. This may not be applicable for my case. wireplumber is not even installed in my system.

Have you tried turning off PulseAudio

systemctl --user stop pulseaudio.socket pulseaudio.service

and testing audio playback direct to ALSA?

If audio from a youtube works does any other audio playback also work?
For example if you play a local audio file in a loop:

mpv --loop-file example.wav

Still the same thing! If I play an audio file that reads “I am just happy to be back” , because of the initial delay, I only hear “happy to be back”.

I have the same problem with audio from youtube or with any local audio file. When I start youtube video or a local audio file, I don’t hear the first 2 seconds of the audio. There is silence until the audio device wakes up to do what it needs to do.

As previously said, if a youtube video is playing (if the audio device is already in use), if I play the audio file that reads “I am just happy to be back”, then I hear the whole thing without the initial silence in the beginning because, in this case, the audio device was already activated (not on idle) since it was playing a youtube video in the background.

If audio playback direct to ALSA device is delayed I suggest you report issue to ALSA developers at kernel.bugzilla.org

Reporting bugs — The Linux Kernel documentation

Since this seems to be tougher one to troubleshoot, why not try something different.

Throw a few live boot distros and Ventoy on a flash drive, and see if any persist with that problem.

And try Manjaro (whatever DE you use) Edition first. That way you could see if it’s a configuration/package/etc issue on your end first, and it would be the easiest to see what is different.

1 Like

I still have the same problem with the Manjaro live boot!

Here is the crazy part; When I plug in earbuds or headphones, everything is perfectly fine! It plays the whole thing without any initial audio delay. The problem (audio delay) is with the internal speakers of the laptop!

You would think there would more likely be a problem with an external device connected to laptop like earbuds and headphones, not with the internal speakers! But no! Go figure!!!