From dfae09ca060df43f9101addfd429af8e1e0666da Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 11 Jun 2015 17:47:47 +0000
Subject: LinHES-config: soundconfig.sh: remove asound.conf when unloading
 ALSA.

exit OSS installed loop after 20 iterations so it doesn't hang forever
---
 abs/core/LinHES-config/PKGBUILD       |  4 ++--
 abs/core/LinHES-config/soundconfig.sh | 32 ++++++++++++++++++--------------
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD
index ad1ae88..1f5ebd3 100755
--- a/abs/core/LinHES-config/PKGBUILD
+++ b/abs/core/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=8.3
-pkgrel=14
+pkgrel=15
 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev LinHes-config )
 pkgdesc="Install and configure your system"
 depends=('bc' 'libstatgrab' 'mysql-python' 'expect' 'curl' 'dnsutils' 'parted'
@@ -151,7 +151,7 @@ md5sums=('17d9dd5a097fbbd4dae75dff8e2677ff'
          '6e5639fff82fa2ba76113ac1ab8f2016'
          'f0376c98a7986897406d393186c0365e'
          '157e73d0f90d7b306aba8f5921aeedd3'
-         '60d4dd50c8f9c91f5ad798c1e89be324'
+         '932cf4a7a3891d1849cf8d3962adf78c'
          'eef9b882ecb70648a8f253f85b73a274'
          '5f890ea9bda6aef652d2560ca19dac07'
          'ab2aa42c2947148c2b1cac0ade6d1d55'
diff --git a/abs/core/LinHES-config/soundconfig.sh b/abs/core/LinHES-config/soundconfig.sh
index 34d81a4..6e7bf70 100755
--- a/abs/core/LinHES-config/soundconfig.sh
+++ b/abs/core/LinHES-config/soundconfig.sh
@@ -23,26 +23,17 @@ function testaudio () {
 function load_alsa() {
     echo "Loading ALSA ..."
     remove_service.sh alsa-utils 1> /dev/null 2> /dev/null
-    KER=`uname -r`
-    cd /lib/modules/$KER/
-    echo "   uncompressing ALSA modules"
-    tar -xf sound-preoss.tar.bz2
-    #echo "   installing alsa-lib"
-    #pacman -S --force --noconfirm  alsa-lib
 
     echo "   uninstalling oss"
     pacman -R --noconfirm oss
 
     echo    "triggering udev module load"
     depmod -a
-    cd - > /dev/null
-    #udevadm trigger
     udevadm settle
     udevadm trigger
-
+    udevadm settle
 
     add_service.sh alsa-utils
-
 }
 
 
@@ -54,6 +45,7 @@ function unload_alsa () {
     rm -rf /dev/adsp*
     rm -rf /dev/snd/*
     rm -rf /dev/audio
+    remove_asound
     modprobe -r $(lsmod |grep ^snd |awk '{print $1}')
 }
 
@@ -136,13 +128,23 @@ function checkOSSinstalled () {
     fi
 }
 
-function write_asound {
-    echo "writing asound.conf file"
+function backup_asound {
+    echo "backup asound.conf file"
     if [ -f /etc/asound.conf ]
     then
         backdate=`date +%b-%d-%Y-%H:%M:%S`
         mv /etc/asound.conf /etc/asound.conf-$backdate
     fi
+}
+
+function remove_asound {
+    echo "removing asound.conf file"
+    backup_asound
+}
+
+function write_asound {
+    echo "writing asound.conf file"
+    backup_asound
     echo 'pcm.!default "'"$AUDIODEVICE"'"' > /etc/asound.conf
 }
 
@@ -162,7 +164,8 @@ function loadsound (){
     checkOSSinstalled
     if [  x$AUDIOTYPE = xOSS  -o   x$AUDIOTYPE = xoss ]
         then
-        while [ $OSSinstalled = "false" ]
+        i=1
+        while [[ $OSSinstalled = "false" && $i -le 20 ]]
         do
             unload_alsa
             if [ -e /tmp/.alsatest ]
@@ -171,6 +174,7 @@ function loadsound (){
             fi
             installOSS
             checkOSSinstalled
+            i=$(( $i + 1 ))
         done
     else
         touch /tmp/.alsatest
@@ -239,7 +243,7 @@ case $SOUNDOPTYPE in
             ossplay  -d$AUDIODEVICE $TESTFILE
         else
             echo "testing ALSA $AUDIODEVICE "
-            echo aplay --device=$AUDIODEVICE $TESTFILE
+            #echo aplay --device=$AUDIODEVICE $TESTFILE
             aplay --device=$AUDIODEVICE $TESTFILE
         fi
     ;;
-- 
cgit v0.12

