home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / artsdsp < prev    next >
Encoding:
Text File  |  2007-01-25  |  2.5 KB  |  136 lines

  1. #!/bin/sh
  2. # artsdsp - wrapper script to allow *some* binary only programs to use artsd
  3. # based on the esddsp script
  4.  
  5. # keep this in sync with artsversion.h
  6. version="1.5.6"
  7.  
  8. # default values for script variables
  9. verbose=0
  10. set_name=0
  11. single_thread=0
  12.  
  13. # check for artsdsp options
  14. while test $# -gt 0; do
  15.  
  16.     case "$1" in
  17.  
  18.     -h|--help)
  19.         echo "artsdsp - attempt to reroute audio device to artsd"
  20.         echo " "
  21.         echo "artsdsp [options] application arguments"
  22.         echo " "
  23.         echo "options:"
  24.         echo "-h, --help                show brief help"
  25.         echo "-n, --name=NAME           use name to identify player to artsd"
  26.         echo "-m, --mmap                emulate memory mapping (i.e. for quake)"
  27.         echo "-s, --single-threaded     use the single-threaded version"
  28.         echo "-v, --verbose             show parameters"
  29.         echo "-V, --version             show version"
  30.         exit 0
  31.         ;;
  32.  
  33.     -n)
  34.         shift
  35.         if test $# -gt 0; then
  36.         export ARTSDSP_NAME=$1
  37.         else
  38.         echo "no player name specified"
  39.         exit 1
  40.         fi
  41.         shift
  42.         set_name=1
  43.         ;;
  44.  
  45.     --name*)
  46.         export ARTSDSP_NAME=`echo $1 | sed -e 's/^[^=]*=//g'`
  47.         set_name=1
  48.         shift
  49.         ;;
  50.  
  51.     -v|--verbose)
  52.         verbose=1
  53.         shift
  54.         ;;
  55.  
  56.     -V|--version)
  57.         echo "artsdsp $version"
  58.         exit
  59.         ;;
  60.  
  61.     -m|--mmap)
  62.         export ARTSDSP_MMAP=1
  63.         shift
  64.         ;;
  65.  
  66.     -s|--single-threaded)
  67.         single_thread=1
  68.         shift
  69.         ;;
  70.  
  71.     *)
  72.         # no more artsdsp options, get on with life
  73.         break
  74.         ;;
  75.     esac
  76. done
  77.  
  78. # echo options if verbose specified
  79. if test "$verbose" = 1; then
  80.     ARTSDSP_VERBOSE=1
  81.     export ARTSDSP_VERBOSE
  82.     echo "artsdsp:       $version"
  83.     echo "name:          $ARTSDSP_NAME"
  84.     echo "command line:  $@"
  85.     if test "$single_thread" = 1; then
  86.         echo "threaded:      no"
  87.     else
  88.         echo "threaded:      yes"
  89.     fi
  90. fi
  91.  
  92. # setup artsdsp preload to hijack calls made to /dev/dsp
  93. origargs="$@"
  94. binary=`which $1`
  95. machine=`uname -m`
  96.  
  97. set `file -L $binary`
  98.  
  99. case $2 in
  100.     ELF)
  101.        ;;
  102.     *)
  103.        echo "artsdsp works only for binaries"
  104.        exit 1
  105.     esac
  106.  
  107. case $3 in
  108.     32-bit)
  109.        arch_libdir=lib
  110.        ;;
  111.     64-bit)
  112.        arch_libdir=lib64
  113.        ;;
  114.     *)
  115.        exit 1
  116. esac
  117.  
  118. set $origargs
  119.  
  120. prefix=/usr
  121. exec_prefix=${prefix}
  122. libdir=${prefix}/${arch_libdir}
  123.  
  124. if test "$single_thread" = 1; then
  125.   LD_PRELOAD=${libdir}/libartsdsp_st.so.0
  126. else
  127.   LD_PRELOAD=${libdir}/libartsdsp.so.0:${libdir}/libartsc.so.0
  128. fi
  129. if test -f ${libdir}/libdl.so.2; then
  130.   LD_PRELOAD=$LD_PRELOAD:${libdir}/libdl.so.2
  131. fi
  132. export LD_PRELOAD
  133.  
  134. # invoke the program with the args given
  135. exec "$@"
  136.