#!/bin/bash
#
source /etc/conf.d/vdr.admin.cfg
source /etc/conf.d/vdr

ALSACTL="/usr/sbin/alsactl"
ASOUNDCFG="/etc/asound.state"

logger -s "ADMIN - ALSA: $ALSA"
/etc/init.d/alsasound stop
rm /etc/asound.state >/dev/null 2>&1
if [ "$ALSA" = "0" ] ; then
   rc-update del alsasound
else
   rc-update add alsasound boot >/dev/null 2>&1
   /etc/init.d/alsasound start
   amixer sset Master,0 100%,100% unmute
   amixer sset CD,0 100%,100% unmute
   amixer sset Line,0 100%,100% unmute
   amixer sset 'Master Digital',0 100%,100% unmute
   amixer sset 'Aux',0 100%,100% unmute
   amixer sset 'PCM',0 100%,100% unmute
   if [ -x $ALSACTL ]; then
      $ALSACTL -f $ASOUNDCFG store
   fi
fi
echo 'Done!'
exit 0

