From 380a3c5818dca563ef139bef32256265a36d7542 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 29 May 2017 15:53:22 +0000 Subject: [PATCH] Modified audio config so audio is only enabled after being requested --- root/etc/modprobe.d/alsa-base.conf | 5 ----- root/usr/bin/tbsetupaudio | 10 ++++++++-- 2 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 root/etc/modprobe.d/alsa-base.conf diff --git a/root/etc/modprobe.d/alsa-base.conf b/root/etc/modprobe.d/alsa-base.conf deleted file mode 100644 index e55ce0f..0000000 --- a/root/etc/modprobe.d/alsa-base.conf +++ /dev/null @@ -1,5 +0,0 @@ -# Sets a USB audio device as the default device, appearing before -# the built-in audio output -options snd_usb_audio index=-1 -options snd_bcm2835 index=-2 -options snd slots=snd_usb_audio,snd_bcm2835 diff --git a/root/usr/bin/tbsetupaudio b/root/usr/bin/tbsetupaudio index 225d326..8237dfd 100755 --- a/root/usr/bin/tbsetupaudio +++ b/root/usr/bin/tbsetupaudio @@ -5,9 +5,15 @@ def main(): sound_drivers = [] with open('/proc/asound/modules') as f: for line in f: - sound_drivers = line.split() + sound_drivers.append(line.split()) - preferred_device_id = sound_drivers[0] + preferred_device_id = 0 + + for sound_driver in sound_drivers: + # a sound_driver object looks like ['0', 'snd_bcm2835'] + if sound_driver[1] == 'snd_usb_audio': + # prefer USB devices + preferred_device_id = sound_driver[0] with open(os.path.expanduser('~/.asoundrc'), 'w') as f: f.write('pcm.!default {{ type plug slave {{ pcm "hw:{d},0" }} }}\nctl.!default {{ type hw card {d} }}'.format(d=preferred_device_id))