Change XBMC's audio output via HDMI-CEC.
#1
Is there any chance of xbmc being able to change its audio output based on which devices are turned on via hdmi-cec/pulse eight adapter? Currently if I want to watch a video with HD sound on just the TV I have to manually change the xbmc audio settings as the TV isn't able to decode the HD audio. Would be very nice if there was a option to output only 2ch analog when the avr is off and output the codecs selected in the xbmc audio settings screen when the avr is on.
Reply
#2
+1
Probably fixing something broken until it works, then fixing it some more until it breaks again.
Reply
#3
Wow, that's really good idea. I'd love that!
Reply
#4
Some AVRs are able to passthrough audio when switched off and some TVs can decode codecs by themselves. How would you deal with that combination?
Reply
#5
I think teeedubb was already laying down passthrough situation (since AVR off and TV on), but can be applied also to dual video output systems. The problem here is that most tv can't decode anything more than stereo (Dolby Digital 5.1/DTS/HD...) so simple passthrough doesn't really help because all you get with multichannel is ugly noise.

This suggested solution would be actually perfect and really easy to do as xbmc setup with CEC adapter can easily detect when AVR off/on status via HDMI-CEC and apply correct audio output accordingly.
Currently it's something you can't do with script detecting AVR on/off status from debug log as there is no direct command you could send to xbmc to switch audio output settings.
Once included in xbmc base code itself as CEC optional toggle it would be just simple as switching that toggle directly in CEC adapter settings. That's why I really digg this feature suggestion!
Reply
#6
Just tried to make a script which would switch analog/hdmi audio output based on 'system audio mode status changed from on to off' and 'system audio mode status changed from off to on'

These are the lines reported in debug log when you switch off/on AVR. Audio output can be then switched with
Code:
{ "jsonrpc" : "2.0", "method" : "Input.ExecuteAction", "params" : { "action" : "audiotoggledigital" }, "id" : 1 }'

What doesn't work is volume control by Xbmc Volume Up/Down + Mute actions which are still mapped to HDMI-CEC AVR controls but they are not sent to TV since AVR is in standby. Workaround would be to map volume controls on your universal remote to TV volume controls, that way it would send HDMI-CEC volume commands to AVR when it is on, and would maintain control of TV volume when AVR is in standby.
Reply
#7
(2013-06-29, 09:06)HeresJohnny Wrote: Some AVRs are able to passthrough audio when switched off and some TVs can decode codecs by themselves. How would you deal with that combination?
My avr does passthrough audio when its off, but my tv is unable to decode hd audio (afaik none are capable of this?) so playback is very jumpy with no audio. The forums are full of post with problems stemming from this situation. To keep it simple audio would be only 2 channel analog when the avr is off which would work with all tv's. I know tv's can decode ac3 and dts which may sound better than analog, but I'm after ease of use here - and after all I feel that bit streaming to tv speakers, especially when you have a avr and speakers (which is who this will target) is a moot point.

(2013-06-29, 11:21)ezechiel1917 Wrote: Just tried to make a script which would switch analog/hdmi audio output based on 'system audio mode status changed from on to off' and 'system audio mode status changed from off to on'

These are the lines reported in debug log when you switch off/on AVR. Audio output can be then switched with
Code:
{ "jsonrpc" : "2.0", "method" : "Input.ExecuteAction", "params" : { "action" : "audiotoggledigital" }, "id" : 1 }'

What doesn't work is volume control by Xbmc Volume Up/Down + Mute actions which are still mapped to HDMI-CEC AVR controls but they are not sent to TV since AVR is in standby. Workaround would be to map volume controls on your universal remote to TV volume controls, that way it would send HDMI-CEC volume commands to AVR when it is on, and would maintain control of TV volume when AVR is in standby.

Very nice find. The json-rpc command will toggle between hdmi > analog > optical so its definitely possible to put together a script/cronjob to change automatically between the two base on whats in the xbmc log file, but using using xbmc's cec functionality would be so much nicer Smile
Reply
#8
Thanks to the idea of nabz to use network connectivity of the AVR I've put together a script for openelec that changes xbmcs audio output based on whether the avr is reachable on the network. It pings the avr every 5 or so seconds and needs to restart xbmc for the settings to take effect. About 10 seconds after the avr is on xbmc is ready to use again

xbmc-audio-switch.sh
Code:
#!/bin/bash

while true ; do

if [ "`ping -c 1 192.168.1.201 | grep "64 bytes from 192.168.1.201"`" ] ; then

if [ -f /tmp/avr.on ] ; then

    echo avr on , avr.on exists

else

    echo avr on, no avr.on
    echo killing xbmc, changing audio settings
    touch /var/lock/xbmc.disabled
    killall -9 xbmc.bin
    sed -i 's$<channels>1</channels>$<channels>8</channels>$' /storage/.xbmc/userdata/guisettings.xml
    sed -i 's$<mode>0</mode>$<mode>2</mode>$' /storage/.xbmc/userdata/guisettings.xml
    sed -i 's$<stereoupmix>true</stereoupmix>$<stereoupmix>false</stereoupmix>$' /storage/.xbmc/userdata/guisettings.xml
    rm /var/lock/xbmc.disabled
    rm /tmp/avr.off
    touch /tmp/avr.on
    sleep 5
    curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"AUDIO OUTPUT","message":"AVR"}}' http://localhost:9191/jsonrpc

fi

else

if [ -f /tmp/avr.off ] ; then

    echo avr off , avr.off exists

else

    echo avr off, no avr.off
    echo killing xbmc, changing audio settings
    touch /var/lock/xbmc.disabled
    killall -9 xbmc.bin
    sed -i 's$<channels>8</channels>$<channels>1</channels>$' /storage/.xbmc/userdata/guisettings.xml
    sed -i 's$<mode>2</mode>$<mode>0</mode>$' /storage/.xbmc/userdata/guisettings.xml
    sed -i 's$<stereoupmix>false</stereoupmix>$<stereoupmix>true</stereoupmix>$' /storage/.xbmc/userdata/guisettings.xml
    rm /var/lock/xbmc.disabled
    rm /tmp/avr.on
    touch /tmp/avr.off
    sleep 5
    curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"AUDIO OUTPUT","message":"TV"}}' http://localhost:9191/jsonrpc

fi

fi


    echo end of script
    echo sleeping...
sleep 5

done

nabz's version for windows is here.
Reply

Logout Mark Read Team Forum Stats Members Help
Change XBMC's audio output via HDMI-CEC.0