From f0dce6aa6732f0792b0348677358b1b134f9a70a Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Mon, 3 Aug 2015 20:45:12 +0000
Subject: LinHES-config: soundconfig.sh: setup dmix for default sound and
 mplayer

---
 abs/core/LinHES-config/PKGBUILD       |  4 +--
 abs/core/LinHES-config/soundconfig.sh | 59 ++++++++++++++++++-----------------
 2 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD
index 33d9a8f..628516b 100755
--- a/abs/core/LinHES-config/PKGBUILD
+++ b/abs/core/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=8.3
-pkgrel=17
+pkgrel=18
 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'
-         '74047c5c5cae2f8576fddbed7d197be4'
+         '6d3340c86c5d0e3f96ea8fa26bb73fb5'
          'eef9b882ecb70648a8f253f85b73a274'
          '5f890ea9bda6aef652d2560ca19dac07'
          'ab2aa42c2947148c2b1cac0ade6d1d55'
diff --git a/abs/core/LinHES-config/soundconfig.sh b/abs/core/LinHES-config/soundconfig.sh
index 810d9b2..a6939a2 100755
--- a/abs/core/LinHES-config/soundconfig.sh
+++ b/abs/core/LinHES-config/soundconfig.sh
@@ -78,28 +78,6 @@ function installOSS {
 }
 
 
-function SYNCXINE {
-    echo "modify xine config file"
-    if [ -f $MYTHHOME/.xine/config ]
-    then
-        cp -f $MYTHHOME/.xine/config  $TEMPLATES/xine.config
-    else
-        cp $TEMPLATES/xine.config.template $TEMPLATES/xine.config
-    fi
-
-    if [ x$Audiotype = xOSS ]
-    then
-       DEVICENUMBER=`echo $SoundDevice|awk -F/ ' { print $3  } '|tr -d dsp `
-        sed -e "s/^.*audio.driver.*$/audio.driver:oss/" \
-               -e "s/^.audio.device.oss_device_name.*$/audio.device.oss_device_name:\/dev\/dsp/" \
-               -e "s/^.audio.devic.oss_device_number.*$/audio.device.oss_device_number:$DEVICENUMER/" \
-               -e "s/^.*audio.output.speaker_arrangement:.*$/Audio.output.speaker_arrangement:PassThrough/" \
-                $TEMPLATES/xine.config > $MYTHHOME/.xine/config
-    else
-        cp $TEMPLATES/xine.config $MYTHHOME/.xine/config
-    fi
-}
-
 function SYNCMPLAYER {
     echo "modify mplayer config file"
     if [ -f /etc/mplayer/mplayer.conf ]
@@ -109,7 +87,12 @@ function SYNCMPLAYER {
     fi
     if [  x$AUDIOTYPE = xALSA  -o   x$AUDIOTYPE = xalsa ]
     then
-        MPLAYERDEVICE=`echo $AUDIODEVICE | tr : = | tr , .`
+        if [ "$mixAUDIODEVICE" ]
+        then
+            MPLAYERDEVICE="dmixer"
+        else
+            MPLAYERDEVICE=`echo $AUDIODEVICE | tr : = | tr , .`
+        fi
         echo "ao=alsa:device=$MPLAYERDEVICE" > /etc/mplayer/mplayer.conf
         echo "ac=hwac3,hwdts," >> /etc/mplayer/mplayer.conf
     else
@@ -149,7 +132,29 @@ function remove_asound {
 function write_asound {
     echo "writing asound.conf file"
     backup_asound
-    echo 'pcm.!default "'"$AUDIODEVICE"'"' > /etc/asound.conf
+    mixAUDIODEVICE=""
+    if [[ $AUDIODEVICE == plughw:* ]]
+    then
+        mixAUDIODEVICE=`echo $AUDIODEVICE | sed 's/plughw:\(.\)/\1/g'`
+        echo 'pcm.dmixer {
+  type dmix
+  ipc_key 2048
+  slave {
+    pcm "hw:'"$mixAUDIODEVICE"'"
+    period_size 512
+    buffer_size 4096
+#    rate 48000
+#    format S16_LE
+  }
+}
+
+pcm.!default {
+  type plug
+  slave.pcm dmixer
+}' > /etc/asound.conf
+    else
+    	echo 'pcm.!default "'"$AUDIODEVICE"'"' > /etc/asound.conf
+    fi
 }
 
 function sound_config_system {
@@ -158,10 +163,6 @@ function sound_config_system {
         write_asound
     fi
     SYNCMPLAYER
-#    if [ x$syncXine = x1 ]
-#    then
-#          SYNCXINE
-#    fi
 }
 
 function loadsound (){
@@ -240,6 +241,8 @@ case $SOUNDOPTYPE in
     ;;
     test|TEST)
         echo $@ > /tmp/audio.test
+        #set iec958 audio bit
+        iecset audio 1
         #loadsound
         if [  x$AUDIOTYPE = xOSS  -o   x$AUDIOTYPE = xoss ]
         then
-- 
cgit v0.12