HDMI Audio glitches

I have been setting up my old Pi3 with the latest version of kodi and addons in preparation for travelling home for christmas (ha!), but have been having issues with audio glitches, dropouts, cutouts, however you want to describe them.

Im now not going home for christmas but I would still like to get the Pi to be able to play without these glitches.

Im almost 100% convinced its an HDMI issue and not strictly speaking a Pi problem. Thats after a lot of changes to the audio/display settings in kodi, and also a lot of variations of options in /boot/config.txt
I was just able to watch something this morning without any noticeable audio glitches and I think it was mostly due to the order in which I switched stuff on and the HDMI cable used.

Currently my config.txt looks like this:

gpu_mem_1024=368
disable_overscan=1
start_x=1
disable_splash=0
gpu_mem_256=112
gpu_mem_512=256
avoid_warnings=1
config_hdmi_boost=4
hdmi_drive=2
smsc95xx.turbo_mode=N
sdtv_aspect=1
hdmi_ignore_cec=1

And cmdline.txt

root=/dev/mmcblk0p2 rootfstype=ext4 rootwait quiet osmcdev=rbp2 sdhci-bcm2708.missing_status=0 sdhci-bcm2708.sync_after_dma=0

On a raspberry Pi 3b with the Osmc November Update, Audio Fixed 2.0, 44.1Khz, No keep audio device alive, no sync playback to display (start/stop only), connected via wifi on a long HDMI lead.

Im on a Panasonic VIERA TX50DX700B, connected to a Pioneer VSX-324.

Obviously im using an amp so I could just enable pass through audio which should eliminate any potential problems. But my goal was to get the Pi setup for when i’m travelling so I would want reliable audio decoded by the Pi as there are no guarantees what formats any TV may support natively.

My Amp does seem to ocassionally drop audio passthrough and takes some coaxing to get it back, and occasionally the TV cant detect the amp which has happened once or twice.

So im pretty sure that the audio glitches are due to the Pi/TV/Amp combo and suspect its EDID related in some way. But hmdi_safe=1 didnt really seem to have much effect when I have tried it (however i havent been doing a power cycle every time, just rebooting the pi).

So does anyone have any specific suggestions about hdmi settings which will be the most generic and least likely to cause these audio glitches?

Ive done debug logging and there doesnt appear to be anything Pi side when it occurs, without an Amp involved or with a cheap TV with no fancy HDMI features (like CEC) is this likely to be a problem?
Im pretty sure the 4k tv in the mix is the main culprit, which is unlikely to be a problem in my parents house or your average hotel room.
But I was curious if anyone with a better handle on EDID’s may have suggestions.

Cheers

Posting some full logs may allow us to see if there’s anything on the Kodi side which needs adjusting.