Solving the 2-second sound delay with XBMC and HDMI

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.

Copy this script to ~/bin or /usr/local/bin and make it executable. It does two things:

  1. 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.
  2. 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.

Tags: ,

  1. Julian’s avatar

    Unfortunately this doesn’t work for me. My decoderbox still doesn’t get any signal when I’m using aplay.


    1. Tyler Wagner’s avatar

      “Still doesn’t get any signal”? Meaning it never gets sound? That’s a different problem.


    2. Øyvind’s avatar

      This kind of helps in my case. My starting point is no sound and really choppy video for a few seconds while my shittysonic TV syncs up. With this trick, the video isn’t choppy, but I still have no sound for two seconds.


      1. Tyler Wagner’s avatar

        Strange. Perhaps the TV is monitoring for a signal containing more than silence? Probably above some dB threshold. Try testing the aplay command but with actual noise, and see if the 2-second delay disappears. If so, that’s the problem (but I have no suggestion to fix it). If not, it must be XBMC itself.

        Next I buy a TV, I’m taking my HTPC into the showroom and testing for this shit. TV manufacturers should fire their TV dev teams and replace them with their PC monitor dev teams.


      2. Kieron’s avatar

        I have tried this on my Ubuntu XBMC HTPC, to no avail. Should the command be different if one is using toslink/optical audio?

        Thanks, hope you can help, this has been driving me mad for almost a year now..


        1. Tyler Wagner’s avatar

          To answer your question, no. The command just plays audio. How it routes through the sound system is another problem.

          There are many reasons that you might experience a delay or other sound issue. It took me over a year just to be sure that the issue was the TV. I can only advise that you start with your ALSA configuration.


        2. Cillian’s avatar

          Absolutely fantastic stuff! I have been seeing this problem with my raspberry pi / xbmc / sound bar set up for months now and had always pegged it to some issue with the rpi.

          Many thanks for this workaround!


        3. jobski’s avatar

          Thanks for this fix. Works on XBMC under Arch Linux

          What I did is I created a screen session with just the command running in it.



Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">