HDMI Audio stops after TV turned off

I've been having this problem. I couldn't find a decent fix, but I have this work around. Note that it's a horrid hack but it does the job for me until the root problem is fixed -- hopefully it will help someone else. Every 5 seconds it checks dmesg for HDMI connection errors and if it finds one it restarts the connection.

I made this watchdog script -- replace "DFP1" with the name of your output (get it from xrandr).

#!/usr/bin/env python
import os
import time

valid = "ELD_Valid=1"
invalid = "ELD_Valid=0"

def executeCommand(the_command):
    temp_list = os.popen(the_command).read()
    return temp_list

def getDMESG():
    return executeCommand("dmesg | grep -i hdmi | tail -n 10")

def needsRefresh():
    list = getDMESG();
    valid_index = list.rfind(valid)
    invalid_index = list.rfind(invalid)
    if invalid_index > valid_index:
        return True
    else:
        return False

def doTest():
    if needsRefresh() == True:
        os.popen("xrandr -display :0 --output DFP1 --off; xrandr -display :0 --output DFP1 --auto").read()

while True:
    doTest()
    time.sleep(5)

If anyone knows a better way to detect the error (with catalyst drivers), please let me know. (With the opensource drivers I think you could trigger the reset bit of the code on drm acpi events if you wanted to do some scripting).

I start it by adding this to /etc/rc.local: (change "xbmc" to the user name that you log in as)

su xbmc -c 'python /home/USERNAME/src/check_hdmi.py &'

In the meantime while the bug report gets a good going over, I've noticed a quick button combination that will save a few headaches.

Simply pull out into a tty and back to your GUI:

CTRL + ALT + F1 (or anything from F1 to F6)

then

CTRL + ALT + F8 (you might need to use F7 instead of F8. One of them will return you to your desktop, the other will give you a black screen and a cursor)

It seems sync is re-established when returning to the GUI.

This is far quicker than logging out and back in, and you're programs etc. remain open.

Button combination. Done. Hassle free.

This of course isn't a fix. It's just a quick keyboard combination to trick the HDMI to re-sync and thus get the audio back.

It works on my end.
Anyone else want to turn their TV off for a second and try it themselves?