From db7c8154dd155d42fe1dfd7865bdf0cf204db612 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sat, 29 Oct 2011 20:28:48 -0500
Subject: LinHES-config: fix up the audio switching between OSS. Always sync
 the frontend, remove the other sync options

---
 abs/core/LinHES-config/PKGBUILD        |   8 +--
 abs/core/LinHES-config/mv_common.py    |   9 +--
 abs/core/LinHES-config/soundconfig.sh  | 105 ++++++++++++++++++---------------
 abs/core/LinHES-config/systemconfig.py |   1 +
 4 files changed, 69 insertions(+), 54 deletions(-)

diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD
index 2c6cdb0..ddfc5a4 100644
--- a/abs/core/LinHES-config/PKGBUILD
+++ b/abs/core/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=2.3
-pkgrel=37
+pkgrel=41
 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'
@@ -112,7 +112,7 @@ md5sums=('6259677916192a92d1adf47b276f7829'
          '9ae8d79f620c6d19973c55c32a921874'
          '7af56cecd1081d45f57fb207df0a0c87'
          'ecf9e5df20683a769c4a8a8f2d65de85'
-         'e459ed069317bccb20351f037a9df3d2'
+         'eaf845dda830c531649d5840e0584f8e'
          '97de45a04f4efbd9d40d9fc0e1db1c3f'
          '6aff504ed5e860adc1b7317cd0780900'
          '55fccb1da0417a896b724f7cfc32dd5a'
@@ -123,7 +123,7 @@ md5sums=('6259677916192a92d1adf47b276f7829'
          '3d1e4a119f38cff0498bf8a67e94e4b3'
          '71fd2d0d448fc2fcd15415a1beed7109'
          '5f3259afe031fda189edae41dd1458f0'
-         '41b03fb1e0a9d9ae7588e3b813212772'
+         '252ae3a088948a0d125ea6e8daa211f5'
          'b845de3e05c1734cce4b9ac5e8f1baaf'
          '4d0464a1bef1819f6f9c100609eb55ad'
          '5e69839659d65ddda35b8a9982dc29e9'
@@ -133,6 +133,6 @@ md5sums=('6259677916192a92d1adf47b276f7829'
          'f0988a801216b44c96bf17e24a23e3a9'
          '23d0e12b7ca1cc6ea6b993c1d7ff20b9'
          '8a713ce49211eb0b91c84ba0b9cf52fe'
-         '5ff552dbae98b3bf312171f9b4c5e787'
+         '5e3e06b31c40fe6b0e74860a8137b720'
          '2596460462cf6c889cf8f95485537b20'
          'a63ff9ef5250965aeabc74bfa8e43981')
diff --git a/abs/core/LinHES-config/mv_common.py b/abs/core/LinHES-config/mv_common.py
index 0272809..5257a5a 100755
--- a/abs/core/LinHES-config/mv_common.py
+++ b/abs/core/LinHES-config/mv_common.py
@@ -196,10 +196,11 @@ def reloadfe(dbhost,RESTART_LCD):
         runcmd(cmd)
 
     restartLCD(RESTART_LCD)
-    for pid in getpid("mythfrontend"):
-        cmd = ''' kill -s USR1 %s ''' %pid
-        #runcmd(cmd)
-        logging.info("    Reloading frontend with pid of %s",pid)
+#    for pid in getpid("mythfrontend"):
+    pid = getpid("mythfrontend")
+    cmd = ''' kill -s USR1 %s ''' %pid
+    runcmd(cmd)
+    logging.info("    Reloading frontend with pid of %s",pid)
 
     logging.debug("__End of reloadfe\n")
 
diff --git a/abs/core/LinHES-config/soundconfig.sh b/abs/core/LinHES-config/soundconfig.sh
index 75998d6..5778cee 100755
--- a/abs/core/LinHES-config/soundconfig.sh
+++ b/abs/core/LinHES-config/soundconfig.sh
@@ -2,13 +2,15 @@
 . /etc/systemconfig
 . /etc/profile
 echo $@ >/tmp/audio.call
-#set -x
+
 BASE=""
 . /etc/profile
-#TEMPLATES="/usr/share/templates"
-#TESTFILE="$TEMPLATES/audio/space_battle_A.wav"
 TESTFILE="/usr/share/sounds/alsa/Front_Center.wav"
 OSSinstalled="false"
+BLACKLIST=/etc/modprobe.d/soundconfig_blacklist.conf
+
+echo "---------------------------------------"
+
 
 function testaudio () {
 
@@ -17,27 +19,30 @@ ossplay  -d$AUDIODEVICE $TESTFILE
 }
 
 function load_alsa() {
-
-    remove_service.sh alsa-utils
-#    cd /lib/modules/2.6.21-STB
+    echo "Loading ALSA ..."
+    remove_service.sh alsa-utils 1> /dev/null 2> /dev/null
     KER=`uname -r`
-    cd /lib/modules/$KER/kernel/
-    tar -xvf /lib/modules/alsa-$KER.tar
-    pacman -Sf --noconfirm  alsa-lib
+    cd /lib/modules/$KER/
+    echo "   uncompressing ALSA modules"
+    tar -xf sound-preoss.tar.bz2
+#    echo "   installing alsa-lib"
+    #pacman -Sf --noconfirm  alsa-lib
 
+    echo    "triggering udev module load"
     depmod -a
-    cd -
-    udevadm trigger
+    cd - > /dev/null
+    #udevadm trigger
     udevadm settle
     udevadm trigger
 
+
     add_service.sh alsa-utils
-    sleep 4
-    sv start alsa-utils
+
 }
 
 
 function unload_alsa () {
+    echo "unloading ALSA ..."
 #kill $(lsof -t /dev/dsp* /dev/audio* /dev/mixer* /dev/snd/*) && modprobe -r $(lsmod |grep ^snd |awk '{print $1}')
     sv stop alsa-utils
     remove_service.sh alsa-utils
@@ -48,24 +53,28 @@ function unload_alsa () {
 }
 
 function unload_oss {
+    echo "unloading OSS ..."
     sv stop oss
     soundoff
     rm -rf /dev/dsp*
     rm -rf /dev/oss*
     rm -rf /dev/sndstat
     remove_service.sh oss
+    rm -f $BLACKLIST
 }
 
 function installOSS {
-    echo "installing oss"
+    echo "installing OSS ..."
     pacman -Q oss 2>/dev/null
     if [  ! $? = 0 ]
     then
         pacman --noconfirm -Sf oss
     fi
+    soundon
     add_service.sh oss
-    sleep 4
-    sv start oss
+    echo "install soundcore /bin/false" >$BLACKLIST
+
+
 }
 
 
@@ -108,51 +117,54 @@ $MV_ROOT/bin/restore_default_settings.sh -c MUSICFRONT
 
 
 function checkOSSinstalled () {
+ echo "Checking if OSS is installed"
  ossinfo |grep Version |grep -q OSS >/dev/null
  resultcode=$?
- echo $resultcode
+
  if [ $resultcode = 0 ]
  then
     OSSinstalled='true'
+    echo "   OSS is loaded"
  else
     OSSinstalled='false'
+    echo "   OSS is NOT loaded"
  fi
 }
 
 function sound_config_system {
-
-    if [ x$syncXine = x1 ]
-    then
-          SYNCXINE
-    fi
-    if [ x$syncMplayer = x1 ]
-    then
-          SYNCMPLAYER
-    fi
-    if [ x$syncMythMusic = x1 ]
-    then
-          SYNCMYTHMUSIC
-    fi
-    if [ x$syncMythFrontend = x1 ]
-    then
-          SYNCMYTHFRONTEND
-    fi
+    
+    SYNCMYTHFRONTEND
+#    if [ x$syncXine = x1 ]
+#    then
+#          SYNCXINE
+#    fi
+#    if [ x$syncMplayer = x1 ]
+#    then
+#          SYNCMPLAYER
+#    fi
+#    if [ x$syncMythMusic = x1 ]
+#    then
+#          SYNCMYTHMUSIC
+#    fi
+#    if [ x$syncMythFrontend = x1 ]
+#    then
+#          SYNCMYTHFRONTEND
+#    fi
 
 }
 
 function loadsound (){
         checkOSSinstalled
         if [  x$AUDIOTYPE = xOSS  -o   x$AUDIOTYPE = xoss ]
-        #then
-        #    if [ $OSSinstalled = "false" ]
             then
                 while [ $OSSinstalled = "false" ]
                 do
                     unload_alsa
-                    rm /tmp/.alsatest
+                    if [ -e /tmp/.alsatest ]
+                    then
+                        rm /tmp/.alsatest
+                    fi
                     installOSS
-                    installOSS
-                    sleep 2
                     checkOSSinstalled
                 done
           #  fi
@@ -160,7 +172,7 @@ function loadsound (){
             touch /tmp/.alsatest
             unload_oss
             load_alsa
-            load_alsa
+            #load_alsa
             rm /tmp/.alsatest
 
         fi
@@ -189,15 +201,15 @@ fi
 while getopts "$OPTSTRING"  SWITCH
 do
     case $SWITCH in
-          \?)  echo "unkown option"
+          \?)  echo "unknown option"
                       exit 11 ;;
-            i)   echo "$SWITCH"  "$OPTARG"
+            i)   #echo "$SWITCH"  "$OPTARG"
                     AUDIOTYPE="$OPTARG"
                     ;;
-            d) echo "$SWITCH"  "$OPTARG"
+            d) #echo "$SWITCH"  "$OPTARG"
                     AUDIODEVICE=$OPTARG
                     ;;
