diff vsound-0.5/vsound.c vsound-0.5.new/vsound.c
33a34
> #include <signal.h>
127a129,131
> 
> 
> 
157a162,163
> static void start_autostop_timer(void);
> static void stop_autostop_timer(void);
165a172
> static int stopdelay = 0, ignore_autostop = 1;
195a203
> 	
208c216
< 		/* DPRINTF ("Not /dev/dsp. open (%s) = %d\n", pathname, fd) ; */
---
> 	        /*DPRINTF ("Not /dev/dsp. open (%s) = %d\n", pathname, fd) ;*/
211a220,222
> 
> 	stop_autostop_timer();
> 
240c251
< 	
---
> 
275c286,287
< 
---
> 	
> 	
294a307
> 		start_autostop_timer();
296a310
> 
303a318
> 
360a376
> 
424a441,447
> 
> 	cptr = getenv("VSOUND_STOPDELAY");
> 	if (cptr)
> 	  stopdelay = atoi(cptr);
> 	  DPRINTF("Autostoping after %d seconds of inactivity\n", stopdelay);
> 	  
> 	  
609a633,695
> 
> /* Signal handler for SIGQUIT. */
> void SIGALRM_handler (int signum)
> {
>   DPRINTF ("Autostop alarm\n") ;
>   if (!ignore_autostop){
>     DPRINTF ("Sending sigint\n") ;   
>     exit(1);
>   }
> }
> 
> static 
> void start_autostop_timer(void)
> {
>   static int firsttime = 1;
>   static struct itimerval timerval;
>   struct itimerval otimerval;
>   struct sigaction sa;
> 
>   if (firsttime && stopdelay) {
>     sigemptyset (&sa.sa_mask);
>     sa.sa_flags = 0;
>     
>     /* Register the handler for SIGALARM. */
>     sa.sa_handler = SIGALRM_handler;
>     sigaction (SIGALRM, &sa, 0);
>           
>     timerval.it_interval.tv_sec = (long)stopdelay;
>     timerval.it_interval.tv_usec = 0;
>     timerval.it_value.tv_sec = (long)stopdelay;
>     timerval.it_value.tv_usec = 0;
>   }
>     
>   if (stopdelay)
>     {     ignore_autostop = 0;
>           setitimer (ITIMER_REAL, &timerval, &otimerval);
>           DPRINTF ("Watchdog started from -> %ld \n", otimerval.it_value.tv_sec) ;
>     }
> 
> } /* start_autostop_timer */
> 
> static
> void stop_autostop_timer(void)
> {
>   static int firsttime = 1;
>   static struct itimerval timerval;
>   struct itimerval otimerval;
> 
> 
>   if (firsttime && stopdelay) {
>     timerval.it_interval.tv_sec = (long)0;
>     timerval.it_interval.tv_usec = 0;
>     timerval.it_value.tv_sec = (long)0;
>     timerval.it_value.tv_usec = 0;
>   }
> 
>   if (stopdelay) {
>     ignore_autostop = 1;
>     setitimer (ITIMER_REAL, &timerval, &otimerval);
>     DPRINTF ("Watchdog stopped at -> %ld \n", otimerval.it_value.tv_sec) ;
>   }
>     
> } /* stop_autostop_timer */
diff vsound-0.5/vsound.in vsound-0.5.new/vsound.in
61a62
> 		echo "-a, --autostop=SEC kill the player after 'SEC' seconds of inactivity."
128a130,140
> 	-a|--autostop)
> 		shift
> 		if test $# -gt 0; then
> 			export VSOUND_STOPDELAY="$1"
> 		else
> 			echo "no autostop delay specified"
> 			exit 1
> 			fi
> 		shift
> 		;;
> 
