summaryrefslogtreecommitdiff
path: root/esddsp
blob: 7f835de8cc74f561d611534df5d9f232b23020ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
# esddsp - wrapper script to allow *some* binary only programs to use esd

# default values for script variables
verbose=0
set_name=0

# check for esddsp options
while test $# -gt 0; do

    case "$1" in

	-h|--help)
		echo "esddsp - attempt to reroute audio device to esd"
		echo " "
		echo "esddsp [options] player arguments"
		echo " "
		echo "options:"
		echo "-h, --help                show brief help"
		echo "-s, --server=HOST:PORT    contact esd server on host at port"
		echo "-m, --mixer               enable mixer support"
		echo "-n, --name=NAME           use name to identify player to esd"
		echo "-v, --verbose             show parameters"
		echo "--mmap                    use memory mapping emulation"
		echo "                          (useful for games like quake)"

		exit 0
		;;

	-s)
		shift
		if test $# -gt 0; then
			ESPEAKER=$1
			export ESPEAKER
		else
			echo "no server specified"
			exit 1
		fi
		shift
		;;

	--server*)
		ESPEAKER=`echo $1 | sed -e 's/^[^=]*=//g'`
		export ESPEAKER
		shift
		;;

	-m|--mixer)
		ESDDSP_MIXER=1
		export ESDDSP_MIXER
		shift
		;;

	-n)
		shift
		if test $# -gt 0; then
			ESDDSP_NAME=$1
			export ESDDSP_NAME
		else
			echo "no player name specified"
			exit 1
		fi
		shift
		set_name=1
		;;

	--name*)
		ESDDSP_NAME=`echo $1 | sed -e 's/^[^=]*=//g'`
		export ESDDSP_NAME
		set_name=1
		shift
		;;

	-v|--verbose)
		verbose=1
		shift
		;;

	--mmap)
	    ESDDSP_MMAP=1
	    export ESDDSP_MMAP
	    shift
	    ;;

	*)
		# no more esddsp options, get on with life
		break
		;;
    esac
done

# default name to player if not specified
if test "$set_name" = 0; then
	ESDDSP_NAME=$1
	export ESDDSP_NAME
fi

# echo options if verbose specified
if test "$verbose" = 1; then
	echo "server:		$ESPEAKER"
	echo "name:		$ESDDSP_NAME"
	echo "command line:	$@"
fi

# setup esd to hijack calls made to /dev/dsp
prefix=/usr/local
exec_prefix=${prefix}

LD_PRELOAD="libesddsp.so.0 libesd.so.0 $LD_PRELOAD"
export LD_PRELOAD

# invoke the program with the args given
exec "$@"