#!/bin/sh
#
# sndtest - simple audio tester
#

usage(){
echo "Usage: sndtest [OPTION]..."
echo "Check if the audio driver is working using sox(1)."
echo
echo "  -h, --help		print this help and exit"
echo "  -v, --version		output version information and exit"
echo
echo "Report bugs to <johne@rootlinux.org>."
exit 0
}

displayversion(){
echo "sndtest (rltools) #VERSION#"
exit 0
}

if [ "$1" = "-h" -o "$1" = "--help" ]; then
  usage
fi

if [ "$1" = "-v" -o "$1" = "--version" ]; then
  displayversion
fi

if ! ( which play >/dev/null 2>/dev/null ); then
  echo "sndtest: sox not found."
  exit 1
fi

if [ ! -f /usr/share/rl/system/rl.wav ]; then
  echo "sndtest: sample sound file not installed."
  exit 1
fi

echo "sndtest: trying to play a sample sound..."

if ! ( play /usr/share/rl/system/rl.wav ); then
  echo "damn..."
 else
  echo "seems to work?"
fi
