Periodic clicking sound (like a metronome) when playing music (or anything)

When playing anything (music, video) from any source (browser, music player, video player) several times the output is a periodic clicking, like a metronome. This is not always the case, there are times when everything is normal. Even it happens, that e.g. a video in firefox starts, sound is normal for a second than the clicking starts. Restarting alsa and pulseaudio does not help. Reboot usually helps, but not always. Suspend and resume also helps sometimes. But sometimes simply time solves the problem, a few hours later everything is fine. The whole problem is totally erratic, but quite frequent. An important point is that this clicking sound sometime audible during booting for some time, probably until sound card is initialized. alsa-info: What could be the problem?

It reads like this bug. (Some hardware is impacted by the snd_hda_intel power_save parameter). That can be inhibited if necessary.

I had this issue few years ago with my AMD-ASRock motherboard and Fedora.
The issue was due to one jack input connector autodetect flickering on/off.

To fix it I installed “Jack retasking for HDA Intel sound cards” and set it manually.

Looks like now I don’t have this issue any more.