-            t) echo "$SWITCH"  "$OPTARG"
+            t) #echo "$SWITCH"  "$OPTARG"
                 SOUNDOPTYPE="$OPTARG"
                 if  [ x"$OPTARG" = xtest ]
                 then
@@ -217,7 +229,7 @@ done
 
 case $SOUNDOPTYPE in
     REAL|real )
-                    loadsound
+                   # loadsound
                     sound_config_system
         ;;
     test|TEST)
@@ -229,7 +241,8 @@ case $SOUNDOPTYPE in
                     ossplay  -d$AUDIODEVICE $TESTFILE
                 else
                     echo "testing ALSA $AUDIODEVICE "
-                    aplay --device=$AUDIODEVICE $TESTFILE
+                    echo aplay --device=$AUDIODEVICE $TESTFILE
+                    aplay -d=$AUDIODEVICE $TESTFILE
                 fi
 
         ;;
diff --git a/abs/core/LinHES-config/systemconfig.py b/abs/core/LinHES-config/systemconfig.py
index 3cba427..31d2164 100755
--- a/abs/core/LinHES-config/systemconfig.py
+++ b/abs/core/LinHES-config/systemconfig.py
@@ -143,6 +143,7 @@ def main(argv):
             if not systemconfig.get("Audiotype") == "tinker":
                 cmd="%s/bin/soundconfig.sh -t real -i %s -d %s" %(MVROOT,systemconfig.get("Audiotype"),systemconfig["SoundDevice"])
                 mv_common.runcmd(cmd)
+                mv_common.reloadfe(systemconfig.get("dbhost"),restartlcd)
             else:
                 logging.debug("    Tinker mode(audio), not changing configuration")
             logging.debug("__End of audio")
-- 
cgit v0.12

