[mythtv-users] Bluetooth headset with ALSA

Patrick Oglesby octoberblu3 at gmail.com
Tue May 31 01:20:18 UTC 2011


On Sun, May 29, 2011 at 5:27 PM, Nick Rout <nick.rout at gmail.com> wrote:
> On Mon, May 30, 2011 at 6:25 AM, Wayne Thomas <waynethomas69 at gmail.com> wrote:
>>> > I want to configure it with ALSA and then switch the device with some
>>> > key on the remote. Does someone make something like this?
>>>
>>> I do not believe ALSA is capable of this.  You have actually found one
>>> of the rare circumstances where it does actually make sense to use
>>> PulseAudio.
>>> _______________________________________________
>>> mythtv-users mailing list
>>> mythtv-users at mythtv.org
>>> http://www.mythtv.org/mailman/listinfo/mythtv-users
>>
>> What about creating a script that alters the content of the .asoundrc file
>> to change the default audio output to the headset (and vice versa) and then
>> force alsa to reload (i.e. sudo alsa force-reload, in this case you would
>> need to alter the sudoers file to allow that command to be executed without
>> a password).  Provided your Mythtv uses "default" as its audio output, and
>> it tolerates alsa vanishing and reappearing this might just work if you
>> execute the script with irexec.
>> Might be worth a try
>
> Similarly might be worth a try writing a script to alter the output
> device of mythtv (a fairly simple mysql update of the settings table I
> think).
>
> I am not sure if the frontend then needs to be restarted though.
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://www.mythtv.org/mailman/listinfo/mythtv-users
>

This has come up sometime before and another user shared a script to
do just this.  I have modified it to suit my particular needs, but
here it is.

-------------------------------------------

#!/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')

------------------------------------------

This just checks the name of the current audio device and toggles
between the standard 6-channel audio pass-through device and then my
bluetooth  a2dp headset.  Feel free to alter for your own situation.

>From my experience, there is quite a delay when starting playback as
the headset established the audio connection with the system.  And if
the connection ever stutters, you can get the audio out of sync with
the video very easily.  In this case, you can just bookmark whatever
you are watching, exit, and restart playback.

- Patrick


More information about the mythtv-users mailing list