Kodi Community Forum
Linux How can I chage the audio output device from the command line. - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Linux (https://forum.kodi.tv/forumdisplay.php?fid=52)
+---- Thread: Linux How can I chage the audio output device from the command line. (/showthread.php?tid=133546)



How can I chage the audio output device from the command line. - shadow - 2012-06-09

I have a bit of media that doesn't play correctly on the XBMC player and on those occasions I just SSH in and watch them by starting mplayer from the command line with any needed options to watch them correctly. To do that I have to go into the settings and change the audio output device in order to unblock it for use by mplayer.

I would like to know if it is possible from the command line so I can script it.

Something like

#!/bin/bash

(command to change output)
export DISPLAY=:0
mplayer -fs -ao etc...
(cammand to change output back)


RE: How can I chage the audio output device from the command line. - Plaguester - 2012-06-09

I think you want to modify ~/.xbmc/userdata/guisettings.xml

I have my audio device and passthrough device set to "hdmi (ALSA)" in XBMC and the relevant section looks like this:
Code:
<audiooutput>
        <ac3passthrough>true</ac3passthrough>
        <audiodevice>alsa:plug:hdmi</audiodevice>
        <channellayout>0</channellayout>
        <customdevice>hdmi</customdevice>
        <custompassthrough></custompassthrough>
        <dontnormalizelevels>true</dontnormalizelevels>
        <dtspassthrough>true</dtspassthrough>
        <mode>2</mode>
        <passthroughaac>false</passthroughaac>
        <passthroughdevice>alsa:hdmi</passthroughdevice>
        <passthroughmp1>false</passthroughmp1>
        <passthroughmp2>false</passthroughmp2>
        <passthroughmp3>false</passthroughmp3>
</audiooutput>

Note the use of plug to denote that the PC is doing the decoding. Ignore the residual settings for customdevice. To change this file on the command line, you might do something like this:

Code:
perl -p -i -e 's#<audiodevice>[^<]*</audiodevice>#<audiodevice>yourNewDeviceHere</audiodevice>#' /home/user/.xbmc/userdata/guisettings.xml

I have no idea if XBMC watches this file for changes. It's possible that it is only read at startup and on UI events within the audio settings window. There may be a command that you can send to ALSA or Pulse to get XBMC to release the device.


RE: How can I chage the audio output device from the command line. - shadow - 2012-06-09

Thanks, I have tested that and it turns out that the file isn't checked except at start so I have to keep looking since the only way with that is to restart the xbmc-live service which I don't want to do since that requires password input to get root permissions. Plus it would require me to go into a ssh shell and not just pass it at the command line using ssh xbmc@htpc.local 'script video.mkv'