#!/bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

set -e

case "$1" in
  start)
        echo -n "Initializing DSP..."

        if [ ! -f /var/run/dsp_mem_reserve -a -x /usr/sbin/dspctl ]
        then
            /usr/sbin/dspctl kmem_reserve 360000
            touch /var/run/dsp_mem_reserve
        fi
        if [ -x /usr/sbin/dsp_dld ]
        then
            /usr/sbin/dsmetool -c 5 -T 300 -t "/usr/sbin/dsp_dld -p --disable-restart -c /lib/dsp/dsp_dld_avs.conf"
        fi
        echo "done."
        ;;
  stop)
        if [ -x /usr/sbin/dsp_dld ]
        then
            /usr/sbin/dsmetool -k /usr/sbin/dsp_dld
        fi
        ;;
  restart|force-reload)
        ;;
  *)
        N=/etc/init.d/dsp-init
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

