On my HTPC, XBMC outputs sound over HDMI to a Panasonic TX-37LZD70 TV. This works great in most respects. However, there is a 2-second delay between when XBMC starts playing audio (music or video with sound), and when it actually outputs from the TV speakers. The sound is in sync with the video; it just takes 2 seconds to start. It’s annoying to always hear a theme song start part-way into the first few notes.
This is a known issue, but isn’t really XBMC’s fault. Basically, this TV (and many like it) doesn’t start playing sound right away. But there is a simple workaround – keep the channel open, by always playing silence. You can do this without any performance penalty.
Run this in a terminal (or in /etc/rc.local, or ~/.gnomerc, or however you like):
aplay -c2 -r48000 -fS16_LE < /dev/zero &
This will constantly play silence to the ALSA sound system (in the case of Ubuntu, via Pulse). As far as I can tell, the sound server just drops it, or consumes very few resources to do it. The system load never increases nor does it appear as active in top.
I've implemented this as a more sophisticated solution. I have created my own xbmc script, which then calls the real XBMC.
#!/bin/bash # if xbmc already running, exit if (ps -ef | grep '[/]usr/lib/xbmc/xbmc.bin' >/dev/null 2>&1) ; then zenity --error --title "XBMC" --text "XBMC is already running. Please select it from the task bar above." die "XBMC is already running!" fi # Keep sound channel open (play silence), to prevent 2-second HDMI delay aplay -c2 -r48000 -fS16_LE < /dev/zero & APLAY_PID=$! /usr/bin/xbmc "$@" kill $APLAY_PID
Copy this script to ~/bin or /usr/local/bin and make it executable. It does two things:
- Prevent launching more than one copy of XBMC. An easy mistake to make since Gnome provides no launch feedback and XBMC takes some time to start. A more elegant solution would restore the other XBMC instance instead of nagging the user.
- Starts playing silence before starting XBMC, then kills it afterward.
A better solution would be for XBMC to maintain the channel itself (which must be what my DVD player does), but I'm happy with this until they release an official fix.
Leave a Reply