[mythtv] Seemingly simple and useful digital audio toggle

Patrick Oglesby octoberblu3 at gmail.com
Sun Dec 4 05:21:09 UTC 2011


On Sat, Dec 3, 2011 at 12:26 PM, Zachary Gleit <zlg1 at yahoo.com> wrote:
> I have my MythTV box hooked up to my TV via an analog stereo connection.  I
> also have the MythTV box hooked up to my surround receiver via an SPDIF
> output.  I use the analog output when just casually watching TV - the news,
> a TV show.  But I want to use digital surround pass-through when I'm
> watching a movie.  The trouble is that there's no easy way to switch
> outputs, as far as I can tell.  Obviously, I know how to go into settings
> and change the audio output, but this is cumbersome.
>
> In an ideal world, both streams would play simultaneously, and I'd just put
> on my surround receiver and mute the TV when I want to listen in surround.
>  I don't know why this would be hard to implement, since the SPDIF should
> just be a pass-through, but I've read that MythTV simply can't play two
> audio streams.
>
> Second best would be a simple menu choice or toggle to easily switch between
> audio outputs.  Any idea how I can do this?
>

Someone else here once wrote this script to do this for switching
between bluetooth and spdif using the python bindings, but I'm sure
you can adapt it to work for you.  Just replace the a2dp with your
preferred analog output.  The print statements are optional.


#!/usr/bin/python

from MythTV import MythBE

be = MythBE()
db = be.db
hostname = db.gethostname()

print 'Host: %s'%hostname
print '\tAudio device: %s'%db.settings[hostname]['AudioOutputDevice']
print '\tMax Channels: %s'%db.settings[hostname]['MaxChannels']
print '\tDTS: %s    AC3:
%s'%(db.settings[hostname]['DTSPassThru'],db.settings[hostname]['AC3PassThru'])

if db.settings[hostname]['AudioOutputDevice']=='ALSA:plug:a2dp':
  db.settings[hostname]['AudioOutputDevice']='ALSA:iec958:CARD=SB,DEV=0'
  db.settings[hostname]['MaxChannels']=u'6'
  db.settings[hostname]['DTSPassThru']=u'1'
  db.settings[hostname]['AC3PassThru']=u'1'
else:
  db.settings[hostname]['AudioOutputDevice']='ALSA:plug:a2dp'
  db.settings[hostname]['MaxChannels']=u'2'
  db.settings[hostname]['DTSPassThru']=u'0'
  db.settings[hostname]['AC3PassThru']=u'0'

print 'Host: %s'%hostname
print '\tAudio device: %s'%db.settings[hostname]['AudioOutputDevice']
print '\tMax Channels: %s'%db.settings[hostname]['MaxChannels']
print '\tDTS: %s    AC3:
%s'%(db.settings[hostname]['DTSPassThru'],db.settings[hostname]['AC3PassThru'])

be.backendCommand('MESSAGE[]:[]CLEAR_SETTINGS_CACHE')


Just place in a file, make executable, and set up a convenient way for
you to execute when switching (perhaps bind the script to a button on
your remote).  Just make sure to do this in a menu, and not during
playback.

Good luck,
Patrick


More information about the mythtv-dev mailing list