Codebase list rplay / f9cb3de
Import Upstream version 3.3.2 Thorsten Alteholz 5 years ago
186 changed file(s) with 8236 addition(s) and 8138 deletion(s). Raw diff Collapse all Expand all
+0
-33
CVS/Entries less more
0 /COPYING/1.1.1.1/Tue Jul 14 22:35:22 1998//
1 /INSTALL.generic/1.1.1.1/Tue Jul 14 22:35:22 1998//
2 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:22 1998//
3 /configure/1.1.1.1/Tue Jul 14 22:35:22 1998//
4 /install-sh/1.1.1.1/Tue Jul 14 22:35:22 1998//
5 /mkinstalldirs/1.1.1.1/Tue Jul 14 22:35:22 1998//
6 /version/1.1.1.1/Tue Jul 14 22:35:22 1998//
7 D/adpcm////
8 D/contrib////
9 D/doc////
10 D/etc////
11 D/examples////
12 D/gsm////
13 D/include////
14 D/java////
15 D/lib////
16 D/librplay////
17 D/perl////
18 D/rplay////
19 D/rplayd////
20 D/rptp////
21 D/rx////
22 /INSTALL/1.2/Thu Aug 13 06:12:58 1998//
23 /Makefile.config.in/1.2/Thu Aug 13 06:12:59 1998//
24 /NEWS/1.2/Thu Aug 13 06:13:00 1998//
25 /PORTING/1.2/Thu Aug 13 06:13:01 1998//
26 /README/1.3/Thu Aug 13 06:13:02 1998//
27 /README.linux/1.2/Thu Aug 13 06:13:03 1998//
28 /README.sgi/1.2/Thu Aug 13 06:13:04 1998//
29 /README.sun/1.2/Thu Aug 13 06:13:05 1998//
30 /TODO/1.2/Thu Aug 13 06:13:06 1998//
31 /configure.in/1.2/Thu Aug 13 06:13:07 1998//
32 /ChangeLog/1.5/Thu Oct 15 15:15:05 1998//
+0
-1
CVS/Repository less more
0 /usr/local/cvsroot/rplay
+0
-1
CVS/Root less more
0 /usr/local/cvsroot
0 1999-03-21 Mark R. Boyns <boyns@doit.org>
1
2 * fixed Makefile dependencies and shared library builds.
3
4 1999-03-09 Mark R. Boyns <boyns@doit.org>
5
6 * rptp/rptp.c: added monitor support
7 support for GNU readline
8 display progress info for get, put, and monitor
9
10 * rplayd/connection.c: monitor support
11
12 * rplayd/rplayd.c: added audio monitor support
13
14 * rplayd/command: added rptp monitor command
15
16 * rplayd/host.c: added "m" monitor access
17
18 1999-03-02 Mark R. Boyns <boyns@doit.org>
19
20 * devrplay/devrplay.c: new fake /dev/dsp hack based on esddsp.
21
22 1998-11-10 Mark R. Boyns <boyns@doit.org>
23
24 * rptp/rptp.c: added set command.
25
26 1998-11-06 Mark R. Boyns <boyns@doit.org>
27
28 * rplayd: fixed SNPRINTF code and other potential buffer overflow
29 problems.
30
031 1998-10-15 Mark R. Boyns <boyns@doit.org>
132
233 * Version 3.3.1 released.
00 rplay NEWS - User-visible changes.
1 Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
1 Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
2
3 Changes since rplay 3.3.1:
4
5 * Added devrplay.so which can be used with LD_PRELOAD to add rplay support
6 to audio applications use /dev/dsp. devrplay is known to work with rvplayer,
7 xmp, mpg123, freeamp, s3mod, esd (Enlightenment Sound Daemon) and even
8 rplayd itself. devrplay.so should be installed in your LD_LIBRARY_PATH.
9 Example usage:
10
11 bash$ LD_PRELOAD=devrplay.so rvplayer
12 bash$ LD_PRELOAD=devrplay.so /usr/X11R6/lib/X11/rvplayer/rvplayer
13 bash$ LD_PRELOAD=devrplay.so dd if=/foo/bar/sound.wav of=/dev/dsp
14 bash$ LD_PRELOAD=devrplay.so xxmp sound.mod
15 bash$ LD_PRELOAD=devrplay.so mpg123 sound.mp3
16
17 tcsh users will probably need to `setenv LD_PRELOAD devrplay.so; command'
18 instead of using the `LD_PRELOAD=devrplay.so command' syntax.
19
20 devrplay has only been tested on Linux, but it should be possible to
21 get it working on other systems.
22
23 * Added rptp "set" command. This can be used to set rplayd
24 variables. One important use of this is to set the audio-close
25 variable. Examples:
26
27 Tell rplayd to close the audio device:
28 $ rptp set audio-close 1
29
30 Tell rplayd *not* to close the audio device:
31 $ rptp set audio-close 0
32
33 * Added rplayd monitor support which allows rptp clients to monitor
34 audio data that is written to the audio device. rptp clients can
35 now issue the "monitor" command to start receiving audio data.
36 One use of this feature is to pipe the audio data to a program
37 for visual display.
38
39 * rptp includes support for GNU readline and also displays progress
40 information when doing get, put, and monitor.
41
42 * Fixed several potential rplayd buffer overflows.
243
344 Changes since rplay 3.2:
445
3475
3576 * Lots of bug fixes.
3677
37 $Id: NEWS,v 1.2 1998/08/13 06:13:00 boyns Exp $
78 $Id: NEWS,v 1.4 1999/03/10 21:17:20 boyns Exp $
00 rplay 3.3 README
1 Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
1 Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
22
33 rplay is a flexible network audio system that allows sounds to be
44 played to and from local and remote Unix systems. Sounds can be
5151
5252 Send suggestions and bug reports to <boyns@doit.org>
5353
54 $Id: README,v 1.3 1998/08/13 06:13:02 boyns Exp $
54 $Id: README,v 1.4 1999/03/10 07:51:00 boyns Exp $
11
22 * rplayd tends to peg the cpu when it is trying to connect to another rplayd.
33 This needs to be fixed.
4
5 * Fix regex.[ch] to compile with a C++ compiler.
64
75 * Support more than one audio device in rplayd. A client should be able to
86 specify which device to use. Should there be more than one audio spool?
97
108 * Add RPLAY_VOLUME_LEFT and RPLAY_VOLUME_RIGHT attributes. RPLAY_VOLUME should
119 still apply to both left & right.
12
13 * Use GNU rx instead of GNU regex. Is rx faster?
14
15 * Add GNU readline support to the rptp client.
1610
1711 * rplayd needs to be updated to use the RPTP `set application=rplayd' command when
1812 connecting to other rplay servers.
2822 of course not play the directory, but it keeps the directory in its sound list.
2923 rplayd should remove the directories from its list.
3024
31 * Implement a C++ interface to the RPLAY and RPTP protocols.
32
3325 * Stereo G.72x files don't work and I don't know how to fix 'em.
3426
3527 * Don't modify audio-port by default
3628
37 * Java support?
38
39 $Id: TODO,v 1.2 1998/08/13 06:13:06 boyns Exp $
29 $Id: TODO,v 1.3 1999/03/10 07:51:00 boyns Exp $
+0
-14
adpcm/CVS/Entries less more
0 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /README/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /README.rplay/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 /g72xdecode.1/1.1.1.1/Tue Jul 14 22:35:23 1998//
4 /g72xencode.1/1.1.1.1/Tue Jul 14 22:35:23 1998//
5 /decode.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
6 /encode.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
7 /g711.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
8 /g721.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
9 /g723_24.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
10 /g723_40.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
11 /g72x.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
12 /g72x.h/1.1.1.1/Thu Aug 13 06:09:31 1998//
13 D
+0
-1
adpcm/CVS/Repository less more
0 /usr/local/cvsroot/rplay/adpcm
+0
-1
adpcm/CVS/Root less more
0 /usr/local/cvsroot
00 #! /bin/sh
11
22 # Guess values for system-dependent variables and create Makefiles.
3 # Generated automatically using autoconf version 2.12
3 # Generated automatically using autoconf version 2.13
44 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
55 #
66 # This configure script is free software; the Free Software Foundation
1414 --enable-rplayd-user=USER"
1515 ac_help="$ac_help
1616 --enable-rplayd-group=GROUP"
17 ac_help="$ac_help
18 --with-x use the X Window System"
1917
2018 # Initialize some variables set by options.
2119 # The variables have the same names as the options, with
5452 # Initialize some other variables.
5553 subdirs=
5654 MFLAGS= MAKEFLAGS=
55 SHELL=${CONFIG_SHELL-/bin/sh}
5756 # Maximum number of lines to put in a shell here document.
5857 ac_max_here_lines=12
5958
337336 verbose=yes ;;
338337
339338 -version | --version | --versio | --versi | --vers)
340 echo "configure generated by autoconf version 2.12"
339 echo "configure generated by autoconf version 2.13"
341340 exit 0 ;;
342341
343342 -with-* | --with-*)
507506 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
508507 ac_cpp='$CPP $CPPFLAGS'
509508 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
510 ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
509 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
511510 cross_compiling=$ac_cv_prog_cc_cross
512511
512 ac_exeext=
513 ac_objext=o
513514 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
514515 # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
515516 if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
542543 # Extract the first word of "gcc", so it can be a program name with args.
543544 set dummy gcc; ac_word=$2
544545 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
545 echo "configure:547: checking for $ac_word" >&5
546 echo "configure:548: checking for $ac_word" >&5
546547 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
547548 echo $ac_n "(cached) $ac_c" 1>&6
548549 else
549550 if test -n "$CC"; then
550551 ac_cv_prog_CC="$CC" # Let the user override the test.
551552 else
552 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
553 for ac_dir in $PATH; do
553 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
554 ac_dummy="$PATH"
555 for ac_dir in $ac_dummy; do
554556 test -z "$ac_dir" && ac_dir=.
555557 if test -f $ac_dir/$ac_word; then
556558 ac_cv_prog_CC="gcc"
571573 # Extract the first word of "cc", so it can be a program name with args.
572574 set dummy cc; ac_word=$2
573575 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
574 echo "configure:576: checking for $ac_word" >&5
576 echo "configure:578: checking for $ac_word" >&5
575577 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
576578 echo $ac_n "(cached) $ac_c" 1>&6
577579 else
578580 if test -n "$CC"; then
579581 ac_cv_prog_CC="$CC" # Let the user override the test.
580582 else
581 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
583 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
582584 ac_prog_rejected=no
583 for ac_dir in $PATH; do
585 ac_dummy="$PATH"
586 for ac_dir in $ac_dummy; do
584587 test -z "$ac_dir" && ac_dir=.
585588 if test -f $ac_dir/$ac_word; then
586589 if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
615618 echo "$ac_t""no" 1>&6
616619 fi
617620
621 if test -z "$CC"; then
622 case "`uname -s`" in
623 *win32* | *WIN32*)
624 # Extract the first word of "cl", so it can be a program name with args.
625 set dummy cl; ac_word=$2
626 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
627 echo "configure:629: checking for $ac_word" >&5
628 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
629 echo $ac_n "(cached) $ac_c" 1>&6
630 else
631 if test -n "$CC"; then
632 ac_cv_prog_CC="$CC" # Let the user override the test.
633 else
634 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
635 ac_dummy="$PATH"
636 for ac_dir in $ac_dummy; do
637 test -z "$ac_dir" && ac_dir=.
638 if test -f $ac_dir/$ac_word; then
639 ac_cv_prog_CC="cl"
640 break
641 fi
642 done
643 IFS="$ac_save_ifs"
644 fi
645 fi
646 CC="$ac_cv_prog_CC"
647 if test -n "$CC"; then
648 echo "$ac_t""$CC" 1>&6
649 else
650 echo "$ac_t""no" 1>&6
651 fi
652 ;;
653 esac
654 fi
618655 test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
619656 fi
620657
621658 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
622 echo "configure:624: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
659 echo "configure:661: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
623660
624661 ac_ext=c
625662 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
626663 ac_cpp='$CPP $CPPFLAGS'
627664 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
628 ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
665 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
629666 cross_compiling=$ac_cv_prog_cc_cross
630667
631 cat > conftest.$ac_ext <<EOF
632 #line 634 "configure"
633 #include "confdefs.h"
668 cat > conftest.$ac_ext << EOF
669
670 #line 672 "configure"
671 #include "confdefs.h"
672
634673 main(){return(0);}
635674 EOF
636 if { (eval echo configure:638: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
675 if { (eval echo configure:677: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
637676 ac_cv_prog_cc_works=yes
638677 # If we can't run a trivial program, we are probably using a cross compiler.
639678 if (./conftest; exit) 2>/dev/null; then
647686 ac_cv_prog_cc_works=no
648687 fi
649688 rm -fr conftest*
689 ac_ext=c
690 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
691 ac_cpp='$CPP $CPPFLAGS'
692 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
693 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
694 cross_compiling=$ac_cv_prog_cc_cross
650695
651696 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
652697 if test $ac_cv_prog_cc_works = no; then
653698 { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
654699 fi
655700 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
656 echo "configure:658: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
701 echo "configure:703: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
657702 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
658703 cross_compiling=$ac_cv_prog_cc_cross
659704
660705 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
661 echo "configure:663: checking whether we are using GNU C" >&5
706 echo "configure:708: checking whether we are using GNU C" >&5
662707 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
663708 echo $ac_n "(cached) $ac_c" 1>&6
664709 else
667712 yes;
668713 #endif
669714 EOF
670 if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:672: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
715 if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:717: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
671716 ac_cv_prog_gcc=yes
672717 else
673718 ac_cv_prog_gcc=no
678723
679724 if test $ac_cv_prog_gcc = yes; then
680725 GCC=yes
681 ac_test_CFLAGS="${CFLAGS+set}"
682 ac_save_CFLAGS="$CFLAGS"
683 CFLAGS=
684 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
685 echo "configure:687: checking whether ${CC-cc} accepts -g" >&5
726 else
727 GCC=
728 fi
729
730 ac_test_CFLAGS="${CFLAGS+set}"
731 ac_save_CFLAGS="$CFLAGS"
732 CFLAGS=
733 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
734 echo "configure:736: checking whether ${CC-cc} accepts -g" >&5
686735 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
687736 echo $ac_n "(cached) $ac_c" 1>&6
688737 else
697746 fi
698747
699748 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
700 if test "$ac_test_CFLAGS" = set; then
701 CFLAGS="$ac_save_CFLAGS"
702 elif test $ac_cv_prog_cc_g = yes; then
749 if test "$ac_test_CFLAGS" = set; then
750 CFLAGS="$ac_save_CFLAGS"
751 elif test $ac_cv_prog_cc_g = yes; then
752 if test "$GCC" = yes; then
703753 CFLAGS="-g -O2"
704754 else
755 CFLAGS="-g"
756 fi
757 else
758 if test "$GCC" = yes; then
705759 CFLAGS="-O2"
760 else
761 CFLAGS=
706762 fi
707 else
708 GCC=
709 test "${CFLAGS+set}" = set || CFLAGS="-g"
710763 fi
711764
712765
743796
744797
745798 echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
746 echo "configure:748: checking for POSIXized ISC" >&5
799 echo "configure:801: checking for POSIXized ISC" >&5
747800 if test -d /etc/conf/kconfig.d &&
748801 grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
749802 then
764817 fi
765818
766819 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
767 echo "configure:769: checking how to run the C preprocessor" >&5
820 echo "configure:822: checking how to run the C preprocessor" >&5
768821 # On Suns, sometimes $CPP names a directory.
769822 if test -n "$CPP" && test -d "$CPP"; then
770823 CPP=
779832 # On the NeXT, cc -E runs the code through the compiler's parser,
780833 # not just through cpp.
781834 cat > conftest.$ac_ext <<EOF
782 #line 784 "configure"
835 #line 837 "configure"
783836 #include "confdefs.h"
784837 #include <assert.h>
785838 Syntax Error
786839 EOF
787840 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
788 { (eval echo configure:790: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
789 ac_err=`grep -v '^ *+' conftest.out`
841 { (eval echo configure:843: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
842 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
790843 if test -z "$ac_err"; then
791844 :
792845 else
796849 rm -rf conftest*
797850 CPP="${CC-cc} -E -traditional-cpp"
798851 cat > conftest.$ac_ext <<EOF
799 #line 801 "configure"
852 #line 854 "configure"
800853 #include "confdefs.h"
801854 #include <assert.h>
802855 Syntax Error
803856 EOF
804857 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
805 { (eval echo configure:807: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
806 ac_err=`grep -v '^ *+' conftest.out`
858 { (eval echo configure:860: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
859 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
807860 if test -z "$ac_err"; then
808861 :
809862 else
811864 echo "configure: failed program was:" >&5
812865 cat conftest.$ac_ext >&5
813866 rm -rf conftest*
867 CPP="${CC-cc} -nologo -E"
868 cat > conftest.$ac_ext <<EOF
869 #line 871 "configure"
870 #include "confdefs.h"
871 #include <assert.h>
872 Syntax Error
873 EOF
874 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
875 { (eval echo configure:877: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
876 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
877 if test -z "$ac_err"; then
878 :
879 else
880 echo "$ac_err" >&5
881 echo "configure: failed program was:" >&5
882 cat conftest.$ac_ext >&5
883 rm -rf conftest*
814884 CPP=/lib/cpp
885 fi
886 rm -f conftest*
815887 fi
816888 rm -f conftest*
817889 fi
850922 # SunOS /usr/etc/install
851923 # IRIX /sbin/install
852924 # AIX /bin/install
925 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
853926 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
854927 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
855928 # ./install, which can be erroneously created by make from ./install.sh.
856929 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
857 echo "configure:859: checking for a BSD compatible install" >&5
930 echo "configure:932: checking for a BSD compatible install" >&5
858931 if test -z "$INSTALL"; then
859932 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
860933 echo $ac_n "(cached) $ac_c" 1>&6
861934 else
862 IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
935 IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
863936 for ac_dir in $PATH; do
864937 # Account for people who put trailing slashes in PATH elements.
865938 case "$ac_dir/" in
866939 /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
867940 *)
868941 # OSF1 and SCO ODT 3.0 have their own names for install.
869 for ac_prog in ginstall installbsd scoinst install; do
942 # Don't use installbsd from OSF since it installs stuff as root
943 # by default.
944 for ac_prog in ginstall scoinst install; do
870945 if test -f $ac_dir/$ac_prog; then
871946 if test $ac_prog = install &&
872947 grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
873948 # AIX install. It has an incompatible calling convention.
874 # OSF/1 installbsd also uses dspmsg, but is usable.
875949 :
876950 else
877951 ac_cv_path_install="$ac_dir/$ac_prog -c"
901975 # It thinks the first close brace ends the variable substitution.
902976 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
903977
978 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
979
904980 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
905981
906982 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
907 echo "configure:909: checking whether ln -s works" >&5
983 echo "configure:985: checking whether ln -s works" >&5
908984 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
909985 echo $ac_n "(cached) $ac_c" 1>&6
910986 else
9271003 # Extract the first word of "ranlib", so it can be a program name with args.
9281004 set dummy ranlib; ac_word=$2
9291005 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
930 echo "configure:932: checking for $ac_word" >&5
1006 echo "configure:1008: checking for $ac_word" >&5
9311007 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
9321008 echo $ac_n "(cached) $ac_c" 1>&6
9331009 else
9341010 if test -n "$RANLIB"; then
9351011 ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
9361012 else
937 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
938 for ac_dir in $PATH; do
1013 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1014 ac_dummy="$PATH"
1015 for ac_dir in $ac_dummy; do
9391016 test -z "$ac_dir" && ac_dir=.
9401017 if test -f $ac_dir/$ac_word; then
9411018 ac_cv_prog_RANLIB="ranlib"
9581035 # Extract the first word of "$ac_prog", so it can be a program name with args.
9591036 set dummy $ac_prog; ac_word=$2
9601037 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
961 echo "configure:963: checking for $ac_word" >&5
1038 echo "configure:1040: checking for $ac_word" >&5
9621039 if eval "test \"`echo '$''{'ac_cv_prog_ETAGS'+set}'`\" = set"; then
9631040 echo $ac_n "(cached) $ac_c" 1>&6
9641041 else
9651042 if test -n "$ETAGS"; then
9661043 ac_cv_prog_ETAGS="$ETAGS" # Let the user override the test.
9671044 else
968 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
969 for ac_dir in $PATH; do
1045 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1046 ac_dummy="$PATH"
1047 for ac_dir in $ac_dummy; do
9701048 test -z "$ac_dir" && ac_dir=.
9711049 if test -f $ac_dir/$ac_word; then
9721050 ac_cv_prog_ETAGS="$ac_prog"
9921070 # Extract the first word of "$ac_prog", so it can be a program name with args.
9931071 set dummy $ac_prog; ac_word=$2
9941072 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
995 echo "configure:997: checking for $ac_word" >&5
1073 echo "configure:1075: checking for $ac_word" >&5
9961074 if eval "test \"`echo '$''{'ac_cv_prog_MAKEDEPEND'+set}'`\" = set"; then
9971075 echo $ac_n "(cached) $ac_c" 1>&6
9981076 else
9991077 if test -n "$MAKEDEPEND"; then
10001078 ac_cv_prog_MAKEDEPEND="$MAKEDEPEND" # Let the user override the test.
10011079 else
1002 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1003 for ac_dir in $PATH; do
1080 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1081 ac_dummy="$PATH"
1082 for ac_dir in $ac_dummy; do
10041083 test -z "$ac_dir" && ac_dir=.
10051084 if test -f $ac_dir/$ac_word; then
10061085 ac_cv_prog_MAKEDEPEND="$ac_prog"
10261105 # Extract the first word of "$ac_prog", so it can be a program name with args.
10271106 set dummy $ac_prog; ac_word=$2
10281107 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1029 echo "configure:1031: checking for $ac_word" >&5
1108 echo "configure:1110: checking for $ac_word" >&5
10301109 if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then
10311110 echo $ac_n "(cached) $ac_c" 1>&6
10321111 else
10331112 if test -n "$MAKEINFO"; then
10341113 ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test.
10351114 else
1036 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1037 for ac_dir in $PATH; do
1115 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1116 ac_dummy="$PATH"
1117 for ac_dir in $ac_dummy; do
10381118 test -z "$ac_dir" && ac_dir=.
10391119 if test -f $ac_dir/$ac_word; then
10401120 ac_cv_prog_MAKEINFO="$ac_prog"
10601140 # Extract the first word of "$ac_prog", so it can be a program name with args.
10611141 set dummy $ac_prog; ac_word=$2
10621142 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1063 echo "configure:1065: checking for $ac_word" >&5
1143 echo "configure:1145: checking for $ac_word" >&5
10641144 if eval "test \"`echo '$''{'ac_cv_prog_TEXI2DVI'+set}'`\" = set"; then
10651145 echo $ac_n "(cached) $ac_c" 1>&6
10661146 else
10671147 if test -n "$TEXI2DVI"; then
10681148 ac_cv_prog_TEXI2DVI="$TEXI2DVI" # Let the user override the test.
10691149 else
1070 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1071 for ac_dir in $PATH; do
1150 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1151 ac_dummy="$PATH"
1152 for ac_dir in $ac_dummy; do
10721153 test -z "$ac_dir" && ac_dir=.
10731154 if test -f $ac_dir/$ac_word; then
10741155 ac_cv_prog_TEXI2DVI="$ac_prog"
10941175 # Extract the first word of "$ac_prog", so it can be a program name with args.
10951176 set dummy $ac_prog; ac_word=$2
10961177 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1097 echo "configure:1099: checking for $ac_word" >&5
1178 echo "configure:1180: checking for $ac_word" >&5
10981179 if eval "test \"`echo '$''{'ac_cv_prog_TEXI2HTML'+set}'`\" = set"; then
10991180 echo $ac_n "(cached) $ac_c" 1>&6
11001181 else
11011182 if test -n "$TEXI2HTML"; then
11021183 ac_cv_prog_TEXI2HTML="$TEXI2HTML" # Let the user override the test.
11031184 else
1104 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1105 for ac_dir in $PATH; do
1185 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1186 ac_dummy="$PATH"
1187 for ac_dir in $ac_dummy; do
11061188 test -z "$ac_dir" && ac_dir=.
11071189 if test -f $ac_dir/$ac_word; then
11081190 ac_cv_prog_TEXI2HTML="$ac_prog"
11281210 # Extract the first word of "$ac_prog", so it can be a program name with args.
11291211 set dummy $ac_prog; ac_word=$2
11301212 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1131 echo "configure:1133: checking for $ac_word" >&5
1213 echo "configure:1215: checking for $ac_word" >&5
11321214 if eval "test \"`echo '$''{'ac_cv_prog_DVIPS'+set}'`\" = set"; then
11331215 echo $ac_n "(cached) $ac_c" 1>&6
11341216 else
11351217 if test -n "$DVIPS"; then
11361218 ac_cv_prog_DVIPS="$DVIPS" # Let the user override the test.
11371219 else
1138 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1139 for ac_dir in $PATH; do
1220 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1221 ac_dummy="$PATH"
1222 for ac_dir in $ac_dummy; do
11401223 test -z "$ac_dir" && ac_dir=.
11411224 if test -f $ac_dir/$ac_word; then
11421225 ac_cv_prog_DVIPS="$ac_prog"
11631246 do
11641247 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
11651248 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
1166 echo "configure:1168: checking for $ac_hdr that defines DIR" >&5
1249 echo "configure:1251: checking for $ac_hdr that defines DIR" >&5
11671250 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
11681251 echo $ac_n "(cached) $ac_c" 1>&6
11691252 else
11701253 cat > conftest.$ac_ext <<EOF
1171 #line 1173 "configure"
1254 #line 1256 "configure"
11721255 #include "confdefs.h"
11731256 #include <sys/types.h>
11741257 #include <$ac_hdr>
11761259 DIR *dirp = 0;
11771260 ; return 0; }
11781261 EOF
1179 if { (eval echo configure:1181: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
1262 if { (eval echo configure:1264: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
11801263 rm -rf conftest*
11811264 eval "ac_cv_header_dirent_$ac_safe=yes"
11821265 else
12011284 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
12021285 if test $ac_header_dirent = dirent.h; then
12031286 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
1204 echo "configure:1206: checking for opendir in -ldir" >&5
1287 echo "configure:1289: checking for opendir in -ldir" >&5
12051288 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
12061289 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
12071290 echo $ac_n "(cached) $ac_c" 1>&6
12091292 ac_save_LIBS="$LIBS"
12101293 LIBS="-ldir $LIBS"
12111294 cat > conftest.$ac_ext <<EOF
1212 #line 1214 "configure"
1295 #line 1297 "configure"
12131296 #include "confdefs.h"
12141297 /* Override any gcc2 internal prototype to avoid an error. */
12151298 /* We use char because int might match the return type of a gcc2
12201303 opendir()
12211304 ; return 0; }
12221305 EOF
1223 if { (eval echo configure:1225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1306 if { (eval echo configure:1308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
12241307 rm -rf conftest*
12251308 eval "ac_cv_lib_$ac_lib_var=yes"
12261309 else
12421325
12431326 else
12441327 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
1245 echo "configure:1247: checking for opendir in -lx" >&5
1328 echo "configure:1330: checking for opendir in -lx" >&5
12461329 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
12471330 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
12481331 echo $ac_n "(cached) $ac_c" 1>&6
12501333 ac_save_LIBS="$LIBS"
12511334 LIBS="-lx $LIBS"
12521335 cat > conftest.$ac_ext <<EOF
1253 #line 1255 "configure"
1336 #line 1338 "configure"
12541337 #include "confdefs.h"
12551338 /* Override any gcc2 internal prototype to avoid an error. */
12561339 /* We use char because int might match the return type of a gcc2
12611344 opendir()
12621345 ; return 0; }
12631346 EOF
1264 if { (eval echo configure:1266: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1347 if { (eval echo configure:1349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
12651348 rm -rf conftest*
12661349 eval "ac_cv_lib_$ac_lib_var=yes"
12671350 else
12841367 fi
12851368
12861369 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
1287 echo "configure:1289: checking for ANSI C header files" >&5
1370 echo "configure:1372: checking for ANSI C header files" >&5
12881371 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
12891372 echo $ac_n "(cached) $ac_c" 1>&6
12901373 else
12911374 cat > conftest.$ac_ext <<EOF
1292 #line 1294 "configure"
1375 #line 1377 "configure"
12931376 #include "confdefs.h"
12941377 #include <stdlib.h>
12951378 #include <stdarg.h>
12971380 #include <float.h>
12981381 EOF
12991382 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
1300 { (eval echo configure:1302: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
1301 ac_err=`grep -v '^ *+' conftest.out`
1383 { (eval echo configure:1385: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
1384 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
13021385 if test -z "$ac_err"; then
13031386 rm -rf conftest*
13041387 ac_cv_header_stdc=yes
13141397 if test $ac_cv_header_stdc = yes; then
13151398 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
13161399 cat > conftest.$ac_ext <<EOF
1317 #line 1319 "configure"
1400 #line 1402 "configure"
13181401 #include "confdefs.h"
13191402 #include <string.h>
13201403 EOF
13321415 if test $ac_cv_header_stdc = yes; then
13331416 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
13341417 cat > conftest.$ac_ext <<EOF
1335 #line 1337 "configure"
1418 #line 1420 "configure"
13361419 #include "confdefs.h"
13371420 #include <stdlib.h>
13381421 EOF
13531436 :
13541437 else
13551438 cat > conftest.$ac_ext <<EOF
1356 #line 1358 "configure"
1439 #line 1441 "configure"
13571440 #include "confdefs.h"
13581441 #include <ctype.h>
13591442 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
13641447 exit (0); }
13651448
13661449 EOF
1367 if { (eval echo configure:1369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
1450 if { (eval echo configure:1452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
13681451 then
13691452 :
13701453 else
13881471 fi
13891472
13901473 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
1391 echo "configure:1393: checking whether time.h and sys/time.h may both be included" >&5
1474 echo "configure:1476: checking whether time.h and sys/time.h may both be included" >&5
13921475 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
13931476 echo $ac_n "(cached) $ac_c" 1>&6
13941477 else
13951478 cat > conftest.$ac_ext <<EOF
1396 #line 1398 "configure"
1479 #line 1481 "configure"
13971480 #include "confdefs.h"
13981481 #include <sys/types.h>
13991482 #include <sys/time.h>
14021485 struct tm *tp;
14031486 ; return 0; }
14041487 EOF
1405 if { (eval echo configure:1407: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
1488 if { (eval echo configure:1490: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
14061489 rm -rf conftest*
14071490 ac_cv_header_time=yes
14081491 else
14221505
14231506 fi
14241507
1425 # If we find X, set shell vars x_includes and x_libraries to the
1426 # paths, otherwise set no_x=yes.
1427 # Uses ac_ vars as temps to allow command line to override cache and checks.
1428 # --without-x overrides everything else, but does not touch the cache.
1429 echo $ac_n "checking for X""... $ac_c" 1>&6
1430 echo "configure:1432: checking for X" >&5
1431
1432 # Check whether --with-x or --without-x was given.
1433 if test "${with_x+set}" = set; then
1434 withval="$with_x"
1435 :
1436 fi
1437
1438 # $have_x is `yes', `no', `disabled', or empty when we do not yet know.
1439 if test "x$with_x" = xno; then
1440 # The user explicitly disabled X.
1441 have_x=disabled
1442 else
1443 if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
1444 # Both variables are already set.
1445 have_x=yes
1446 else
1447 if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then
1448 echo $ac_n "(cached) $ac_c" 1>&6
1449 else
1450 # One or both of the vars are not set, and there is no cached value.
1451 ac_x_includes=NO ac_x_libraries=NO
1452 rm -fr conftestdir
1453 if mkdir conftestdir; then
1454 cd conftestdir
1455 # Make sure to not put "make" in the Imakefile rules, since we grep it out.
1456 cat > Imakefile <<'EOF'
1457 acfindx:
1458 @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
1459 EOF
1460 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
1461 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
1462 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
1463 # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
1464 for ac_extension in a so sl; do
1465 if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
1466 test -f $ac_im_libdir/libX11.$ac_extension; then
1467 ac_im_usrlibdir=$ac_im_libdir; break
1468 fi
1469 done
1470 # Screen out bogus values from the imake configuration. They are
1471 # bogus both because they are the default anyway, and because
1472 # using them would break gcc on systems where it needs fixed includes.
1473 case "$ac_im_incroot" in
1474 /usr/include) ;;
1475 *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;;
1476 esac
1477 case "$ac_im_usrlibdir" in
1478 /usr/lib | /lib) ;;
1479 *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;;
1480 esac
1481 fi
1482 cd ..
1483 rm -fr conftestdir
1484 fi
1485
1486 if test "$ac_x_includes" = NO; then
1487 # Guess where to find include files, by looking for this one X11 .h file.
1488 test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
1489
1490 # First, try using that file with no special directory specified.
1491 cat > conftest.$ac_ext <<EOF
1492 #line 1494 "configure"
1493 #include "confdefs.h"
1494 #include <$x_direct_test_include>
1495 EOF
1496 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
1497 { (eval echo configure:1499: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
1498 ac_err=`grep -v '^ *+' conftest.out`
1499 if test -z "$ac_err"; then
1500 rm -rf conftest*
1501 # We can compile using X headers with no special include directory.
1502 ac_x_includes=
1503 else
1504 echo "$ac_err" >&5
1505 echo "configure: failed program was:" >&5
1506 cat conftest.$ac_ext >&5
1507 rm -rf conftest*
1508 # Look for the header file in a standard set of common directories.
1509 # Check X11 before X11Rn because it is often a symlink to the current release.
1510 for ac_dir in \
1511 /usr/X11/include \
1512 /usr/X11R6/include \
1513 /usr/X11R5/include \
1514 /usr/X11R4/include \
1515 \
1516 /usr/include/X11 \
1517 /usr/include/X11R6 \
1518 /usr/include/X11R5 \
1519 /usr/include/X11R4 \
1520 \
1521 /usr/local/X11/include \
1522 /usr/local/X11R6/include \
1523 /usr/local/X11R5/include \
1524 /usr/local/X11R4/include \
1525 \
1526 /usr/local/include/X11 \
1527 /usr/local/include/X11R6 \
1528 /usr/local/include/X11R5 \
1529 /usr/local/include/X11R4 \
1530 \
1531 /usr/X386/include \
1532 /usr/x386/include \
1533 /usr/XFree86/include/X11 \
1534 \
1535 /usr/include \
1536 /usr/local/include \
1537 /usr/unsupported/include \
1538 /usr/athena/include \
1539 /usr/local/x11r5/include \
1540 /usr/lpp/Xamples/include \
1541 \
1542 /usr/openwin/include \
1543 /usr/openwin/share/include \
1544 ; \
1545 do
1546 if test -r "$ac_dir/$x_direct_test_include"; then
1547 ac_x_includes=$ac_dir
1548 break
1549 fi
1550 done
1551 fi
1552 rm -f conftest*
1553 fi # $ac_x_includes = NO
1554
1555 if test "$ac_x_libraries" = NO; then
1556 # Check for the libraries.
1557
1558 test -z "$x_direct_test_library" && x_direct_test_library=Xt
1559 test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
1560
1561 # See if we find them without any special options.
1562 # Don't add to $LIBS permanently.
1563 ac_save_LIBS="$LIBS"
1564 LIBS="-l$x_direct_test_library $LIBS"
1565 cat > conftest.$ac_ext <<EOF
1566 #line 1568 "configure"
1567 #include "confdefs.h"
1568
1569 int main() {
1570 ${x_direct_test_function}()
1571 ; return 0; }
1572 EOF
1573 if { (eval echo configure:1575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1574 rm -rf conftest*
1575 LIBS="$ac_save_LIBS"
1576 # We can link X programs with no special library path.
1577 ac_x_libraries=
1578 else
1579 echo "configure: failed program was:" >&5
1580 cat conftest.$ac_ext >&5
1581 rm -rf conftest*
1582 LIBS="$ac_save_LIBS"
1583 # First see if replacing the include by lib works.
1584 # Check X11 before X11Rn because it is often a symlink to the current release.
1585 for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
1586 /usr/X11/lib \
1587 /usr/X11R6/lib \
1588 /usr/X11R5/lib \
1589 /usr/X11R4/lib \
1590 \
1591 /usr/lib/X11 \
1592 /usr/lib/X11R6 \
1593 /usr/lib/X11R5 \
1594 /usr/lib/X11R4 \
1595 \
1596 /usr/local/X11/lib \
1597 /usr/local/X11R6/lib \
1598 /usr/local/X11R5/lib \
1599 /usr/local/X11R4/lib \
1600 \
1601 /usr/local/lib/X11 \
1602 /usr/local/lib/X11R6 \
1603 /usr/local/lib/X11R5 \
1604 /usr/local/lib/X11R4 \
1605 \
1606 /usr/X386/lib \
1607 /usr/x386/lib \
1608 /usr/XFree86/lib/X11 \
1609 \
1610 /usr/lib \
1611 /usr/local/lib \
1612 /usr/unsupported/lib \
1613 /usr/athena/lib \
1614 /usr/local/x11r5/lib \
1615 /usr/lpp/Xamples/lib \
1616 /lib/usr/lib/X11 \
1617 \
1618 /usr/openwin/lib \
1619 /usr/openwin/share/lib \
1620 ; \
1621 do
1622 for ac_extension in a so sl; do
1623 if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
1624 ac_x_libraries=$ac_dir
1625 break 2
1626 fi
1627 done
1628 done
1629 fi
1630 rm -f conftest*
1631 fi # $ac_x_libraries = NO
1632
1633 if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
1634 # Didn't find X anywhere. Cache the known absence of X.
1635 ac_cv_have_x="have_x=no"
1636 else
1637 # Record where we found X for the cache.
1638 ac_cv_have_x="have_x=yes \
1639 ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
1640 fi
1641 fi
1642 fi
1643 eval "$ac_cv_have_x"
1644 fi # $with_x != no
1645
1646 if test "$have_x" != yes; then
1647 echo "$ac_t""$have_x" 1>&6
1648 no_x=yes
1649 else
1650 # If each of the values was on the command line, it overrides each guess.
1651 test "x$x_includes" = xNONE && x_includes=$ac_x_includes
1652 test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
1653 # Update the cache value to reflect the command line values.
1654 ac_cv_have_x="have_x=yes \
1655 ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
1656 echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6
1657 fi
1658
1659 if test "$no_x" = yes; then
1660 # Not all programs may use this symbol, but it does not hurt to define it.
1661 cat >> confdefs.h <<\EOF
1662 #define X_DISPLAY_MISSING 1
1663 EOF
1664
1665 X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
1666 else
1667 if test -n "$x_includes"; then
1668 X_CFLAGS="$X_CFLAGS -I$x_includes"
1669 fi
1670
1671 # It would also be nice to do this for all -L options, not just this one.
1672 if test -n "$x_libraries"; then
1673 X_LIBS="$X_LIBS -L$x_libraries"
1674 # For Solaris; some versions of Sun CC require a space after -R and
1675 # others require no space. Words are not sufficient . . . .
1676 case "`(uname -sr) 2>/dev/null`" in
1677 "SunOS 5"*)
1678 echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
1679 echo "configure:1681: checking whether -R must be followed by a space" >&5
1680 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
1681 cat > conftest.$ac_ext <<EOF
1682 #line 1684 "configure"
1683 #include "confdefs.h"
1684
1685 int main() {
1686
1687 ; return 0; }
1688 EOF
1689 if { (eval echo configure:1691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1690 rm -rf conftest*
1691 ac_R_nospace=yes
1692 else
1693 echo "configure: failed program was:" >&5
1694 cat conftest.$ac_ext >&5
1695 rm -rf conftest*
1696 ac_R_nospace=no
1697 fi
1698 rm -f conftest*
1699 if test $ac_R_nospace = yes; then
1700 echo "$ac_t""no" 1>&6
1701 X_LIBS="$X_LIBS -R$x_libraries"
1702 else
1703 LIBS="$ac_xsave_LIBS -R $x_libraries"
1704 cat > conftest.$ac_ext <<EOF
1705 #line 1707 "configure"
1706 #include "confdefs.h"
1707
1708 int main() {
1709
1710 ; return 0; }
1711 EOF
1712 if { (eval echo configure:1714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1713 rm -rf conftest*
1714 ac_R_space=yes
1715 else
1716 echo "configure: failed program was:" >&5
1717 cat conftest.$ac_ext >&5
1718 rm -rf conftest*
1719 ac_R_space=no
1720 fi
1721 rm -f conftest*
1722 if test $ac_R_space = yes; then
1723 echo "$ac_t""yes" 1>&6
1724 X_LIBS="$X_LIBS -R $x_libraries"
1725 else
1726 echo "$ac_t""neither works" 1>&6
1727 fi
1728 fi
1729 LIBS="$ac_xsave_LIBS"
1730 esac
1731 fi
1732
1733 # Check for system-dependent libraries X programs must link with.
1734 # Do this before checking for the system-independent R6 libraries
1735 # (-lICE), since we may need -lsocket or whatever for X linking.
1736
1737 if test "$ISC" = yes; then
1738 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
1739 else
1740 # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
1741 # libraries were built with DECnet support. And karl@cs.umb.edu says
1742 # the Alpha needs dnet_stub (dnet does not exist).
1743 echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
1744 echo "configure:1746: checking for dnet_ntoa in -ldnet" >&5
1745 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
1746 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
1747 echo $ac_n "(cached) $ac_c" 1>&6
1748 else
1749 ac_save_LIBS="$LIBS"
1750 LIBS="-ldnet $LIBS"
1751 cat > conftest.$ac_ext <<EOF
1752 #line 1754 "configure"
1753 #include "confdefs.h"
1754 /* Override any gcc2 internal prototype to avoid an error. */
1755 /* We use char because int might match the return type of a gcc2
1756 builtin and then its argument prototype would still apply. */
1757 char dnet_ntoa();
1758
1759 int main() {
1760 dnet_ntoa()
1761 ; return 0; }
1762 EOF
1763 if { (eval echo configure:1765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1764 rm -rf conftest*
1765 eval "ac_cv_lib_$ac_lib_var=yes"
1766 else
1767 echo "configure: failed program was:" >&5
1768 cat conftest.$ac_ext >&5
1769 rm -rf conftest*
1770 eval "ac_cv_lib_$ac_lib_var=no"
1771 fi
1772 rm -f conftest*
1773 LIBS="$ac_save_LIBS"
1774
1775 fi
1776 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
1777 echo "$ac_t""yes" 1>&6
1778 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
1779 else
1780 echo "$ac_t""no" 1>&6
1781 fi
1782
1783 if test $ac_cv_lib_dnet_dnet_ntoa = no; then
1784 echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
1785 echo "configure:1787: checking for dnet_ntoa in -ldnet_stub" >&5
1786 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
1787 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
1788 echo $ac_n "(cached) $ac_c" 1>&6
1789 else
1790 ac_save_LIBS="$LIBS"
1791 LIBS="-ldnet_stub $LIBS"
1792 cat > conftest.$ac_ext <<EOF
1793 #line 1795 "configure"
1794 #include "confdefs.h"
1795 /* Override any gcc2 internal prototype to avoid an error. */
1796 /* We use char because int might match the return type of a gcc2
1797 builtin and then its argument prototype would still apply. */
1798 char dnet_ntoa();
1799
1800 int main() {
1801 dnet_ntoa()
1802 ; return 0; }
1803 EOF
1804 if { (eval echo configure:1806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1805 rm -rf conftest*
1806 eval "ac_cv_lib_$ac_lib_var=yes"
1807 else
1808 echo "configure: failed program was:" >&5
1809 cat conftest.$ac_ext >&5
1810 rm -rf conftest*
1811 eval "ac_cv_lib_$ac_lib_var=no"
1812 fi
1813 rm -f conftest*
1814 LIBS="$ac_save_LIBS"
1815
1816 fi
1817 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
1818 echo "$ac_t""yes" 1>&6
1819 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
1820 else
1821 echo "$ac_t""no" 1>&6
1822 fi
1823
1824 fi
1825
1826 # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
1827 # to get the SysV transport functions.
1828 # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4)
1829 # needs -lnsl.
1830 # The nsl library prevents programs from opening the X display
1831 # on Irix 5.2, according to dickey@clark.net.
1832 echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
1833 echo "configure:1835: checking for gethostbyname" >&5
1834 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
1835 echo $ac_n "(cached) $ac_c" 1>&6
1836 else
1837 cat > conftest.$ac_ext <<EOF
1838 #line 1840 "configure"
1839 #include "confdefs.h"
1840 /* System header to define __stub macros and hopefully few prototypes,
1841 which can conflict with char gethostbyname(); below. */
1842 #include <assert.h>
1843 /* Override any gcc2 internal prototype to avoid an error. */
1844 /* We use char because int might match the return type of a gcc2
1845 builtin and then its argument prototype would still apply. */
1846 char gethostbyname();
1847
1848 int main() {
1849
1850 /* The GNU C library defines this for functions which it implements
1851 to always fail with ENOSYS. Some functions are actually named
1852 something starting with __ and the normal name is an alias. */
1853 #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
1854 choke me
1855 #else
1856 gethostbyname();
1857 #endif
1858
1859 ; return 0; }
1860 EOF
1861 if { (eval echo configure:1863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1862 rm -rf conftest*
1863 eval "ac_cv_func_gethostbyname=yes"
1864 else
1865 echo "configure: failed program was:" >&5
1866 cat conftest.$ac_ext >&5
1867 rm -rf conftest*
1868 eval "ac_cv_func_gethostbyname=no"
1869 fi
1870 rm -f conftest*
1871 fi
1872
1873 if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then
1874 echo "$ac_t""yes" 1>&6
1875 :
1876 else
1877 echo "$ac_t""no" 1>&6
1878 fi
1879
1880 if test $ac_cv_func_gethostbyname = no; then
1881 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
1882 echo "configure:1884: checking for gethostbyname in -lnsl" >&5
1883 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
1884 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
1885 echo $ac_n "(cached) $ac_c" 1>&6
1886 else
1887 ac_save_LIBS="$LIBS"
1888 LIBS="-lnsl $LIBS"
1889 cat > conftest.$ac_ext <<EOF
1890 #line 1892 "configure"
1891 #include "confdefs.h"
1892 /* Override any gcc2 internal prototype to avoid an error. */
1893 /* We use char because int might match the return type of a gcc2
1894 builtin and then its argument prototype would still apply. */
1895 char gethostbyname();
1896
1897 int main() {
1898 gethostbyname()
1899 ; return 0; }
1900 EOF
1901 if { (eval echo configure:1903: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1902 rm -rf conftest*
1903 eval "ac_cv_lib_$ac_lib_var=yes"
1904 else
1905 echo "configure: failed program was:" >&5
1906 cat conftest.$ac_ext >&5
1907 rm -rf conftest*
1908 eval "ac_cv_lib_$ac_lib_var=no"
1909 fi
1910 rm -f conftest*
1911 LIBS="$ac_save_LIBS"
1912
1913 fi
1914 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
1915 echo "$ac_t""yes" 1>&6
1916 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
1917 else
1918 echo "$ac_t""no" 1>&6
1919 fi
1920
1921 fi
1922
1923 # lieder@skyler.mavd.honeywell.com says without -lsocket,
1924 # socket/setsockopt and other routines are undefined under SCO ODT
1925 # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
1926 # on later versions), says simon@lia.di.epfl.ch: it contains
1927 # gethostby* variants that don't use the nameserver (or something).
1928 # -lsocket must be given before -lnsl if both are needed.
1929 # We assume that if connect needs -lnsl, so does gethostbyname.
1930 echo $ac_n "checking for connect""... $ac_c" 1>&6
1931 echo "configure:1933: checking for connect" >&5
1932 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
1933 echo $ac_n "(cached) $ac_c" 1>&6
1934 else
1935 cat > conftest.$ac_ext <<EOF
1936 #line 1938 "configure"
1937 #include "confdefs.h"
1938 /* System header to define __stub macros and hopefully few prototypes,
1939 which can conflict with char connect(); below. */
1940 #include <assert.h>
1941 /* Override any gcc2 internal prototype to avoid an error. */
1942 /* We use char because int might match the return type of a gcc2
1943 builtin and then its argument prototype would still apply. */
1944 char connect();
1945
1946 int main() {
1947
1948 /* The GNU C library defines this for functions which it implements
1949 to always fail with ENOSYS. Some functions are actually named
1950 something starting with __ and the normal name is an alias. */
1951 #if defined (__stub_connect) || defined (__stub___connect)
1952 choke me
1953 #else
1954 connect();
1955 #endif
1956
1957 ; return 0; }
1958 EOF
1959 if { (eval echo configure:1961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1960 rm -rf conftest*
1961 eval "ac_cv_func_connect=yes"
1962 else
1963 echo "configure: failed program was:" >&5
1964 cat conftest.$ac_ext >&5
1965 rm -rf conftest*
1966 eval "ac_cv_func_connect=no"
1967 fi
1968 rm -f conftest*
1969 fi
1970
1971 if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then
1972 echo "$ac_t""yes" 1>&6
1973 :
1974 else
1975 echo "$ac_t""no" 1>&6
1976 fi
1977
1978 if test $ac_cv_func_connect = no; then
1979 echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
1980 echo "configure:1982: checking for connect in -lsocket" >&5
1981 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
1982 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
1983 echo $ac_n "(cached) $ac_c" 1>&6
1984 else
1985 ac_save_LIBS="$LIBS"
1986 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
1987 cat > conftest.$ac_ext <<EOF
1988 #line 1990 "configure"
1989 #include "confdefs.h"
1990 /* Override any gcc2 internal prototype to avoid an error. */
1991 /* We use char because int might match the return type of a gcc2
1992 builtin and then its argument prototype would still apply. */
1993 char connect();
1994
1995 int main() {
1996 connect()
1997 ; return 0; }
1998 EOF
1999 if { (eval echo configure:2001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2000 rm -rf conftest*
2001 eval "ac_cv_lib_$ac_lib_var=yes"
2002 else
2003 echo "configure: failed program was:" >&5
2004 cat conftest.$ac_ext >&5
2005 rm -rf conftest*
2006 eval "ac_cv_lib_$ac_lib_var=no"
2007 fi
2008 rm -f conftest*
2009 LIBS="$ac_save_LIBS"
2010
2011 fi
2012 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
2013 echo "$ac_t""yes" 1>&6
2014 X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
2015 else
2016 echo "$ac_t""no" 1>&6
2017 fi
2018
2019 fi
2020
2021 # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
2022 echo $ac_n "checking for remove""... $ac_c" 1>&6
2023 echo "configure:2025: checking for remove" >&5
2024 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
2025 echo $ac_n "(cached) $ac_c" 1>&6
2026 else
2027 cat > conftest.$ac_ext <<EOF
2028 #line 2030 "configure"
2029 #include "confdefs.h"
2030 /* System header to define __stub macros and hopefully few prototypes,
2031 which can conflict with char remove(); below. */
2032 #include <assert.h>
2033 /* Override any gcc2 internal prototype to avoid an error. */
2034 /* We use char because int might match the return type of a gcc2
2035 builtin and then its argument prototype would still apply. */
2036 char remove();
2037
2038 int main() {
2039
2040 /* The GNU C library defines this for functions which it implements
2041 to always fail with ENOSYS. Some functions are actually named
2042 something starting with __ and the normal name is an alias. */
2043 #if defined (__stub_remove) || defined (__stub___remove)
2044 choke me
2045 #else
2046 remove();
2047 #endif
2048
2049 ; return 0; }
2050 EOF
2051 if { (eval echo configure:2053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2052 rm -rf conftest*
2053 eval "ac_cv_func_remove=yes"
2054 else
2055 echo "configure: failed program was:" >&5
2056 cat conftest.$ac_ext >&5
2057 rm -rf conftest*
2058 eval "ac_cv_func_remove=no"
2059 fi
2060 rm -f conftest*
2061 fi
2062
2063 if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then
2064 echo "$ac_t""yes" 1>&6
2065 :
2066 else
2067 echo "$ac_t""no" 1>&6
2068 fi
2069
2070 if test $ac_cv_func_remove = no; then
2071 echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
2072 echo "configure:2074: checking for remove in -lposix" >&5
2073 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
2074 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
2075 echo $ac_n "(cached) $ac_c" 1>&6
2076 else
2077 ac_save_LIBS="$LIBS"
2078 LIBS="-lposix $LIBS"
2079 cat > conftest.$ac_ext <<EOF
2080 #line 2082 "configure"
2081 #include "confdefs.h"
2082 /* Override any gcc2 internal prototype to avoid an error. */
2083 /* We use char because int might match the return type of a gcc2
2084 builtin and then its argument prototype would still apply. */
2085 char remove();
2086
2087 int main() {
2088 remove()
2089 ; return 0; }
2090 EOF
2091 if { (eval echo configure:2093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2092 rm -rf conftest*
2093 eval "ac_cv_lib_$ac_lib_var=yes"
2094 else
2095 echo "configure: failed program was:" >&5
2096 cat conftest.$ac_ext >&5
2097 rm -rf conftest*
2098 eval "ac_cv_lib_$ac_lib_var=no"
2099 fi
2100 rm -f conftest*
2101 LIBS="$ac_save_LIBS"
2102
2103 fi
2104 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
2105 echo "$ac_t""yes" 1>&6
2106 X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
2107 else
2108 echo "$ac_t""no" 1>&6
2109 fi
2110
2111 fi
2112
2113 # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
2114 echo $ac_n "checking for shmat""... $ac_c" 1>&6
2115 echo "configure:2117: checking for shmat" >&5
2116 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
2117 echo $ac_n "(cached) $ac_c" 1>&6
2118 else
2119 cat > conftest.$ac_ext <<EOF
2120 #line 2122 "configure"
2121 #include "confdefs.h"
2122 /* System header to define __stub macros and hopefully few prototypes,
2123 which can conflict with char shmat(); below. */
2124 #include <assert.h>
2125 /* Override any gcc2 internal prototype to avoid an error. */
2126 /* We use char because int might match the return type of a gcc2
2127 builtin and then its argument prototype would still apply. */
2128 char shmat();
2129
2130 int main() {
2131
2132 /* The GNU C library defines this for functions which it implements
2133 to always fail with ENOSYS. Some functions are actually named
2134 something starting with __ and the normal name is an alias. */
2135 #if defined (__stub_shmat) || defined (__stub___shmat)
2136 choke me
2137 #else
2138 shmat();
2139 #endif
2140
2141 ; return 0; }
2142 EOF
2143 if { (eval echo configure:2145: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2144 rm -rf conftest*
2145 eval "ac_cv_func_shmat=yes"
2146 else
2147 echo "configure: failed program was:" >&5
2148 cat conftest.$ac_ext >&5
2149 rm -rf conftest*
2150 eval "ac_cv_func_shmat=no"
2151 fi
2152 rm -f conftest*
2153 fi
2154
2155 if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then
2156 echo "$ac_t""yes" 1>&6
2157 :
2158 else
2159 echo "$ac_t""no" 1>&6
2160 fi
2161
2162 if test $ac_cv_func_shmat = no; then
2163 echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
2164 echo "configure:2166: checking for shmat in -lipc" >&5
2165 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
2166 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
2167 echo $ac_n "(cached) $ac_c" 1>&6
2168 else
2169 ac_save_LIBS="$LIBS"
2170 LIBS="-lipc $LIBS"
2171 cat > conftest.$ac_ext <<EOF
2172 #line 2174 "configure"
2173 #include "confdefs.h"
2174 /* Override any gcc2 internal prototype to avoid an error. */
2175 /* We use char because int might match the return type of a gcc2
2176 builtin and then its argument prototype would still apply. */
2177 char shmat();
2178
2179 int main() {
2180 shmat()
2181 ; return 0; }
2182 EOF
2183 if { (eval echo configure:2185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2184 rm -rf conftest*
2185 eval "ac_cv_lib_$ac_lib_var=yes"
2186 else
2187 echo "configure: failed program was:" >&5
2188 cat conftest.$ac_ext >&5
2189 rm -rf conftest*
2190 eval "ac_cv_lib_$ac_lib_var=no"
2191 fi
2192 rm -f conftest*
2193 LIBS="$ac_save_LIBS"
2194
2195 fi
2196 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
2197 echo "$ac_t""yes" 1>&6
2198 X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
2199 else
2200 echo "$ac_t""no" 1>&6
2201 fi
2202
2203 fi
2204 fi
2205
2206 # Check for libraries that X11R6 Xt/Xaw programs need.
2207 ac_save_LDFLAGS="$LDFLAGS"
2208 test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
2209 # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
2210 # check for ICE first), but we must link in the order -lSM -lICE or
2211 # we get undefined symbols. So assume we have SM if we have ICE.
2212 # These have to be linked with before -lX11, unlike the other
2213 # libraries we check for below, so use a different variable.
2214 # --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
2215 echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
2216 echo "configure:2218: checking for IceConnectionNumber in -lICE" >&5
2217 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
2218 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
2219 echo $ac_n "(cached) $ac_c" 1>&6
2220 else
2221 ac_save_LIBS="$LIBS"
2222 LIBS="-lICE $LIBS"
2223 cat > conftest.$ac_ext <<EOF
2224 #line 2226 "configure"
2225 #include "confdefs.h"
2226 /* Override any gcc2 internal prototype to avoid an error. */
2227 /* We use char because int might match the return type of a gcc2
2228 builtin and then its argument prototype would still apply. */
2229 char IceConnectionNumber();
2230
2231 int main() {
2232 IceConnectionNumber()
2233 ; return 0; }
2234 EOF
2235 if { (eval echo configure:2237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2236 rm -rf conftest*
2237 eval "ac_cv_lib_$ac_lib_var=yes"
2238 else
2239 echo "configure: failed program was:" >&5
2240 cat conftest.$ac_ext >&5
2241 rm -rf conftest*
2242 eval "ac_cv_lib_$ac_lib_var=no"
2243 fi
2244 rm -f conftest*
2245 LIBS="$ac_save_LIBS"
2246
2247 fi
2248 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
2249 echo "$ac_t""yes" 1>&6
2250 X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
2251 else
2252 echo "$ac_t""no" 1>&6
2253 fi
2254
2255 LDFLAGS="$ac_save_LDFLAGS"
2256
2257 fi
2258
2259 for ac_hdr in fcntl.h sys/file.h sys/ioctl.h sys/time.h stdlib.h unistd.h memory.h string.h strings.h utime.h limits.h forms.h X11/forms.h
1508 for ac_hdr in fcntl.h sys/file.h sys/ioctl.h sys/time.h stdlib.h unistd.h memory.h string.h strings.h utime.h limits.h gsm.h gsm/gsm.h rxposix.h rx/rxposix.h
22601509 do
22611510 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
22621511 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
2263 echo "configure:2265: checking for $ac_hdr" >&5
1512 echo "configure:1514: checking for $ac_hdr" >&5
22641513 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
22651514 echo $ac_n "(cached) $ac_c" 1>&6
22661515 else
22671516 cat > conftest.$ac_ext <<EOF
2268 #line 2270 "configure"
1517 #line 1519 "configure"
22691518 #include "confdefs.h"
22701519 #include <$ac_hdr>
22711520 EOF
22721521 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
2273 { (eval echo configure:2275: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
2274 ac_err=`grep -v '^ *+' conftest.out`
1522 { (eval echo configure:1524: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
1523 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
22751524 if test -z "$ac_err"; then
22761525 rm -rf conftest*
22771526 eval "ac_cv_header_$ac_safe=yes"
22971546 done
22981547
22991548 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
2300 echo "configure:2302: checking for sys/wait.h that is POSIX.1 compatible" >&5
1549 echo "configure:1551: checking for sys/wait.h that is POSIX.1 compatible" >&5
23011550 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
23021551 echo $ac_n "(cached) $ac_c" 1>&6
23031552 else
23041553 cat > conftest.$ac_ext <<EOF
2305 #line 2307 "configure"
1554 #line 1556 "configure"
23061555 #include "confdefs.h"
23071556 #include <sys/types.h>
23081557 #include <sys/wait.h>
23181567 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
23191568 ; return 0; }
23201569 EOF
2321 if { (eval echo configure:2323: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
1570 if { (eval echo configure:1572: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
23221571 rm -rf conftest*
23231572 ac_cv_header_sys_wait_h=yes
23241573 else
23401589
23411590
23421591 echo $ac_n "checking for working const""... $ac_c" 1>&6
2343 echo "configure:2345: checking for working const" >&5
1592 echo "configure:1594: checking for working const" >&5
23441593 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
23451594 echo $ac_n "(cached) $ac_c" 1>&6
23461595 else
23471596 cat > conftest.$ac_ext <<EOF
2348 #line 2350 "configure"
1597 #line 1599 "configure"
23491598 #include "confdefs.h"
23501599
23511600 int main() {
23941643
23951644 ; return 0; }
23961645 EOF
2397 if { (eval echo configure:2399: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
1646 if { (eval echo configure:1648: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
23981647 rm -rf conftest*
23991648 ac_cv_c_const=yes
24001649 else
24151664 fi
24161665
24171666 echo $ac_n "checking for size_t""... $ac_c" 1>&6
2418 echo "configure:2420: checking for size_t" >&5
1667 echo "configure:1669: checking for size_t" >&5
24191668 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
24201669 echo $ac_n "(cached) $ac_c" 1>&6
24211670 else
24221671 cat > conftest.$ac_ext <<EOF
2423 #line 2425 "configure"
1672 #line 1674 "configure"
24241673 #include "confdefs.h"
24251674 #include <sys/types.h>
24261675 #if STDC_HEADERS
24291678 #endif
24301679 EOF
24311680 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
2432 egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
1681 egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
24331682 rm -rf conftest*
24341683 ac_cv_type_size_t=yes
24351684 else
24521701 do
24531702 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
24541703 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
2455 echo "configure:2457: checking for $ac_hdr" >&5
1704 echo "configure:1706: checking for $ac_hdr" >&5
24561705 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
24571706 echo $ac_n "(cached) $ac_c" 1>&6
24581707 else
24591708 cat > conftest.$ac_ext <<EOF
2460 #line 2462 "configure"
1709 #line 1711 "configure"
24611710 #include "confdefs.h"
24621711 #include <$ac_hdr>
24631712 EOF
24641713 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
2465 { (eval echo configure:2467: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
2466 ac_err=`grep -v '^ *+' conftest.out`
1714 { (eval echo configure:1716: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
1715 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
24671716 if test -z "$ac_err"; then
24681717 rm -rf conftest*
24691718 eval "ac_cv_header_$ac_safe=yes"
24911740 for ac_func in getpagesize
24921741 do
24931742 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
2494 echo "configure:2496: checking for $ac_func" >&5
1743 echo "configure:1745: checking for $ac_func" >&5
24951744 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
24961745 echo $ac_n "(cached) $ac_c" 1>&6
24971746 else
24981747 cat > conftest.$ac_ext <<EOF
2499 #line 2501 "configure"
1748 #line 1750 "configure"
25001749 #include "confdefs.h"
25011750 /* System header to define __stub macros and hopefully few prototypes,
25021751 which can conflict with char $ac_func(); below. */
25191768
25201769 ; return 0; }
25211770 EOF
2522 if { (eval echo configure:2524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1771 if { (eval echo configure:1773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
25231772 rm -rf conftest*
25241773 eval "ac_cv_func_$ac_func=yes"
25251774 else
25441793 done
25451794
25461795 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
2547 echo "configure:2549: checking for working mmap" >&5
1796 echo "configure:1798: checking for working mmap" >&5
25481797 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
25491798 echo $ac_n "(cached) $ac_c" 1>&6
25501799 else
25521801 ac_cv_func_mmap_fixed_mapped=no
25531802 else
25541803 cat > conftest.$ac_ext <<EOF
2555 #line 2557 "configure"
1804 #line 1806 "configure"
25561805 #include "confdefs.h"
25571806
25581807 /* Thanks to Mike Haertel and Jim Avera for this test.
26921941 }
26931942
26941943 EOF
2695 if { (eval echo configure:2697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
1944 if { (eval echo configure:1946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
26961945 then
26971946 ac_cv_func_mmap_fixed_mapped=yes
26981947 else
27151964 fi
27161965
27171966 echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
2718 echo "configure:2720: checking for 8-bit clean memcmp" >&5
1967 echo "configure:1969: checking for 8-bit clean memcmp" >&5
27191968 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
27201969 echo $ac_n "(cached) $ac_c" 1>&6
27211970 else
27231972 ac_cv_func_memcmp_clean=no
27241973 else
27251974 cat > conftest.$ac_ext <<EOF
2726 #line 2728 "configure"
1975 #line 1977 "configure"
27271976 #include "confdefs.h"
27281977
27291978 main()
27331982 }
27341983
27351984 EOF
2736 if { (eval echo configure:2738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
1985 if { (eval echo configure:1987: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
27371986 then
27381987 ac_cv_func_memcmp_clean=yes
27391988 else
27481997 fi
27491998
27501999 echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
2751 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o"
2000 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
27522001
27532002 echo $ac_n "checking for vprintf""... $ac_c" 1>&6
2754 echo "configure:2756: checking for vprintf" >&5
2003 echo "configure:2005: checking for vprintf" >&5
27552004 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
27562005 echo $ac_n "(cached) $ac_c" 1>&6
27572006 else
27582007 cat > conftest.$ac_ext <<EOF
2759 #line 2761 "configure"
2008 #line 2010 "configure"
27602009 #include "confdefs.h"
27612010 /* System header to define __stub macros and hopefully few prototypes,
27622011 which can conflict with char vprintf(); below. */
27792028
27802029 ; return 0; }
27812030 EOF
2782 if { (eval echo configure:2784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2031 if { (eval echo configure:2033: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
27832032 rm -rf conftest*
27842033 eval "ac_cv_func_vprintf=yes"
27852034 else
28032052
28042053 if test "$ac_cv_func_vprintf" != yes; then
28052054 echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
2806 echo "configure:2808: checking for _doprnt" >&5
2055 echo "configure:2057: checking for _doprnt" >&5
28072056 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
28082057 echo $ac_n "(cached) $ac_c" 1>&6
28092058 else
28102059 cat > conftest.$ac_ext <<EOF
2811 #line 2813 "configure"
2060 #line 2062 "configure"
28122061 #include "confdefs.h"
28132062 /* System header to define __stub macros and hopefully few prototypes,
28142063 which can conflict with char _doprnt(); below. */
28312080
28322081 ; return 0; }
28332082 EOF
2834 if { (eval echo configure:2836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2083 if { (eval echo configure:2085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
28352084 rm -rf conftest*
28362085 eval "ac_cv_func__doprnt=yes"
28372086 else
28562105 fi
28572106
28582107 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
2859 echo "configure:2861: checking return type of signal handlers" >&5
2108 echo "configure:2110: checking return type of signal handlers" >&5
28602109 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
28612110 echo $ac_n "(cached) $ac_c" 1>&6
28622111 else
28632112 cat > conftest.$ac_ext <<EOF
2864 #line 2866 "configure"
2113 #line 2115 "configure"
28652114 #include "confdefs.h"
28662115 #include <sys/types.h>
28672116 #include <signal.h>
28782127 int i;
28792128 ; return 0; }
28802129 EOF
2881 if { (eval echo configure:2883: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2130 if { (eval echo configure:2132: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
28822131 rm -rf conftest*
28832132 ac_cv_type_signal=void
28842133 else
28962145 EOF
28972146
28982147
2899 for ac_func in getcwd gethostname mkdir re_comp regcomp select snprintf socket strdup strerror strstr fstat fchmod fchown utime utimes memmove sigset vsnprintf waitpid
2148 for ac_func in getcwd gethostname mkdir re_comp regcomp select snprintf socket strdup strerror strstr fstat fchmod fchown utime utimes memmove sigset vsnprintf waitpid random srandom
29002149 do
29012150 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
2902 echo "configure:2904: checking for $ac_func" >&5
2151 echo "configure:2153: checking for $ac_func" >&5
29032152 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
29042153 echo $ac_n "(cached) $ac_c" 1>&6
29052154 else
29062155 cat > conftest.$ac_ext <<EOF
2907 #line 2909 "configure"
2156 #line 2158 "configure"
29082157 #include "confdefs.h"
29092158 /* System header to define __stub macros and hopefully few prototypes,
29102159 which can conflict with char $ac_func(); below. */
29272176
29282177 ; return 0; }
29292178 EOF
2930 if { (eval echo configure:2932: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2179 if { (eval echo configure:2181: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
29312180 rm -rf conftest*
29322181 eval "ac_cv_func_$ac_func=yes"
29332182 else
29522201 done
29532202
29542203 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
2955 echo "configure:2957: checking for socket in -lsocket" >&5
2204 echo "configure:2206: checking for socket in -lsocket" >&5
29562205 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
29572206 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
29582207 echo $ac_n "(cached) $ac_c" 1>&6
29602209 ac_save_LIBS="$LIBS"
29612210 LIBS="-lsocket $LIBS"
29622211 cat > conftest.$ac_ext <<EOF
2963 #line 2965 "configure"
2212 #line 2214 "configure"
29642213 #include "confdefs.h"
29652214 /* Override any gcc2 internal prototype to avoid an error. */
29662215 /* We use char because int might match the return type of a gcc2
29712220 socket()
29722221 ; return 0; }
29732222 EOF
2974 if { (eval echo configure:2976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2223 if { (eval echo configure:2225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
29752224 rm -rf conftest*
29762225 eval "ac_cv_lib_$ac_lib_var=yes"
29772226 else
29922241 fi
29932242
29942243 echo $ac_n "checking for t_accept in -lnsl""... $ac_c" 1>&6
2995 echo "configure:2997: checking for t_accept in -lnsl" >&5
2244 echo "configure:2246: checking for t_accept in -lnsl" >&5
29962245 ac_lib_var=`echo nsl'_'t_accept | sed 'y%./+-%__p_%'`
29972246 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
29982247 echo $ac_n "(cached) $ac_c" 1>&6
30002249 ac_save_LIBS="$LIBS"
30012250 LIBS="-lnsl $LIBS"
30022251 cat > conftest.$ac_ext <<EOF
3003 #line 3005 "configure"
2252 #line 2254 "configure"
30042253 #include "confdefs.h"
30052254 /* Override any gcc2 internal prototype to avoid an error. */
30062255 /* We use char because int might match the return type of a gcc2
30112260 t_accept()
30122261 ; return 0; }
30132262 EOF
3014 if { (eval echo configure:3016: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
2263 if { (eval echo configure:2265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
30152264 rm -rf conftest*
30162265 eval "ac_cv_lib_$ac_lib_var=yes"
30172266 else
30322281 fi
30332282
30342283
2284 echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6
2285 echo "configure:2287: checking for readline in -lreadline" >&5
2286 ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'`
2287 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
2288 echo $ac_n "(cached) $ac_c" 1>&6
2289 else
2290 ac_save_LIBS="$LIBS"
2291 LIBS="-lreadline $LIBS"
2292 cat > conftest.$ac_ext <<EOF
2293 #line 2295 "configure"
2294 #include "confdefs.h"
2295 /* Override any gcc2 internal prototype to avoid an error. */
2296 /* We use char because int might match the return type of a gcc2
2297 builtin and then its argument prototype would still apply. */
2298 char readline();
2299
2300 int main() {
2301 readline()
2302 ; return 0; }
2303 EOF
2304 if { (eval echo configure:2306: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
2305 rm -rf conftest*
2306 eval "ac_cv_lib_$ac_lib_var=yes"
2307 else
2308 echo "configure: failed program was:" >&5
2309 cat conftest.$ac_ext >&5
2310 rm -rf conftest*
2311 eval "ac_cv_lib_$ac_lib_var=no"
2312 fi
2313 rm -f conftest*
2314 LIBS="$ac_save_LIBS"
2315
2316 fi
2317 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
2318 echo "$ac_t""yes" 1>&6
2319 RL_LIBS="-lreadline"
2320 else
2321 echo "$ac_t""no" 1>&6
2322 fi
2323
2324
2325
2326 echo $ac_n "checking for gsm_decode in -lgsm""... $ac_c" 1>&6
2327 echo "configure:2329: checking for gsm_decode in -lgsm" >&5
2328 ac_lib_var=`echo gsm'_'gsm_decode | sed 'y%./+-%__p_%'`
2329 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
2330 echo $ac_n "(cached) $ac_c" 1>&6
2331 else
2332 ac_save_LIBS="$LIBS"
2333 LIBS="-lgsm $LIBS"
2334 cat > conftest.$ac_ext <<EOF
2335 #line 2337 "configure"
2336 #include "confdefs.h"
2337 /* Override any gcc2 internal prototype to avoid an error. */
2338 /* We use char because int might match the return type of a gcc2
2339 builtin and then its argument prototype would still apply. */
2340 char gsm_decode();
2341
2342 int main() {
2343 gsm_decode()
2344 ; return 0; }
2345 EOF
2346 if { (eval echo configure:2348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
2347 rm -rf conftest*
2348 eval "ac_cv_lib_$ac_lib_var=yes"
2349 else
2350 echo "configure: failed program was:" >&5
2351 cat conftest.$ac_ext >&5
2352 rm -rf conftest*
2353 eval "ac_cv_lib_$ac_lib_var=no"
2354 fi
2355 rm -f conftest*
2356 LIBS="$ac_save_LIBS"
2357
2358 fi
2359 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
2360 echo "$ac_t""yes" 1>&6
2361 HAVE_GSM="yes"
2362 else
2363 echo "$ac_t""no" 1>&6
2364 fi
2365
2366 if test "$HAVE_GSM" = "yes"; then
2367 GSM_LIBS="-lgsm"
2368 GSM_INCS=""
2369 else
2370 GSM_LIBS="-L../gsm -lgsm"
2371 GSM_INCS="-I\${srcdir}/../gsm"
2372 fi
2373
2374
2375
2376 echo $ac_n "checking for regncomp in -lrx""... $ac_c" 1>&6
2377 echo "configure:2379: checking for regncomp in -lrx" >&5
2378 ac_lib_var=`echo rx'_'regncomp | sed 'y%./+-%__p_%'`
2379 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
2380 echo $ac_n "(cached) $ac_c" 1>&6
2381 else
2382 ac_save_LIBS="$LIBS"
2383 LIBS="-lrx $LIBS"
2384 cat > conftest.$ac_ext <<EOF
2385 #line 2387 "configure"
2386 #include "confdefs.h"
2387 /* Override any gcc2 internal prototype to avoid an error. */
2388 /* We use char because int might match the return type of a gcc2
2389 builtin and then its argument prototype would still apply. */
2390 char regncomp();
2391
2392 int main() {
2393 regncomp()
2394 ; return 0; }
2395 EOF
2396 if { (eval echo configure:2398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
2397 rm -rf conftest*
2398 eval "ac_cv_lib_$ac_lib_var=yes"
2399 else
2400 echo "configure: failed program was:" >&5
2401 cat conftest.$ac_ext >&5
2402 rm -rf conftest*
2403 eval "ac_cv_lib_$ac_lib_var=no"
2404 fi
2405 rm -f conftest*
2406 LIBS="$ac_save_LIBS"
2407
2408 fi
2409 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
2410 echo "$ac_t""yes" 1>&6
2411 HAVE_RX="yes"
2412 else
2413 echo "$ac_t""no" 1>&6
2414 fi
2415
2416 if test "$HAVE_RX" = "yes"; then
2417 RX_LIBS="-lrx"
2418 RX_INCS=""
2419 else
2420 RX_LIBS="-L../rx -lrx"
2421 RX_INCS="-I\${srcdir}/../rx"
2422 fi
2423
2424
2425
30352426 RPLAY_TOP=`pwd`
30362427
30372428
30422433
30432434 if test -z "$RPLAY_TARGET"; then
30442435 echo $ac_n "checking for sun""... $ac_c" 1>&6
3045 echo "configure:3047: checking for sun" >&5
2436 echo "configure:2438: checking for sun" >&5
30462437 cat > conftest.$ac_ext <<EOF
3047 #line 3049 "configure"
2438 #line 2440 "configure"
30482439 #include "confdefs.h"
30492440
30502441 #ifdef sun
30682459 fi
30692460 if test "$RPLAY_TARGET"; then
30702461 echo $ac_n "checking for solaris""... $ac_c" 1>&6
3071 echo "configure:3073: checking for solaris" >&5
2462 echo "configure:2464: checking for solaris" >&5
30722463 if test ! -f /vmunix; then
30732464 is_solaris=yes
30742465 RPLAY_TARGET="solaris"
30812472
30822473 if test -z "$RPLAY_TARGET"; then
30832474 echo $ac_n "checking for linux""... $ac_c" 1>&6
3084 echo "configure:3086: checking for linux" >&5
2475 echo "configure:2477: checking for linux" >&5
30852476 cat > conftest.$ac_ext <<EOF
3086 #line 3088 "configure"
2477 #line 2479 "configure"
30872478 #include "confdefs.h"
30882479
30892480 #ifdef linux
31092500
31102501 if test -z "$RPLAY_TARGET"; then
31112502 echo $ac_n "checking for hpux""... $ac_c" 1>&6
3112 echo "configure:3114: checking for hpux" >&5
2503 echo "configure:2505: checking for hpux" >&5
31132504 cat > conftest.$ac_ext <<EOF
3114 #line 3116 "configure"
2505 #line 2507 "configure"
31152506 #include "confdefs.h"
31162507
31172508 #ifdef __hpux
31372528
31382529 if test -z "$RPLAY_TARGET"; then
31392530 echo $ac_n "checking for sgi""... $ac_c" 1>&6
3140 echo "configure:3142: checking for sgi" >&5
2531 echo "configure:2533: checking for sgi" >&5
31412532 cat > conftest.$ac_ext <<EOF
3142 #line 3144 "configure"
2533 #line 2535 "configure"
31432534 #include "confdefs.h"
31442535
31452536 #ifdef sgi
31612552 if test $is_sgi = "yes"; then
31622553 RPLAY_TARGET="sgi"
31632554 echo $ac_n "checking for multimedia development kit""... $ac_c" 1>&6
3164 echo "configure:3166: checking for multimedia development kit" >&5
2555 echo "configure:2557: checking for multimedia development kit" >&5
31652556 for ac_hdr in audio.h
31662557 do
31672558 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
31682559 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
3169 echo "configure:3171: checking for $ac_hdr" >&5
2560 echo "configure:2562: checking for $ac_hdr" >&5
31702561 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
31712562 echo $ac_n "(cached) $ac_c" 1>&6
31722563 else
31732564 cat > conftest.$ac_ext <<EOF
3174 #line 3176 "configure"
2565 #line 2567 "configure"
31752566 #include "confdefs.h"
31762567 #include <$ac_hdr>
31772568 EOF
31782569 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
3179 { (eval echo configure:3181: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
3180 ac_err=`grep -v '^ *+' conftest.out`
2570 { (eval echo configure:2572: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
2571 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
31812572 if test -z "$ac_err"; then
31822573 rm -rf conftest*
31832574 eval "ac_cv_header_$ac_safe=yes"
32122603
32132604 if test -z "$RPLAY_TARGET"; then
32142605 echo $ac_n "checking for FreeBSD""... $ac_c" 1>&6
3215 echo "configure:3217: checking for FreeBSD" >&5
2606 echo "configure:2608: checking for FreeBSD" >&5
32162607 cat > conftest.$ac_ext <<EOF
3217 #line 3219 "configure"
2608 #line 2610 "configure"
32182609 #include "confdefs.h"
32192610
32202611 #ifdef __FreeBSD__
32672658 fi
32682659
32692660
3270 BUILD_TARGETS="include lib rx adpcm gsm librplay rplayd rplay rptp doc"
3271
3272
3273 subdirs="rx"
2661 BUILD_TARGETS="include lib adpcm"
2662 if test "$HAVE_RX" != "yes"; then
2663 BUILD_TARGETS="$BUILD_TARGETS rx"
2664 subdirs="rx"
2665
2666 fi
2667 if test "$HAVE_GSM" != "yes"; then
2668 BUILD_TARGETS="$BUILD_TARGETS gsm"
2669 fi
2670
2671 BUILD_TARGETS="$BUILD_TARGETS librplay rplayd rplay rptp doc"
2672
2673 if test $RPLAY_TARGET = "oss"; then
2674 BUILD_TARGETS="$BUILD_TARGETS devrplay"
2675 fi
2676
2677
32742678
32752679 trap '' 1 2 15
32762680 cat > confcache <<\EOF
32952699 # Ultrix sh set writes to stderr and can't be redirected directly,
32962700 # and sets the high bit in the cache file unless we assign to the vars.
32972701 (set) 2>&1 |
3298 case `(ac_space=' '; set) 2>&1` in
2702 case `(ac_space=' '; set | grep ac_space) 2>&1` in
32992703 *ac_space=\ *)
33002704 # `set' does not quote correctly, so add quotes (double-quote substitution
33012705 # turns \\\\ into \\, and sed turns \\ into \).
33622766 echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
33632767 exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
33642768 -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
3365 echo "$CONFIG_STATUS generated by autoconf version 2.12"
2769 echo "$CONFIG_STATUS generated by autoconf version 2.13"
33662770 exit 0 ;;
33672771 -help | --help | --hel | --he | --h)
33682772 echo "\$ac_cs_usage"; exit 0 ;;
33732777 ac_given_srcdir=$srcdir
33742778 ac_given_INSTALL="$INSTALL"
33752779
3376 trap 'rm -fr `echo "Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
2780 trap 'rm -fr `echo "Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile devrplay/Makefile include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
33772781 EOF
33782782 cat >> $CONFIG_STATUS <<EOF
33792783
33822786 s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
33832787 $ac_vpsub
33842788 $extrasub
2789 s%@SHELL@%$SHELL%g
33852790 s%@CFLAGS@%$CFLAGS%g
33862791 s%@CPPFLAGS@%$CPPFLAGS%g
33872792 s%@CXXFLAGS@%$CXXFLAGS%g
2793 s%@FFLAGS@%$FFLAGS%g
33882794 s%@DEFS@%$DEFS%g
33892795 s%@LDFLAGS@%$LDFLAGS%g
33902796 s%@LIBS@%$LIBS%g
34072813 s%@CC@%$CC%g
34082814 s%@CPP@%$CPP%g
34092815 s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
2816 s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
34102817 s%@INSTALL_DATA@%$INSTALL_DATA%g
34112818 s%@LN_S@%$LN_S%g
34122819 s%@RANLIB@%$RANLIB%g
34162823 s%@TEXI2DVI@%$TEXI2DVI%g
34172824 s%@TEXI2HTML@%$TEXI2HTML%g
34182825 s%@DVIPS@%$DVIPS%g
3419 s%@X_CFLAGS@%$X_CFLAGS%g
3420 s%@X_PRE_LIBS@%$X_PRE_LIBS%g
3421 s%@X_LIBS@%$X_LIBS%g
3422 s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g
34232826 s%@LIBOBJS@%$LIBOBJS%g
2827 s%@RL_LIBS@%$RL_LIBS%g
2828 s%@GSM_LIBS@%$GSM_LIBS%g
2829 s%@GSM_INCS@%$GSM_INCS%g
2830 s%@RX_LIBS@%$RX_LIBS%g
2831 s%@RX_INCS@%$RX_INCS%g
34242832 s%@RPLAY_TOP@%$RPLAY_TOP%g
34252833 s%@RPLAY_TARGET@%$RPLAY_TARGET%g
2834 s%@subdirs@%$subdirs%g
34262835 s%@BUILD_TARGETS@%$BUILD_TARGETS%g
3427 s%@subdirs@%$subdirs%g
34282836
34292837 CEOF
34302838 EOF
34662874
34672875 cat >> $CONFIG_STATUS <<EOF
34682876
3469 CONFIG_FILES=\${CONFIG_FILES-"Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile"}
2877 CONFIG_FILES=\${CONFIG_FILES-"Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile devrplay/Makefile"}
34702878 EOF
34712879 cat >> $CONFIG_STATUS <<\EOF
34722880 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
0 dnl $Id: configure.in,v 1.2 1998/08/13 06:13:07 boyns Exp $
0 dnl $Id: configure.in,v 1.5 1999/06/09 06:26:28 boyns Exp $
11 dnl
22 dnl Process this file with autoconf to produce a configure script.
33 dnl
5656 AC_HEADER_DIRENT
5757 AC_HEADER_STDC
5858 AC_HEADER_TIME
59 AC_PATH_XTRA
60 AC_CHECK_HEADERS(fcntl.h sys/file.h sys/ioctl.h sys/time.h stdlib.h unistd.h memory.h string.h strings.h utime.h limits.h forms.h X11/forms.h)
59 dnl AC_PATH_XTRA
60 AC_CHECK_HEADERS(fcntl.h sys/file.h sys/ioctl.h sys/time.h stdlib.h unistd.h memory.h string.h strings.h utime.h limits.h gsm.h gsm/gsm.h rxposix.h rx/rxposix.h)
6161 AC_HEADER_SYS_WAIT
6262
6363 dnl Check for typedefs, structures, and compiler characteristics.
6969 AC_FUNC_MEMCMP
7070 AC_FUNC_VPRINTF
7171 AC_TYPE_SIGNAL
72 AC_CHECK_FUNCS(getcwd gethostname mkdir re_comp regcomp select snprintf socket strdup strerror strstr fstat fchmod fchown utime utimes memmove sigset vsnprintf waitpid)
72 AC_CHECK_FUNCS(getcwd gethostname mkdir re_comp regcomp select snprintf socket strdup strerror strstr fstat fchmod fchown utime utimes memmove sigset vsnprintf waitpid random srandom)
7373 AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"])
7474 AC_CHECK_LIB(nsl, t_accept, [LIBS="$LIBS -lnsl"])
75
76 AC_CHECK_LIB(readline, readline, [RL_LIBS="-lreadline"])
77 AC_SUBST(RL_LIBS)
78
79 AC_CHECK_LIB(gsm, gsm_decode, [HAVE_GSM="yes"])
80 if test "$HAVE_GSM" = "yes"; then
81 GSM_LIBS="-lgsm"
82 GSM_INCS=""
83 else
84 GSM_LIBS="-L../gsm -lgsm"
85 GSM_INCS="-I\${srcdir}/../gsm"
86 fi
87 AC_SUBST(GSM_LIBS)
88 AC_SUBST(GSM_INCS)
89
90 AC_CHECK_LIB(rx, regncomp, [HAVE_RX="yes"])
91 if test "$HAVE_RX" = "yes"; then
92 RX_LIBS="-lrx"
93 RX_INCS=""
94 else
95 RX_LIBS="-L../rx -lrx"
96 RX_INCS="-I\${srcdir}/../rx"
97 fi
98 AC_SUBST(RX_LIBS)
99 AC_SUBST(RX_INCS)
75100
76101 RPLAY_TOP=`pwd`
77102 AC_SUBST(RPLAY_TOP)
224249 fi
225250 AC_SUBST(LIBS)
226251
227 BUILD_TARGETS="include lib rx adpcm gsm librplay rplayd rplay rptp doc"
252 BUILD_TARGETS="include lib adpcm"
253 if test "$HAVE_RX" != "yes"; then
254 BUILD_TARGETS="$BUILD_TARGETS rx"
255 AC_CONFIG_SUBDIRS(rx)
256 fi
257 if test "$HAVE_GSM" != "yes"; then
258 BUILD_TARGETS="$BUILD_TARGETS gsm"
259 fi
260
261 BUILD_TARGETS="$BUILD_TARGETS librplay rplayd rplay rptp doc"
262
263 if test $RPLAY_TARGET = "oss"; then
264 BUILD_TARGETS="$BUILD_TARGETS devrplay"
265 fi
266
228267 AC_SUBST(BUILD_TARGETS)
229268
230 AC_CONFIG_SUBDIRS(rx)
231 AC_OUTPUT(Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile)
269 AC_OUTPUT(Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile devrplay/Makefile)
+0
-13
contrib/CVS/Entries less more
0 /README.crossfire/1.1.1.1/Tue Jul 14 22:35:22 1998//
1 /mailnoise/1.1.1.1/Tue Jul 14 22:35:22 1998//
2 D/cdrplay////
3 D/fingergoodies////
4 D/jukebox-1.3////
5 D/mailsound////
6 D/pos////
7 D/rplaytool-1.1////
8 D/tkrplay////
9 D/vu////
10 D/window_managers////
11 D/xjukebox-0.9////
12 D/xpilot////
+0
-1
contrib/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib
+0
-1
contrib/CVS/Root less more
0 /usr/local/cvsroot
+0
-2
contrib/cdrplay/CVS/Entries less more
0 /cdrplay.c/1.2/Thu Aug 13 06:13:18 1998//
1 D
+0
-1
contrib/cdrplay/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/cdrplay
+0
-1
contrib/cdrplay/CVS/Root less more
0 /usr/local/cvsroot
0 /* $Id: cdrplay.c,v 1.2 1998/08/13 06:13:18 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1996 Mark Boyns <boyns@sdsu.edu>
0 /* $Id: cdrplay.c,v 1.3 1999/03/10 07:51:42 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
5 * This file is part of cdrplay.
5 * This file is part of rplay.
66 *
7 * This program is free software; you can redistribute it and/or modify
7 * rplay is free software; you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
99 * the Free Software Foundation; either version 2 of the License, or
1010 * (at your option) any later version.
1111 *
12 * This program is distributed in the hope that it will be useful,
12 * rplay is distributed in the hope that it will be useful,
1313 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1414 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515 * GNU General Public License for more details.
1616 *
1717 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * along with rplay; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2021 */
2122
2223 /* A lot of the CDDA code is based on read_cdda 1.01 by Jim Mintha
+0
-4
contrib/fingergoodies/CVS/Entries less more
0 /.fingerrc/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /getcalleraddr.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
2 /random.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
3 D
+0
-1
contrib/fingergoodies/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/fingergoodies
+0
-1
contrib/fingergoodies/CVS/Root less more
0 /usr/local/cvsroot
+0
-3
contrib/jukebox-1.3/CVS/Entries less more
0 /Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 D/man1////
2 /jukebox.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
+0
-1
contrib/jukebox-1.3/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/jukebox-1.3
+0
-1
contrib/jukebox-1.3/CVS/Root less more
0 /usr/local/cvsroot
+0
-2
contrib/jukebox-1.3/man1/CVS/Entries less more
0 /jukebox.1/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 D
+0
-1
contrib/jukebox-1.3/man1/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/jukebox-1.3/man1
+0
-1
contrib/jukebox-1.3/man1/CVS/Root less more
0 /usr/local/cvsroot
+0
-4
contrib/mailsound/CVS/Entries less more
0 /Makefile/1.1.1.1/Tue Jul 14 22:35:22 1998//
1 /mailsound.1/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /mailsound.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
3 D
+0
-1
contrib/mailsound/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/mailsound
+0
-1
contrib/mailsound/CVS/Root less more
0 /usr/local/cvsroot
+0
-3
contrib/pos/CVS/Entries less more
0 /Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /pos.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
2 D
+0
-1
contrib/pos/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/pos
+0
-1
contrib/pos/CVS/Root less more
0 /usr/local/cvsroot
+0
-20
contrib/rplaytool-1.1/CVS/Entries less more
0 /COPYING/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /ChangeLog/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 /README/1.1.1.1/Tue Jul 14 22:35:23 1998//
4 /list/1.1.1.1/Tue Jul 14 22:35:23 1998//
5 /rplaytool.G/1.1.1.1/Tue Jul 14 22:35:23 1998//
6 /rplaytool.P/1.1.1.1/Tue Jul 14 22:35:23 1998//
7 /rplaytool.info/1.1.1.1/Tue Jul 14 22:35:23 1998//
8 /rplaytool.make/1.1.1.1/Tue Jul 14 22:35:23 1998//
9 D/icons////
10 /misc.c/1.2/Thu Aug 13 06:13:19 1998//
11 /misc.h/1.2/Thu Aug 13 06:13:20 1998//
12 /rptp.c/1.2/Thu Aug 13 06:13:21 1998//
13 /rptp.h/1.2/Thu Aug 13 06:13:22 1998//
14 /getopt.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
15 /getopt.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
16 /getopt1.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
17 /rplaytool_stubs.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
18 /rplaytool_ui.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
19 /rplaytool_ui.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
+0
-1
contrib/rplaytool-1.1/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/rplaytool-1.1
+0
-1
contrib/rplaytool-1.1/CVS/Root less more
0 /usr/local/cvsroot
+0
-19
contrib/rplaytool-1.1/icons/CVS/Entries less more
0 /arrow.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /directory.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /file.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 /none.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
4 /pause.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
5 /pause1.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
6 /pause2.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
7 /pause3.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
8 /pause4.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
9 /play.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
10 /play1.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
11 /play2.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
12 /play3.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
13 /play4.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
14 /rplaytool.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
15 /rplaytool_mask.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
16 /sound.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
17 /watch.icon/1.1.1.1/Tue Jul 14 22:35:23 1998//
18 D
+0
-1
contrib/rplaytool-1.1/icons/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/rplaytool-1.1/icons
+0
-1
contrib/rplaytool-1.1/icons/CVS/Root less more
0 /usr/local/cvsroot
+0
-4
contrib/tkrplay/CVS/Entries less more
0 /README/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /foo/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /tkrplay/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 D
+0
-1
contrib/tkrplay/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/tkrplay
+0
-1
contrib/tkrplay/CVS/Root less more
0 /usr/local/cvsroot
+0
-4
contrib/vu/CVS/Entries less more
0 /Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /vu.1/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /vu.c/1.1.1.1/Thu Aug 13 06:09:36 1998//
3 D
+0
-1
contrib/vu/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/vu
+0
-1
contrib/vu/CVS/Root less more
0 /usr/local/cvsroot
+0
-5
contrib/window_managers/CVS/Entries less more
0 /ctwm/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /fvwm/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /tvtwm/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 /twm/1.1.1.1/Tue Jul 14 22:35:23 1998//
4 D/olvwm////
+0
-1
contrib/window_managers/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/window_managers
+0
-1
contrib/window_managers/CVS/Root less more
0 /usr/local/cvsroot
+0
-5
contrib/window_managers/olvwm/CVS/Entries less more
0 /.olvwm-sounds/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /README/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /olvwm-3.3-patch/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 /olvwm.events/1.1.1.1/Tue Jul 14 22:35:23 1998//
4 D
+0
-1
contrib/window_managers/olvwm/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/window_managers/olvwm
+0
-1
contrib/window_managers/olvwm/CVS/Root less more
0 /usr/local/cvsroot
+0
-15
contrib/xjukebox-0.9/CVS/Entries less more
0 /INSTALL/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /Imakefile/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 /README/1.1.1.1/Tue Jul 14 22:35:23 1998//
4 /TODO/1.1.1.1/Tue Jul 14 22:35:23 1998//
5 /XJukebox-color.ad/1.1.1.1/Tue Jul 14 22:35:23 1998//
6 /XJukebox.ad/1.1.1.1/Tue Jul 14 22:35:23 1998//
7 /ad2c/1.1.1.1/Tue Jul 14 22:35:23 1998//
8 /xjukebox.xpm/1.1.1.1/Tue Jul 14 22:35:23 1998//
9 /XJukebox.ad.h/1.1.1.1/Thu Aug 13 06:09:36 1998//
10 /rptpstuff.c/1.1.1.1/Thu Aug 13 06:09:36 1998//
11 /widgets.c/1.1.1.1/Thu Aug 13 06:09:36 1998//
12 /xjukebox.c/1.1.1.1/Thu Aug 13 06:09:36 1998//
13 /xjukebox.h/1.1.1.1/Thu Aug 13 06:09:36 1998//
14 D
+0
-1
contrib/xjukebox-0.9/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/xjukebox-0.9
+0
-1
contrib/xjukebox-0.9/CVS/Root less more
0 /usr/local/cvsroot
+0
-9
contrib/xpilot/CVS/Entries less more
0 /README/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /arnold_sounds/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /ren+stimpy_sounds/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 /sounds/1.1.1.1/Tue Jul 14 22:35:23 1998//
4 /sounds-3.1.0/1.1.1.1/Tue Jul 14 22:35:23 1998//
5 /sounds-simpsons/1.1.1.1/Tue Jul 14 22:35:23 1998//
6 /st_sounds/1.1.1.1/Tue Jul 14 22:35:23 1998//
7 /sttng_sounds/1.1.1.1/Tue Jul 14 22:35:23 1998//
8 D
+0
-1
contrib/xpilot/CVS/Repository less more
0 /usr/local/cvsroot/rplay/contrib/xpilot
+0
-1
contrib/xpilot/CVS/Root less more
0 /usr/local/cvsroot
0 include @RPLAY_TOP@/Makefile.config
1
2 srcdir = @srcdir@
3 VPATH = @srcdir@
4
5 INSTALL = @INSTALL@
6 INSTALL_PROGRAM = @INSTALL_PROGRAM@
7 INSTALL_DATA = @INSTALL_DATA@
8 MKINSTALLDIRS= @srcdir@/../mkinstalldirs
9
10 CPPFLAGS= $(CC_OPTIONS) -fPIC -I. -I../include -I@srcdir@/../include @DEFS@
11
12 .c.o:
13 $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
14
15 LDFLAGS= $(LD_OPTIONS) -shared @LDFLAGS@ @LIBS@ -L../librplay -lrplay -ldl
16
17 TARGET= devrplay.so
18 SRCS= devrplay.c
19 OBJS= devrplay.o
20
21 all: $(TARGET)
22
23 #$(TARGET): $(OBJS) ../librplay/librplay.so
24 # $(CC) -o $@ $(OBJS) ../librplay/rplay.lo ../librplay/rptp.lo $(LDFLAGS)
25
26 $(TARGET): $(OBJS) ../librplay/librplay.so
27 $(CC) -o $@ $(OBJS) $(LDFLAGS)
28
29 ../librplay/librplay.so:
30 (cd ../librplay; $(MAKE) $(MFLAGS) librplay.so)
31
32 install: all
33 $(MKINSTALLDIRS) $(libdir)
34 $(INSTALL_DATA) $(TARGET) $(libdir)
35
36 uninstall:
37 $(RM) $(libdir)/$(TARGET)
38
39 clean:
40 $(RM) $(OBJS) $(TARGET) a.out core *~ *.bak *.orig TAGS
41
42 distclean: clean
43 $(RM) Makefile
44
45 tags:
46 $(TAGS) *.[ch]
47
48 TAGS: tags
49
50 etags: tags
51
52 depend:
53 $(MAKEDEPEND) -- $(CPPFLAGS) $(CFLAGS) -- $(SRCS)
54
0 /* $Id: devrplay.c,v 1.4 1999/03/21 00:44:48 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
4 *
5 * This file is part of rplay.
6 *
7 * rplay is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * rplay is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with rplay; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23 /*
24 * based on esddsp.c
25 * Copyright (C) 1998, 1999 Manish Singh <yosh@gimp.org>
26 */
27
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31 #include <stdarg.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <unistd.h>
35 #include <fcntl.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 #include <sys/time.h>
39 #include <stdio.h>
40 #include "rplay.h"
41
42 #define DEVRPLAY_SOUND "devrplay"
43
44 #ifdef linux
45
46 #include <sys/soundcard.h>
47 #include <dlfcn.h>
48 #define REAL_LIBC RTLD_NEXT
49
50 static int rplay_fd = -1;
51 static int spool_id = -1;
52 static int dsp_fmt;
53 static int dsp_speed;
54 static int dsp_channels;
55 static int dsp_speed;
56 static int dsp_blksize;
57 static int streaming;
58
59 static char *
60 getsound()
61 {
62 char *p = getenv("DEVRPLAY_SOUND");
63 return p ? p : DEVRPLAY_SOUND;
64 }
65
66 static char *
67 getinfo()
68 {
69 char *p = getenv("DEVRPLAY_INFO");
70 return p ? p : 0;
71 }
72
73 static char *
74 getopts()
75 {
76 char *p = getenv("DEVRPLAY_OPTS");
77 return p ? p : 0;
78 }
79
80 int
81 open(const char *pathname, int flags,...)
82 {
83 static int (*func)(const char *, int, mode_t) = NULL;
84 va_list args;
85 mode_t mode;
86 char response[RPTP_MAX_LINE];
87
88 if (!func)
89 func = (int (*)(const char *, int, mode_t)) dlsym(REAL_LIBC, "open");
90
91 va_start(args, flags);
92 mode = va_arg(args, mode_t);
93 va_end(args);
94
95 if (strcmp(pathname, "/dev/dsp") == 0)
96 {
97 rplay_fd = rptp_open(rplay_default_host(), RPTP_PORT, response,
98 sizeof(response));
99 if (rplay_fd < 0)
100 {
101 rptp_perror(rplay_default_host());
102 }
103 return rplay_fd;
104 }
105 else
106 {
107 return (*func)(pathname, flags, mode);
108 }
109 }
110
111 static int
112 dspctl(int fd, int request, void *argp)
113 {
114 int *arg = (int *) argp;
115
116 switch (request)
117 {
118 case SNDCTL_DSP_SETFMT:
119 dsp_fmt = *arg;
120 break;
121
122 case SNDCTL_DSP_SPEED:
123 dsp_speed = *arg;
124 break;
125
126 case SNDCTL_DSP_STEREO:
127 dsp_channels = *arg ? 2 : 1;
128 break;
129
130 case SNDCTL_DSP_CHANNELS:
131 dsp_channels = *arg;
132 break;
133
134 case SNDCTL_DSP_GETBLKSIZE:
135 *arg = 65535;
136 break;
137
138 case SNDCTL_DSP_GETFMTS:
139 *arg = 0x38;
140 break;
141
142 case SNDCTL_DSP_GETCAPS:
143 *arg = 0;
144 break;
145
146 case SNDCTL_DSP_GETOSPACE:
147 {
148 audio_buf_info *info = (audio_buf_info *) argp;
149 info->fragments = 16;
150 info->fragstotal = 16;
151 info->fragsize = 4096;
152 info->bytes = 44100;
153 }
154 break;
155
156 default:
157 break;
158 }
159
160 if (spool_id == -1 && dsp_fmt && dsp_speed && dsp_channels)
161 {
162 char response[RPTP_MAX_LINE];
163
164 streaming = 1;
165 rptp_putline(rplay_fd,
166 "play input=flow input-info=%s,%d,%d,%d,%s %s sound=\"%s\"",
167 dsp_fmt == 16 ? "linear16" : "ulinear8",
168 dsp_speed,
169 dsp_fmt,
170 dsp_channels,
171 "little-endian",
172 getopts(),
173 getsound());
174 rptp_getline(rplay_fd, response, sizeof(response));
175
176 spool_id = atoi(1 + rptp_parse(response, "id"));
177
178 rptp_putline(rplay_fd, "put id=#%d size=0", spool_id);
179 rptp_getline(rplay_fd, response, sizeof(response));
180 }
181
182 return 0;
183 }
184
185 int
186 ioctl(int fd, int request,...)
187 {
188 static int (*func)(int, int, void *) = NULL;
189 va_list args;
190 void *argp;
191
192 if (!func)
193 func = (int (*)(int, int, void *)) dlsym(REAL_LIBC, "ioctl");
194 va_start(args, request);
195 argp = va_arg(args, void *);
196 va_end(args);
197
198 if (fd != rplay_fd)
199 {
200 return (*func)(fd, request, argp);
201 }
202 else if (fd == rplay_fd)
203 {
204 return dspctl(fd, request, argp);
205 }
206 }
207
208 ssize_t
209 write(int fd, const void *buf, size_t count)
210 {
211 static int (*func)(int, const void *, size_t) = NULL;
212
213 if (!func)
214 func = (int (*)(int, const void *, size_t)) dlsym(REAL_LIBC, "write");
215
216 if (fd == rplay_fd && !streaming)
217 {
218 char info[64];
219 char response[RPTP_MAX_LINE];
220
221 info[0] = '\0';
222
223 /* use dsp defaults if something was specified */
224 if (dsp_speed || dsp_fmt || dsp_channels)
225 {
226 if (!dsp_speed) dsp_speed = 8000;
227 if (!dsp_fmt) dsp_fmt = 8;
228 if (!dsp_channels) dsp_channels = 1;
229 sprintf(info, "input-info=%s,%d,%d,%d,%s",
230 dsp_fmt == 16 ? "linear16" : "ulinear8",
231 dsp_speed,
232 dsp_fmt,
233 dsp_channels,
234 "little-endian");
235 }
236 /* try user specified sound info */
237 else if (getinfo())
238 {
239 strncpy(info, getinfo(), sizeof(info)-1);
240 }
241 /* otherwise let rplayd figure out the format using
242 the sound header and/or name. */
243
244 streaming = 1;
245 rptp_putline(rplay_fd, "play input=flow %s sound=\"%s\"",
246 info, getsound());
247 rptp_getline(rplay_fd, response, sizeof(response));
248
249 spool_id = atoi(1 + rptp_parse(response, "id"));
250
251 rptp_putline(rplay_fd, "put id=#%d size=0", spool_id);
252 rptp_getline(rplay_fd, response, sizeof(response));
253 }
254
255 return (*func)(fd, buf, count);
256 }
257
258 int
259 close(int fd)
260 {
261 static int (*func)(int) = NULL;
262
263 if (!func)
264 func = (int (*)(int)) dlsym(REAL_LIBC, "close");
265
266 if (fd == rplay_fd)
267 {
268 rplay_fd = -1;
269 spool_id = -1;
270 streaming = 0;
271 dsp_fmt = dsp_speed = dsp_channels = dsp_speed = dsp_blksize = 0;
272 }
273
274 return (*func)(fd);
275 }
276
277 #endif /* linux */
+0
-21
doc/CVS/Entries less more
0 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /RPLAY.info/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /RPLAY.texi/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 /RPTP.info/1.1.1.1/Tue Jul 14 22:35:23 1998//
4 /RPTP.texi/1.1.1.1/Tue Jul 14 22:35:23 1998//
5 /genman/1.1.1.1/Tue Jul 14 22:35:23 1998//
6 /librplay.info/1.1.1.1/Tue Jul 14 22:35:23 1998//
7 /librplay.texi/1.1.1.1/Tue Jul 14 22:35:23 1998//
8 /rplay.1/1.1.1.1/Tue Jul 14 22:35:23 1998//
9 /rplay.1.in/1.1.1.1/Tue Jul 14 22:35:23 1998//
10 /rplay.conf.5/1.1.1.1/Tue Jul 14 22:35:23 1998//
11 /rplay.helpers.5/1.1.1.1/Tue Jul 14 22:35:23 1998//
12 /rplay.hosts.5/1.1.1.1/Tue Jul 14 22:35:23 1998//
13 /rplay.info/1.1.1.1/Tue Jul 14 22:35:23 1998//
14 /rplay.servers.5/1.1.1.1/Tue Jul 14 22:35:23 1998//
15 /rplay.texi/1.1.1.1/Tue Jul 14 22:35:23 1998//
16 /rplayd.8/1.1.1.1/Tue Jul 14 22:35:23 1998//
17 /rplayd.8.in/1.1.1.1/Tue Jul 14 22:35:23 1998//
18 /rptp.1/1.1.1.1/Tue Jul 14 22:35:23 1998//
19 /rptp.1.in/1.1.1.1/Tue Jul 14 22:35:23 1998//
20 D
+0
-1
doc/CVS/Repository less more
0 /usr/local/cvsroot/rplay/doc
+0
-1
doc/CVS/Root less more
0 /usr/local/cvsroot
+0
-5
etc/CVS/Entries less more
0 /rplay.conf/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /rplay.hosts/1.1.1.1/Tue Jul 14 22:35:23 1998//
2 /rplay.servers/1.1.1.1/Tue Jul 14 22:35:23 1998//
3 /rplay.helpers/1.2/Tue Oct 6 05:48:44 1998//
4 D
+0
-1
etc/CVS/Repository less more
0 /usr/local/cvsroot/rplay/etc
+0
-1
etc/CVS/Root less more
0 /usr/local/cvsroot
+0
-5
examples/CVS/Entries less more
0 /async1.c/1.2/Thu Aug 13 06:13:23 1998//
1 /async2.c/1.2/Thu Aug 13 06:13:24 1998//
2 /flow1.c/1.2/Thu Aug 13 06:13:25 1998//
3 /level.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
4 D
+0
-1
examples/CVS/Repository less more
0 /usr/local/cvsroot/rplay/examples
+0
-1
examples/CVS/Root less more
0 /usr/local/cvsroot
0 /* $Id: async1.c,v 1.2 1998/08/13 06:13:23 boyns Exp $ */
0 /* $Id: async1.c,v 1.3 1998/11/07 21:15:11 boyns Exp $ */
11
22 #include <rplay.h>
33
4 static void event_callback (int fd, int event, char *line);
4 static void event_callback(int fd, int event, char *line);
55
6 main (int argc, char **argv)
6 main(int argc, char **argv)
77 {
88 char buf[RPTP_MAX_LINE];
99 int fd;
1010
11 fd = rptp_open (rplay_default_host (), RPTP_PORT, buf, sizeof (buf));
11 fd = rptp_open(rplay_default_host(), RPTP_PORT, buf, sizeof(buf));
1212
13 rptp_async_notify (fd,
14 RPTP_EVENT_PLAY|RPTP_EVENT_PAUSE|RPTP_EVENT_DONE|RPTP_EVENT_CONTINUE,
15 event_callback);
13 rptp_async_notify(fd,
14 RPTP_EVENT_PLAY | RPTP_EVENT_PAUSE | RPTP_EVENT_DONE | RPTP_EVENT_CONTINUE,
15 event_callback);
1616
17 rptp_main_loop ();
17 rptp_main_loop();
1818
19 exit (0);
19 exit(0);
2020 }
2121
22 static void
23 event_callback (int fd, int event, char *line)
22 static void
23 event_callback(int fd, int event, char *line)
2424 {
2525 switch (event)
2626 {
2727 case RPTP_EVENT_PLAY:
28 printf ("%s is playing\n", rptp_parse (line, "sound"));
28 printf("%s is playing\n", rptp_parse(line, "sound"));
2929 break;
3030
3131 case RPTP_EVENT_PAUSE:
32 printf ("%s is paused\n", rptp_parse (line, "sound"));
32 printf("%s is paused\n", rptp_parse(line, "sound"));
3333 break;
3434
3535 case RPTP_EVENT_DONE:
36 printf ("%s is done\n", rptp_parse (line, "sound"));
36 printf("%s is done\n", rptp_parse(line, "sound"));
3737 break;
3838
3939 case RPTP_EVENT_CONTINUE:
40 printf ("%s continue\n", rptp_parse (line, "sound"));
40 printf("%s continue\n", rptp_parse(line, "sound"));
4141 break;
4242 }
4343 }
0 /* $Id: async2.c,v 1.2 1998/08/13 06:13:24 boyns Exp $ */
0 /* $Id: async2.c,v 1.3 1998/11/07 21:15:12 boyns Exp $ */
11
22 #include <rplay.h>
33 #include <stdio.h>
44
5 static void process_input (int fd);
6 static void event_callback (int fd, int event, char *line);
5 static void process_input(int fd);
6 static void event_callback(int fd, int event, char *line);
77
88 static int rptp_fd;
99
10 main (int argc, char **argv)
10 main(int argc, char **argv)
1111 {
1212 char buf[RPTP_MAX_LINE];
1313
14 rptp_fd = rptp_open (rplay_default_host (), RPTP_PORT, buf, sizeof (buf));
14 rptp_fd = rptp_open(rplay_default_host(), RPTP_PORT, buf, sizeof(buf));
1515
16 rptp_async_register (0, RPTP_ASYNC_READ, process_input);
17 rptp_async_notify (rptp_fd, RPTP_EVENT_ALL, event_callback);
16 rptp_async_register(0, RPTP_ASYNC_READ, process_input);
17 rptp_async_notify(rptp_fd, RPTP_EVENT_ALL, event_callback);
1818
19 rptp_main_loop ();
19 rptp_main_loop();
2020
21 exit (0);
21 exit(0);
2222 }
2323
2424 static void
25 process_input (int fd)
25 process_input(int fd)
2626 {
2727 char buf[BUFSIZ];
2828
29 fgets (buf, sizeof (buf), stdin);
30 buf[strlen (buf) - 1] = '\0';
29 fgets(buf, sizeof(buf), stdin);
30 buf[strlen(buf) - 1] = '\0';
3131
32 rptp_async_putline (rptp_fd, NULL, buf);
32 rptp_async_putline(rptp_fd, NULL, buf);
3333 }
3434
35 static void
36 event_callback (int fd, int event, char *line)
35 static void
36 event_callback(int fd, int event, char *line)
3737 {
38 rptp_parse (line, 0);
38 rptp_parse(line, 0);
3939
4040 switch (event)
4141 {
4242 case RPTP_EVENT_OK:
43 break;
43 break;
4444
4545 case RPTP_EVENT_ERROR:
46 printf ("Error: %s\n", rptp_parse (0, "error"));
47 break;
46 printf("Error: %s\n", rptp_parse(0, "error"));
47 break;
4848
4949 case RPTP_EVENT_PLAY:
50 printf ("[%s] Play %s\n", rptp_parse (0, "id"), rptp_parse (0, "sound"));
50 printf("[%s] Play %s\n", rptp_parse(0, "id"), rptp_parse(0, "sound"));
5151 break;
5252
5353 case RPTP_EVENT_PAUSE:
54 printf ("[%s] Pause %s\n", rptp_parse (0, "id"), rptp_parse (0, "sound"));
54 printf("[%s] Pause %s\n", rptp_parse(0, "id"), rptp_parse(0, "sound"));
5555 break;
5656
5757 case RPTP_EVENT_DONE:
58 printf ("[%s] Done %s\n", rptp_parse (0, "id"), rptp_parse (0, "sound"));
58 printf("[%s] Done %s\n", rptp_parse(0, "id"), rptp_parse(0, "sound"));
5959 break;
6060
6161 case RPTP_EVENT_CONTINUE:
62 printf ("[%s] Continue %s\n", rptp_parse (0, "id"), rptp_parse (0, "sound"));
62 printf("[%s] Continue %s\n", rptp_parse(0, "id"), rptp_parse(0, "sound"));
6363 break;
6464 }
6565 }
0 /* $Id: flow1.c,v 1.2 1998/08/13 06:13:25 boyns Exp $ */
0 /* $Id: flow1.c,v 1.3 1998/11/07 21:15:12 boyns Exp $ */
11
22 /* usage: flow1 soundfile */
33
66 #include <stdio.h>
77 #include <rplay.h>
88
9 main (int argc, char **argv)
9 main(int argc, char **argv)
1010 {
1111 FILE *fp;
1212 int rptp_fd, size, n, nwritten;
1717 char buf[8000];
1818
1919 /* First determine how big the audio file is. */
20 if (stat (argv[1], &st) < 0)
20 if (stat(argv[1], &st) < 0)
2121 {
22 perror (argv[1]);
23 exit (1);
22 perror(argv[1]);
23 exit(1);
2424 }
2525 size = st.st_size;
2626
27 fp = fopen (argv[1], "r");
27 fp = fopen(argv[1], "r");
2828 if (fp == NULL)
2929 {
30 perror (argv[1]);
31 exit (1);
30 perror(argv[1]);
31 exit(1);
3232 }
3333
3434 /* Connect to the audio server. */
35 rptp_fd = rptp_open (rplay_default_host (), RPTP_PORT, response, sizeof (response));
35 rptp_fd = rptp_open(rplay_default_host(), RPTP_PORT, response, sizeof(response));
3636 if (rptp_fd < 0)
3737 {
38 rptp_perror (rplay_default_host ());
39 exit (1);
38 rptp_perror(rplay_default_host());
39 exit(1);
4040 }
4141
4242 /* Start the flow using `input-storage=none'. */
43 sprintf (line, "play input=flow input-storage=none sound=%s", argv[1]);
44 switch (rptp_command (rptp_fd, line, response, sizeof (response)))
43 sprintf(line, "play input=flow input-storage=none sound=%s", argv[1]);
44 switch (rptp_command(rptp_fd, line, response, sizeof(response)))
4545 {
4646 case -1:
47 rptp_perror (argv[0]);
48 exit (1);
47 rptp_perror(argv[0]);
48 exit(1);
4949
5050 case 1:
51 fprintf (stderr, "%s\n", rptp_parse (response, "error"));
52 exit (1);
51 fprintf(stderr, "%s\n", rptp_parse(response, "error"));
52 exit(1);
5353
5454 case 0:
5555 break;
5656 }
5757
5858 /* Save the spool id so `put' can use it later. */
59 id = rptp_parse (response, "id");
59 id = rptp_parse(response, "id");
6060
6161 /* Read chunks of audio from the file and send them to rplayd.
6262 rplayd will deal with flow-control. */
6363 while (size > 0)
6464 {
65 n = fread (buf, 1, sizeof (buf), fp);
65 n = fread(buf, 1, sizeof(buf), fp);
6666
6767 /* Use `put' to send the audio data. */
68 sprintf (line, "put id=%s size=%d", id, n);
69 switch (rptp_command (rptp_fd, line, response, sizeof (response)))
68 sprintf(line, "put id=%s size=%d", id, n);
69 switch (rptp_command(rptp_fd, line, response, sizeof(response)))
7070 {
7171 case -1:
72 rptp_perror (argv[0]);
73 exit (1);
72 rptp_perror(argv[0]);
73 exit(1);
7474
7575 case 1:
76 fprintf (stderr, "%s\n", rptp_parse (response, "error"));
77 exit (1);
76 fprintf(stderr, "%s\n", rptp_parse(response, "error"));
77 exit(1);
7878
7979 case 0:
8080 break;
8181 }
8282
83 nwritten = rptp_write (rptp_fd, buf, n);
83 nwritten = rptp_write(rptp_fd, buf, n);
8484 if (nwritten != n)
8585 {
86 rptp_perror ("flow");
86 rptp_perror("flow");
8787 break;
8888 }
8989 size -= nwritten;
9090 }
9191
92 fclose (fp);
92 fclose(fp);
9393
9494 /* Always send `done' when the flow is over. */
95 sprintf (line, "done id=%s", id);
96 switch (rptp_command (rptp_fd, line, response, sizeof (response)))
95 sprintf(line, "done id=%s", id);
96 switch (rptp_command(rptp_fd, line, response, sizeof(response)))
9797 {
9898 case -1:
99 rptp_perror (argv[0]);
100 exit (1);
99 rptp_perror(argv[0]);
100 exit(1);
101101
102102 case 1:
103 fprintf (stderr, "%s\n", rptp_parse (response, "error"));
104 exit (1);
103 fprintf(stderr, "%s\n", rptp_parse(response, "error"));
104 exit(1);
105105
106106 case 0:
107107 break;
108108 }
109109
110 exit (0);
110 exit(0);
111111 }
00 #include <rplay.h>
11
2 static void event_callback (int fd, int event, char *line);
2 static void event_callback(int fd, int event, char *line);
33
4 main (int argc, char **argv)
4 main(int argc, char **argv)
55 {
66 char buf[RPTP_MAX_LINE];
77 int fd;
88
9 fd = rptp_open (rplay_default_host (), RPTP_PORT, buf, sizeof (buf));
10 rptp_async_notify (fd, RPTP_EVENT_LEVEL|RPTP_EVENT_CLOSE, event_callback);
11 rptp_main_loop ();
9 fd = rptp_open(rplay_default_host(), RPTP_PORT, buf, sizeof(buf));
10 rptp_async_notify(fd, RPTP_EVENT_LEVEL | RPTP_EVENT_CLOSE, event_callback);
11 rptp_main_loop();
1212
13 exit (0);
13 exit(0);
1414 }
1515
16 static void
17 event_callback (int fd, int event, char *line)
16 static void
17 event_callback(int fd, int event, char *line)
1818 {
1919 static int i;
2020 int left, right;
21
21
2222 switch (event)
2323 {
2424 case RPTP_EVENT_LEVEL:
25 left = atoi (rptp_parse (line, "left"));
26 right = atoi (rptp_parse (0, "right"));
27 printf ("%3d %3d\n", left, right);
25 left = atoi(rptp_parse(line, "left"));
26 right = atoi(rptp_parse(0, "right"));
27 printf("%3d %3d\n", left, right);
2828 break;
2929
3030 case RPTP_EVENT_CLOSE:
31 exit (0);
31 exit(0);
3232 }
3333 }
+0
-40
gsm/CVS/Entries less more
0 /COPYRIGHT/1.1.1.1/Tue Jul 14 22:35:24 1998//
1 /INSTALL/1.1.1.1/Tue Jul 14 22:35:24 1998//
2 /MACHINES/1.1.1.1/Tue Jul 14 22:35:24 1998//
3 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998//
4 /README/1.1.1.1/Tue Jul 14 22:35:24 1998//
5 /README.rplay/1.1.1.1/Tue Jul 14 22:35:24 1998//
6 /gsm.3/1.1.1.1/Tue Jul 14 22:35:24 1998//
7 /gsm_explode.3/1.1.1.1/Tue Jul 14 22:35:24 1998//
8 /gsm_option.3/1.1.1.1/Tue Jul 14 22:35:24 1998//
9 /gsm_print.3/1.1.1.1/Tue Jul 14 22:35:24 1998//
10 /toast.1/1.1.1.1/Tue Jul 14 22:35:24 1998//
11 /add.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
12 /code.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
13 /debug.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
14 /decode.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
15 /gsm.h/1.1.1.1/Thu Aug 13 06:09:31 1998//
16 /gsm_create.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
17 /gsm_decode.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
18 /gsm_destroy.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
19 /gsm_encode.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
20 /gsm_explode.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
21 /gsm_implode.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
22 /gsm_option.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
23 /gsm_print.c/1.1.1.1/Thu Aug 13 06:09:31 1998//
24 /long_term.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
25 /lpc.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
26 /preprocess.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
27 /private.h/1.1.1.1/Thu Aug 13 06:09:32 1998//
28 /proto.h/1.1.1.1/Thu Aug 13 06:09:32 1998//
29 /rpe.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
30 /short_term.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
31 /table.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
32 /toast.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
33 /toast.h/1.1.1.1/Thu Aug 13 06:09:32 1998//
34 /toast_alaw.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
35 /toast_audio.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
36 /toast_lin.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
37 /toast_ulaw.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
38 /unproto.h/1.1.1.1/Thu Aug 13 06:09:32 1998//
39 D
+0
-1
gsm/CVS/Repository less more
0 /usr/local/cvsroot/rplay/gsm
+0
-1
gsm/CVS/Root less more
0 /usr/local/cvsroot
+0
-5
include/CVS/Entries less more
0 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:22 1998//
1 /rplay.h/1.2/Thu Aug 13 06:13:26 1998//
2 /config.h.in/1.2/Thu Aug 13 14:33:54 1998//
3 /version.h/1.3/Mon Oct 12 16:03:18 1998//
4 D
+0
-1
include/CVS/Repository less more
0 /usr/local/cvsroot/rplay/include
+0
-1
include/CVS/Root less more
0 /usr/local/cvsroot
0 /* $Id: config.h.in,v 1.2 1998/08/13 14:33:54 boyns Exp $ -*- c -*- */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: config.h.in,v 1.4 1999/06/09 06:25:20 boyns Exp $ -*- c -*- */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
188188 #undef HAVE_WAITPID
189189 #undef HAVE_SNPRINTF
190190 #undef HAVE_VSNPRINTF
191 #undef HAVE_LIBREADLINE
192 #undef HAVE_RANDOM
193 #undef HAVE_SRANDOM
191194
192195 #undef HAVE_STDC_HEADERS
193196 #undef HAVE_MEMORY_H
201204 #undef HAVE_UTIME_H
202205 #undef HAVE_SYS_WAIT_H
203206
204 #undef HAVE_FORMS_H
205 #undef HAVE_X11_FORMS_H
207 #undef HAVE_GSM_H
208 #undef HAVE_GSM_GSM_H
209 #undef HAVE_RXPOSIX_H
210 #undef HAVE_RX_RXPOSIX_H
206211
207212 /* Convert HAVE_ to HAS_ for gsm. See gsm/include/config.h.gsm */
208213 #ifdef HAVE_STDLIB_H
258263 * Solaris 2.x using gcc or SunPro cc and HP-UX
259264 */
260265 #if (defined(sun) && (defined(__svr4__) || defined(SVR4))) || defined(__hpux)
266 #ifndef HAVE_RANDOM
261267 #define random() lrand48()
268 #endif
269 #ifndef HAVE_SRANDOM
262270 #define srandom(x) srand48(x)
271 #endif
263272 #endif
264273
265274 #ifndef MIN
0 /* $Id: rplay.h,v 1.2 1998/08/13 06:13:26 boyns Exp $ */
0 /* $Id: rplay.h,v 1.3 1999/03/10 07:57:27 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: version.h,v 1.3 1998/10/12 16:03:18 boyns Exp $ */
0 /* $Id: version.h,v 1.5 1999/03/10 07:57:27 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
2626
2727 #define RPLAY_MAJOR_VERSION 3
2828 #define RPLAY_MINOR_VERSION 3
29 #define RPLAY_PATCHLEVEL 1
29 #define RPLAY_PATCHLEVEL 2
3030 #define RPLAY_STATUS ""
3131
3232 #endif /* _version_h */
+0
-1
java/CVS/Entries less more
0 D/org////
+0
-1
java/CVS/Repository less more
0 /usr/local/cvsroot/rplay/java
+0
-1
java/CVS/Root less more
0 /usr/local/cvsroot
+0
-1
java/org/CVS/Entries less more
0 D/doit////
+0
-1
java/org/CVS/Repository less more
0 /usr/local/cvsroot/rplay/java/org
+0
-1
java/org/CVS/Root less more
0 /usr/local/cvsroot
+0
-2
java/org/doit/CVS/Entries less more
0 D/io////
1 D/rplay////
+0
-1
java/org/doit/CVS/Repository less more
0 /usr/local/cvsroot/rplay/java/org/doit
+0
-1
java/org/doit/CVS/Root less more
0 /usr/local/cvsroot
+0
-2
java/org/doit/io/CVS/Entries less more
0 /ByteArray.java/1.2/Thu Aug 13 14:33:58 1998//
1 D
+0
-1
java/org/doit/io/CVS/Repository less more
0 /usr/local/cvsroot/rplay/java/org/doit/io
+0
-1
java/org/doit/io/CVS/Root less more
0 /usr/local/cvsroot
+0
-2
java/org/doit/rplay/CVS/Entries less more
0 /RPlay.java/1.3/Thu Aug 13 14:33:59 1998//
1 D
+0
-1
java/org/doit/rplay/CVS/Repository less more
0 /usr/local/cvsroot/rplay/java/org/doit/rplay
+0
-1
java/org/doit/rplay/CVS/Root less more
0 /usr/local/cvsroot
+0
-13
lib/CVS/Entries less more
0 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /hash.c/1.2/Thu Aug 13 06:13:29 1998//
2 /hash.h/1.2/Thu Aug 13 06:13:30 1998//
3 /strdup.c/1.2/Thu Aug 13 06:13:31 1998//
4 /strdup.h/1.2/Thu Aug 13 06:13:32 1998//
5 /tilde.c/1.2/Thu Aug 13 06:13:33 1998//
6 /xmalloc.c/1.2/Thu Aug 13 06:13:34 1998//
7 /ansidecl.h/1.1.1.1/Thu Aug 13 06:09:32 1998//
8 /getopt.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
9 /getopt.h/1.1.1.1/Thu Aug 13 06:09:32 1998//
10 /getopt1.c/1.1.1.1/Thu Aug 13 06:09:32 1998//
11 /tilde.h/1.1.1.1/Thu Aug 13 06:09:32 1998//
12 D
+0
-1
lib/CVS/Repository less more
0 /usr/local/cvsroot/rplay/lib
+0
-1
lib/CVS/Root less more
0 /usr/local/cvsroot
0 /* $Id: strdup.c,v 1.2 1998/08/13 06:13:31 boyns Exp $ */
0 /* $Id: strdup.c,v 1.4 1999/03/10 07:57:53 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
2223
23
2424 #ifdef HAVE_CONFIG_H
2525 #include "config.h"
2626 #endif
3030 #ifndef HAVE_STRDUP
3131 #ifdef __STDC__
3232 char *
33 strdup (char *str)
33 strdup(char *str)
3434 #else
3535 char *
36 strdup (str)
37 char *str;
36 strdup(str)
37 char *str;
3838 #endif
3939 {
40 char *p;
40 char *p;
4141
42 p = (char *)malloc(strlen(str)+1);
43 if (p == NULL)
44 {
45 return NULL;
46 }
47 else
48 {
49 strcpy(p, str);
50 return p;
51 }
42 p = (char *) malloc(strlen(str) + 1);
43 if (p == NULL)
44 {
45 return NULL;
46 }
47 else
48 {
49 strcpy(p, str);
50 return p;
51 }
5252 }
5353 #endif /* HAVE_STRDUP */
0 /* $Id: strdup.h,v 1.2 1998/08/13 06:13:32 boyns Exp $ */
0 /* $Id: strdup.h,v 1.3 1999/03/10 07:57:53 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: tilde.c,v 1.2 1998/08/13 06:13:33 boyns Exp $ */
1
2 /* Copyright (C) 1988,1989 Free Software Foundation, Inc.
3
4 This file is part of GNU Readline, a library for reading lines
5 of text with interactive input and history editing.
6
7 Readline is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 1, or (at your option) any
10 later version.
11
12 Readline is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Readline; see the file COPYING. If not, write to the Free
19 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
0 /* $Id: tilde.c,v 1.3 1999/03/10 07:57:53 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
4 *
5 * This file is part of rplay.
6 *
7 * rplay is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * rplay is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with rplay; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21 */
2022
2123 #if defined (HAVE_CONFIG_H)
2224 # include "config.h"
0 /* $Id: xmalloc.c,v 1.2 1998/08/13 06:13:34 boyns Exp $ */
0 /* $Id: xmalloc.c,v 1.4 1999/03/10 07:57:53 boyns Exp $ */
11
2 /*
3 * Copyright (C) 1994 Mark Boyns
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
5 * This file is part of rplay
5 * This file is part of rplay.
66 *
7 * This program is free software; you can redistribute it and/or modify
7 * rplay is free software; you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
99 * the Free Software Foundation; either version 2 of the License, or
1010 * (at your option) any later version.
1111 *
12 * This program is distributed in the hope that it will be useful,
12 * rplay is distributed in the hope that it will be useful,
1313 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1414 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515 * GNU General Public License for more details.
1616 *
1717 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * along with rplay; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2021 */
2122
2223 #include "ansidecl.h"
3031
3132 #ifdef __STDC__
3233 PTR
33 xmalloc (size_t size)
34 xmalloc(size_t size)
3435 #else
3536 PTR
36 xmalloc (size)
37 xmalloc(size)
3738 size_t size;
3839 #endif
3940 {
4041 PTR p;
4142
42 p = (PTR) malloc (size);
43 p = (PTR) malloc(size);
4344 if (p == 0)
4445 {
45 fprintf (stderr, "xmalloc: Virtual memory exhausted.\n");
46 exit (1);
46 fprintf(stderr, "xmalloc: Virtual memory exhausted.\n");
47 exit(1);
4748 }
4849 return p;
4950 }
5051
5152 #ifdef __STDC__
5253 PTR
53 xrealloc (PTR oldmem, size_t size)
54 xrealloc(PTR oldmem, size_t size)
5455 #else
5556 PTR
56 xrealloc (oldmem, size)
57 xrealloc(oldmem, size)
5758 PTR oldmem;
5859 size_t size;
5960 #endif
6566 size = 1;
6667 }
6768
68 newmem = (oldmem) ? (PTR) realloc (oldmem, size) : (PTR) malloc (size);
69
69 newmem = (oldmem) ? (PTR) realloc(oldmem, size) : (PTR) malloc(size);
70
7071 if (!newmem)
7172 {
72 fprintf (stderr, "xrealloc: Virtual memory exhausted.\n");
73 exit (1);
73 fprintf(stderr, "xrealloc: Virtual memory exhausted.\n");
74 exit(1);
7475 }
7576
7677 return newmem;
7778 }
78
+0
-5
librplay/CVS/Entries less more
0 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:22 1998//
1 /async.c/1.2/Thu Aug 13 06:13:35 1998//
2 /rplay.c/1.3/Thu Aug 13 06:13:36 1998//
3 /rptp.c/1.2/Thu Aug 13 06:13:38 1998//
4 D
+0
-1
librplay/CVS/Repository less more
0 /usr/local/cvsroot/rplay/librplay
+0
-1
librplay/CVS/Root less more
0 /usr/local/cvsroot
88 MKINSTALLDIRS= @srcdir@/../mkinstalldirs
99
1010 CPPFLAGS= $(CC_OPTIONS) -I. -I../include -I@srcdir@/../include @DEFS@
11 LDFLAGS= $(LD_OPTIONS) -shared @LDFLAGS@
1112
1213 .c.o:
1314 $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
1415
16 .SUFFIXES: .lo
17 .c.lo:
18 $(CC) -c -fPIC $(CPPFLAGS) $(CFLAGS) -o $@ $<
19
1520 TARGET= $(LIBRPLAY_NAME)
1621 SRCS= rplay.c rptp.c async.c
1722 OBJS= rplay.o rptp.o async.o
23 SHAREDOBJS= rplay.lo rptp.lo async.lo
1824
19 all: $(TARGET)
25 all: $(TARGET) librplay.so
2026
2127 #
2228 # Use the following for SunOS 4.1.x, Solaris 2.x, Linux, NetBSD
2430 $(TARGET): $(OBJS)
2531 $(AR) rcv $@ $?
2632 $(RANLIB) $@
33
34 librplay.so: $(SHAREDOBJS)
35 $(CC) -o $@ $(SHAREDOBJS) $(LDFLAGS)
2736
2837 #
2938 # For HP-UX comment above and uncomment below.
4049 install: all
4150 $(MKINSTALLDIRS) $(libdir)
4251 $(INSTALL_DATA) $(TARGET) $(libdir)
52 $(INSTALL_DATA) librplay.so $(libdir)
4353
4454 uninstall:
4555 $(RM) $(libdir)/$(TARGET)
56 $(RM) $(libdir)/librplay.so
4657
4758 clean:
48 $(RM) $(OBJS) $(TARGET) a.out core *~ *.bak *.orig TAGS
59 $(RM) $(OBJS) $(SHAREDOBJS) $(TARGET) librplay.so a.out core *~ *.bak *.orig TAGS
4960
5061 distclean: clean
5162 $(RM) Makefile
0 /* $Id: rplay.c,v 1.3 1998/08/13 06:13:36 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: rplay.c,v 1.6 1999/03/10 07:57:56 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifdef HAVE_CONFIG_H
2624 #include "config.h"
7371 "unknown rplay modifier", /* RPLAY_ERROR_MODIFIER */
7472 };
7573 /*
76 #ifdef __STDC__
77 unsigned long inet_addr (char *rp);
78 #else
79 unsigned long inet_addr ();
80 #endif
81 */
74 #ifdef __STDC__
75 unsigned long inet_addr (char *rp);
76 #else
77 unsigned long inet_addr ();
78 #endif
79 */
8280 /* A simple version a strdup. */
8381 #ifndef HAVE_STRDUP
8482 #ifdef __STDC__
8583 static char *
86 strdup (char *str)
84 strdup(char *str)
8785 #else
8886 static char *
89 strdup (str)
87 strdup(str)
9088 char *str;
9189 #endif
9290 {
9391 char *p;
9492
95 p = (char *) malloc (strlen (str) + 1);
93 p = (char *) malloc(strlen(str) + 1);
9694 if (p == NULL)
9795 {
9896 return NULL;
9997 }
10098 else
10199 {
102 strcpy (p, str);
100 strcpy(p, str);
103101 return p;
104102 }
105103 }
110108 */
111109 #ifdef __STDC__
112110 static RPLAY_ATTRS *
113 rplay_attrs_create (void)
111 rplay_attrs_create(void)
114112 #else
115113 static RPLAY_ATTRS *
116 rplay_attrs_create ()
114 rplay_attrs_create()
117115 #endif
118116 {
119117 RPLAY_ATTRS *attrs;
120118
121 attrs = (RPLAY_ATTRS *) malloc (sizeof (RPLAY_ATTRS));
119 attrs = (RPLAY_ATTRS *) malloc(sizeof(RPLAY_ATTRS));
122120 if (attrs == NULL)
123121 {
124122 return NULL;
141139 */
142140 #ifdef __STDC__
143141 static void
144 rplay_attrs_destroy (RPLAY_ATTRS *attrs)
142 rplay_attrs_destroy(RPLAY_ATTRS *attrs)
145143 #else
146144 static void
147 rplay_attrs_destroy (attrs)
145 rplay_attrs_destroy(attrs)
148146 RPLAY_ATTRS *attrs;
149147 #endif
150148 {
151149 if (*attrs->sound)
152150 {
153 free ((char *) attrs->sound);
151 free((char *) attrs->sound);
154152 }
155153 if (attrs->rptp_server)
156154 {
157 free ((char *) attrs->rptp_server);
155 free((char *) attrs->rptp_server);
158156 }
159157 if (*attrs->client_data)
160158 {
161 free ((char *) attrs->client_data);
162 }
163 free ((char *) attrs);
159 free((char *) attrs->client_data);
160 }
161 free((char *) attrs);
164162 }
165163
166164 #define COPY_SIZE 128
195193 */
196194 #ifdef __STDC__
197195 int
198 rplay_pack (RPLAY *rp)
199 #else
200 int
201 rplay_pack (rp)
196 rplay_pack(RPLAY *rp)
197 #else
198 int
199 rplay_pack(rp)
202200 RPLAY *rp;
203201 #endif
204202 {
211209
212210 rp->len = 0;
213211 val = RPLAY_PACKET_ID;
214 COPY (rp, &val, sizeof (val));
212 COPY(rp, &val, sizeof(val));
215213 val = rp->command;
216 COPY (rp, &val, sizeof (val));
214 COPY(rp, &val, sizeof(val));
217215
218216 if (rp->count != RPLAY_DEFAULT_LIST_COUNT)
219217 {
220218 val = RPLAY_LIST_COUNT;
221 COPY (rp, &val, sizeof (val));
219 COPY(rp, &val, sizeof(val));
222220 val = rp->count;
223 COPY (rp, &val, sizeof (val));
221 COPY(rp, &val, sizeof(val));
224222 }
225223
226224 if (rp->priority != RPLAY_DEFAULT_PRIORITY)
227225 {
228226 val = RPLAY_PRIORITY;
229 COPY (rp, &val, sizeof (val));
227 COPY(rp, &val, sizeof(val));
230228 val = rp->priority;
231 COPY (rp, &val, sizeof (val));
229 COPY(rp, &val, sizeof(val));
232230 }
233231
234232 if (*rp->list_name)
235233 {
236234 val = RPLAY_LIST_NAME;
237 COPY (rp, &val, sizeof (val));
238 len = strlen (rp->list_name) + 1;
239 COPY (rp, rp->list_name, len);
235 COPY(rp, &val, sizeof(val));
236 len = strlen(rp->list_name) + 1;
237 COPY(rp, rp->list_name, len);
240238 }
241239
242240 if (rp->id != RPLAY_NULL)
243241 {
244242 val = RPLAY_ID;
245 COPY (rp, &val, sizeof (val));
246 val = rp->id;
247 COPY (rp, &val, sizeof (val));
243 COPY(rp, &val, sizeof(val));
244 lval = htonl(rp->id);
245 COPY(rp, &lval, sizeof(lval));
248246 }
249247
250248 if (rp->sequence != -1)
251249 {
252250 val = RPLAY_SEQUENCE;
253 COPY (rp, &val, sizeof (val));
254 lval = htonl (rp->sequence);
255 COPY (rp, &lval, sizeof (lval));
251 COPY(rp, &val, sizeof(val));
252 lval = htonl(rp->sequence);
253 COPY(rp, &lval, sizeof(lval));
256254 }
257255
258256 if (rp->data != RPLAY_NULL && rp->data_size > 0)
259257 {
260258 val = RPLAY_DATA_SIZE;
261 COPY (rp, &val, sizeof (val));
262 sval = htons (rp->data_size);
263 COPY (rp, &sval, sizeof (sval));
264
259 COPY(rp, &val, sizeof(val));
260 sval = htons(rp->data_size);
261 COPY(rp, &sval, sizeof(sval));
262
265263 val = RPLAY_DATA;
266 COPY (rp, &val, sizeof (val));
267 COPY (rp, rp->data, rp->data_size);
268 }
269
264 COPY(rp, &val, sizeof(val));
265 COPY(rp, rp->data, rp->data_size);
266 }
267
270268 for (i = 0, attrs = rp->attrs; attrs; attrs = attrs->next, i++)
271269 {
272270 if (rp->random_sound != RPLAY_DEFAULT_RANDOM_SOUND)
280278 if (*attrs->sound)
281279 {
282280 val = RPLAY_SOUND;
283 COPY (rp, &val, sizeof (val));
284 len = strlen (attrs->sound) + 1;
285 COPY (rp, attrs->sound, len);
281 COPY(rp, &val, sizeof(val));
282 len = strlen(attrs->sound) + 1;
283 COPY(rp, attrs->sound, len);
286284 }
287285
288286 if (attrs->volume != RPLAY_DEFAULT_VOLUME)
289287 {
290288 val = RPLAY_VOLUME;
291 COPY (rp, &val, sizeof (val));
289 COPY(rp, &val, sizeof(val));
292290 val = attrs->volume;
293 COPY (rp, &val, sizeof (val));
291 COPY(rp, &val, sizeof(val));
294292 }
295293
296294 if (attrs->count != RPLAY_DEFAULT_COUNT)
297295 {
298296 val = RPLAY_COUNT;
299 COPY (rp, &val, sizeof (val));
297 COPY(rp, &val, sizeof(val));
300298 val = attrs->count;
301 COPY (rp, &val, sizeof (val));
299 COPY(rp, &val, sizeof(val));
302300 }
303301
304302 if (attrs->rptp_server)
305303 {
306304 val = RPLAY_RPTP_SERVER;
307 COPY (rp, &val, sizeof (val));
308 len = strlen (attrs->rptp_server) + 1;
309 COPY (rp, attrs->rptp_server, len);
305 COPY(rp, &val, sizeof(val));
306 len = strlen(attrs->rptp_server) + 1;
307 COPY(rp, attrs->rptp_server, len);
310308 }
311309
312310 if (attrs->rptp_server_port != RPTP_PORT)
313311 {
314312 val = RPLAY_RPTP_SERVER_PORT;
315 COPY (rp, &val, sizeof (val));
316 size = htons (attrs->rptp_server_port);
317 COPY (rp, &size, sizeof (size));
313 COPY(rp, &val, sizeof(val));
314 size = htons(attrs->rptp_server_port);
315 COPY(rp, &size, sizeof(size));
318316 }
319317
320318 if (attrs->rptp_search == FALSE)
321319 {
322320 val = RPLAY_RPTP_SEARCH;
323 COPY (rp, &val, sizeof (val));
321 COPY(rp, &val, sizeof(val));
324322 val = attrs->rptp_search;
325 COPY (rp, &val, sizeof (val));
323 COPY(rp, &val, sizeof(val));
326324 }
327325
328326 if (attrs->sample_rate != RPLAY_DEFAULT_SAMPLE_RATE)
329327 {
330328 val = RPLAY_SAMPLE_RATE;
331 COPY (rp, &val, sizeof (val));
332 lval = htonl (attrs->sample_rate);
333 COPY (rp, &lval, sizeof (lval));
329 COPY(rp, &val, sizeof(val));
330 lval = htonl(attrs->sample_rate);
331 COPY(rp, &lval, sizeof(lval));
334332 }
335333
336334 if (*attrs->client_data)
337335 {
338336 val = RPLAY_CLIENT_DATA;
339 COPY (rp, &val, sizeof (val));
340 len = strlen (attrs->client_data) + 1;
341 COPY (rp, attrs->client_data, len);
337 COPY(rp, &val, sizeof(val));
338 len = strlen(attrs->client_data) + 1;
339 COPY(rp, attrs->client_data, len);
342340 }
343341
344342 val = RPLAY_NULL;
345 COPY (rp, &val, sizeof (val));
343 COPY(rp, &val, sizeof(val));
346344 }
347345
348346 if (i == 0)
349347 {
350348 val = RPLAY_NULL;
351 COPY (rp, &val, sizeof (val));
349 COPY(rp, &val, sizeof(val));
352350 }
353351
354352 val = RPLAY_NULL;
355 COPY (rp, &val, sizeof (val));
353 COPY(rp, &val, sizeof(val));
356354
357355 return 0;
358356 }
362360 */
363361 #ifdef __STDC__
364362 RPLAY *
365 rplay_unpack (char *packet)
363 rplay_unpack(char *packet)
366364 #else
367365 RPLAY *
368 rplay_unpack (packet)
366 rplay_unpack(packet)
369367 char *packet;
370368 #endif
371369 {
376374 rplay_errno = RPLAY_ERROR_NONE;
377375
378376 version = *packet++;
379 rp = rplay_create (*packet++);
377 rp = rplay_create(*packet++);
380378 if (rp == NULL)
381379 {
382380 rplay_errno = RPLAY_ERROR_MEMORY;
383381 return NULL;
384382 }
385383
386 *(rp->attrsp) = rplay_attrs_create ();
384 *(rp->attrsp) = rplay_attrs_create();
387385 if (*(rp->attrsp) == NULL)
388386 {
389387 rplay_errno = RPLAY_ERROR_MEMORY;
399397 break;
400398
401399 case RPLAY_LIST_NAME:
402 rp->list_name = strdup (packet);
403 packet += strlen (packet) + 1;
400 rp->list_name = strdup(packet);
401 packet += strlen(packet) + 1;
404402 break;
405
403
406404 case RPLAY_PRIORITY:
407405 rp->priority = (unsigned char) *packet++;
408406 break;
409407
410408 case RPLAY_SOUND:
411 (*rp->attrsp)->sound = strdup (packet);
412 packet += strlen (packet) + 1;
409 (*rp->attrsp)->sound = strdup(packet);
410 packet += strlen(packet) + 1;
413411 break;
414412
415413 case RPLAY_VOLUME:
421419 break;
422420
423421 case RPLAY_RPTP_SERVER:
424 (*rp->attrsp)->rptp_server = strdup (packet);
425 packet += strlen (packet) + 1;
422 (*rp->attrsp)->rptp_server = strdup(packet);
423 packet += strlen(packet) + 1;
426424 break;
427425
428426 case RPLAY_RPTP_SERVER_PORT:
429 memcpy ((char *) &(*rp->attrsp)->rptp_server_port, packet, sizeof ((*rp->attrsp)->rptp_server_port));
430 (*rp->attrsp)->rptp_server_port = ntohs ((*rp->attrsp)->rptp_server_port);
431 packet += sizeof ((*rp->attrsp)->rptp_server_port);
427 memcpy((char *) &(*rp->attrsp)->rptp_server_port, packet, sizeof((*rp->attrsp)->rptp_server_port));
428 (*rp->attrsp)->rptp_server_port = ntohs((*rp->attrsp)->rptp_server_port);
429 packet += sizeof((*rp->attrsp)->rptp_server_port);
432430 break;
433431
434432
437435 break;
438436
439437 case RPLAY_SAMPLE_RATE:
440 memcpy ((char *) &(*rp->attrsp)->sample_rate, packet, sizeof ((*rp->attrsp)->sample_rate));
441 (*rp->attrsp)->sample_rate = ntohl ((*rp->attrsp)->sample_rate);
442 packet += sizeof ((*rp->attrsp)->sample_rate);
438 memcpy((char *) &(*rp->attrsp)->sample_rate, packet,
439 sizeof((*rp->attrsp)->sample_rate));
440 (*rp->attrsp)->sample_rate = ntohl((*rp->attrsp)->sample_rate);
441 packet += sizeof((*rp->attrsp)->sample_rate);
443442 break;
444443
445444 case RPLAY_CLIENT_DATA:
446 (*rp->attrsp)->client_data = strdup (packet);
447 packet += strlen (packet) + 1;
445 (*rp->attrsp)->client_data = strdup(packet);
446 packet += strlen(packet) + 1;
448447 break;
449448
450449 case RPLAY_ID:
451 rp->id = (unsigned char) *packet++;
450 memcpy((char *) &rp->id, packet, sizeof(rp->id));
451 rp->id = ntohl(rp->id);
452 packet += sizeof(rp->id);
452453 break;
453454
454455 case RPLAY_SEQUENCE:
455 memcpy ((char *) &rp->sequence, packet, sizeof (rp->sequence));
456 rp->sequence = ntohl (rp->sequence);
457 packet += sizeof (rp->sequence);
456 memcpy((char *) &rp->sequence, packet, sizeof(rp->sequence));
457 rp->sequence = ntohl(rp->sequence);
458 packet += sizeof(rp->sequence);
458459 break;
459460
460461 case RPLAY_DATA_SIZE:
461 memcpy ((char *) &rp->data_size, packet, sizeof (rp->data_size));
462 rp->data_size = ntohs (rp->data_size);
463 packet += sizeof (rp->data_size);
462 memcpy((char *) &rp->data_size, packet, sizeof(rp->data_size));
463 rp->data_size = ntohs(rp->data_size);
464 packet += sizeof(rp->data_size);
464465 break;
465466
466467 case RPLAY_DATA:
467 rp->data = (char *) malloc (rp->data_size);
468 memcpy (rp->data, packet, rp->data_size);
468 rp->data = (char *) malloc(rp->data_size);
469 memcpy(rp->data, packet, rp->data_size);
469470 packet += rp->data_size;
470471 break;
471
472
472473 case RPLAY_NULL:
473474 rp->nsounds++;
474475 rp->attrsp = &(*rp->attrsp)->next;
478479 }
479480 else
480481 {
481 *(rp->attrsp) = rplay_attrs_create ();
482 *(rp->attrsp) = rplay_attrs_create();
482483 if (*(rp->attrsp) == NULL)
483484 {
484485 rplay_errno = RPLAY_ERROR_MEMORY;
490491 default:
491492 rplay_errno = RPLAY_ERROR_ATTRIBUTE;
492493 #if 1
493 printf ("unpack: unknown attr '%d'\n", *packet);
494 printf("unpack: unknown attr '%d'\n", *packet);
494495 #endif
495496 return NULL;
496497 }
507508 */
508509 #ifdef __STDC__
509510 RPLAY *
510 rplay_create (int command)
511 rplay_create(int command)
511512 #else
512513 RPLAY *
513 rplay_create (command)
514 rplay_create(command)
514515 int command;
515516 #endif
516517 {
518519
519520 rplay_errno = RPLAY_ERROR_NONE;
520521
521 rp = (RPLAY *) malloc (sizeof (RPLAY));
522 rp = (RPLAY *) malloc(sizeof(RPLAY));
522523 if (rp == NULL)
523524 {
524525 rplay_errno = RPLAY_ERROR_MEMORY;
527528
528529 rp->attrs = NULL;
529530 rp->attrsp = &rp->attrs;
530 rp->buf = (char *) malloc (COPY_SIZE);
531 rp->buf = (char *) malloc(COPY_SIZE);
531532 if (rp->buf == NULL)
532533 {
533534 rplay_errno = RPLAY_ERROR_MEMORY;
546547 rp->sequence = -1;
547548 rp->data = NULL;
548549 rp->data_size = 0;
549
550
550551 switch (command)
551552 {
552553 case RPLAY_PLAY:
573574 */
574575 #ifdef __STDC__
575576 static RPLAY_ATTRS *
576 get_attrs (RPLAY_ATTRS *attrs, int index)
577 get_attrs(RPLAY_ATTRS *attrs, int index)
577578 #else
578579 static RPLAY_ATTRS *
579 get_attrs (attrs, index)
580 get_attrs(attrs, index)
580581 RPLAY_ATTRS *attrs;
581582 int index;
582583 #endif
601602 */
602603 #ifdef __STDC__
603604 long
604 rplay_set (RPLAY *rp,...)
605 rplay_set(RPLAY *rp,...)
605606 #else
606607 long
607 rplay_set (va_alist)
608 rplay_set(va_alist)
608609 va_dcl
609610 #endif
610611 {
615616 time_t seed;
616617
617618 #ifdef __STDC__
618 va_start (args, rp);
619 va_start(args, rp);
619620 #else
620621 RPLAY *rp;
621 va_start (args);
622 rp = va_arg (args, RPLAY *);
622 va_start(args);
623 rp = va_arg(args, RPLAY *);
623624 #endif
624625
625626 rplay_errno = RPLAY_ERROR_NONE;
626627
627 modifier = va_arg (args, long);
628 modifier = va_arg(args, long);
628629
629630 switch (modifier)
630631 {
631632 case RPLAY_APPEND:
632 *(rp->attrsp) = attrs = rplay_attrs_create ();
633 *(rp->attrsp) = attrs = rplay_attrs_create();
633634 if (attrs == NULL)
634635 {
635636 rplay_errno = RPLAY_ERROR_MEMORY;
640641 break;
641642
642643 case RPLAY_INSERT:
643 index = va_arg (args, long);
644 index = va_arg(args, long);
644645 if (index < 0)
645646 {
646647 rplay_errno = RPLAY_ERROR_INDEX;
656657 rplay_errno = RPLAY_ERROR_INDEX;
657658 return -1;
658659 }
659 attrs = rplay_attrs_create ();
660 attrs = rplay_attrs_create();
660661 if (attrs == NULL)
661662 {
662663 rplay_errno = RPLAY_ERROR_MEMORY;
679680 break;
680681
681682 case RPLAY_DELETE:
682 index = va_arg (args, long);
683 index = va_arg(args, long);
683684 if (index < 0)
684685 {
685686 rplay_errno = RPLAY_ERROR_INDEX;
711712 rp->attrsp = &rp->attrs;
712713 }
713714 }
714 rplay_attrs_destroy (curr);
715 rplay_attrs_destroy(curr);
715716 rp->nsounds--;
716717 break;
717718
718719 case RPLAY_CHANGE:
719 index = va_arg (args, long);
720 attrs = get_attrs (rp->attrs, index);
720 index = va_arg(args, long);
721 attrs = get_attrs(rp->attrs, index);
721722 if (attrs == NULL)
722723 {
723724 rplay_errno = RPLAY_ERROR_INDEX;
726727 break;
727728
728729 case RPLAY_LIST_COUNT:
729 rp->count = va_arg (args, long);
730 rp->count = va_arg(args, long);
730731 break;
731732
732733 case RPLAY_LIST_NAME:
733734 if (*rp->list_name)
734735 {
735 free ((char *) rp->list_name);
736 }
737 rp->list_name = strdup (va_arg (args, char *));
736 free((char *) rp->list_name);
737 }
738 rp->list_name = strdup(va_arg(args, char *));
738739 break;
739
740
740741 case RPLAY_PRIORITY:
741 rp->priority = va_arg (args, long);
742 rp->priority = va_arg(args, long);
742743 break;
743744
744745 case RPLAY_RANDOM_SOUND:
745 seed = time (0);
746 srandom ((int) seed);
747 rp->random_sound = (int) (random () % rp->nsounds);
746 seed = time(0);
747 srandom((int) seed);
748 rp->random_sound = (int) (random() % rp->nsounds);
748749 break;
749750
750751 case RPLAY_ID:
751 rp->id = va_arg (args, long);
752 rp->id = va_arg(args, long);
752753 break;
753754
754755 case RPLAY_SEQUENCE:
755 rp->sequence = va_arg (args, unsigned long);
756 rp->sequence = va_arg(args, unsigned long);
756757 break;
757758
758759 case RPLAY_DATA_SIZE:
762763 case RPLAY_DATA:
763764 if (rp->data)
764765 {
765 free ((char *) rp->data);
766 }
767
768 data = va_arg (args, char *);
769 rp->data_size = va_arg (args, long);
770 rp->data = (char *) malloc (rp->data_size);
766 free((char *) rp->data);
767 }
768
769 data = va_arg(args, char *);
770 rp->data_size = va_arg(args, long);
771 rp->data = (char *) malloc(rp->data_size);
771772 if (rp->data == NULL)
772773 {
773774 rplay_errno = RPLAY_ERROR_MEMORY;
774775 return -1;
775776 }
776 memcpy (rp->data, data, rp->data_size);
777 memcpy(rp->data, data, rp->data_size);
777778 break;
778
779
779780 default:
780781 rplay_errno = RPLAY_ERROR_MODIFIER;
781782 return -1;
785786 {
786787 int attribute;
787788
788 while ((attribute = va_arg (args, long)))
789 while ((attribute = va_arg(args, long)))
789790 {
790791 switch (attribute)
791792 {
792793 case RPLAY_LIST_COUNT:
793 rp->count = va_arg (args, long);
794 rp->count = va_arg(args, long);
794795 break;
795796
796797 case RPLAY_LIST_NAME:
797798 if (*rp->list_name)
798799 {
799 free ((char *) rp->list_name);
800 free((char *) rp->list_name);
800801 }
801 rp->list_name = strdup (va_arg (args, char *));
802 rp->list_name = strdup(va_arg(args, char *));
802803 break;
803
804
804805 case RPLAY_PRIORITY:
805 rp->priority = va_arg (args, long);
806 rp->priority = va_arg(args, long);
806807 break;
807808
808809 case RPLAY_SOUND:
809810 if (*attrs->sound)
810811 {
811 free ((char *) attrs->sound);
812 free((char *) attrs->sound);
812813 }
813 attrs->sound = strdup (va_arg (args, char *));
814 attrs->sound = strdup(va_arg(args, char *));
814815 break;
815816
816817 case RPLAY_VOLUME:
817 attrs->volume = va_arg (args, long);
818 attrs->volume = va_arg(args, long);
818819 break;
819820
820821 case RPLAY_COUNT:
821 attrs->count = va_arg (args, long);
822 attrs->count = va_arg(args, long);
822823 break;
823824
824825 case RPLAY_RPTP_SERVER:
827828 struct hostent *hp;
828829 u_long addr;
829830 struct sockaddr_in s;
830 char *host = va_arg (args, char *);
831 char *host = va_arg(args, char *);
831832 char hostname[MAXHOSTNAMELEN];
832833
833834 if (attribute == RPLAY_RPTP_FROM_SENDER)
834835 {
835 if (gethostname (hostname, sizeof (hostname)) < 0)
836 if (gethostname(hostname, sizeof(hostname)) < 0)
836837 {
837838 rplay_errno = RPLAY_ERROR_HOST;
838839 return -1;
841842 }
842843 else
843844 {
844 host = va_arg (args, char *);
845 host = va_arg(args, char *);
845846 }
846847
847 memset ((char *) &s, 0, sizeof (s));
848 addr = inet_addr (host);
848 memset((char *) &s, 0, sizeof(s));
849 addr = inet_addr(host);
849850 if (addr == 0xffffffff)
850851 {
851 hp = gethostbyname (host);
852 hp = gethostbyname(host);
852853 if (hp == NULL)
853854 {
854855 rplay_errno = RPLAY_ERROR_HOST;
855856 return -1;
856857 }
857 memcpy ((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
858 memcpy((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
858859 }
859860 else
860861 {
861 memcpy ((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof (addr));
862 memcpy((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof(addr));
862863 }
863 attrs->rptp_server = strdup ((char *) inet_ntoa (s.sin_addr));
864 attrs->rptp_server = strdup((char *) inet_ntoa(s.sin_addr));
864865 break;
865866 }
866867
867868 case RPLAY_RPTP_SERVER_PORT:
868 attrs->rptp_server_port = (unsigned short) va_arg (args, long);
869 attrs->rptp_server_port = (unsigned short) va_arg(args, long);
869870 break;
870871
871872 case RPLAY_RPTP_SEARCH:
872 attrs->rptp_search = va_arg (args, long);
873 attrs->rptp_search = va_arg(args, long);
873874 break;
874875
875876 case RPLAY_SAMPLE_RATE:
876 attrs->sample_rate = va_arg (args, unsigned long);
877 attrs->sample_rate = va_arg(args, unsigned long);
877878 break;
878879
879880 case RPLAY_CLIENT_DATA:
880881 if (*attrs->client_data)
881882 {
882 free ((char *) attrs->client_data);
883 free((char *) attrs->client_data);
883884 }
884 attrs->client_data = strdup (va_arg (args, char *));
885 attrs->client_data = strdup(va_arg(args, char *));
885886 break;
886
887
887888 default:
888889 rplay_errno = RPLAY_ERROR_ATTRIBUTE;
889890 return -1;
891892 }
892893 }
893894
894 return rplay_pack (rp);
895 return rplay_pack(rp);
895896 }
896897
897898 /*
899900 */
900901 #ifdef __STDC__
901902 long
902 rplay_get (RPLAY *rp,...)
903 rplay_get(RPLAY *rp,...)
903904 #else
904905 long
905 rplay_get (va_alist)
906 rplay_get(va_alist)
906907 va_dcl
907908 #endif
908909 {
911912 int get, index;
912913
913914 #ifdef __STDC__
914 va_start (args, rp);
915 va_start(args, rp);
915916 #else
916917 RPLAY *rp;
917 va_start (args);
918 rp = va_arg (args, RPLAY *);
918 va_start(args);
919 rp = va_arg(args, RPLAY *);
919920 #endif
920921 rplay_errno = RPLAY_ERROR_NONE;
921922
922 get = va_arg (args, long);
923 get = va_arg(args, long);
923924
924925 switch (get)
925926 {
934935
935936 case RPLAY_LIST_NAME:
936937 return (long) rp->list_name;
937
938
938939 case RPLAY_PRIORITY:
939940 return rp->priority;
940941
952953
953954 case RPLAY_DATA:
954955 return (long) rp->data;
955
956
956957 case RPLAY_SOUND:
957 index = va_arg (args, long);
958 attrs = get_attrs (rp->attrs, index);
958 index = va_arg(args, long);
959 attrs = get_attrs(rp->attrs, index);
959960 if (attrs == NULL)
960961 {
961962 rplay_errno = RPLAY_ERROR_INDEX;
964965 return (long) attrs->sound;
965966
966967 case RPLAY_VOLUME:
967 index = va_arg (args, long);
968 attrs = get_attrs (rp->attrs, index);
968 index = va_arg(args, long);
969 attrs = get_attrs(rp->attrs, index);
969970 if (attrs == NULL)
970971 {
971972 rplay_errno = RPLAY_ERROR_INDEX;
974975 return attrs->volume;
975976
976977 case RPLAY_COUNT:
977 index = va_arg (args, long);
978 attrs = get_attrs (rp->attrs, index);
978 index = va_arg(args, long);
979 attrs = get_attrs(rp->attrs, index);
979980 if (attrs == NULL)
980981 {
981982 rplay_errno = RPLAY_ERROR_INDEX;
984985 return attrs->count;
985986
986987 case RPLAY_RPTP_SERVER:
987 index = va_arg (args, long);
988 attrs = get_attrs (rp->attrs, index);
988 index = va_arg(args, long);
989 attrs = get_attrs(rp->attrs, index);
989990 if (attrs == NULL)
990991 {
991992 rplay_errno = RPLAY_ERROR_INDEX;
994995 return (long) attrs->rptp_server;
995996
996997 case RPLAY_RPTP_SERVER_PORT:
997 index = va_arg (args, long);
998 attrs = get_attrs (rp->attrs, index);
998 index = va_arg(args, long);
999 attrs = get_attrs(rp->attrs, index);
9991000 if (attrs == NULL)
10001001 {
10011002 rplay_errno = RPLAY_ERROR_INDEX;
10041005 return (long) attrs->rptp_server_port;
10051006
10061007 case RPLAY_RPTP_SEARCH:
1007 index = va_arg (args, long);
1008 attrs = get_attrs (rp->attrs, index);
1008 index = va_arg(args, long);
1009 attrs = get_attrs(rp->attrs, index);
10091010 if (attrs == NULL)
10101011 {
10111012 rplay_errno = RPLAY_ERROR_INDEX;
10141015 return attrs->rptp_search;
10151016
10161017 case RPLAY_SAMPLE_RATE:
1017 index = va_arg (args, long);
1018 attrs = get_attrs (rp->attrs, index);
1018 index = va_arg(args, long);
1019 attrs = get_attrs(rp->attrs, index);
10191020 if (attrs == NULL)
10201021 {
10211022 rplay_errno = RPLAY_ERROR_INDEX;
10241025 return attrs->sample_rate;
10251026
10261027 case RPLAY_CLIENT_DATA:
1027 index = va_arg (args, int);
1028 attrs = get_attrs (rp->attrs, index);
1028 index = va_arg(args, int);
1029 attrs = get_attrs(rp->attrs, index);
10291030 if (attrs == NULL)
10301031 {
10311032 rplay_errno = RPLAY_ERROR_INDEX;
10321033 return -1;
10331034 }
10341035 return (long) attrs->client_data;
1035
1036
10361037 default:
10371038 rplay_errno = RPLAY_ERROR_ATTRIBUTE;
10381039 return -1;
10441045 */
10451046 #ifdef __STDC__
10461047 void
1047 rplay_destroy (RPLAY *rp)
1048 rplay_destroy(RPLAY *rp)
10481049 #else
10491050 void
1050 rplay_destroy (rp)
1051 rplay_destroy(rp)
10511052 RPLAY *rp;
10521053 #endif
10531054 {
10551056
10561057 rplay_errno = RPLAY_ERROR_NONE;
10571058
1058 for (p = rp->attrs; p; q = p, p = p->next, rplay_attrs_destroy (q)) ;
1059 for (p = rp->attrs; p; q = p, p = p->next, rplay_attrs_destroy(q)) ;
10591060 if (*rp->list_name)
10601061 {
1061 free ((char *) rp->list_name);
1062 free((char *) rp->list_name);
10621063 }
10631064 if (rp->data)
10641065 {
1065 free ((char *) rp->data);
1066 }
1067 free ((char *) rp->buf);
1068 free ((char *) rp);
1066 free((char *) rp->data);
1067 }
1068 free((char *) rp->buf);
1069 free((char *) rp);
10691070 }
10701071
10711072 /*
10741075 #ifdef OLD_RPLAY
10751076 #ifdef __STDC__
10761077 char *
1077 rplay_convert (char *p)
1078 rplay_convert(char *p)
10781079 #else
10791080 char *
1080 rplay_convert (p)
1081 rplay_convert(p)
10811082 char *p;
10821083 #endif
10831084 {
11081109 do
11091110 {
11101111 *q++ = RPLAY_SOUND;
1111 strcpy (q, p);
1112 len = strlen (p) + 1;
1112 strcpy(q, p);
1113 len = strlen(p) + 1;
11131114 p += len;
11141115 q += len;
11151116 *q++ = RPLAY_VOLUME;
11251126 #endif /* OLD_RPLAY */
11261127
11271128 static int
1128 default_rplay_port ()
1129 default_rplay_port()
11291130 {
11301131 struct servent *sp;
11311132 int port;
11321133
1133 sp = getservbyname ("rplay", "udp");
1134 sp = getservbyname("rplay", "udp");
11341135 if (sp)
11351136 {
1136 port = ntohs (sp->s_port); /* htons is used later */
1137 port = ntohs(sp->s_port); /* htons is used later */
11371138 }
11381139 else
11391140 {
11451146
11461147 #ifdef __STDC__
11471148 int
1148 rplay_open (char *host)
1149 #else
1150 int
1151 rplay_open (host)
1149 rplay_open(char *host)
1150 #else
1151 int
1152 rplay_open(host)
11521153 char *host;
11531154 #endif
11541155 {
11551156 int port;
11561157
1157 port = default_rplay_port ();
1158
1159 return rplay_open_port (host, port);
1158 port = default_rplay_port();
1159
1160 return rplay_open_port(host, port);
11601161 }
11611162
11621163 /*
11661167 */
11671168 #ifdef __STDC__
11681169 int
1169 rplay_open_port (char *host, int port)
1170 #else
1171 int
1172 rplay_open_port (host, port)
1170 rplay_open_port(char *host, int port)
1171 #else
1172 int
1173 rplay_open_port(host, port)
11731174 char *host;
11741175 int port;
11751176 #endif
11801181
11811182 rplay_errno = RPLAY_ERROR_NONE;
11821183
1183 memset ((char *) &s, 0, sizeof (s));
1184
1185 addr = inet_addr (host);
1184 memset((char *) &s, 0, sizeof(s));
1185
1186 addr = inet_addr(host);
11861187 if (addr == 0xffffffff)
11871188 {
1188 hp = gethostbyname (host);
1189 hp = gethostbyname(host);
11891190 if (hp == NULL)
11901191 {
11911192 rplay_errno = RPLAY_ERROR_HOST;
11921193 return -1;
11931194 }
1194 memcpy ((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
1195 memcpy((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
11951196 }
11961197 else
11971198 {
1198 memcpy ((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof (addr));
1199 }
1200
1201 s.sin_port = htons (port);
1199 memcpy((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof(addr));
1200 }
1201
1202 s.sin_port = htons(port);
12021203 s.sin_family = AF_INET;
12031204
1204 return rplay_open_sockaddr_in (&s);
1205 }
1206
1207 #ifdef __STDC__
1208 int
1209 rplay_open_sockaddr_in (struct sockaddr_in *saddr)
1210 #else
1211 int
1212 rplay_open_sockaddr_in (saddr)
1205 return rplay_open_sockaddr_in(&s);
1206 }
1207
1208 #ifdef __STDC__
1209 int
1210 rplay_open_sockaddr_in(struct sockaddr_in *saddr)
1211 #else
1212 int
1213 rplay_open_sockaddr_in(saddr)
12131214 struct sockaddr_in *saddr;
12141215 #endif
12151216 {
12161217 int rplay_fd;
12171218 int on = 1;
12181219
1219 rplay_fd = socket (AF_INET, SOCK_DGRAM, 0);
1220 rplay_fd = socket(AF_INET, SOCK_DGRAM, 0);
12201221 if (rplay_fd < 0)
12211222 {
12221223 rplay_errno = RPLAY_ERROR_SOCKET;
12261227 /*
12271228 * enable broadcasting
12281229 */
1229 if (setsockopt (rplay_fd, SOL_SOCKET, SO_BROADCAST, (char *) &on, sizeof (on)) < 0)
1230 if (setsockopt(rplay_fd, SOL_SOCKET, SO_BROADCAST, (char *) &on, sizeof(on)) < 0)
12301231 {
12311232 rplay_errno = RPLAY_ERROR_BROADCAST;
12321233 return -1;
12331234 }
12341235
1235 if (connect (rplay_fd, (struct sockaddr *) saddr, sizeof (*saddr)) < 0)
1236 if (connect(rplay_fd, (struct sockaddr *) saddr, sizeof(*saddr)) < 0)
12361237 {
12371238 rplay_errno = RPLAY_ERROR_CONNECT;
12381239 return -1;
12461247 */
12471248 #ifdef __STDC__
12481249 int
1249 rplay (int rplay_fd, RPLAY *rp)
1250 #else
1251 int
1252 rplay (rplay_fd, rp)
1250 rplay(int rplay_fd, RPLAY *rp)
1251 #else
1252 int
1253 rplay(rplay_fd, rp)
12531254 int rplay_fd;
12541255 RPLAY *rp;
12551256 #endif
12561257 {
12571258 rplay_errno = RPLAY_ERROR_NONE;
12581259
1259 if (write (rplay_fd, rp->buf, rp->len) != rp->len)
1260 if (write(rplay_fd, rp->buf, rp->len) != rp->len)
12601261 {
12611262 rplay_errno = RPLAY_ERROR_WRITE;
12621263 return -1;
12701271 */
12711272 #ifdef __STDC__
12721273 int
1273 rplay_close (int rplay_fd)
1274 #else
1275 int
1276 rplay_close (rplay_fd)
1274 rplay_close(int rplay_fd)
1275 #else
1276 int
1277 rplay_close(rplay_fd)
12771278 int rplay_fd;
12781279 #endif
12791280 {
12801281 rplay_errno = RPLAY_ERROR_NONE;
12811282
1282 if (close (rplay_fd) < 0)
1283 if (close(rplay_fd) < 0)
12831284 {
12841285 rplay_errno = RPLAY_ERROR_CLOSE;
12851286 return -1;
12931294 */
12941295 #ifdef __STDC__
12951296 void
1296 rplay_perror (char *s)
1297 rplay_perror(char *s)
12971298 #else
12981299 void
1299 rplay_perror (s)
1300 rplay_perror(s)
13001301 char *s;
13011302 #endif
13021303 {
1303 fprintf (stderr, "%s: %s\n", s, rplay_errlist[rplay_errno]);
1304 fprintf(stderr, "%s: %s\n", s, rplay_errlist[rplay_errno]);
13041305 }
13051306
13061307 /*
13091310 */
13101311 #ifdef __STDC__
13111312 int
1312 rplay_open_display (void)
1313 #else
1314 int
1315 rplay_open_display ()
1313 rplay_open_display(void)
1314 #else
1315 int
1316 rplay_open_display()
13161317 #endif
13171318 {
13181319 char *display, *p;
13191320 char host[MAXHOSTNAMELEN];
13201321
1321 display = getenv ("DISPLAY");
1322 display = getenv("DISPLAY");
13221323 if (display == NULL || display[0] == ':')
13231324 {
1324 strcpy (host, "localhost");
1325 strcpy(host, "localhost");
13251326 }
13261327 else
13271328 {
1328 strcpy (host, display);
1329 p = strchr (host, ':');
1329 strcpy(host, display);
1330 p = strchr(host, ':');
13301331 if (p)
13311332 {
13321333 *p = '\0';
13331334 }
1334 if (strcmp (host, "unix") == 0 || strcmp (host, "local") == 0 || strcmp (host, "X") == 0)
1335 {
1336 strcpy (host, "localhost");
1337 }
1338 }
1339
1340 return rplay_open (host);
1335 if (strcmp(host, "unix") == 0 || strcmp(host, "local") == 0 || strcmp(host, "X") == 0)
1336 {
1337 strcpy(host, "localhost");
1338 }
1339 }
1340
1341 return rplay_open(host);
13411342 }
13421343
13431344 /*
13451346 */
13461347 #ifdef __STDC__
13471348 int
1348 rplay_display (char *sound)
1349 #else
1350 int
1351 rplay_display (sound)
1349 rplay_display(char *sound)
1350 #else
1351 int
1352 rplay_display(sound)
13521353 char *sound;
13531354 #endif
13541355 {
13551356 int rplay_fd;
13561357
1357 rplay_fd = rplay_open_display ();
1358 rplay_fd = rplay_open_display();
13581359 if (rplay_fd < 0)
13591360 {
13601361 return -1;
13611362 }
13621363
1363 return rplay_sound (rplay_fd, sound);
1364 return rplay_sound(rplay_fd, sound);
13641365 }
13651366
13661367 /*
13681369 */
13691370 #ifdef __STDC__
13701371 int
1371 rplay_local (char *sound)
1372 #else
1373 int
1374 rplay_local (sound)
1372 rplay_local(char *sound)
1373 #else
1374 int
1375 rplay_local(sound)
13751376 char *sound;
13761377 #endif
13771378 {
1378 return rplay_host ("localhost", sound);
1379 return rplay_host("localhost", sound);
13791380 }
13801381
13811382 /*
13831384 */
13841385 #ifdef __STDC__
13851386 int
1386 rplay_host (char *host, char *sound)
1387 #else
1388 int
1389 rplay_host (host, sound)
1387 rplay_host(char *host, char *sound)
1388 #else
1389 int
1390 rplay_host(host, sound)
13901391 char *host;
13911392 char *sound;
13921393 #endif
13931394 {
13941395 int rplay_fd;
13951396
1396 rplay_fd = rplay_open (host);
1397 rplay_fd = rplay_open(host);
13971398 if (rplay_fd < 0)
13981399 {
13991400 return -1;
14001401 }
14011402
1402 return rplay_sound (rplay_fd, sound);
1403 return rplay_sound(rplay_fd, sound);
14031404 }
14041405
14051406 /*
14071408 */
14081409 #ifdef __STDC__
14091410 int
1410 rplay_sound (int rplay_fd, char *sound)
1411 #else
1412 int
1413 rplay_sound (rplay_fd, sound)
1411 rplay_sound(int rplay_fd, char *sound)
1412 #else
1413 int
1414 rplay_sound(rplay_fd, sound)
14141415 int rplay_fd;
14151416 char *sound;
14161417 #endif
14171418 {
14181419 RPLAY *rp;
14191420
1420 rp = rplay_create (RPLAY_PLAY);
1421 rp = rplay_create(RPLAY_PLAY);
14211422 if (rp == NULL)
14221423 {
14231424 return -1;
14241425 }
14251426
1426 if (rplay_set (rp, RPLAY_APPEND, RPLAY_SOUND, sound, NULL) < 0)
1427 {
1428 return -1;
1429 }
1430
1431 if (rplay (rplay_fd, rp) < 0)
1432 {
1433 return -1;
1434 }
1435
1436 rplay_destroy (rp);
1427 if (rplay_set(rp, RPLAY_APPEND, RPLAY_SOUND, sound, NULL) < 0)
1428 {
1429 return -1;
1430 }
1431
1432 if (rplay(rplay_fd, rp) < 0)
1433 {
1434 return -1;
1435 }
1436
1437 rplay_destroy(rp);
14371438
14381439 return 0;
14391440 }
14431444 */
14441445 #ifdef __STDC__
14451446 int
1446 rplay_ping (char *host)
1447 #else
1448 int
1449 rplay_ping (host)
1447 rplay_ping(char *host)
1448 #else
1449 int
1450 rplay_ping(host)
14501451 char *host;
14511452 #endif
14521453 {
14551456 int error1 = 0, error2 = 0;
14561457
14571458 /* Ping the default port. */
1458 port = default_rplay_port ();
1459 rplay_fd = rplay_open_port (host, port);
1459 port = default_rplay_port();
1460 rplay_fd = rplay_open_port(host, port);
14601461 if (rplay_fd < 0)
14611462 {
14621463 return -1;
14631464 }
1464 error1 = rplay_ping_sockfd (rplay_fd);
1465 error1 = rplay_ping_sockfd(rplay_fd);
14651466
14661467 #ifdef OTHER_RPLAY_PORTS
14671468 /* Pick an alternative port. */
14751476 }
14761477
14771478 /* Ping the alternative port. */
1478 rplay_fd = rplay_open_port (host, port);
1479 rplay_fd = rplay_open_port(host, port);
14791480 if (rplay_fd < 0)
14801481 {
14811482 return -1;
14821483 }
1483 error2 = rplay_ping_sockfd (rplay_fd);
1484 error2 = rplay_ping_sockfd(rplay_fd);
14841485 #endif /* OTHER_RPLAY_PORTS */
14851486
14861487 /* Only return -1 if both pings fail. */
14961497
14971498 #ifdef __STDC__
14981499 int
1499 rplay_ping_sockfd (int rplay_fd)
1500 #else
1501 int
1502 rplay_ping_sockfd (rplay_fd)
1500 rplay_ping_sockfd(int rplay_fd)
1501 #else
1502 int
1503 rplay_ping_sockfd(rplay_fd)
15031504 int rplay_fd;
15041505 #endif
15051506 {
15061507 RPLAY *rp;
15071508
1508 rp = rplay_create (RPLAY_PING);
1509 rp = rplay_create(RPLAY_PING);
15091510 if (rp == NULL)
15101511 {
15111512 return -1;
15121513 }
15131514
1514 if (rplay_pack (rp) < 0)
1515 {
1516 return -1;
1517 }
1518
1519 if (rplay (rplay_fd, rp) < 0)
1520 {
1521 return -1;
1522 }
1523
1524 rplay_close (rplay_fd);
1525 rplay_destroy (rp);
1515 if (rplay_pack(rp) < 0)
1516 {
1517 return -1;
1518 }
1519
1520 if (rplay(rplay_fd, rp) < 0)
1521 {
1522 return -1;
1523 }
1524
1525 rplay_close(rplay_fd);
1526 rplay_destroy(rp);
15261527
15271528 return 0;
15281529 }
15291530
15301531 #ifdef __STDC__
15311532 int
1532 rplay_ping_sockaddr_in (struct sockaddr_in *saddr)
1533 #else
1534 int
1535 rplay_ping_sockaddr_in (saddr)
1533 rplay_ping_sockaddr_in(struct sockaddr_in *saddr)
1534 #else
1535 int
1536 rplay_ping_sockaddr_in(saddr)
15361537 struct sockaddr_in *saddr;
15371538 #endif
15381539 {
15391540 int rplay_fd;
15401541
1541 rplay_fd = rplay_open_sockaddr_in (saddr);
1542 rplay_fd = rplay_open_sockaddr_in(saddr);
15421543 if (rplay_fd < 0)
15431544 {
15441545 return -1;
15451546 }
15461547
1547 return rplay_ping_sockfd (rplay_fd);
1548 return rplay_ping_sockfd(rplay_fd);
15481549 }
15491550
15501551 /*
15521553 */
15531554 #ifdef __STDC__
15541555 int
1555 rplay_host_volume (char *host, char *sound, int volume)
1556 #else
1557 int
1558 rplay_host_volume (host, sound, volume)
1556 rplay_host_volume(char *host, char *sound, int volume)
1557 #else
1558 int
1559 rplay_host_volume(host, sound, volume)
15591560 char *host;
15601561 char *sound;
15611562 int volume;
15641565 int rplay_fd;
15651566 RPLAY *rp;
15661567
1567 rplay_fd = rplay_open (host);
1568 rplay_fd = rplay_open(host);
15681569 if (rplay_fd < 0)
15691570 {
15701571 return -1;
15711572 }
15721573
1573 rp = rplay_create (RPLAY_PLAY);
1574 rp = rplay_create(RPLAY_PLAY);
15741575 if (rp == NULL)
15751576 {
15761577 return -1;
15771578 }
15781579
1579 if (rplay_set (rp, RPLAY_APPEND, RPLAY_SOUND, sound, RPLAY_VOLUME, volume, NULL) < 0)
1580 {
1581 return -1;
1582 }
1583
1584 if (rplay (rplay_fd, rp) < 0)
1585 {
1586 return -1;
1587 }
1588
1589 rplay_destroy (rp);
1580 if (rplay_set(rp, RPLAY_APPEND, RPLAY_SOUND, sound, RPLAY_VOLUME, volume, NULL) < 0)
1581 {
1582 return -1;
1583 }
1584
1585 if (rplay(rplay_fd, rp) < 0)
1586 {
1587 return -1;
1588 }
1589
1590 rplay_destroy(rp);
15901591
15911592 return 0;
15921593 }
15961597 */
15971598 #ifdef __STDC__
15981599 char *
1599 rplay_default_host (void)
1600 rplay_default_host(void)
16001601 #else
16011602 char *
1602 rplay_default_host ()
1603 rplay_default_host()
16031604 #endif
16041605 {
16051606 char *host;
16061607
1607 host = getenv ("RPLAY_HOST");
1608 host = getenv("RPLAY_HOST");
16081609
16091610 return host ? host : "localhost";
16101611 }
16141615 */
16151616 #ifdef __STDC__
16161617 int
1617 rplay_default (char *sound)
1618 #else
1619 int
1620 rplay_default (sound)
1618 rplay_default(char *sound)
1619 #else
1620 int
1621 rplay_default(sound)
16211622 char *sound;
16221623 #endif
16231624 {
1624 return rplay_host (rplay_default_host (), sound);
1625 return rplay_host(rplay_default_host(), sound);
16251626 }
16261627
16271628 /*
16291630 */
16301631 #ifdef __STDC__
16311632 int
1632 rplay_open_default (void)
1633 #else
1634 int
1635 rplay_open_default ()
1636 #endif
1637 {
1638 return rplay_open (rplay_default_host ());
1639 }
1633 rplay_open_default(void)
1634 #else
1635 int
1636 rplay_open_default()
1637 #endif
1638 {
1639 return rplay_open(rplay_default_host());
1640 }
0 /* $Id: rptp.c,v 1.2 1998/08/13 06:13:38 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: rptp.c,v 1.4 1999/03/10 07:57:56 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
6363 };
6464
6565 #ifdef __STDC__
66 unsigned long inet_addr (char *rp);
67 #else
68 unsigned long inet_addr ();
66 unsigned long inet_addr(char *rp);
67 #else
68 unsigned long inet_addr();
6969 #endif
7070
7171 #ifndef HAVE_STRDUP
7272 #ifdef __STDC__
7373 static char *
74 strdup (char *str)
74 strdup(char *str)
7575 #else
7676 static char *
77 strdup (str)
77 strdup(str)
7878 char *str;
7979 #endif
8080 {
8181 char *p;
8282
83 p = (char *) malloc (strlen (str) + 1);
83 p = (char *) malloc(strlen(str) + 1);
8484 if (p == NULL)
8585 {
8686 return NULL;
8787 }
8888 else
8989 {
90 strcpy (p, str);
90 strcpy(p, str);
9191 return p;
9292 }
9393 }
9999 */
100100 #ifdef __STDC__
101101 int
102 rptp_open (char *host, int port, char *response, int response_size)
103 #else
104 int
105 rptp_open (host, port, response, response_size)
102 rptp_open(char *host, int port, char *response, int response_size)
103 #else
104 int
105 rptp_open(host, port, response, response_size)
106106 char *host;
107107 int port;
108108 char *response;
117117
118118 rptp_errno = RPTP_ERROR_NONE;
119119
120 memset ((char *) &s, 0, sizeof (s));
121
122 addr = inet_addr (host);
120 memset((char *) &s, 0, sizeof(s));
121
122 addr = inet_addr(host);
123123 if (addr == 0xffffffff)
124124 {
125 hp = gethostbyname (host);
125 hp = gethostbyname(host);
126126 if (hp == NULL)
127127 {
128128 rptp_errno = RPTP_ERROR_HOST;
129129 return -1;
130130 }
131 memcpy ((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
131 memcpy((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
132132 }
133133 else
134134 {
135 memcpy ((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof (addr));
136 }
137
138 s.sin_port = htons (port);
135 memcpy((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof(addr));
136 }
137
138 s.sin_port = htons(port);
139139 s.sin_family = AF_INET;
140140
141141 for (i = 0; i < RPTP_CONNECT_ATTEMPTS; i++)
142142 {
143 if (rplay_ping (host) < 0)
143 if (rplay_ping(host) < 0)
144144 {
145145 rptp_errno = RPTP_ERROR_PING;
146146 return -1;
147147 }
148148
149 rptp_fd = socket (AF_INET, SOCK_STREAM, 0);
149 rptp_fd = socket(AF_INET, SOCK_STREAM, 0);
150150 if (rptp_fd < 0)
151151 {
152152 rptp_errno = RPTP_ERROR_SOCKET;
153153 return -1;
154154 }
155155
156 n = connect (rptp_fd, (struct sockaddr *) &s, sizeof (s));
156 n = connect(rptp_fd, (struct sockaddr *) &s, sizeof(s));
157157 if (n == 0)
158158 {
159159 /*
160160 * successful connection
161161 */
162 rptp_getline (rptp_fd, response, response_size);
162 rptp_getline(rptp_fd, response, response_size);
163163 if (response[0] == RPTP_ERROR)
164164 {
165165 rptp_errno = RPTP_ERROR_OPEN;
172172 {
173173 case ECONNREFUSED:
174174 case EINTR:
175 close (rptp_fd);
175 close(rptp_fd);
176176 if (i + 1 != RPTP_CONNECT_ATTEMPTS)
177177 {
178 sleep (RPTP_PING_DELAY);
178 sleep(RPTP_PING_DELAY);
179179 }
180180 break;
181181
200200 */
201201 #ifdef __STDC__
202202 int
203 rptp_read (int rptp_fd, char *ptr, int nbytes)
204 #else
205 int
206 rptp_read (rptp_fd, ptr, nbytes)
203 rptp_read(int rptp_fd, char *ptr, int nbytes)
204 #else
205 int
206 rptp_read(rptp_fd, ptr, nbytes)
207207 int rptp_fd;
208208 char *ptr;
209209 int nbytes;
217217
218218 while (nleft > 0)
219219 {
220 nread = read (rptp_fd, ptr, nleft);
220 nread = read(rptp_fd, ptr, nleft);
221221 if (nread < 0)
222222 {
223223 if (errno == EINTR)
248248 */
249249 #ifdef __STDC__
250250 int
251 rptp_write (int rptp_fd, char *ptr, int nbytes)
252 #else
253 int
254 rptp_write (rptp_fd, ptr, nbytes)
251 rptp_write(int rptp_fd, char *ptr, int nbytes)
252 #else
253 int
254 rptp_write(rptp_fd, ptr, nbytes)
255255 int rptp_fd;
256256 char *ptr;
257257 int nbytes;
265265
266266 while (nleft > 0)
267267 {
268 nwritten = write (rptp_fd, ptr, nleft);
268 nwritten = write(rptp_fd, ptr, nleft);
269269 if (nwritten < 0)
270270 {
271271 if (errno == EINTR)
294294 */
295295 #ifdef __STDC__
296296 int
297 rptp_putline (int rptp_fd, char *fmt,...)
298 #else
299 int
300 rptp_putline (va_alist)
297 rptp_putline(int rptp_fd, char *fmt,...)
298 #else
299 int
300 rptp_putline(va_alist)
301301 va_dcl
302302 #endif
303303 {
305305 char buf[RPTP_MAX_LINE];
306306
307307 #ifdef __STDC__
308 va_start (args, fmt);
308 va_start(args, fmt);
309309 #else
310310 int rptp_fd;
311311 char *fmt;
312 va_start (args);
313 rptp_fd = va_arg (args, int);
314 fmt = va_arg (args, char *);
312 va_start(args);
313 rptp_fd = va_arg(args, int);
314 fmt = va_arg(args, char *);
315315 #endif
316316
317317 rptp_errno = RPTP_ERROR_NONE;
318318
319 vsprintf (buf, fmt, args);
320 va_end (args);
321 strcat (buf, "\r\n");
322
323 return rptp_write (rptp_fd, buf, strlen (buf)) != strlen (buf) ? -1 : 0;
319 vsprintf(buf, fmt, args);
320 va_end(args);
321 strcat(buf, "\r\n");
322
323 return rptp_write(rptp_fd, buf, strlen(buf)) != strlen(buf) ? -1 : 0;
324324 }
325325
326326 /*
330330 */
331331 #ifdef __STDC__
332332 int
333 rptp_getline (int rptp_fd, char *buf, int nbytes)
334 #else
335 int
336 rptp_getline (rptp_fd, buf, nbytes)
333 rptp_getline(int rptp_fd, char *buf, int nbytes)
334 #else
335 int
336 rptp_getline(rptp_fd, buf, nbytes)
337337 int rptp_fd;
338338 char *buf;
339339 int nbytes;
354354 * peek at the message so only the necessary data
355355 * is actually read
356356 */
357 n = recv (rptp_fd, ptr, nleft, MSG_PEEK);
357 n = recv(rptp_fd, ptr, nleft, MSG_PEEK);
358358 if (n < 0)
359359 {
360360 if (errno == EINTR)
383383 }
384384 }
385385 again:
386 x = read (rptp_fd, tmp_buf, i == n ? n : i + 1);
386 x = read(rptp_fd, tmp_buf, i == n ? n : i + 1);
387387 if (x < 0)
388388 {
389389 if (errno == EINTR)
419419 */
420420 #ifdef __STDC__
421421 int
422 rptp_command (int rptp_fd, char *command, char *response, int response_size)
423 #else
424 int
425 rptp_command (rptp_fd, command, response, response_size)
422 rptp_command(int rptp_fd, char *command, char *response, int response_size)
423 #else
424 int
425 rptp_command(rptp_fd, command, response, response_size)
426426 int rptp_fd;
427427 char *command;
428428 char *response;
431431 {
432432 rptp_errno = RPTP_ERROR_NONE;
433433
434 if (rptp_putline (rptp_fd, command) < 0)
434 if (rptp_putline(rptp_fd, command) < 0)
435435 {
436436 return -1;
437437 }
438 if (rptp_getline (rptp_fd, response, response_size) < 0)
438 if (rptp_getline(rptp_fd, response, response_size) < 0)
439439 {
440440 return -1;
441441 }
463463 */
464464 #ifdef __STDC__
465465 int
466 rptp_close (int rptp_fd)
467 #else
468 int
469 rptp_close (rptp_fd)
466 rptp_close(int rptp_fd)
467 #else
468 int
469 rptp_close(rptp_fd)
470470 int rptp_fd;
471471 #endif
472472 {
473473 rptp_errno = RPTP_ERROR_NONE;
474474
475 close (rptp_fd);
475 close(rptp_fd);
476476
477477 return 0;
478478 }
482482 */
483483 #ifdef __STDC__
484484 void
485 rptp_perror (char *message)
485 rptp_perror(char *message)
486486 #else
487487 void
488 rptp_perror (message)
488 rptp_perror(message)
489489 char *message;
490490 #endif
491491 {
492 fprintf (stderr, "%s: %s\n", message, rptp_errlist[rptp_errno]);
492 fprintf(stderr, "%s: %s\n", message, rptp_errlist[rptp_errno]);
493493 }
494494
495495 /*
529529
530530 #ifdef __STDC__
531531 char *
532 rptp_parse (char *response, char *name)
532 rptp_parse(char *response, char *name)
533533 #else
534534 char *
535 rptp_parse (response, name)
535 rptp_parse(response, name)
536536 char *response;
537537 char *name;
538538 #endif
551551 char *p;
552552 char *response_name = "", *response_value = "";
553553
554 list_free ();
554 list_free();
555555 if (buf)
556556 {
557 free ((char *) buf);
558 }
559 buf = strdup (response);
557 free((char *) buf);
558 }
559 buf = strdup(response);
560560
561561 p = buf;
562562
573573 while (p && *p)
574574 {
575575 /* Skip white-space. */
576 if (isspace (*p))
577 {
578 for (p++; isspace (*p); p++) ;
576 if (isspace(*p))
577 {
578 for (p++; isspace(*p); p++) ;
579579 continue;
580580 }
581581
582582 /* `name' */
583583 response_name = p;
584 p = strpbrk (p, "= \t\r\n");
584 p = strpbrk(p, "= \t\r\n");
585585
586586 /* `value' */
587587 if (p && *p == '=')
599599 response_value = p;
600600 if (quoted)
601601 {
602 p = strchr (p, '"');
602 p = strchr(p, '"');
603603 }
604604 else
605605 {
606 p = strpbrk (p, " \t\r\n");
606 p = strpbrk(p, " \t\r\n");
607607 }
608608 if (p)
609609 {
615615 *p++ = '\0';
616616 }
617617
618 list_add (response_name, response_value);
618 list_add(response_name, response_value);
619619 response_name = "";
620620 response_value = "";
621621 }
629629 {
630630 LIST *l;
631631 char *p;
632
632
633633 /* Skip any leading dashes. */
634634 while (*name == '-')
635635 {
636636 name++;
637637 }
638
638
639639 if (cache_pos)
640640 {
641 for (p = cache_pos->name; *p && *p == '-'; p++) ; /* skip leading dashes */
642 if (strcmp (name, p) == 0)
641 for (p = cache_pos->name; *p && *p == '-'; p++) ; /* skip leading dashes */
642 if (strcmp(name, p) == 0)
643643 {
644644 return cache_pos->value;
645645 }
647647
648648 for (l = list; l; l = l->next)
649649 {
650 for (p = l->name; *p && *p == '-'; p++) ; /* skip leading dashes */
651 if (strcmp (p, name) == 0)
650 for (p = l->name; *p && *p == '-'; p++) ; /* skip leading dashes */
651 if (strcmp(p, name) == 0)
652652 {
653653 return l->value;
654654 }
+0
-8
perl/CVS/Entries less more
0 /.Mailsounds/1.1.1.1/Tue Jul 14 22:35:24 1998//
1 /example.pl/1.1.1.1/Tue Jul 14 22:35:24 1998//
2 /rplay.ph/1.1.1.1/Tue Jul 14 22:35:24 1998//
3 /RPlay.pm/1.2/Mon Sep 7 01:56:59 1998//
4 /Mailsound/1.3/Sat Sep 19 18:46:41 1998//
5 /Mailsound.1/1.2/Sat Sep 19 18:49:33 1998//
6 /RPTP.pm/1.1/Mon Oct 12 16:07:05 1998//
7 D
+0
-1
perl/CVS/Repository less more
0 /usr/local/cvsroot/rplay/perl
+0
-1
perl/CVS/Root less more
0 /usr/local/cvsroot
0 # $Id: RPTP.pm,v 1.1 1998/10/12 16:07:05 boyns Exp $ -*-perl-*-
1 #
2 # Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 #
4 # This file is part of rplay.
5 #
6 # rplay is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # rplay is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with rplay; see the file COPYING. If not, write to the
18 # Free Software Foundation, Inc.,
19 # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20 #
0 # $Id: RPTP.pm,v 1.2 1999/03/12 18:51:45 boyns Exp $ -*-perl-*-
1 #
2 # Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 #
4 # This file is part of rplay.
5 #
6 # rplay is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # rplay is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with rplay; see the file COPYING. If not, write to the
18 # Free Software Foundation, Inc.,
19 # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20 #
21
22 require "rplay.ph";
23 require 5.000;
2124
2225 package RPTP;
2326
24 require 5.000;
25 require "rplay.ph";
2627 require "shellwords.pl";
2728 use FileHandle;
2829 use Socket;
6263 my $tcp = $proto;
6364 #($name, $aliases, $port, $proto) = getservbyname ('rplay', 'udp');
6465
65 $that_port = &RPTP_PORT;
66 $that_port = &main::RPTP_PORT;
6667
6768 chop ($this_host = `hostname`);
6869 ($name, $aliases, $addrtype, $length, $this_addr) =
257258 "!" => "timeout",
258259 "@" => "event"
259260 );
260
261
261262 sub mainloop
262263 {
263264 my $self = shift;
264 my $emask;
265 foreach (keys %{$self->{callbacks}})
266 {
267 next if /(ok|error|timeout|event)/;
268 $emask .= "$_|";
269 }
270 chop $emask;
271
272 $self->writeline("set notify=$emask");
265 my $single = shift;
266
267 if (!$self->{initialized})
268 {
269 my $emask;
270 foreach (keys %{$self->{callbacks}})
271 {
272 next if /(ok|error|timeout|event)/;
273 $emask .= "$_|";
274 }
275 chop $emask;
276 $self->writeline("set notify=$emask");
277 $self->{initialized} = 1;
278 }
273279
274280 for (;;)
275281 {
276282 my %hash = $self->readline();
277283 my $type = $proto{$hash{_type}};
278 if ($hash{command} eq "set")
279 {
280 next;
281 }
284 next if ($hash{command} eq "set");
282285 my $func;
283286 if (exists($self->{callbacks}{all}))
284287 {
293296 $func = $self->{callbacks}{$hash{$type}};
294297 }
295298 &$func(%hash) if $func;
299 last if $single;
296300 }
297301 }
298302
0 # $Id: RPlay.pm,v 1.2 1998/08/13 06:18:06 boyns Exp $ -*-perl-*-
1 #
2 # Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 #
4 # This file is part of rplay.
5 #
6 # rplay is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # rplay is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with rplay; see the file COPYING. If not, write to the
18 # Free Software Foundation, Inc.,
19 # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20 #
0 # $Id: RPlay.pm,v 1.4 1999/06/10 05:39:06 boyns Exp $ -*-perl-*-
1 #
2 # Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 #
4 # This file is part of rplay.
5 #
6 # rplay is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # rplay is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with rplay; see the file COPYING. If not, write to the
18 # Free Software Foundation, Inc.,
19 # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20 #
21
22 require "rplay.ph";
23 require 5.000;
2124
2225 package RPlay;
23
24 require 5.000;
25 require "rplay.ph";
2626
2727 use Socket;
2828
5454
5555 if (!$that_port)
5656 {
57 $that_port = $name ? $port : &RPLAY_PORT;
57 $that_port = $name ? $port : &main::RPLAY_PORT;
5858 }
5959
6060 chop ($this_host = `hostname`);
8181 sub disconnect
8282 {
8383 my $self = shift;
84
84
8585 close (RPLAY);
8686 $connected = 0;
8787 }
129129 my $self = shift;
130130 my $command = shift;
131131 my @refs = $self->parse (@_);
132 my (%attrs, $name, $packet);
132 my (%attrs, $name, $packet, $data_size, $data);
133133
134134 die "Not connected - use connect () first." unless $connected;
135135
136136 ## Packet header.
137 $packet = pack ("C", &RPLAY_PACKET_ID);
137 $packet = pack ("C", &main::RPLAY_PACKET_ID);
138138 $packet .= pack ("C", $command);
139139
140140 ## Convert name-value hash pairs to RPLAY attributes.
142142 {
143143 %attrs = %$_;
144144
145 if (!$attrs{'sound'})
145 if (!$attrs{'sound'} && $command ne &main::RPLAY_PUT)
146146 {
147147 die "Missing `sound' attribute.";
148148 }
150150 {
151151 if (/sound/)
152152 {
153 $packet .= pack ("C", &RPLAY_SOUND);
153 $packet .= pack ("C", &main::RPLAY_SOUND);
154154 $packet .= "$attrs{$_}\0";
155155 }
156156 elsif (/volume/)
157157 {
158 $packet .= pack ("C", &RPLAY_VOLUME);
158 $packet .= pack ("C", &main::RPLAY_VOLUME);
159159 $packet .= pack ("C", $attrs{$_});
160160 }
161161 elsif (/list_count/)
162162 {
163 $packet .= pack ("C", &RPLAY_LIST_COUNT);
163 $packet .= pack ("C", &main::RPLAY_LIST_COUNT);
164164 $packet .= pack ("C", $attrs{$_});
165165 }
166166 elsif (/priority/)
167167 {
168 $packet .= pack ("C", &RPLAY_PRIORITY);
168 $packet .= pack ("C", &main::RPLAY_PRIORITY);
169169 $packet .= pack ("C", $attrs{$_});
170170 }
171171 elsif (/sample_rate/)
172172 {
173 $packet .= pack ("C", &RPLAY_SAMPLE_RATE);
174 $packet .= pack ("C", $attrs{$_});
173 $packet .= pack ("C", &main::RPLAY_SAMPLE_RATE);
174 $packet .= pack ("N", $attrs{$_});
175175 }
176176 elsif (/list_name/)
177177 {
178 $packet .= pack ("C", &RPLAY_CLIENT_DATA);
178 $packet .= pack ("C", &main::RPLAY_LIST_NAME);
179179 $packet .= "$attrs{$_}\0";
180180 }
181 elsif (/id/)
182 {
183 $packet .= pack ("C", &main::RPLAY_ID);
184 $packet .= pack ("N", $attrs{$_});
185 }
186 elsif (/sequence/)
187 {
188 $packet .= pack ("C", &main::RPLAY_SEQUENCE);
189 $packet .= pack ("N", $attrs{$_});
190 }
191 elsif (/data_size/)
192 {
193 $data_size = $attrs{$_};
194 }
195 elsif (/data/)
196 {
197 $data = $attrs{$_};
198 }
181199 else
182200 {
183201 #warn "Uknown attribute `$_'";
184202 }
185203 }
186 $packet .= pack ("C", &RPLAY_NULL);
187 }
188 $packet .= pack ("C", &RPLAY_NULL);
204
205 if ($data && $data_size)
206 {
207 $packet .= pack ("C", &main::RPLAY_DATA_SIZE);
208 $packet .= pack ("n", $data_size);
209 $packet .= pack ("C", &main::RPLAY_DATA);
210 $packet .= $data;
211 }
212
213 $packet .= pack ("C", &main::RPLAY_NULL);
214 }
215 $packet .= pack ("C", &main::RPLAY_NULL);
189216
190217 send (RPLAY, $packet, 0) || die "send: $!";
191218 }
194221 sub play
195222 {
196223 my $self = shift;
197 $self->doit (&RPLAY_PLAY, @_);
224 $self->doit (&main::RPLAY_PLAY, @_);
198225 }
199226
200227 ## Pause sounds.
201228 sub pause
202229 {
203230 my $self = shift;
204 $self->doit (&RPLAY_PAUSE, @_);
231 $self->doit (&main::RPLAY_PAUSE, @_);
205232 }
206233
207234 ## Continue sounds.
208235 sub continue
209236 {
210237 my $self = shift;
211 $self->doit (&RPLAY_CONTINUE, @_);
238 $self->doit (&main::RPLAY_CONTINUE, @_);
212239 }
213240
214241 ## Stop sounds.
215242 sub stop
216243 {
217244 my $self = shift;
218 $self->doit (&RPLAY_STOP, @_);
245 $self->doit (&main::RPLAY_STOP, @_);
219246 }
220247
221248 ## Done sounds.
222249 sub done
223250 {
224251 my $self = shift;
225 $self->doit (&RPLAY_DONE, @_);
252 $self->doit (&main::RPLAY_DONE, @_);
253 }
254
255 sub put
256 {
257 my $self = shift;
258 $self->doit (&main::RPLAY_PUT, @_);
226259 }
227260
228261 1;
+0
-3
rplay/CVS/Entries less more
0 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:22 1998//
1 /rplay.c/1.4/Thu Oct 15 15:15:25 1998//
2 D
+0
-1
rplay/CVS/Repository less more
0 /usr/local/cvsroot/rplay/rplay
+0
-1
rplay/CVS/Root less more
0 /usr/local/cvsroot
2323 $(TARGET): $(OBJS) ../librplay/$(LIBRPLAY_NAME) ../lib/librp.a
2424 $(CC) -o $@ $(OBJS) $(LDFLAGS)
2525
26 ../librplay/$(LIBRPLAY_NAME):
27 (cd ../librplay; $(MAKE) $(MFLAGS))
28
29 ../lib/librp.a:
30 (cd ../lib; $(MAKE) $(MFLAGS))
31
2632 install: all
2733 $(MKINSTALLDIRS) $(bindir)
2834 $(INSTALL_PROGRAM) $(TARGET) $(bindir)/$(TARGET)
0 /* $Id: rplay.c,v 1.4 1998/10/15 15:15:25 boyns Exp $ */
0 /* $Id: rplay.c,v 1.8 1999/03/10 07:57:59 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifdef HAVE_CONFIG_H
2624 #include "config.h"
4745 {
4846 {"continue", no_argument, NULL, 'c'},
4947 {"count", required_argument, NULL, 'n'},
48 {"flow", required_argument, NULL, 14},
5049 {"help", no_argument, NULL, 3},
5150 {"host", required_argument, NULL, 'h'},
5251 {"hosts", required_argument, NULL, 'h'},
5655 {"info-cs4231", no_argument, NULL, 10},
5756 {"info-dbri", no_argument, NULL, 9},
5857 {"info-gsm", no_argument, NULL, 13},
58 {"info-cd", no_argument, NULL, 15},
5959 {"buffer-size", required_argument, NULL, 'b'},
6060 {"list-count", required_argument, NULL, 'N'},
6161 {"list-name", required_argument, NULL, 7},
8686 typedef int (*PLAY_FUNC) ();
8787 #endif
8888
89 void doit (), play (), usage (), interrupt ();
90 int server_has_sound ();
91 char *info2str ();
92 int play_with_flow (), play_with_play ();
89 void doit(), play(), usage(), interrupt();
90 int server_has_sound();
91 char *info2str();
92 int play_with_flow(), play_with_play();
9393
9494 RPLAY *rp;
9595 char cwd[MAXPATHLEN];
9999 int buffer_size = BUFFER_SIZE;
100100
101101 #ifdef __STDC__
102 main (int argc, char **argv)
102 main(int argc, char **argv)
103103 #else
104 main (argc, argv)
104 main(argc, argv)
105105 int argc;
106106 char **argv;
107107 #endif
117117
118118 if (argc < 2)
119119 {
120 usage ();
121 }
122
123 signal (SIGPIPE, SIG_IGN);
124
125 if (getcwd (cwd, sizeof (cwd)) == NULL)
120 usage();
121 }
122
123 signal(SIGPIPE, SIG_IGN);
124
125 if (getcwd(cwd, sizeof(cwd)) == NULL)
126126 {
127127 cwd[0] = '\0';
128128 }
129
129
130130 command = RPLAY_PLAY;
131131 list_count = RPLAY_DEFAULT_LIST_COUNT;
132132 list_name = NULL;
133133 priority = RPLAY_DEFAULT_PRIORITY;
134134 do_random = 0;
135 hosts = rplay_default_host ();
135 hosts = rplay_default_host();
136136
137137 name = NULL;
138138 sample_rate = RPLAY_DEFAULT_SAMPLE_RATE;
140140 count = RPLAY_DEFAULT_COUNT;
141141
142142 /* First scan the args to see what the command is. */
143 opterr = 0; /* disable getopt errors */
144 while ((c = getopt_long (argc, argv, OPTIONS, longopts, 0)) != -1)
143 opterr = 0; /* disable getopt errors */
144 while ((c = getopt_long(argc, argv, OPTIONS, longopts, 0)) != -1)
145145 {
146146 switch (c)
147147 {
148148 case 2: /* --version */
149 printf ("rplay %s\n", RPLAY_VERSION);
150 exit (0);
149 printf("rplay %s\n", RPLAY_VERSION);
150 exit(0);
151151
152152 case 3: /* --help */
153 usage ();
153 usage();
154154
155155 case 5: /* --reset */
156156 if (command != RPLAY_PLAY)
157157 {
158 usage ();
158 usage();
159159 }
160160 command = RPLAY_RESET;
161161 break;
163163 case 's':
164164 if (command != RPLAY_PLAY)
165165 {
166 usage ();
166 usage();
167167 }
168168 command = RPLAY_STOP;
169169 break;
171171 case 'p':
172172 if (command != RPLAY_PLAY)
173173 {
174 usage ();
174 usage();
175175 }
176176 command = RPLAY_PAUSE;
177177 break;
179179 case 'c':
180180 if (command != RPLAY_PLAY)
181181 {
182 usage ();
182 usage();
183183 }
184184 command = RPLAY_CONTINUE;
185185 break;
189189 optind = optind_val; /* reset optind */
190190
191191 /* Create the RPLAY object. */
192 rp = rplay_create (command);
192 rp = rplay_create(command);
193193 if (rp == NULL)
194194 {
195 rplay_perror ("rplay_create");
196 exit (1);
195 rplay_perror("rplay_create");
196 exit(1);
197197 }
198198
199199 /* Build a list of sounds to be played along with their
200200 attributes. */
201201 while (argc > 1)
202202 {
203 while ((c = getopt_long (argc, argv, OPTIONS, longopts, 0)) != -1)
203 while ((c = getopt_long(argc, argv, OPTIONS, longopts, 0)) != -1)
204204 {
205205 switch (c)
206206 {
210210
211211 case 1:
212212 break;
213
213
214214 case 2: /* --version */
215 printf ("rplay %s\n", RPLAY_VERSION);
216 exit (0);
215 printf("rplay %s\n", RPLAY_VERSION);
216 exit(0);
217217
218218 case 3: /* --help */
219 usage ();
219 usage();
220220
221221 case 4: /* --port */
222 which_port = atoi (optarg);
222 which_port = atoi(optarg);
223223 break;
224224
225225 case 5: /* --reset */
259259 /* GSM encoded u-law files */
260260 sound_info = "gsm,8000";
261261 break;
262
262
263 case 15: /* --info-cd */
264 /* cd quality */
265 sound_info = "linear16,44100,16,2,little-endian";
266 break;
267
263268 case 'N':
264 list_count = atoi (optarg);
269 list_count = atoi(optarg);
265270 break;
266271
267272 case 'P':
268 priority = atoi (optarg);
273 priority = atoi(optarg);
269274 break;
270275
271276 case 'r':
277282 break;
278283
279284 case 'v':
280 volume = atoi (optarg);
285 volume = atoi(optarg);
281286 break;
282287
283288 case 'n':
284 count = atoi (optarg);
289 count = atoi(optarg);
285290 break;
286291
287292 case 'R':
288 sample_rate = atoi (optarg);
293 sample_rate = atoi(optarg);
289294 break;
290295
291296 case 'i':
293298 break;
294299
295300 case 'b':
296 buffer_size = atoi (optarg);
301 buffer_size = atoi(optarg);
297302 break;
298303
299304 default:
300 fprintf (stderr, "Try `rplay --help' for more information.\n");
301 exit (1);
305 fprintf(stderr, "Try `rplay --help' for more information.\n");
306 exit(1);
302307 }
303308 }
304309
306311 {
307312 if (command == RPLAY_PLAY)
308313 {
309 usage ();
314 usage();
310315 }
311316 name = "#0";
312317 }
313318 /* Convert relative file names to absolute. */
314 else if ((*(argv[optind]) != '/') && (strchr (argv[optind], '/')))
319 else if ((*(argv[optind]) != '/') && (strchr(argv[optind], '/')))
315320 {
316321 if (*cwd)
317322 {
318 name = (char *) malloc (strlen (cwd) + strlen (argv[optind]) + 2);
319 strcpy (name, cwd);
320 strcat (name, "/");
321 if (strncmp (argv[optind], "./", 2) == 0)
323 name = (char *) malloc(strlen(cwd) + strlen(argv[optind]) + 2);
324 strcpy(name, cwd);
325 strcat(name, "/");
326 if (strncmp(argv[optind], "./", 2) == 0)
322327 {
323 strcat (name, argv[optind]+2);
328 strcat(name, argv[optind] + 2);
324329 }
325330 else
326331 {
327 strcat (name, argv[optind]);
332 strcat(name, argv[optind]);
328333 }
329334 }
330335 else
341346 argc -= optind;
342347 optind = optind_val;
343348
344 if (rplay_set (rp, RPLAY_LIST_COUNT, list_count, NULL) < 0)
345 {
346 rplay_perror ("rplay_set");
347 exit (1);
348 }
349
350 if (rplay_set (rp, RPLAY_PRIORITY, priority, NULL) < 0)
351 {
352 rplay_perror ("rplay_set");
353 exit (1);
354 }
355
356 if (list_name && rplay_set (rp, RPLAY_LIST_NAME, list_name, NULL) < 0)
357 {
358 rplay_perror ("rplay_set");
359 exit (1);
360 }
361
362 val = rplay_set (rp, RPLAY_APPEND,
363 RPLAY_SOUND, name,
364 RPLAY_VOLUME, volume,
365 RPLAY_COUNT, count,
366 RPLAY_SAMPLE_RATE, sample_rate,
367 RPLAY_CLIENT_DATA, sound_info,
368 NULL);
349 if (rplay_set(rp, RPLAY_LIST_COUNT, list_count, NULL) < 0)
350 {
351 rplay_perror("rplay_set");
352 exit(1);
353 }
354
355 if (rplay_set(rp, RPLAY_PRIORITY, priority, NULL) < 0)
356 {
357 rplay_perror("rplay_set");
358 exit(1);
359 }
360
361 if (list_name && rplay_set(rp, RPLAY_LIST_NAME, list_name, NULL) < 0)
362 {
363 rplay_perror("rplay_set");
364 exit(1);
365 }
366
367 val = rplay_set(rp, RPLAY_APPEND,
368 RPLAY_SOUND, name,
369 RPLAY_VOLUME, volume,
370 RPLAY_COUNT, count,
371 RPLAY_SAMPLE_RATE, sample_rate,
372 RPLAY_CLIENT_DATA, sound_info,
373 NULL);
369374 if (val < 0)
370375 {
371 rplay_perror ("rplay_set");
372 exit (1);
376 rplay_perror("rplay_set");
377 exit(1);
373378 }
374379 }
375380
376381 /* Pick the random sound. */
377382 if (do_random)
378383 {
379 val = rplay_set (rp, RPLAY_RANDOM_SOUND, NULL);
384 val = rplay_set(rp, RPLAY_RANDOM_SOUND, NULL);
380385 if (val < 0)
381386 {
382 rplay_perror ("rplay_set");
383 exit (1);
384 }
385 }
386
387 doit (hosts);
388
389 exit (0);
387 rplay_perror("rplay_set");
388 exit(1);
389 }
390 }
391
392 doit(hosts);
393
394 exit(0);
390395 }
391396
392397 #ifdef __STDC__
393398 void
394 doit (char *hostp)
399 doit(char *hostp)
395400 #else
396401 void
397 doit (hostp)
402 doit(hostp)
398403 char *hostp;
399404 #endif
400405 {
401406 PLAY_FUNC *play_table;
402407 char *host;
403408
404 play_table = (PLAY_FUNC *) malloc (rplay_get (rp, RPLAY_NSOUNDS) * sizeof (PLAY_FUNC));
409 play_table = (PLAY_FUNC *) malloc(rplay_get(rp, RPLAY_NSOUNDS) * sizeof(PLAY_FUNC));
405410 if (play_table == NULL)
406411 {
407 fprintf (stderr, "rplay: out of memory\n");
408 exit (1);
409 }
410
412 fprintf(stderr, "rplay: out of memory\n");
413 exit(1);
414 }
415
411416 /* Cycle through each colon-separated host. */
412417 do
413418 {
414419 int protocol, port;
415420 int rplay_fd = -1;
416
421
417422 host = hostp;
418 hostp = strchr (host, ':');
423 hostp = strchr(host, ':');
419424 if (hostp != NULL)
420425 {
421426 *hostp++ = '\0';
423428
424429 /* Determine which protocol to use. */
425430
426 if (rplay_get (rp, RPLAY_COMMAND) != RPLAY_PLAY)
431 if (rplay_get(rp, RPLAY_COMMAND) != RPLAY_PLAY)
427432 {
428433 protocol = PROTOCOL_RPLAY;
429434 }
430 else if (strcmp ((char *) rplay_get (rp, RPLAY_SOUND, 0), "-") == 0)
435 else if (strcmp((char *) rplay_get(rp, RPLAY_SOUND, 0), "-") == 0)
431436 {
432437 protocol = PROTOCOL_RPTP;
433438 play_table[0] = play_with_flow;
435440 else if (which_protocol == PROTOCOL_GUESS)
436441 {
437442 char response[RPTP_MAX_LINE];
438 rplay_fd = rptp_open (host, RPTP_PORT, response, sizeof (response));
443 rplay_fd = rptp_open(host, RPTP_PORT, response, sizeof(response));
439444 if (rplay_fd < 0)
440445 {
441446 protocol = PROTOCOL_RPLAY;
444449 {
445450 int i, n, sounds_not_found = 0;
446451 char *sound_name;
447
452
448453 /* Count the number of sounds the server doesn't have */
449 n = (int) rplay_get (rp, RPLAY_NSOUNDS);
454 n = (int) rplay_get(rp, RPLAY_NSOUNDS);
450455 for (i = 0; i < n; i++)
451456 {
452457 struct stat st;
453
454 sound_name = (char *) rplay_get (rp, RPLAY_SOUND, i);
455 if (stat (sound_name, &st) < 0)
458
459 sound_name = (char *) rplay_get(rp, RPLAY_SOUND, i);
460 if (stat(sound_name, &st) < 0)
456461 {
457462 st.st_size = 0;
458463 }
459
460 if (!server_has_sound (rplay_fd, sound_name, (int)st.st_size))
464
465 if (!server_has_sound(rplay_fd, sound_name, (int) st.st_size))
461466 {
462467 if (st.st_size)
463468 {
467472 else
468473 {
469474 /* Assume the server can get the sound
470 from another server. */
475 from another server. */
471476 play_table[i] = play_with_play;
472477 }
473478 }
491496
492497 /* Allow the protocol choice to be overridden. */
493498 if (which_protocol != PROTOCOL_GUESS
494 && rplay_get (rp, RPLAY_COMMAND) == RPLAY_PLAY)
499 && rplay_get(rp, RPLAY_COMMAND) == RPLAY_PLAY)
495500 {
496501 int i, n;
497
502
498503 protocol = which_protocol;
499 n = (int) rplay_get (rp, RPLAY_NSOUNDS);
504 n = (int) rplay_get(rp, RPLAY_NSOUNDS);
500505 for (i = 0; i < n; i++)
501506 {
502507 play_table[i] = (protocol == PROTOCOL_RPTP) ? play_with_flow : play_with_play;
503508 }
504509 }
505
510
506511 port = which_port;
507512 if (port == -1)
508513 {
511516 case PROTOCOL_RPLAY:
512517 port = RPLAY_PORT;
513518 break;
514
519
515520 case PROTOCOL_RPTP:
516521 port = RPTP_PORT;
517522 break;
521526 switch (protocol)
522527 {
523528 case PROTOCOL_RPTP:
524 play (rplay_fd, host, port, rp, play_table);
529 play(rplay_fd, host, port, rp, play_table);
525530 break;
526531
527532 case PROTOCOL_RPLAY:
528533 if (rplay_fd != -1)
529534 {
530 rptp_close (rplay_fd);
531 }
532 rplay_fd = rplay_open_port (host, port);
535 rptp_close(rplay_fd);
536 }
537 rplay_fd = rplay_open_port(host, port);
533538 if (rplay_fd < 0)
534539 {
535 rplay_perror (host);
536 exit (1);
537 }
538 if (rplay (rplay_fd, rp) < 0)
539 {
540 rplay_perror (host);
541 exit (1);
542 }
543 rplay_close (rplay_fd);
540 rplay_perror(host);
541 exit(1);
542 }
543 if (rplay(rplay_fd, rp) < 0)
544 {
545 rplay_perror(host);
546 exit(1);
547 }
548 rplay_close(rplay_fd);
544549 break;
545550
546551 default:
547 fprintf (stderr, "unknown protocol\n");
548 exit (1);
552 fprintf(stderr, "unknown protocol\n");
553 exit(1);
549554 }
550555 }
551556 while (hostp != NULL);
554559
555560 #ifdef __STDC__
556561 int
557 server_has_sound (int rplay_fd, char *sound_name, int size)
562 server_has_sound(int rplay_fd, char *sound_name, int size)
558563 #else
559564 int
560 server_has_sound (rplay_fd, sound_name, size)
565 server_has_sound(rplay_fd, sound_name, size)
561566 int rplay_fd;
562567 char *sound_name;
563568 int size;
564 #endif
569 #endif
565570 {
566571 char command[RPTP_MAX_LINE];
567572 char response[RPTP_MAX_LINE];
573578 {
574579 if (try == 0)
575580 {
576 sprintf (command, "info sound=%s", sound_name);
581 sprintf(command, "info sound=%s", sound_name);
577582 }
578583 else
579584 {
580 sprintf (command, "info sound=%s/%s", cwd, sound_name);
581 }
582
583 if (rptp_command (rplay_fd, command, response, sizeof (response)) < 0)
585 sprintf(command, "info sound=%s/%s", cwd, sound_name);
586 }
587
588 if (rptp_command(rplay_fd, command, response, sizeof(response)) < 0)
584589 {
585590 return 0;
586591 }
587592
588593 remote_size = -1;
589 p = rptp_parse (response, "size");
590 if (p) remote_size = atoi(p);
594 p = rptp_parse(response, "size");
595 if (p)
596 remote_size = atoi(p);
591597
592598 if (remote_size != -1
593599 && (size == 0 || remote_size == 0 || size == remote_size))
601607
602608 #ifdef __STDC__
603609 void
604 play (int rplay_fd, char *host, int port, RPLAY *rp, PLAY_FUNC *play_table)
610 play(int rplay_fd, char *host, int port, RPLAY *rp, PLAY_FUNC *play_table)
605611 #else
606612 void
607 play (rplay_fd, rp, play_table)
613 play(rplay_fd, rp, play_table)
608614 int rplay_fd;
609615 RPLAY *rp;
610616 PLAY_TABLE *play_table;
611 #endif
617 #endif
612618 {
613619 int i, n;
614620 char response[RPTP_MAX_LINE];
615621
616 n = rplay_get (rp, RPLAY_NSOUNDS);
622 n = rplay_get(rp, RPLAY_NSOUNDS);
617623 for (i = 0; i < n; i++)
618624 {
619625 if (rplay_fd < 0)
620626 {
621 rplay_fd = rptp_open (host, port, response, sizeof (response));
627 rplay_fd = rptp_open(host, port, response, sizeof(response));
622628 }
623629 if (rplay_fd < 0)
624630 {
625 rptp_perror (host);
631 rptp_perror(host);
626632 continue;
627633 }
628 if ((*play_table[i])(rplay_fd, host, port, rp, i) < 0)
629 {
630 rptp_close (rplay_fd);
634 if ((*play_table[i]) (rplay_fd, host, port, rp, i) < 0)
635 {
636 rptp_close(rplay_fd);
631637 rplay_fd = -1;
632638 }
633639 }
635641
636642 #ifdef __STDC__
637643 int
638 play_with_play (int rplay_fd, char *host, int port, RPLAY *rp, int index)
644 play_with_play(int rplay_fd, char *host, int port, RPLAY *rp, int index)
639645 #else
640646 int
641 play_with_play (rplay_fd, host, port, rp, index)
647 play_with_play(rplay_fd, host, port, rp, index)
642648 int rplay_fd;
643649 char *host;
644650 int port;
650656 char response[RPTP_MAX_LINE];
651657
652658 /* Enable `done' notification. */
653 rptp_putline (rplay_fd, "set notify=done,position notify-rate=1.0");
654 rptp_getline (rplay_fd, response, sizeof (response));
659 rptp_putline(rplay_fd, "set notify=done,position notify-rate=1.0");
660 rptp_getline(rplay_fd, response, sizeof(response));
655661
656662 /* Play the sound. */
657 rptp_putline (rplay_fd, "play priority=%d sample-rate=%d volume=%d list-name=\"%s\" sound=\"%s\"",
658 (int) rplay_get (rp, RPLAY_PRIORITY, index),
659 (int) rplay_get (rp, RPLAY_SAMPLE_RATE, index),
660 (int) rplay_get (rp, RPLAY_VOLUME, index),
661 rplay_get (rp, RPLAY_LIST_NAME) ? (char *) rplay_get (rp, RPLAY_LIST_NAME) : "",
662 (int) rplay_get (rp, RPLAY_SOUND, index));
663 n = rptp_getline (rplay_fd, response, sizeof (response));
663 rptp_putline(rplay_fd, "play priority=%d sample-rate=%d volume=%d list-name=\"%s\" sound=\"%s\"",
664 (int) rplay_get(rp, RPLAY_PRIORITY, index),
665 (int) rplay_get(rp, RPLAY_SAMPLE_RATE, index),
666 (int) rplay_get(rp, RPLAY_VOLUME, index),
667 rplay_get(rp, RPLAY_LIST_NAME) ? (char *) rplay_get(rp, RPLAY_LIST_NAME) : "",
668 (int) rplay_get(rp, RPLAY_SOUND, index));
669 n = rptp_getline(rplay_fd, response, sizeof(response));
664670 if (n < 0 || response[0] != RPTP_OK)
665671 {
666 fprintf (stderr, "rplay: can't play `%s'\n",
667 (int) rplay_get (rp, RPLAY_SOUND, index));
672 fprintf(stderr, "rplay: can't play `%s'\n",
673 (int) rplay_get(rp, RPLAY_SOUND, index));
668674 return -1;
669675 }
670
676
671677 /* Grab the spool id. */
672 spool_id = atoi (1 + rptp_parse (response, "id"));
673
678 spool_id = atoi(1 + rptp_parse(response, "id"));
679
674680 /* Wait for the sound to finish playing. */
675 signal (SIGINT, interrupt);
681 signal(SIGINT, interrupt);
676682 interrupted = 0;
677683 for (;;)
678684 {
679 n = rptp_getline (rplay_fd, response, sizeof (response));
680 fprintf(stderr, response);
685 n = rptp_getline(rplay_fd, response, sizeof(response));
681686 if (interrupted)
682687 {
683688 break;
688693 }
689694 else if (response[0] != RPTP_NOTIFY)
690695 {
691 fprintf (stderr, "rplay: %s\n", response+1);
696 fprintf(stderr, "rplay: %s\n", response + 1);
692697 break;
693698 }
694699
695700 rptp_parse(response, NULL);
696 if (strcmp (rptp_parse(NULL, "event"), "done") == 0
697 && atoi (1 + rptp_parse (NULL, "id")) == spool_id)
698 {
699 break;
700 }
701 }
702 signal (SIGINT, SIG_DFL);
701 if (strcmp(rptp_parse(NULL, "event"), "done") == 0
702 && atoi(1 + rptp_parse(NULL, "id")) == spool_id)
703 {
704 break;
705 }
706 }
707 signal(SIGINT, SIG_DFL);
703708
704709 /* Eat any events and turn off notification. */
705 rptp_putline (rplay_fd, "set notify=none");
710 rptp_putline(rplay_fd, "set notify=none");
706711 for (;;)
707712 {
708 n = rptp_getline (rplay_fd, response, sizeof (response));
713 n = rptp_getline(rplay_fd, response, sizeof(response));
709714 if (n < 0)
710715 {
711716 return -1;
721726
722727 #ifdef __STDC__
723728 int
724 play_with_flow (int rplay_fd, char *host, int port, RPLAY *rp, int index)
729 play_with_flow(int rplay_fd, char *host, int port, RPLAY *rp, int index)
725730 #else
726731 int
727 play_with_flow (rplay_fd, host, port, rp, index)
732 play_with_flow(rplay_fd, host, port, rp, index)
728733 int rplay_fd;
729734 char *host;
730735 int port;
731736 RPLAY *rp;
732737 int index;
733 #endif
738 #endif
734739 {
735 char *sound_name = (char *) rplay_get (rp, RPLAY_SOUND, index);
736 char *sound_info = (char *) rplay_get (rp, RPLAY_CLIENT_DATA, index);
740 char *sound_name = (char *) rplay_get(rp, RPLAY_SOUND, index);
741 char *sound_info = (char *) rplay_get(rp, RPLAY_CLIENT_DATA, index);
737742 char command[RPTP_MAX_LINE];
738743 char response[RPTP_MAX_LINE];
739744 char *buffer;
740745 int spool_id, n, fd, flow_fd;
741746
742 if (strcmp (sound_name, "-") == 0)
747 if (strcmp(sound_name, "-") == 0)
743748 {
744749 fd = 0;
745750 }
746751 else
747752 {
748 fd = open (sound_name, O_RDONLY, 0);
753 fd = open(sound_name, O_RDONLY, 0);
749754 if (fd < 0)
750755 {
751 fprintf (stderr, "rplay: sound `%s' not found\n", sound_name);
756 fprintf(stderr, "rplay: sound `%s' not found\n", sound_name);
752757 return 0;
753758 }
754759 }
755760
756761 /* Open a connection for the flow. */
757 flow_fd = rptp_open (host, port, response, sizeof (response));
762 flow_fd = rptp_open(host, port, response, sizeof(response));
758763 if (flow_fd < 0)
759764 {
760 rptp_perror (host);
765 rptp_perror(host);
761766 return -1;
762767 }
763
768
764769 /* Enable `done' notification. */
765 rptp_putline (rplay_fd, "set notify=done");
766 rptp_getline (rplay_fd, response, sizeof (response));
770 rptp_putline(rplay_fd, "set notify=done");
771 rptp_getline(rplay_fd, response, sizeof(response));
767772
768773 /* Send the flow play command. */
769 rptp_putline (flow_fd, "play input=flow %s priority=%d sample-rate=%d volume=%d list-name=\"%s\" sound=\"%s\"",
770 info2str (sound_info),
771 (int) rplay_get (rp, RPLAY_PRIORITY, index),
772 (int) rplay_get (rp, RPLAY_SAMPLE_RATE, index),
773 (int) rplay_get (rp, RPLAY_VOLUME, index),
774 rplay_get (rp, RPLAY_LIST_NAME) ? (char *) rplay_get (rp, RPLAY_LIST_NAME) : "",
775 strcmp (sound_name, "-") ? sound_name : "stdin");
776 n = rptp_getline (flow_fd, response, sizeof (response));
774 rptp_putline(flow_fd, "play input=flow %s priority=%d sample-rate=%d volume=%d list-name=\"%s\" sound=\"%s\"",
775 info2str(sound_info),
776 (int) rplay_get(rp, RPLAY_PRIORITY, index),
777 (int) rplay_get(rp, RPLAY_SAMPLE_RATE, index),
778 (int) rplay_get(rp, RPLAY_VOLUME, index),
779 rplay_get(rp, RPLAY_LIST_NAME) ? (char *) rplay_get(rp, RPLAY_LIST_NAME) : "",
780 strcmp(sound_name, "-") ? sound_name : "stdin");
781 n = rptp_getline(flow_fd, response, sizeof(response));
777782 if (n < 0 || response[0] != RPTP_OK)
778783 {
779 fprintf (stderr, "rplay: can't play `%s'\n",
780 (int) rplay_get (rp, RPLAY_SOUND, index));
784 fprintf(stderr, "rplay: can't play `%s'\n",
785 (int) rplay_get(rp, RPLAY_SOUND, index));
781786 return -1;
782787 }
783788
784789 /* Grab the spool id. */
785 spool_id = atoi (1 + rptp_parse (response, "id"));
790 spool_id = atoi(1 + rptp_parse(response, "id"));
786791
787792 /* Send the put command. */
788 rptp_putline (flow_fd, "put id=#%d size=0", spool_id);
789 n = rptp_getline (flow_fd, response, sizeof (response));
793 rptp_putline(flow_fd, "put id=#%d size=0", spool_id);
794 n = rptp_getline(flow_fd, response, sizeof(response));
790795 if (n < 0 || response[0] != RPTP_OK)
791796 {
792 fprintf (stderr, "rplay: can't play `%s'\n",
793 (int) rplay_get (rp, RPLAY_SOUND, index));
797 fprintf(stderr, "rplay: can't play `%s'\n",
798 (int) rplay_get(rp, RPLAY_SOUND, index));
794799 return -1;
795800 }
796
801
797802 /* Allocate the buffer. */
798 buffer = (char *) malloc (buffer_size);
803 buffer = (char *) malloc(buffer_size);
799804 if (buffer == NULL)
800805 {
801 fprintf (stderr, "rplay: out of memory\n");
802 exit (1);
803 }
804
805 signal (SIGINT, interrupt);
806 fprintf(stderr, "rplay: out of memory\n");
807 exit(1);
808 }
809
810 signal(SIGINT, interrupt);
806811 interrupted = 0;
807812 for (;;)
808813 {
810815 {
811816 break;
812817 }
813 n = read (fd, buffer, buffer_size);
818 n = read(fd, buffer, buffer_size);
814819 if (n <= 0)
815820 {
816821 break;
817822 }
818 if (rptp_write (flow_fd, buffer, n) != n)
819 {
820 break;
821 }
822 }
823
824 close (fd);
825 /*sleep (1);*/
826 rptp_close (flow_fd);
823 if (rptp_write(flow_fd, buffer, n) != n)
824 {
825 break;
826 }
827 }
828
829 close(fd);
830 /*sleep (1); */
831 rptp_close(flow_fd);
827832
828833 /* Wait for the sound to finish. */
829834 for (;;)
830835 {
831 n = rptp_getline (rplay_fd, response, sizeof (response));
836 n = rptp_getline(rplay_fd, response, sizeof(response));
832837 if (interrupted)
833838 {
834839 break;
839844 }
840845 else if (response[0] != RPTP_NOTIFY)
841846 {
842 fprintf (stderr, "rplay: %s\n", response+1);
843 break;
844 }
845 else if (atoi (1 + rptp_parse (response, "id")) == spool_id)
846 {
847 break;
848 }
849 }
850
851 signal (SIGINT, SIG_DFL);
847 fprintf(stderr, "rplay: %s\n", response + 1);
848 break;
849 }
850 else if (atoi(1 + rptp_parse(response, "id")) == spool_id)
851 {
852 break;
853 }
854 }
855
856 signal(SIGINT, SIG_DFL);
852857
853858 /* Eat any events and turn off notification. */
854 rptp_putline (rplay_fd, "set notify=none");
859 rptp_putline(rplay_fd, "set notify=none");
855860 for (;;)
856861 {
857 n = rptp_getline (rplay_fd, response, sizeof (response));
862 n = rptp_getline(rplay_fd, response, sizeof(response));
858863 if (n < 0)
859864 {
860865 return -1;
870875
871876 #ifdef __STDC__
872877 char *
873 info2str (char *sound_info)
878 info2str(char *sound_info)
874879 #else
875880 char *
876 info2str (sound_info)
881 info2str(sound_info)
877882 char *sound_info;
878 #endif
883 #endif
879884 {
880885 static char str[1024];
881886
884889 {
885890 char buf[1024];
886891 char *p;
887
888 strcpy (buf, sound_info);
892
893 strcpy(buf, sound_info);
889894 /* Example: ulaw,8000,8,1,big-endian,offset */
890 p = strtok (buf, ", ");
891 if (p) sprintf (str + strlen(str), "input-format=%s ", p);
892 p = strtok (NULL, ", ");
893 if (p) sprintf (str + strlen(str), "input-sample-rate=%s ", p);
894 p = strtok (NULL, ", ");
895 if (p) sprintf (str + strlen(str), "input-bits=%s ", p);
896 p = strtok (NULL, ", ");
897 if (p) sprintf (str + strlen(str), "input-channels=%s ", p);
898 p = strtok (NULL, ", ");
899 if (p) sprintf (str + strlen(str), "input-byte-order=%s ", p);
900 p = strtok (NULL, ", ");
901 if (p) sprintf (str + strlen(str), "input-offset=%s ", p);
902 }
903
895 p = strtok(buf, ", ");
896 if (p)
897 sprintf(str + strlen(str), "input-format=%s ", p);
898 p = strtok(NULL, ", ");
899 if (p)
900 sprintf(str + strlen(str), "input-sample-rate=%s ", p);
901 p = strtok(NULL, ", ");
902 if (p)
903 sprintf(str + strlen(str), "input-bits=%s ", p);
904 p = strtok(NULL, ", ");
905 if (p)
906 sprintf(str + strlen(str), "input-channels=%s ", p);
907 p = strtok(NULL, ", ");
908 if (p)
909 sprintf(str + strlen(str), "input-byte-order=%s ", p);
910 p = strtok(NULL, ", ");
911 if (p)
912 sprintf(str + strlen(str), "input-offset=%s ", p);
913 }
914
904915 return str;
905916 }
906917
907918 void
908 interrupt ()
919 interrupt()
909920 {
910921 interrupted++;
911922 fprintf(stderr, "rplay: *interrupt*\n");
912923 }
913924
914925 void
915 usage ()
926 usage()
916927 {
917 printf ("\nrplay %s\n\n", RPLAY_VERSION);
918 printf ("usage: rplay [options] [sound ... ]\n\n");
919
920 printf ("-b BYTES, --buffer-size=BYTES\n");
921 printf ("\tUse of a buffer size of BYTES when playing sounds using RPTP flows.\n");
922 printf ("\tThe default is 8K.\n");
923 printf ("\n");
924
925 printf ("-c, --continue\n");
926 printf ("\tContinue sounds.\n");
927 printf ("\n");
928
929 printf ("-n N, --count=N\n");
930 printf ("\tNumber of times to play the sound, default = %d.\n",
931 RPLAY_DEFAULT_COUNT);
932 printf ("\n");
933
934 printf ("-N N, --list-count=N\n");
935 printf ("\tNumber of times to play all the sounds, default = %d.\n",
936 RPLAY_DEFAULT_LIST_COUNT);
937 printf ("\n");
938
939 printf ("--list-name=NAME\n");
940 printf ("\tName this list NAME. rplayd appends sounds with the same\n");
941 printf ("\tNAME into the same sound list -- it plays them sequentially.\n");
942 printf ("\n");
943
944 printf ("--help\n");
945 printf ("\tDisplay helpful information.\n");
946 printf ("\n");
947
948 printf ("-h HOST, --host=HOST, --hosts=HOST\n");
949 printf ("\tSpecify the rplay host, default = %s.\n", rplay_default_host ());
950 printf ("\n");
951
952 printf ("-i INFO, --info=INFO\n");
953 printf ("\tAudio information for a sound file. This option is intended\n");
954 printf ("\tto be used when sounds are read from standard input.\n");
955 printf ("\tINFO must be of the form:\n");
956 printf ("\t `format,sample-rate,bits,channels,byte-order,offset'\n");
957 printf ("\tExamples: ulaw,8000,8,1,big-endian,0\n");
958 printf ("\t gsm,8000\n");
959 printf ("\tShorthand info is provided for Sun's audio devices using the\n");
960 printf ("\tfollowing options: --info-amd, --info-dbri, --info-cs4231.\n");
961 printf ("\tThere's also: --info-ulaw and --info-gsm.\n");
962 printf ("\n");
963
964 printf ("-p, --pause\n");
965 printf ("\tPause sounds.\n");
966 printf ("\n");
967
968 printf ("--port=PORT\n");
969 printf ("\tUse PORT instead of the default RPLAY/UDP or RPTP/TCP port.\n");
970 printf ("\n");
971
972 printf ("-P N, --priority=N\n");
973 printf ("\tPlay sounds at priority N (%d <= N <= %d), default = %d.\n",
974 RPLAY_MIN_PRIORITY,
975 RPLAY_MAX_PRIORITY,
976 RPLAY_DEFAULT_PRIORITY);
977 printf ("\n");
978
979 printf ("-r, --random\n");
980 printf ("\tRandomly choose one of the given sounds.\n");
981 printf ("\n");
982
983 printf ("--reset\n");
984 printf ("\tTell the server to reset itself.\n");
985 printf ("\n");
986
987 printf ("--rplay, --RPLAY\n");
988 printf ("\tForce the use of the RPLAY protocol.\n");
989 printf ("\
928 printf("\nrplay %s\n\n", RPLAY_VERSION);
929 printf("usage: rplay [options] [sound ... ]\n\n");
930
931 printf("-b BYTES, --buffer-size=BYTES\n");
932 printf("\tUse of a buffer size of BYTES when playing sounds using RPTP flows.\n");
933 printf("\tThe default is 8K.\n");
934 printf("\n");
935
936 printf("-c, --continue\n");
937 printf("\tContinue sounds.\n");
938 printf("\n");
939
940 printf("-n N, --count=N\n");
941 printf("\tNumber of times to play the sound, default = %d.\n",
942 RPLAY_DEFAULT_COUNT);
943 printf("\n");
944
945 printf("-N N, --list-count=N\n");
946 printf("\tNumber of times to play all the sounds, default = %d.\n",
947 RPLAY_DEFAULT_LIST_COUNT);
948 printf("\n");
949
950 printf("--list-name=NAME\n");
951 printf("\tName this list NAME. rplayd appends sounds with the same\n");
952 printf("\tNAME into the same sound list -- it plays them sequentially.\n");
953 printf("\n");
954
955 printf("--help\n");
956 printf("\tDisplay helpful information.\n");
957 printf("\n");
958
959 printf("-h HOST, --host=HOST, --hosts=HOST\n");
960 printf("\tSpecify the rplay host, default = %s.\n", rplay_default_host());
961 printf("\n");
962
963 printf("-i INFO, --info=INFO\n");
964 printf("\tAudio information for a sound file. This option is intended\n");
965 printf("\tto be used when sounds are read from standard input.\n");
966 printf("\tINFO must be of the form:\n");
967 printf("\t `format,sample-rate,bits,channels,byte-order,offset'\n");
968 printf("\tExamples: ulaw,8000,8,1,big-endian,0\n");
969 printf("\t gsm,8000\n");
970 printf("\tShorthand info is provided for Sun's audio devices using the\n");
971 printf("\tfollowing options: --info-amd, --info-dbri, --info-cs4231.\n");
972 printf("\tThere's also: --info-ulaw and --info-gsm.\n");
973 printf("\n");
974
975 printf("-p, --pause\n");
976 printf("\tPause sounds.\n");
977 printf("\n");
978
979 printf("--port=PORT\n");
980 printf("\tUse PORT instead of the default RPLAY/UDP or RPTP/TCP port.\n");
981 printf("\n");
982
983 printf("-P N, --priority=N\n");
984 printf("\tPlay sounds at priority N (%d <= N <= %d), default = %d.\n",
985 RPLAY_MIN_PRIORITY,
986 RPLAY_MAX_PRIORITY,
987 RPLAY_DEFAULT_PRIORITY);
988 printf("\n");
989
990 printf("-r, --random\n");
991 printf("\tRandomly choose one of the given sounds.\n");
992 printf("\n");
993
994 printf("--reset\n");
995 printf("\tTell the server to reset itself.\n");
996 printf("\n");
997
998 printf("--rplay, --RPLAY\n");
999 printf("\tForce the use of the RPLAY protocol.\n");
1000 printf("\
9901001 \tThe default protocol to be used is determined by checking whether or not\n\
9911002 \tthe server has local access to the specified sounds. RPLAY is used when\n\
9921003 \tsounds are accessible, otherwise RPTP and possibly flows are used.\n\
9931004 \tRPLAY will also be used when sound accessibility cannot be determined.\n");
994 printf ("\n");
995
996 printf ("--rptp, --RPTP\n");
997 printf ("\tForce the use of the RPTP protocol.\n");
998 printf ("\tSee `--rplay' for more information about protocols.\n");
999 printf ("\n");
1000
1001 printf ("-R N, --sample-rate=N\n");
1002 printf ("\tPlay sounds at sample rate N, default = %d.\n",
1003 RPLAY_DEFAULT_SAMPLE_RATE);
1004 printf ("\n");
1005
1006 printf ("-s, --stop\n");
1007 printf ("\tStop sounds.\n");
1008 printf ("\n");
1009
1010 printf ("--version\n");
1011 printf ("\tPrint the rplay version and exit.\n");
1012 printf ("\n");
1013
1014 printf ("-v N, --volume=N\n");
1015 printf ("\tPlay sounds at volume N (%d <= N <= %d), default = %d.\n",
1016 RPLAY_MIN_VOLUME,
1017 RPLAY_MAX_VOLUME,
1018 RPLAY_DEFAULT_VOLUME);
1019
1020 exit (1);
1005 printf("\n");
1006
1007 printf("--rptp, --RPTP\n");
1008 printf("\tForce the use of the RPTP protocol.\n");
1009 printf("\tSee `--rplay' for more information about protocols.\n");
1010 printf("\n");
1011
1012 printf("-R N, --sample-rate=N\n");
1013 printf("\tPlay sounds at sample rate N, default = %d.\n",
1014 RPLAY_DEFAULT_SAMPLE_RATE);
1015 printf("\n");
1016
1017 printf("-s, --stop\n");
1018 printf("\tStop sounds.\n");
1019 printf("\n");
1020
1021 printf("--version\n");
1022 printf("\tPrint the rplay version and exit.\n");
1023 printf("\n");
1024
1025 printf("-v N, --volume=N\n");
1026 printf("\tPlay sounds at volume N (%d <= N <= %d), default = %d.\n",
1027 RPLAY_MIN_VOLUME,
1028 RPLAY_MAX_VOLUME,
1029 RPLAY_DEFAULT_VOLUME);
1030
1031 exit(1);
10211032 }
+0
-36
rplayd/CVS/Entries less more
0 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 D/audio////
2 /buffer.c/1.2/Thu Aug 13 06:13:40 1998//
3 /buffer.h/1.2/Thu Aug 13 06:13:41 1998//
4 /cache.c/1.2/Thu Aug 13 06:13:42 1998//
5 /cache.h/1.2/Thu Aug 13 06:13:43 1998//
6 /cdrom.c/1.2/Thu Aug 13 06:13:44 1998//
7 /cdrom.h/1.2/Thu Aug 13 06:13:45 1998//
8 /command.c/1.2/Thu Aug 13 06:13:46 1998//
9 /command.h/1.2/Thu Aug 13 06:13:47 1998//
10 /connection.h/1.2/Thu Aug 13 06:13:49 1998//
11 /flange.c/1.2/Thu Aug 13 06:13:50 1998//
12 /flange.h/1.2/Thu Aug 13 06:13:51 1998//
13 /helper.c/1.2/Thu Aug 13 06:13:52 1998//
14 /helper.h/1.2/Thu Aug 13 06:13:53 1998//
15 /host.c/1.2/Thu Aug 13 06:13:54 1998//
16 /host.h/1.2/Thu Aug 13 06:13:55 1998//
17 /misc.c/1.2/Thu Aug 13 06:13:56 1998//
18 /misc.h/1.2/Thu Aug 13 06:13:57 1998//
19 /native.c/1.2/Thu Aug 13 06:13:58 1998//
20 /native.h/1.2/Thu Aug 13 06:14:00 1998//
21 /rplayd.c/1.2/Thu Aug 13 06:14:01 1998//
22 /rplayd.h/1.2/Thu Aug 13 06:14:02 1998//
23 /server.c/1.2/Thu Aug 13 06:14:03 1998//
24 /server.h/1.2/Thu Aug 13 06:14:04 1998//
25 /sound.h/1.2/Thu Aug 13 06:14:06 1998//
26 /spool.c/1.2/Thu Aug 13 06:14:07 1998//
27 /spool.h/1.2/Thu Aug 13 06:14:08 1998//
28 /timer.c/1.2/Thu Aug 13 06:14:09 1998//
29 /timer.h/1.2/Thu Aug 13 06:14:10 1998//
30 /ulaw.c/1.2/Thu Aug 13 06:14:11 1998//
31 /ulaw.h/1.2/Thu Aug 13 06:14:12 1998//
32 /xhash.c/1.2/Thu Aug 13 06:14:13 1998//
33 /xhash.h/1.2/Thu Aug 13 06:14:14 1998//
34 /connection.c/1.3/Mon Oct 12 16:03:20 1998//
35 /sound.c/1.6/Thu Oct 15 15:15:25 1998//
+0
-1
rplayd/CVS/Repository less more
0 /usr/local/cvsroot/rplay/rplayd
+0
-1
rplayd/CVS/Root less more
0 /usr/local/cvsroot
88 INSTALL_DATA = @INSTALL_DATA@
99 MKINSTALLDIRS= @srcdir@/../mkinstalldirs
1010
11 CPPFLAGS = $(CC_OPTIONS) -I. -I../include -I@srcdir@ -I@srcdir@/../include -I@srcdir@/../lib -I@srcdir@/../adpcm -I@srcdir@/../gsm -I@srcdir@/../rx @DEFS@ \
11 CPPFLAGS = $(CC_OPTIONS) -I. -I../include -I${srcdir} -I${srcdir}/../include \
12 -I${srcdir}/../lib -I${srcdir}/../adpcm \
13 @GSM_INCS@ \
14 @RX_INCS@ @DEFS@ \
1215 -DRPLAY_CONF=\"${sysconfdir}/rplay.conf\" \
1316 -DRPLAY_HOSTS=\"${sysconfdir}/rplay.hosts\" \
1417 -DRPLAY_SERVERS=\"${sysconfdir}/rplay.servers\" \
2124 $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
2225
2326 LDFLAGS= $(LD_OPTIONS) -L../librplay -lrplay -L../lib -lrp \
24 -L../adpcm -ladpcm -L../gsm -lgsm -L../rx -lrx @LDFLAGS@ @LIBS@ -lm
27 -L../adpcm -ladpcm @GSM_LIBS@ -L../rx -lrx @LDFLAGS@ @LIBS@ -lm
2528
2629 TARGET= rplayd
2730
3538
3639 all: $(TARGET)
3740
38 $(TARGET): $(OBJS) ../librplay/$(LIBRPLAY_NAME) ../lib/librp.a ../adpcm/libadpcm.a ../rx/librx.a
41 $(TARGET): $(OBJS) ../librplay/$(LIBRPLAY_NAME) ../lib/librp.a ../adpcm/libadpcm.a
3942 $(CC) -o $@ $(OBJS) $(LDFLAGS)
43
44 ../librplay/$(LIBRPLAY_NAME):
45 (cd ../librplay; $(MAKE) $(MFLAGS))
46
47 ../lib/librp.a:
48 (cd ../lib; $(MAKE) $(MFLAGS))
49
50 ../adpcm/libadpcm.a:
51 (cd ../adpcm; $(MAKE) $(MFLAGS))
4052
4153 install: all
4254 $(MKINSTALLDIRS) $(sbindir)
+0
-16
rplayd/audio/CVS/Entries less more
0 /README/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /audio_FreeBSD.h/1.2/Thu Aug 13 06:14:16 1998//
2 /audio_generic.h/1.2/Thu Aug 13 06:14:18 1998//
3 /audio_oss.h/1.2/Thu Aug 13 06:14:20 1998//
4 /audio_sgi.c/1.2/Thu Aug 13 06:14:21 1998//
5 /audio_sgi.h/1.2/Thu Aug 13 06:14:22 1998//
6 /audio_solaris.h/1.2/Thu Aug 13 06:14:25 1998//
7 /audio_sun.h/1.2/Thu Aug 13 06:14:27 1998//
8 /audio_hpux.h/1.1.1.1/Thu Aug 13 06:09:36 1998//
9 /audio_FreeBSD.c/1.3/Thu Sep 3 06:08:44 1998//
10 /audio_generic.c/1.3/Thu Sep 3 06:08:45 1998//
11 /audio_hpux.c/1.2/Thu Sep 3 05:48:37 1998//
12 /audio_oss.c/1.3/Thu Sep 3 06:08:47 1998//
13 /audio_solaris.c/1.3/Thu Sep 3 06:08:48 1998//
14 /audio_sun.c/1.3/Thu Sep 3 06:08:49 1998//
15 D
+0
-1
rplayd/audio/CVS/Repository less more
0 /usr/local/cvsroot/rplay/rplayd/audio
+0
-1
rplayd/audio/CVS/Root less more
0 /usr/local/cvsroot
0 /* $Id: audio_FreeBSD.c,v 1.3 1998/09/03 06:08:44 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: audio_FreeBSD.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
8585 * Return 0 on success and -1 on error.
8686 */
8787
88 int
89 rplay_audio_init (void)
88 int
89 rplay_audio_init(void)
9090 {
9191 int n;
9292
9393 if (rplay_audio_fd == -1)
9494 {
95 if (rplay_audio_open () == -1)
95 if (rplay_audio_open() == -1)
9696 {
97 report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n", rplay_audio_device);
97 report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n", rplay_audio_device);
9898 return -1;
9999 }
100100 }
110110 */
111111 n = rplay_audio_precision;
112112
113 if (ioctl (rplay_audio_fd, SNDCTL_DSP_SAMPLESIZE, &n) == -1)
114 {
115 report (REPORT_ERROR, "rplay_audio_init: can't set audio precision to %d (%d)\n",
116 rplay_audio_precision, n);
113 if (ioctl(rplay_audio_fd, SNDCTL_DSP_SAMPLESIZE, &n) == -1)
114 {
115 report(REPORT_ERROR, "rplay_audio_init: can't set audio precision to %d (%d)\n",
116 rplay_audio_precision, n);
117117 return -1;
118118 }
119119
120120 if (n != rplay_audio_precision)
121121 {
122 report (REPORT_NOTICE, "rplay_audio_init: audio precision changed from %d to %d\n",
123 rplay_audio_precision, n);
122 report(REPORT_NOTICE, "rplay_audio_init: audio precision changed from %d to %d\n",
123 rplay_audio_precision, n);
124124 rplay_audio_precision = n;
125125 }
126126
129129 */
130130 n = rplay_audio_channels;
131131
132 if (ioctl (rplay_audio_fd, SOUND_PCM_WRITE_CHANNELS, &n) == -1)
133 {
134 report (REPORT_ERROR, "rplay_audio_init: can't set audio channels to %d (%d)\n",
135 rplay_audio_channels, n);
132 if (ioctl(rplay_audio_fd, SOUND_PCM_WRITE_CHANNELS, &n) == -1)
133 {
134 report(REPORT_ERROR, "rplay_audio_init: can't set audio channels to %d (%d)\n",
135 rplay_audio_channels, n);
136136 return -1;
137137 }
138138
139139 if (n != rplay_audio_channels)
140140 {
141 report (REPORT_NOTICE, "rplay_audio_init: audio channels changed from %d to %d\n",
142 rplay_audio_channels, n);
141 report(REPORT_NOTICE, "rplay_audio_init: audio channels changed from %d to %d\n",
142 rplay_audio_channels, n);
143143 rplay_audio_channels = n;
144144 }
145145
149149
150150 n = rplay_audio_sample_rate;
151151
152 if (ioctl (rplay_audio_fd, SNDCTL_DSP_SPEED, &n) == -1)
153 {
154 report (REPORT_ERROR, "rplay_audio_init: can't set audio sample rate to %d (%d)\n",
155 rplay_audio_sample_rate, n);
152 if (ioctl(rplay_audio_fd, SNDCTL_DSP_SPEED, &n) == -1)
153 {
154 report(REPORT_ERROR, "rplay_audio_init: can't set audio sample rate to %d (%d)\n",
155 rplay_audio_sample_rate, n);
156156 return (-1);
157157 }
158158
159159 if (n != rplay_audio_sample_rate)
160160 {
161 report (REPORT_NOTICE, "rplay_audio_init: audio sample rate changed from %d to %d\n",
162 rplay_audio_sample_rate, n);
161 report(REPORT_NOTICE, "rplay_audio_init: audio sample rate changed from %d to %d\n",
162 rplay_audio_sample_rate, n);
163163 rplay_audio_sample_rate = n;
164164 }
165165
191191 n = AFMT_IMA_ADPCM;
192192 break;
193193 default:
194 report (REPORT_ERROR, "rplay_audio_init: unknown audio format (%d)\n", rplay_audio_format);
195 return (-1);
196 }
197
198 if (ioctl (rplay_audio_fd, SNDCTL_DSP_SETFMT, &n) == -1)
199 {
200 report (REPORT_ERROR, "rplay_audio_init: can't set audio format\n");
194 report(REPORT_ERROR, "rplay_audio_init: unknown audio format (%d)\n", rplay_audio_format);
195 return (-1);
196 }
197
198 if (ioctl(rplay_audio_fd, SNDCTL_DSP_SETFMT, &n) == -1)
199 {
200 report(REPORT_ERROR, "rplay_audio_init: can't set audio format\n");
201201 return (-1);
202202 }
203203
206206 */
207207 if (n = curr_bufsize)
208208 {
209 if (ioctl (rplay_audio_fd, SNDCTL_DSP_SETBLKSIZE, &n) == -1)
209 if (ioctl(rplay_audio_fd, SNDCTL_DSP_SETBLKSIZE, &n) == -1)
210210 {
211 report (REPORT_ERROR, "rplay_audio_init: can't set audio blocksize to %d\n", curr_bufsize);
211 report(REPORT_ERROR, "rplay_audio_init: can't set audio blocksize to %d\n", curr_bufsize);
212212 return (-1);
213213 }
214 report (REPORT_DEBUG, "rplay_audio_init: device blksize set to %d\n", n);
214 report(REPORT_DEBUG, "rplay_audio_init: device blksize set to %d\n", n);
215215 }
216216
217217 rplay_audio_port = RPLAY_AUDIO_PORT_SPEAKER;
224224 *
225225 * Return 0 on success and -1 on error.
226226 */
227 int
228 rplay_audio_open (void)
229 {
230 if ((rplay_audio_fd = open (rplay_audio_device, (O_WRONLY | O_NONBLOCK), 0)) < 0)
227 int
228 rplay_audio_open(void)
229 {
230 if ((rplay_audio_fd = open(rplay_audio_device, (O_WRONLY | O_NONBLOCK), 0)) < 0)
231231 return -1;
232232
233 if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0)
234 {
235 report (REPORT_ERROR,
236 "rplay_audio_open: close-on-exec %d\n",
237 sys_err_str(errno));
233 if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0)
234 {
235 report(REPORT_ERROR,
236 "rplay_audio_open: close-on-exec %d\n",
237 sys_err_str(errno));
238238 /* return -1; */
239239 }
240240
241 if (rplay_audio_init () < 0)
241 if (rplay_audio_init() < 0)
242242 return -1;
243243
244244 return 0;
249249 *
250250 * Return 1 for true and 0 for false.
251251 */
252 int
253 rplay_audio_isopen (void)
252 int
253 rplay_audio_isopen(void)
254254 {
255255 return (rplay_audio_fd != -1);
256256 }
261261 * Return 0 on success and -1 on error.
262262 */
263263
264 int
265 rplay_audio_flush (void)
264 int
265 rplay_audio_flush(void)
266266 {
267267 if (rplay_audio_fd != -1)
268 return (ioctl (rplay_audio_fd, SNDCTL_DSP_POST, 0));
268 return (ioctl(rplay_audio_fd, SNDCTL_DSP_POST, 0));
269269
270270 return 0;
271271 }
275275 *
276276 * Return bytes written on success and -1 on error.
277277 */
278 int
279 rplay_audio_write (char *buf, int nbytes)
278 int
279 rplay_audio_write(char *buf, int nbytes)
280280 {
281281 int remain = nbytes;
282282 int xr;
283283
284284 while (remain > 0)
285285 {
286 if ((xr = write (rplay_audio_fd, buf, remain)) == -1)
286 if ((xr = write(rplay_audio_fd, buf, remain)) == -1)
287287 {
288288 switch (errno)
289289 {
290290 case EWOULDBLOCK:
291291 continue;
292292 default:
293 report (REPORT_ERROR, "Error while writing to audio device (%s)\n", strerror (errno));
293 report(REPORT_ERROR, "Error while writing to audio device (%s)\n", strerror(errno));
294294 return (-1);
295295 }
296296 }
308308 *
309309 * Return 0 on success and -1 on error.
310310 */
311 int
312 rplay_audio_close (void)
311 int
312 rplay_audio_close(void)
313313 {
314314 if (rplay_audio_fd != -1)
315315 {
316 close (rplay_audio_fd);
316 close(rplay_audio_fd);
317317 }
318318
319319 rplay_audio_fd = -1;
326326 *
327327 * Return 0-255 or -1 on error.
328328 */
329 int
330 rplay_audio_get_volume (void)
329 int
330 rplay_audio_get_volume(void)
331331 {
332332 #ifndef FAKE_VOLUME
333
333
334334 int mx;
335335 int mxdevmask;
336336 int left_vol;
339339
340340 vol = left_vol = right_vol = 0;
341341
342 if ((mx = open (RPLAY_MIXER_DEVICE, O_RDONLY)) == -1)
343 {
344 report (REPORT_ERROR, "rplay_audio_get_volume: unable to open mixer device\n");
345 return (-1);
346 }
347
348 if (ioctl (mx, SOUND_MIXER_READ_DEVMASK, &mxdevmask) == -1)
349 {
350 report (REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer device mask\n");
351 close (mx);
342 if ((mx = open(RPLAY_MIXER_DEVICE, O_RDONLY)) == -1)
343 {
344 report(REPORT_ERROR, "rplay_audio_get_volume: unable to open mixer device\n");
345 return (-1);
346 }
347
348 if (ioctl(mx, SOUND_MIXER_READ_DEVMASK, &mxdevmask) == -1)
349 {
350 report(REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer device mask\n");
351 close(mx);
352352 return (-1);
353353 }
354354
355355 if (!(mxdevmask & SOUND_MIXER_PCM))
356356 {
357 report (REPORT_ERROR, "rplay_audio_get_volume: pcm mixer device not installed\n");
358 close (mx);
359 return (-1);
360 }
361
362 if (ioctl (mx, SOUND_MIXER_READ_PCM, &vol) == -1)
363 {
364 report (REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer volume\n");
365 close (mx);
357 report(REPORT_ERROR, "rplay_audio_get_volume: pcm mixer device not installed\n");
358 close(mx);
359 return (-1);
360 }
361
362 if (ioctl(mx, SOUND_MIXER_READ_PCM, &vol) == -1)
363 {
364 report(REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer volume\n");
365 close(mx);
366366 return (-1);
367367 }
368368 else
372372
373373 vol = (int) ((left_vol + right_vol) / 2);
374374
375 report (REPORT_DEBUG, "current pcm-volume: %d:%d => %d\n", left_vol, right_vol, vol);
376 }
377
378 close (mx);
375 report(REPORT_DEBUG, "current pcm-volume: %d:%d => %d\n", left_vol, right_vol, vol);
376 }
377
378 close(mx);
379379
380380 return (vol);
381381
390390 *
391391 * Return the volume of the audio device 0-255 or -1.
392392 */
393 int
394 rplay_audio_set_volume (int volume)
393 int
394 rplay_audio_set_volume(int volume)
395395 {
396396 #ifndef FAKE_VOLUME
397397
403403
404404 vol |= ((vol & 0x00ff) << 8);
405405
406 if ((mx = open (RPLAY_MIXER_DEVICE, O_RDONLY)) == -1)
407 {
408 report (REPORT_ERROR, "rplay_audio_set_volume: unable to open mixer device\n");
409 return (-1);
410 }
411
412 if (ioctl (mx, SOUND_MIXER_READ_DEVMASK, &mxdevmask) == -1)
413 {
414 report (REPORT_ERROR, "rplay_audio_set_volume: unable to get mixer device mask\n");
415 close (mx);
406 if ((mx = open(RPLAY_MIXER_DEVICE, O_RDONLY)) == -1)
407 {
408 report(REPORT_ERROR, "rplay_audio_set_volume: unable to open mixer device\n");
409 return (-1);
410 }
411
412 if (ioctl(mx, SOUND_MIXER_READ_DEVMASK, &mxdevmask) == -1)
413 {
414 report(REPORT_ERROR, "rplay_audio_set_volume: unable to get mixer device mask\n");
415 close(mx);
416416 return (-1);
417417 }
418418
419419 if (!(mxdevmask & SOUND_MIXER_PCM))
420420 {
421 report (REPORT_ERROR, "rplay_audio_set_volume: pcm mixer device not installed\n");
422 close (mx);
423 return (-1);
424 }
425
426 if (ioctl (mx, SOUND_MIXER_WRITE_PCM, &vol) == -1)
427 {
428 report (REPORT_ERROR, "rplay_audio_set_volume: unable to set mixer volume\n");
429 close (mx);
421 report(REPORT_ERROR, "rplay_audio_set_volume: pcm mixer device not installed\n");
422 close(mx);
423 return (-1);
424 }
425
426 if (ioctl(mx, SOUND_MIXER_WRITE_PCM, &vol) == -1)
427 {
428 report(REPORT_ERROR, "rplay_audio_set_volume: unable to set mixer volume\n");
429 close(mx);
430430 return (-1);
431431 }
432432 else
436436
437437 vol = (int) ((left_vol + right_vol) / 2);
438438
439 report (REPORT_DEBUG, "rplay_audio_set_volume: pcm-volume set to %d:%d => %d\n",
440 left_vol, right_vol, vol);
441 }
442
443 close (mx);
439 report(REPORT_DEBUG, "rplay_audio_set_volume: pcm-volume set to %d:%d => %d\n",
440 left_vol, right_vol, vol);
441 }
442
443 close(mx);
444444
445445 rplay_audio_volume = vol;
446
446
447447 return rplay_audio_volume;
448448
449449 #else
0 /* $Id: audio_FreeBSD.h,v 1.2 1998/08/13 06:14:16 boyns Exp $ */
0 /* $Id: audio_FreeBSD.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: audio_generic.c,v 1.3 1998/09/03 06:08:45 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: audio_generic.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #include "rplayd.h"
2626
2727 /*
8484 * Return 0 on success and -1 on error.
8585 */
8686 int
87 rplay_audio_init ()
87 rplay_audio_init()
8888 {
8989 if (rplay_audio_fd == -1)
9090 {
91 rplay_audio_open ();
91 rplay_audio_open();
9292 if (rplay_audio_fd == -1)
9393 {
94 report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n",
95 rplay_audio_device);
94 report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n",
95 rplay_audio_device);
9696 return -1;
9797 }
9898 }
113113 * Return 0 on success and -1 on error.
114114 */
115115 int
116 rplay_audio_open ()
116 rplay_audio_open()
117117 {
118118 int flags;
119119
120 rplay_audio_fd = open (rplay_audio_device, O_WRONLY | O_NDELAY, 0);
120 rplay_audio_fd = open(rplay_audio_device, O_WRONLY | O_NDELAY, 0);
121121 if (rplay_audio_fd < 0)
122122 {
123123 return -1;
124124 }
125125
126 if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0)
127 {
128 report (REPORT_ERROR,
129 "rplay_audio_open: close-on-exec %d\n",
130 sys_err_str(errno));
126 if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0)
127 {
128 report(REPORT_ERROR,
129 "rplay_audio_open: close-on-exec %d\n",
130 sys_err_str(errno));
131131 /* return -1; */
132132 }
133133
134 if (rplay_audio_init () < 0)
134 if (rplay_audio_init() < 0)
135135 {
136136 return -1;
137137 }
139139 /*
140140 * Make sure the audio device writes are non-blocking.
141141 */
142 flags = fcntl (rplay_audio_fd, F_GETFL, 0);
142 flags = fcntl(rplay_audio_fd, F_GETFL, 0);
143143 if (flags < 0)
144144 {
145145 return -1;
146146 }
147147 flags |= FNDELAY;
148 if (fcntl (rplay_audio_fd, F_SETFL, flags) < 0)
148 if (fcntl(rplay_audio_fd, F_SETFL, flags) < 0)
149149 {
150150 return -1;
151151 }
159159 * Return 1 for true and 0 for false.
160160 */
161161 int
162 rplay_audio_isopen ()
162 rplay_audio_isopen()
163163 {
164164 return rplay_audio_fd != -1;
165165 }
170170 * Return 0 on success and -1 on error.
171171 */
172172 int
173 rplay_audio_flush ()
173 rplay_audio_flush()
174174 {
175175 return 0;
176176 }
182182 */
183183 #ifdef __STDC__
184184 int
185 rplay_audio_write (char *buf, int nbytes)
185 rplay_audio_write(char *buf, int nbytes)
186186 #else
187187 int
188 rplay_audio_write (buf, nbytes)
188 rplay_audio_write(buf, nbytes)
189189 char *buf;
190190 int nbytes;
191191 #endif
198198
199199 for (p = buf; nleft > 0; nleft -= n, p += n)
200200 {
201 n = write (rplay_audio_fd, p, nleft);
201 n = write(rplay_audio_fd, p, nleft);
202202 if (n < 0)
203203 {
204204 if (errno == EWOULDBLOCK)
226226 * Return 0 on success and -1 on error.
227227 */
228228 int
229 rplay_audio_close ()
229 rplay_audio_close()
230230 {
231231 if (rplay_audio_fd != -1)
232232 {
233 close (rplay_audio_fd);
233 close(rplay_audio_fd);
234234 }
235235
236236 rplay_audio_fd = -1;
244244 * Return 0-255 or -1 on error.
245245 */
246246 int
247 rplay_audio_get_volume ()
247 rplay_audio_get_volume()
248248 {
249249 #ifdef FAKE_VOLUME
250250 return rplay_audio_volume;
261261 */
262262 #ifdef __STDC__
263263 int
264 rplay_audio_set_volume (int volume)
264 rplay_audio_set_volume(int volume)
265265 #else
266266 int
267 rplay_audio_set_volume (volume)
267 rplay_audio_set_volume(volume)
268268 int volume;
269269 #endif
270270 {
0 /* $Id: audio_generic.h,v 1.2 1998/08/13 06:14:18 boyns Exp $ */
0 /* $Id: audio_generic.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
00 /*
1 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
1 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
22 *
33 * This file is part of rplay.
44 *
7979 * Return 0 on success and -1 on error.
8080 */
8181 int
82 rplay_audio_init ()
82 rplay_audio_init()
8383 {
8484 struct audio_describe ad;
8585 struct audio_status as;
9191 /* Open the audio device */
9292 if (rplay_audio_fd == -1)
9393 {
94 rplay_audio_open ();
94 rplay_audio_open();
9595 if (rplay_audio_fd == -1)
9696 {
97 report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n",
98 rplay_audio_device);
97 report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n",
98 rplay_audio_device);
9999 return -1;
100100 }
101101 }
102102
103103 /* Reset the audio device */
104 if (ioctl (rplay_audio_fd, AUDIO_RESET, RESET_RX_BUF | RESET_TX_BUF | RESET_RX_OVF | RESET_TX_UNF) < 0)
105 {
106 report (REPORT_ERROR, "rplay_audio_init: AUDIO_RESET: %s\n", sys_err_str (errno));
104 if (ioctl(rplay_audio_fd, AUDIO_RESET, RESET_RX_BUF | RESET_TX_BUF | RESET_RX_OVF | RESET_TX_UNF) < 0)
105 {
106 report(REPORT_ERROR, "rplay_audio_init: AUDIO_RESET: %s\n", sys_err_str(errno));
107107 return -1;
108108 }
109109
110110 /* Interrogate the audio device */
111 if (ioctl (rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0)
112 {
113 report (REPORT_ERROR, "rplay_audio_init: AUDIO_DESCRIBE: %s\n", sys_err_str (errno));
114 return -1;
115 }
116
117 if (ioctl (rplay_audio_fd, AUDIO_GET_STATUS, &as) < 0)
118 {
119 report (REPORT_ERROR, "rplay_audio_init: AUDIO_GET_STATUS: %s\n", sys_err_str (errno));
120 return -1;
121 }
122 if (ioctl (rplay_audio_fd, AUDIO_GET_SAMPLE_RATE, &ar) < 0)
123 {
124 report (REPORT_ERROR, "rplay_audio_init: AUDIO_GET_SAMPLE_RATE: %s\n", sys_err_str (errno));
125 return -1;
126 }
127 if (ioctl (rplay_audio_fd, AUDIO_GET_DATA_FORMAT, &af) < 0)
128 {
129 report (REPORT_ERROR, "rplay_audio_init: AUDIO_GET_DATA_FORMAT: %s\n", sys_err_str (errno));
130 return -1;
131 }
132 if (ioctl (rplay_audio_fd, AUDIO_GET_OUTPUT, &ao) < 0)
133 {
134 report (REPORT_ERROR, "rplay_audio_init: AUDIO_GET_OUTPUT: %s\n", sys_err_str (errno));
111 if (ioctl(rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0)
112 {
113 report(REPORT_ERROR, "rplay_audio_init: AUDIO_DESCRIBE: %s\n", sys_err_str(errno));
114 return -1;
115 }
116
117 if (ioctl(rplay_audio_fd, AUDIO_GET_STATUS, &as) < 0)
118 {
119 report(REPORT_ERROR, "rplay_audio_init: AUDIO_GET_STATUS: %s\n", sys_err_str(errno));
120 return -1;
121 }
122 if (ioctl(rplay_audio_fd, AUDIO_GET_SAMPLE_RATE, &ar) < 0)
123 {
124 report(REPORT_ERROR, "rplay_audio_init: AUDIO_GET_SAMPLE_RATE: %s\n", sys_err_str(errno));
125 return -1;
126 }
127 if (ioctl(rplay_audio_fd, AUDIO_GET_DATA_FORMAT, &af) < 0)
128 {
129 report(REPORT_ERROR, "rplay_audio_init: AUDIO_GET_DATA_FORMAT: %s\n", sys_err_str(errno));
130 return -1;
131 }
132 if (ioctl(rplay_audio_fd, AUDIO_GET_OUTPUT, &ao) < 0)
133 {
134 report(REPORT_ERROR, "rplay_audio_init: AUDIO_GET_OUTPUT: %s\n", sys_err_str(errno));
135135 return -1;
136136 }
137137
138138 #ifdef DEBUG
139 printf ("*** AUDIO_DESCRIBE DATA ***\n");
140 printf ("audio_id:\t\t%d\tnrates:\t\t\t%d\tflags:\t%X\n",
141 ad.audio_id, ad.nrates, ad.flags);
142 printf ("max_bits_per_sample:\t%d\tnchannels:\t\t%d\n",
143 ad.max_bits_per_sample, ad.nchannels);
144 printf ("min_receive_gain:\t%d\tmin_transmit_gain:\t%d\tmin_monitor_gain:\t%d\n",
145 ad.min_receive_gain, ad.min_transmit_gain, ad.min_monitor_gain);
146 printf ("max_receive_gain:\t%d\tmax_transmit_gain:\t%d\tmax_monitor_gain:\t%d\n",
147 ad.max_receive_gain, ad.max_transmit_gain, ad.max_monitor_gain);
148 printf ("*** AUDIO_STATUS DATA ***\n");
149 printf ("receive_status: %x\treceive_buffer_count: %d\treceive_overflow_count: %d\n",
150 as.receive_status, as.receive_buffer_count, as.receive_overflow_count);
151 printf ("transmit_status: %x\ttransmit_buffer_count: %d\ttransmit_underflow_count: %d\n",
152 as.transmit_status, as.transmit_buffer_count, as.transmit_underflow_count);
153 printf ("*** END DATA ***\n");
139 printf("*** AUDIO_DESCRIBE DATA ***\n");
140 printf("audio_id:\t\t%d\tnrates:\t\t\t%d\tflags:\t%X\n",
141 ad.audio_id, ad.nrates, ad.flags);
142 printf("max_bits_per_sample:\t%d\tnchannels:\t\t%d\n",
143 ad.max_bits_per_sample, ad.nchannels);
144 printf("min_receive_gain:\t%d\tmin_transmit_gain:\t%d\tmin_monitor_gain:\t%d\n",
145 ad.min_receive_gain, ad.min_transmit_gain, ad.min_monitor_gain);
146 printf("max_receive_gain:\t%d\tmax_transmit_gain:\t%d\tmax_monitor_gain:\t%d\n",
147 ad.max_receive_gain, ad.max_transmit_gain, ad.max_monitor_gain);
148 printf("*** AUDIO_STATUS DATA ***\n");
149 printf("receive_status: %x\treceive_buffer_count: %d\treceive_overflow_count: %d\n",
150 as.receive_status, as.receive_buffer_count, as.receive_overflow_count);
151 printf("transmit_status: %x\ttransmit_buffer_count: %d\ttransmit_underflow_count: %d\n",
152 as.transmit_status, as.transmit_buffer_count, as.transmit_underflow_count);
153 printf("*** END DATA ***\n");
154154 #endif
155155
156156 /* Set internal configuration */
168168 /* Only Ulaw, Alaw and linear 16-bit formats are allowed - anyone know what Alaw is ? */
169169 rplay_audio_format = optional_format ?
170170 ((optional_format == RPLAY_FORMAT_ULAW) ? RPLAY_FORMAT_ULAW :
171 RPLAY_FORMAT_LINEAR_16) : RPLAY_FORMAT_LINEAR_16;
171 RPLAY_FORMAT_LINEAR_16) : RPLAY_FORMAT_LINEAR_16;
172172 af = (rplay_audio_format == RPLAY_FORMAT_ULAW) ? AUDIO_FORMAT_ULAW :
173173 AUDIO_FORMAT_LINEAR16BIT;
174174
177177
178178 /* Set the output device - how should this be specified ? */
179179 rplay_audio_port = optional_port ? optional_port :
180 RPLAY_AUDIO_PORT_SPEAKER | RPLAY_AUDIO_PORT_HEADPHONE; /* default ports */
180 RPLAY_AUDIO_PORT_SPEAKER | RPLAY_AUDIO_PORT_HEADPHONE; /* default ports */
181181 ao = 0;
182 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT))
182 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT))
183183 {
184184 #ifdef AUDIO_LINE_OUT
185 SET_BIT (ao, AUDIO_LINE_OUT);
185 SET_BIT(ao, AUDIO_LINE_OUT);
186186 #endif
187187 #ifdef AUDIO_OUT_LINE
188 SET_BIT (ao, AUDIO_OUT_LINE);
189 #endif
190 }
191 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE))
192 {
193 SET_BIT (ao, AUDIO_OUT_HEADPHONE);
194 }
195 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
196 {
197 SET_BIT (ao, AUDIO_OUT_SPEAKER);
188 SET_BIT(ao, AUDIO_OUT_LINE);
189 #endif
190 }
191 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE))
192 {
193 SET_BIT(ao, AUDIO_OUT_HEADPHONE);
194 }
195 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
196 {
197 SET_BIT(ao, AUDIO_OUT_SPEAKER);
198198 }
199199
200200 /* Program the audio device */
201 if (ioctl (rplay_audio_fd, AUDIO_SET_SAMPLE_RATE, ar) < 0)
202 {
203 report (REPORT_ERROR, "rplay_audio_init: AUDIO_SET_SAMPLE_RATE: %s\n", sys_err_str (errno));
204 return -1;
205 }
206 if (ioctl (rplay_audio_fd, AUDIO_SET_CHANNELS, ac) < 0)
207 {
208 report (REPORT_ERROR, "rplay_audio_init: AUDIO_SET_CHANNELS: %s\n", sys_err_str (errno));
209 return -1;
210 }
211 if (ioctl (rplay_audio_fd, AUDIO_SET_DATA_FORMAT, af) < 0)
212 {
213 report (REPORT_ERROR, "rplay_audio_init: AUDIO_SET_DATA_FORMAT: %s\n", sys_err_str (errno));
214 return -1;
215 }
216 if (ioctl (rplay_audio_fd, AUDIO_SET_OUTPUT, ao) < 0)
217 {
218 report (REPORT_ERROR, "rplay_audio_init: AUDIO_SET_OUTPUTT: %s\n", sys_err_str (errno));
201 if (ioctl(rplay_audio_fd, AUDIO_SET_SAMPLE_RATE, ar) < 0)
202 {
203 report(REPORT_ERROR, "rplay_audio_init: AUDIO_SET_SAMPLE_RATE: %s\n", sys_err_str(errno));
204 return -1;
205 }
206 if (ioctl(rplay_audio_fd, AUDIO_SET_CHANNELS, ac) < 0)
207 {
208 report(REPORT_ERROR, "rplay_audio_init: AUDIO_SET_CHANNELS: %s\n", sys_err_str(errno));
209 return -1;
210 }
211 if (ioctl(rplay_audio_fd, AUDIO_SET_DATA_FORMAT, af) < 0)
212 {
213 report(REPORT_ERROR, "rplay_audio_init: AUDIO_SET_DATA_FORMAT: %s\n", sys_err_str(errno));
214 return -1;
215 }
216 if (ioctl(rplay_audio_fd, AUDIO_SET_OUTPUT, ao) < 0)
217 {
218 report(REPORT_ERROR, "rplay_audio_init: AUDIO_SET_OUTPUTT: %s\n", sys_err_str(errno));
219219 return -1;
220220 }
221221
228228 * Return 0 on success and -1 on error.
229229 */
230230 int
231 rplay_audio_open ()
231 rplay_audio_open()
232232 {
233233 int flags;
234234
235 report (REPORT_DEBUG, "opening device >%s<\n", rplay_audio_device);
236
237 rplay_audio_fd = open (rplay_audio_device, O_WRONLY | O_NDELAY, 0);
235 report(REPORT_DEBUG, "opening device >%s<\n", rplay_audio_device);
236
237 rplay_audio_fd = open(rplay_audio_device, O_WRONLY | O_NDELAY, 0);
238238 if (rplay_audio_fd < 0)
239239 {
240240 return -1;
241241 }
242242
243 if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0)
244 {
245 report (REPORT_ERROR,
246 "rplay_audio_open: close-on-exec %d\n",
247 sys_err_str(errno));
243 if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0)
244 {
245 report(REPORT_ERROR,
246 "rplay_audio_open: close-on-exec %d\n",
247 sys_err_str(errno));
248248 /* return -1; */
249249 }
250250
251 if (rplay_audio_init () < 0)
251 if (rplay_audio_init() < 0)
252252 {
253253 return -1;
254254 }
256256 /*
257257 * Make sure the audio device writes are non-blocking.
258258 */
259 flags = fcntl (rplay_audio_fd, F_GETFL, 0);
259 flags = fcntl(rplay_audio_fd, F_GETFL, 0);
260260 if (flags < 0)
261261 {
262262 return -1;
263263 }
264264 flags |= FNDELAY;
265 if (fcntl (rplay_audio_fd, F_SETFL, flags) < 0)
265 if (fcntl(rplay_audio_fd, F_SETFL, flags) < 0)
266266 {
267267 return -1;
268268 }
276276 * Return 1 for true and 0 for false.
277277 */
278278 int
279 rplay_audio_isopen ()
279 rplay_audio_isopen()
280280 {
281281 return (rplay_audio_fd != -1);
282282 }
287287 * Return 0 on success and -1 on error.
288288 */
289289 int
290 rplay_audio_flush ()
290 rplay_audio_flush()
291291 {
292292 if (rplay_audio_fd != -1)
293293 {
294 if (ioctl (rplay_audio_fd, AUDIO_DRAIN, 0) < 0)
294 if (ioctl(rplay_audio_fd, AUDIO_DRAIN, 0) < 0)
295295 {
296 report (REPORT_ERROR, "rplay_audio_init: AUDIO_DRAIN: %s\n", sys_err_str (errno));
296 report(REPORT_ERROR, "rplay_audio_init: AUDIO_DRAIN: %s\n", sys_err_str(errno));
297297 }
298298 }
299299
307307 */
308308 #ifdef __STDC__
309309 int
310 rplay_audio_write (char *buf, int nbytes)
310 rplay_audio_write(char *buf, int nbytes)
311311 #else
312312 int
313 rplay_audio_write (buf, nbytes)
313 rplay_audio_write(buf, nbytes)
314314 char *buf;
315315 int nbytes;
316316 #endif
323323
324324 for (p = buf; nleft > 0; nleft -= n, p += n)
325325 {
326 if ((n = write (rplay_audio_fd, p, nleft)) < 0)
326 if ((n = write(rplay_audio_fd, p, nleft)) < 0)
327327 {
328328 /* report(RPLAY_DEBUG, "rplay_audio_write: %s\n", sys_err_str(errno)); */
329329
333333 }
334334 else if (errno != EINTR)
335335 {
336 report (REPORT_ERROR, "rplay_audio_write: %s\n", sys_err_str (errno));
336 report(REPORT_ERROR, "rplay_audio_write: %s\n", sys_err_str(errno));
337337 return -1;
338338 }
339339 n = 0;
353353 * Return 0 on success and -1 on error.
354354 */
355355 int
356 rplay_audio_close ()
356 rplay_audio_close()
357357 {
358358 if (rplay_audio_fd != -1)
359359 {
360 close (rplay_audio_fd);
360 close(rplay_audio_fd);
361361 }
362362
363363 rplay_audio_fd = -1;
371371 * Return 0-255 or -1 on error.
372372 */
373373 int
374 rplay_audio_get_volume ()
374 rplay_audio_get_volume()
375375 {
376376 #ifdef FAKE_VOLUME
377377 return rplay_audio_volume;
381381
382382 if (rplay_audio_fd < 0)
383383 {
384 rplay_audio_open ();
384 rplay_audio_open();
385385 }
386386 if (rplay_audio_fd < 0)
387387 {
388388 return -1;
389389 }
390 if (ioctl (rplay_audio_fd, AUDIO_GET_GAINS, &ag) < 0)
391 {
392 report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_GET_GAINS: %s\n", sys_err_str (errno));
393 return -1;
394 }
395 if (ioctl (rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0)
396 {
397 report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_DESCRIBE: %s\n", sys_err_str (errno));
390 if (ioctl(rplay_audio_fd, AUDIO_GET_GAINS, &ag) < 0)
391 {
392 report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_GET_GAINS: %s\n", sys_err_str(errno));
393 return -1;
394 }
395 if (ioctl(rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0)
396 {
397 report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_DESCRIBE: %s\n", sys_err_str(errno));
398398 return -1;
399399 }
400400
401401 #ifdef DEBUG
402 printf ("audio.c: ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n",
403 ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain);
404 printf ("audio.c: ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n",
405 ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain);
406 printf ("audio.c: channel_mask: %d\n", ag.channel_mask);
402 printf("audio.c: ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n",
403 ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain);
404 printf("audio.c: ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n",
405 ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain);
406 printf("audio.c: channel_mask: %d\n", ag.channel_mask);
407407 #endif
408408
409409 return ((unsigned char) (
410 ((double) ag.cgain[1].transmit_gain - ad.min_transmit_gain)
411 / (ad.max_transmit_gain - ad.min_transmit_gain)
412 * 256));
410 ((double) ag.cgain[1].transmit_gain - ad.min_transmit_gain)
411 / (ad.max_transmit_gain - ad.min_transmit_gain)
412 * 256));
413413 #endif /* not FAKE_VOLUME */
414414 }
415415
421421 */
422422 #ifdef __STDC__
423423 int
424 rplay_audio_set_volume (int volume)
424 rplay_audio_set_volume(int volume)
425425 #else
426426 int
427 rplay_audio_set_volume (volume)
427 rplay_audio_set_volume(volume)
428428 int volume;
429429 #endif
430430 {
448448
449449 if (rplay_audio_fd < 0)
450450 {
451 rplay_audio_open ();
451 rplay_audio_open();
452452 }
453453 if (rplay_audio_fd < 0)
454454 {
455455 return -1;
456456 }
457 if (ioctl (rplay_audio_fd, AUDIO_GET_GAINS, &ag) < 0)
458 {
459 report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_GET_GAINS: %s\n", sys_err_str (errno));
460 return -1;
461 }
462 if (ioctl (rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0)
463 {
464 report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_DESCRIBE: %s\n", sys_err_str (errno));
457 if (ioctl(rplay_audio_fd, AUDIO_GET_GAINS, &ag) < 0)
458 {
459 report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_GET_GAINS: %s\n", sys_err_str(errno));
460 return -1;
461 }
462 if (ioctl(rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0)
463 {
464 report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_DESCRIBE: %s\n", sys_err_str(errno));
465465 return -1;
466466 }
467467
468468 #ifdef DEBUG
469 printf ("ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n",
470 ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain);
471 printf ("ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n",
472 ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain);
473 printf ("channel_mask: %d\n", ag.channel_mask);
469 printf("ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n",
470 ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain);
471 printf("ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n",
472 ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain);
473 printf("channel_mask: %d\n", ag.channel_mask);
474474 #endif
475475
476476 ag.cgain[1].transmit_gain = ((int) (
477 (((double) volume)
478 * (ad.max_transmit_gain - ad.min_transmit_gain)
479 / 256)
480 + ad.min_transmit_gain));
481
482 #ifdef DEBUG
483 printf ("ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n",
484 ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain);
485 printf ("ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n",
486 ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain);
487 printf ("channel_mask: %d\n", ag.channel_mask);
488 #endif
489
490 if (ioctl (rplay_audio_fd, AUDIO_SET_GAINS, ag) < 0)
491 {
492 report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_SET_GAINS: %s\n", sys_err_str (errno));
493 return -1;
494 }
495
496 rplay_audio_volume = rplay_audio_get_volume ();
477 (((double) volume)
478 * (ad.max_transmit_gain - ad.min_transmit_gain)
479 / 256)
480 + ad.min_transmit_gain));
481
482 #ifdef DEBUG
483 printf("ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n",
484 ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain);
485 printf("ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n",
486 ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain);
487 printf("channel_mask: %d\n", ag.channel_mask);
488 #endif
489
490 if (ioctl(rplay_audio_fd, AUDIO_SET_GAINS, ag) < 0)
491 {
492 report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_SET_GAINS: %s\n", sys_err_str(errno));
493 return -1;
494 }
495
496 rplay_audio_volume = rplay_audio_get_volume();
497497
498498 return rplay_audio_volume;
499499 #endif /* not FAKE_VOLUME */
00 /*
1 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
1 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
22 *
33 * This file is part of rplay.
44 *
0 /* $Id: audio_oss.c,v 1.3 1998/09/03 06:08:47 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: audio_oss.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #include "rplayd.h"
2626
2727 /*
7777 * Return 0 on success and -1 on error.
7878 */
7979 int
80 rplay_audio_init ()
80 rplay_audio_init()
8181 {
8282 int n;
8383
8484 if (rplay_audio_fd == -1)
8585 {
86 rplay_audio_open ();
86 rplay_audio_open();
8787 if (rplay_audio_fd == -1)
8888 {
89 report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n", rplay_audio_device);
89 report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n", rplay_audio_device);
9090 return -1;
9191 }
9292 }
9393
9494 /* /dev/audio */
95 if (strcmp (rplay_audio_device, "/dev/audio") == 0)
95 if (strcmp(rplay_audio_device, "/dev/audio") == 0)
9696 {
9797 rplay_audio_sample_rate = 8000;
9898 rplay_audio_precision = 8;
9999 rplay_audio_channels = 1;
100100 rplay_audio_format = RPLAY_FORMAT_ULAW;
101 rplay_audio_set_port ();
101 rplay_audio_set_port();
102102 }
103103 /* /dev/dsp */
104 else if (strcmp (rplay_audio_device, "/dev/dsp") == 0)
104 else if (strcmp(rplay_audio_device, "/dev/dsp") == 0)
105105 {
106106 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 44100;
107107 rplay_audio_precision = optional_precision ? optional_precision : 16;
108108 rplay_audio_channels = optional_channels ? optional_channels : 2;
109 rplay_audio_set_port ();
109 rplay_audio_set_port();
110110
111111 /* Precision */
112112 n = rplay_audio_precision;
113 if (ioctl (rplay_audio_fd, SNDCTL_DSP_SETFMT, &n) == -1)
114 {
115 report (REPORT_ERROR, "rplay_audio_init: can't set audio precision to %d (%d)\n",
116 rplay_audio_precision, n);
113 if (ioctl(rplay_audio_fd, SNDCTL_DSP_SETFMT, &n) == -1)
114 {
115 report(REPORT_ERROR, "rplay_audio_init: can't set audio precision to %d (%d)\n",
116 rplay_audio_precision, n);
117117 return -1;
118118 }
119119 if (n != rplay_audio_precision)
120120 {
121 report (REPORT_NOTICE, "rplay_audio_init: audio precision changed from %d to %d\n",
122 rplay_audio_precision, n);
121 report(REPORT_NOTICE, "rplay_audio_init: audio precision changed from %d to %d\n",
122 rplay_audio_precision, n);
123123 rplay_audio_precision = n;
124124 }
125125
126126 /* Channels */
127127 n = rplay_audio_channels;
128 if (ioctl (rplay_audio_fd, SNDCTL_DSP_CHANNELS, &n) == -1)
129 {
130 report (REPORT_ERROR, "rplay_audio_init: can't set audio channels to %d (%d)\n",
131 rplay_audio_channels, n);
128 if (ioctl(rplay_audio_fd, SNDCTL_DSP_CHANNELS, &n) == -1)
129 {
130 report(REPORT_ERROR, "rplay_audio_init: can't set audio channels to %d (%d)\n",
131 rplay_audio_channels, n);
132132 return -1;
133133 }
134134 if (n != rplay_audio_channels)
135135 {
136 report (REPORT_NOTICE, "rplay_audio_init: audio channels changed from %d to %d\n",
137 rplay_audio_channels, n);
136 report(REPORT_NOTICE, "rplay_audio_init: audio channels changed from %d to %d\n",
137 rplay_audio_channels, n);
138138 rplay_audio_channels = n;
139139 }
140140
141141 /* Sample rate */
142142 n = rplay_audio_sample_rate;
143 ioctl (rplay_audio_fd, SNDCTL_DSP_SYNC, NULL);
144 if (ioctl (rplay_audio_fd, SNDCTL_DSP_SPEED, &n) == -1)
145 {
146 report (REPORT_ERROR, "rplay_audio_init: can't set audio sample rate to %d (%d)\n",
147 rplay_audio_sample_rate, n);
143 ioctl(rplay_audio_fd, SNDCTL_DSP_SYNC, NULL);
144 if (ioctl(rplay_audio_fd, SNDCTL_DSP_SPEED, &n) == -1)
145 {
146 report(REPORT_ERROR, "rplay_audio_init: can't set audio sample rate to %d (%d)\n",
147 rplay_audio_sample_rate, n);
148148 return -1;
149149 }
150150 if (n != rplay_audio_sample_rate)
151151 {
152 report (REPORT_NOTICE, "rplay_audio_init: audio sample rate changed from %d to %d\n",
153 rplay_audio_sample_rate, n);
152 report(REPORT_NOTICE, "rplay_audio_init: audio sample rate changed from %d to %d\n",
153 rplay_audio_sample_rate, n);
154154 rplay_audio_sample_rate = n;
155155 }
156156
160160 }
161161 else
162162 {
163 report (REPORT_ERROR, "rplay_audio_init: `%s' unknown audio device\n",
164 rplay_audio_device);
163 report(REPORT_ERROR, "rplay_audio_init: `%s' unknown audio device\n",
164 rplay_audio_device);
165165 return -1;
166166 }
167167
174174 * Return 0 on success and -1 on error.
175175 */
176176 int
177 rplay_audio_open ()
177 rplay_audio_open()
178178 {
179179 int flags;
180180 audio_buf_info info;
181181 int n, i;
182182
183 rplay_audio_fd = open (rplay_audio_device, O_WRONLY, 0);
183 rplay_audio_fd = open(rplay_audio_device, O_WRONLY, 0);
184184 if (rplay_audio_fd < 0)
185185 {
186186 return -1;
187187 }
188188
189 if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0)
190 {
191 report (REPORT_ERROR,
192 "rplay_audio_open: close-on-exec %d\n",
193 sys_err_str(errno));
189 if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0)
190 {
191 report(REPORT_ERROR,
192 "rplay_audio_open: close-on-exec %d\n",
193 sys_err_str(errno));
194194 /* return -1; */
195195 }
196196
197197 /*
198 From the OSS driver docs:
199
200 Argument of this call is an integer encoded as 0xMMMMSSSS (in hex).
201
202 The 16 least significant bits determine the fragment size. The size is
203 2SSSS. For example SSSS=0008 gives fragment size of 256 bytes (28).
204 The minimum is 16 bytes (SSSS=4) and the maximum is
205 total_buffer_size/2. Some devices or processor architectures may
206 require larger fragments in this case the requested fragment size is
207 automatically increased.
208
209 The 16 most significant bits (MMMM) determine maximum number of
210 fragments. By default the deriver computes this based on available
211 buffer space. The minimum value is 2 and the maximum depends on the
212 situation. Set MMMM=0x7fff if you don't want to limit the number of
213 fragments.
214 */
198 From the OSS driver docs:
199
200 Argument of this call is an integer encoded as 0xMMMMSSSS (in hex).
201
202 The 16 least significant bits determine the fragment size. The size is
203 2SSSS. For example SSSS=0008 gives fragment size of 256 bytes (28).
204 The minimum is 16 bytes (SSSS=4) and the maximum is
205 total_buffer_size/2. Some devices or processor architectures may
206 require larger fragments in this case the requested fragment size is
207 automatically increased.
208
209 The 16 most significant bits (MMMM) determine maximum number of
210 fragments. By default the deriver computes this based on available
211 buffer space. The minimum value is 2 and the maximum depends on the
212 situation. Set MMMM=0x7fff if you don't want to limit the number of
213 fragments.
214 */
215215
216216 /* Set the audio buffer fragment size. Default to zero which
217217 lets the driver pick. */
224224 {
225225 n = 4096;
226226 }
227
227
228228 for (i = 0; n > 1; i++)
229229 {
230230 n >>= 1;
231231 }
232232
233 rplay_audio_setfragsize ((0x7fff << 16) | i);
234
235 ioctl (rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info);
236 report (REPORT_DEBUG, "OSS info: fragments=%d totalfrags=%d fragsize=%d DSP=%d\n",
237 info.fragments, info.fragstotal, info.fragsize, info.fragsize*info.fragstotal);
233 rplay_audio_setfragsize((0x7fff << 16) | i);
234
235 ioctl(rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info);
236 report(REPORT_DEBUG, "OSS info: fragments=%d totalfrags=%d fragsize=%d DSP=%d\n",
237 info.fragments, info.fragstotal, info.fragsize, info.fragsize * info.fragstotal);
238238
239239 rplay_audio_fragsize = info.fragsize;
240
241 if (rplay_audio_init () < 0)
240
241 if (rplay_audio_init() < 0)
242242 {
243243 return -1;
244244 }
252252 * Return 1 for true and 0 for false.
253253 */
254254 int
255 rplay_audio_isopen ()
255 rplay_audio_isopen()
256256 {
257257 return rplay_audio_fd != -1;
258258 }
263263 * Return 0 on success and -1 on error.
264264 */
265265 int
266 rplay_audio_flush ()
266 rplay_audio_flush()
267267 {
268268 if (rplay_audio_fd != -1)
269269 {
270 ioctl (rplay_audio_fd, SNDCTL_DSP_SYNC, 0);
270 ioctl(rplay_audio_fd, SNDCTL_DSP_SYNC, 0);
271271 }
272272
273273 return 0;
280280 */
281281 #ifdef __STDC__
282282 int
283 rplay_audio_write (char *buf, int nbytes)
283 rplay_audio_write(char *buf, int nbytes)
284284 #else
285285 int
286 rplay_audio_write (buf, nbytes)
286 rplay_audio_write(buf, nbytes)
287287 char *buf;
288288 int nbytes;
289289 #endif
290290 {
291 return write (rplay_audio_fd, buf, nbytes);
291 return write(rplay_audio_fd, buf, nbytes);
292292 }
293293
294294 /*
297297 * Return 0 on success and -1 on error.
298298 */
299299 int
300 rplay_audio_close ()
300 rplay_audio_close()
301301 {
302302 if (rplay_audio_fd != -1)
303303 {
304 close (rplay_audio_fd);
304 close(rplay_audio_fd);
305305 }
306306
307307 rplay_audio_fd = -1;
310310 }
311311
312312 int
313 rplay_audio_set_port ()
313 rplay_audio_set_port()
314314 {
315315 int mask = 0;
316316 int vol = 0;
317
317
318318 if (rplay_audio_mixer_fd == -1)
319319 {
320 if (rplay_audio_mixer_open () < 0)
320 if (rplay_audio_mixer_open() < 0)
321321 {
322322 return -1;
323323 }
324324 }
325325
326 if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0)
327 {
328 return -1;
329 }
330
326 if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0)
327 {
328 return -1;
329 }
330
331331 rplay_audio_port = optional_port ? optional_port :
332332 RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_SPEAKER | RPLAY_AUDIO_PORT_HEADPHONE;
333333
334334 /* Clear any ports that aren't available. */
335 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT|RPLAY_AUDIO_PORT_HEADPHONE))
336 {
337 if (! (mask & SOUND_MASK_VOLUME))
338 {
339 CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT|RPLAY_AUDIO_PORT_HEADPHONE);
340 }
341 }
342 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
343 {
344 if (! (mask & SOUND_MASK_SPEAKER))
345 {
346 CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER);
347 }
348 }
349
350 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT|RPLAY_AUDIO_PORT_HEADPHONE))
351 {
352 rplay_audio_port |= RPLAY_AUDIO_PORT_LINEOUT|RPLAY_AUDIO_PORT_HEADPHONE;
335 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_HEADPHONE))
336 {
337 if (!(mask & SOUND_MASK_VOLUME))
338 {
339 CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_HEADPHONE);
340 }
341 }
342 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
343 {
344 if (!(mask & SOUND_MASK_SPEAKER))
345 {
346 CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER);
347 }
348 }
349
350 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_HEADPHONE))
351 {
352 rplay_audio_port |= RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_HEADPHONE;
353353
354354 /* Make sure the volume isn't zero. */
355355 vol = 0;
356 ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_VOLUME , &vol);
356 ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_VOLUME, &vol);
357357 if (vol == 0)
358358 {
359359 vol = 50;
360360 vol |= ((vol & 0x00ff) << 8);
361 ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_VOLUME , &vol);
361 ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_VOLUME, &vol);
362362 }
363363 }
364364 else
365365 {
366366 /* Zero the volume. */
367367 vol = 0;
368 ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_VOLUME , &vol);
369 }
370
371 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
368 ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_VOLUME, &vol);
369 }
370
371 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
372372 {
373373 vol = 0;
374 ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_SPEAKER , &vol);
374 ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_SPEAKER, &vol);
375375 /* Make sure the volume isn't zero. */
376376 if (vol == 0)
377377 {
378378 vol = 50;
379379 vol |= ((vol & 0x00ff) << 8);
380 ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_SPEAKER , &vol);
380 ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_SPEAKER, &vol);
381381 }
382382 }
383383 else
384384 {
385385 /* Zero the volume. */
386386 vol = 0;
387 ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_SPEAKER , &vol);
387 ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_SPEAKER, &vol);
388388 }
389389 }
390390
394394 * Return 0-255 or -1 on error.
395395 */
396396 int
397 rplay_audio_get_volume ()
397 rplay_audio_get_volume()
398398 {
399399 #ifdef FAKE_VOLUME
400400 return rplay_audio_volume;
408408
409409 if (rplay_audio_mixer_fd == -1)
410410 {
411 if (rplay_audio_mixer_open () < 0)
411 if (rplay_audio_mixer_open() < 0)
412412 {
413413 return -1;
414414 }
415415 }
416
417 if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0)
418 {
419 report (REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer device mask\n");
416
417 if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0)
418 {
419 report(REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer device mask\n");
420420 return -1;
421421 }
422422
423423 if (!(mask & SOUND_MASK_PCM))
424424 {
425 report (REPORT_ERROR, "rplay_audio_get_volume: pcm mixer device not installed\n");
426 return -1;
427 }
428
429 if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_PCM, &vol) < 0)
430 {
431 report (REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer volume\n");
425 report(REPORT_ERROR, "rplay_audio_get_volume: pcm mixer device not installed\n");
426 return -1;
427 }
428
429 if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_PCM, &vol) < 0)
430 {
431 report(REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer volume\n");
432432 return -1;
433433 }
434434 else
450450 */
451451 #ifdef __STDC__
452452 int
453 rplay_audio_set_volume (int volume)
453 rplay_audio_set_volume(int volume)
454454 #else
455455 int
456 rplay_audio_set_volume (volume)
456 rplay_audio_set_volume(volume)
457457 int volume;
458458 #endif
459459 {
479479
480480 if (rplay_audio_mixer_fd == -1)
481481 {
482 if (rplay_audio_mixer_open () < 0)
482 if (rplay_audio_mixer_open() < 0)
483483 {
484484 return -1;
485485 }
486486 }
487487
488 if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0)
489 {
490 report (REPORT_ERROR, "rplay_audio_set_volume: unable to get mixer device mask\n");
488 if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0)
489 {
490 report(REPORT_ERROR, "rplay_audio_set_volume: unable to get mixer device mask\n");
491491 return -1;
492492 }
493493
494494 if (!(mask & SOUND_MASK_PCM))
495495 {
496 report (REPORT_ERROR, "rplay_audio_set_volume: pcm mixer device not installed\n");
497 return -1;
498 }
499
500 if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_PCM , &vol) < 0)
501 {
502 report (REPORT_ERROR, "rplay_audio_set_volume: unable to set mixer volume\n");
496 report(REPORT_ERROR, "rplay_audio_set_volume: pcm mixer device not installed\n");
497 return -1;
498 }
499
500 if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_PCM, &vol) < 0)
501 {
502 report(REPORT_ERROR, "rplay_audio_set_volume: unable to set mixer volume\n");
503503 return -1;
504504 }
505505 else
510510 }
511511
512512 rplay_audio_volume = vol;
513
513
514514 return rplay_audio_volume;
515515 #endif /* not FAKE_VOLUME */
516516 }
517517
518518 int
519 rplay_audio_getblksize ()
519 rplay_audio_getblksize()
520520 {
521521 int blksize;
522
522
523523 if (rplay_audio_fd == -1)
524524 {
525525 return -1;
526526 }
527527
528 if (ioctl (rplay_audio_fd, SNDCTL_DSP_GETBLKSIZE, &blksize) < 0)
529 {
530 report (REPORT_NOTICE, "DSP_GETBLKSIZE failed\n");
528 if (ioctl(rplay_audio_fd, SNDCTL_DSP_GETBLKSIZE, &blksize) < 0)
529 {
530 report(REPORT_NOTICE, "DSP_GETBLKSIZE failed\n");
531531 return -1;
532532 }
533533 else
538538
539539 #ifdef __STDC__
540540 int
541 rplay_audio_setfragsize (int frag)
541 rplay_audio_setfragsize(int frag)
542542 #else
543543 int
544 rplay_audio_setfragsize (frag)
544 rplay_audio_setfragsize(frag)
545545 int frag;
546546 #endif
547547 {
552552 return -1;
553553 }
554554
555 n = ioctl (rplay_audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag);
555 n = ioctl(rplay_audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag);
556556 if (n < 0)
557557 {
558 report (REPORT_NOTICE, "DSP_SETFRAGMENT failed n = %d\n", n);
559 return -1;
560 }
561
558 report(REPORT_NOTICE, "DSP_SETFRAGMENT failed n = %d\n", n);
559 return -1;
560 }
561
562562 return 0;
563563 }
564564
565565 int
566 rplay_audio_getospace_bytes ()
566 rplay_audio_getospace_bytes()
567567 {
568568 audio_buf_info info;
569569
571571 {
572572 return 0;
573573 }
574 ioctl (rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info);
574 ioctl(rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info);
575575 /* printf ("frags=%d fragtotal=%d fragsize=%d bytes=%d\n", */
576 /* info.fragments, info.fragstotal, info.fragsize, info.bytes); */
576 /* info.fragments, info.fragstotal, info.fragsize, info.bytes); */
577577 return info.bytes;
578578 }
579579
580580 int
581 rplay_audio_getospace_fragsize ()
581 rplay_audio_getospace_fragsize()
582582 {
583583 audio_buf_info info;
584584
586586 {
587587 return 0;
588588 }
589 ioctl (rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info);
589 ioctl(rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info);
590590 return info.fragsize;
591591 }
592592
593593 int
594 rplay_audio_getfd ()
594 rplay_audio_getfd()
595595 {
596596 return rplay_audio_fd;
597597 }
598598
599599 int
600 rplay_audio_mixer_open ()
601 {
602 rplay_audio_mixer_fd = open (RPLAY_AUDIO_MIXER_DEVICE, O_RDONLY);
600 rplay_audio_mixer_open()
601 {
602 rplay_audio_mixer_fd = open(RPLAY_AUDIO_MIXER_DEVICE, O_RDONLY);
603603 if (rplay_audio_mixer_fd < 0)
604604 {
605 report (REPORT_ERROR, "rplay_audio_mixer_open: unable to open mixer device\n");
605 report(REPORT_ERROR, "rplay_audio_mixer_open: unable to open mixer device\n");
606606 return -1;
607607 }
608608
610610 }
611611
612612 int
613 rplay_audio_mixer_close ()
613 rplay_audio_mixer_close()
614614 {
615615 if (rplay_audio_mixer_fd != -1)
616616 {
617 close (rplay_audio_mixer_fd);
617 close(rplay_audio_mixer_fd);
618618 rplay_audio_mixer_fd = -1;
619619 }
620620 }
621621
622622 int
623 rplay_audio_mixer_isopen ()
623 rplay_audio_mixer_isopen()
624624 {
625625 return rplay_audio_mixer_fd != -1;
626626 }
627
0 /* $Id: audio_oss.h,v 1.2 1998/08/13 06:14:20 boyns Exp $ */
0 /* $Id: audio_oss.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: audio_sgi.c,v 1.2 1998/08/13 06:14:21 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0
1 /* $Id: audio_sgi.c,v 1.4 1999/03/10 07:58:10 boyns Exp $ */
2
3 /*
4 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
45 *
56 * This file is part of rplay.
67 *
7980 * Return 0 on success and -1 on error.
8081 */
8182 int
82 rplay_audio_init ()
83 rplay_audio_init()
8384 {
8485 ALconfig SGIconfig;
8586 long PVbuffer[4];
9697 */
9798 if (rplay_audio_fd == NULL)
9899 {
99 SGIconfig = ALnewconfig ();
100 SGIconfig = ALnewconfig();
100101 }
101102 else
102103 {
103 SGIconfig = ALgetconfig (rplay_audio_fd);
104 SGIconfig = ALgetconfig(rplay_audio_fd);
104105 }
105106 if (SGIconfig == NULL)
106107 {
115116 switch (rplay_audio_precision)
116117 {
117118 case 8:
118 ALsetwidth (SGIconfig, AL_SAMPLE_8);
119 ALsetwidth(SGIconfig, AL_SAMPLE_8);
119120 if (errno != 0)
120121 {
121122 return -1;
122123 }
123124 break;
124125 case 16:
125 ALsetwidth (SGIconfig, AL_SAMPLE_16);
126 ALsetwidth(SGIconfig, AL_SAMPLE_16);
126127 if (errno != 0)
127128 {
128129 return -1;
138139 */
139140 rplay_audio_format = (rplay_audio_precision == 16) ? RPLAY_FORMAT_LINEAR_16 : RPLAY_FORMAT_LINEAR_8;
140141 #ifdef AL_SAMPFMT_TWOSCOMP
141 if (ALsetsampfmt (SGIconfig, AL_SAMPFMT_TWOSCOMP) < 0)
142 if (ALsetsampfmt(SGIconfig, AL_SAMPFMT_TWOSCOMP) < 0)
142143 if (errno != 0)
143144 {
144145 return -1;
153154 switch (rplay_audio_channels)
154155 {
155156 case 1:
156 ALsetchannels (SGIconfig, AL_MONO);
157 ALsetchannels(SGIconfig, AL_MONO);
157158 if (errno != 0)
158159 {
159160 return -1;
160161 }
161162 break;
162163 case 2:
163 ALsetchannels (SGIconfig, AL_STEREO);
164 ALsetchannels(SGIconfig, AL_STEREO);
164165 if (errno != 0)
165166 {
166167 return -1;
173174 /*
174175 * Open the audio port.
175176 */
176 rplay_audio_fd = ALopenport ("rplayd", "w", SGIconfig);
177 if (rplay_audio_fd == NULL)
178 {
179 return -1;
180 }
181 ALfreeconfig (SGIconfig);
177 rplay_audio_fd = ALopenport("rplayd", "w", SGIconfig);
178 if (rplay_audio_fd == NULL)
179 {
180 return -1;
181 }
182 ALfreeconfig(SGIconfig);
182183
183184 /*
184185 * Set the sample rate of the output port. This defaults to 44100Khz
187188 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 44100;
188189 PVbuffer[0] = AL_OUTPUT_RATE;
189190 PVbuffer[1] = rplay_audio_sample_rate;
190 ALsetparams (AL_DEFAULT_DEVICE, PVbuffer, 2);
191 ALsetparams(AL_DEFAULT_DEVICE, PVbuffer, 2);
191192 if (errno != 0)
192193 {
193194 return -1;
208209 * Return 0 on success and -1 on error.
209210 */
210211 int
211 rplay_audio_open ()
212 {
213 if (rplay_audio_init () < 0)
212 rplay_audio_open()
213 {
214 if (rplay_audio_init() < 0)
214215 {
215216 return -1;
216217 }
224225 * Return 1 for true and 0 for false.
225226 */
226227 int
227 rplay_audio_isopen ()
228 rplay_audio_isopen()
228229 {
229230 return rplay_audio_fd != NULL;
230231 }
235236 * Return 0 on success and -1 on error.
236237 */
237238 int
238 rplay_audio_flush ()
239 rplay_audio_flush()
239240 {
240241 return 0;
241242 }
247248 */
248249 #ifdef __STDC__
249250 int
250 rplay_audio_write (char *buf, int nbytes)
251 rplay_audio_write(char *buf, int nbytes)
251252 #else
252253 int
253 rplay_audio_write (buf, nbytes)
254 rplay_audio_write(buf, nbytes)
254255 char *buf;
255256 int nbytes;
256257 #endif
259260
260261 if (rplay_audio_fd == NULL)
261262 {
262 if (rplay_audio_open () < 0)
263 if (rplay_audio_open() < 0)
263264 {
264265 return -1;
265266 }
273274 /*
274275 * Write the samples to the audio port.
275276 */
276 ALwritesamps (rplay_audio_fd, buf, samples);
277 ALwritesamps(rplay_audio_fd, buf, samples);
277278 if (errno != 0)
278279 {
279280 return nbytes;
287288 * Return 0 on success and -1 on error.
288289 */
289290 int
290 rplay_audio_close ()
291 rplay_audio_close()
291292 {
292293 if (rplay_audio_fd != NULL)
293294 {
294 ALcloseport (rplay_audio_fd);
295 ALcloseport(rplay_audio_fd);
295296 }
296297
297298 rplay_audio_fd = NULL;
305306 * Return 0-255 or -1 on error.
306307 */
307308 int
308 rplay_audio_get_volume ()
309 rplay_audio_get_volume()
309310 {
310311 long PVbuffer[4];
311312
314315 #else /* not FAKE_VOLUME */
315316 if (rplay_audio_fd == NULL)
316317 {
317 rplay_audio_open ();
318 rplay_audio_open();
318319 }
319320 if (rplay_audio_fd == NULL)
320321 {
322323 }
323324 PVbuffer[0] = AL_LEFT_SPEAKER_GAIN;
324325 PVbuffer[2] = AL_RIGHT_SPEAKER_GAIN;
325 ALgetparams (AL_DEFAULT_DEVICE, PVbuffer, 4);
326 ALgetparams(AL_DEFAULT_DEVICE, PVbuffer, 4);
326327 if (errno != 0)
327328 {
328329 return -1;
339340 */
340341 #ifdef __STDC__
341342 int
342 rplay_audio_set_volume (int volume)
343 rplay_audio_set_volume(int volume)
343344 #else
344345 int
345 rplay_audio_set_volume (volume)
346 rplay_audio_set_volume(volume)
346347 int volume;
347348 #endif
348349 {
366367
367368 if (rplay_audio_fd == NULL)
368369 {
369 rplay_audio_open ();
370 rplay_audio_open();
370371 }
371372 if (rplay_audio_fd == NULL)
372373 {
376377 PVbuffer[1] = volume;
377378 PVbuffer[2] = AL_RIGHT_SPEAKER_GAIN;
378379 PVbuffer[3] = volume;
379 ALsetparams (AL_DEFAULT_DEVICE, PVbuffer, 4);
380 ALsetparams(AL_DEFAULT_DEVICE, PVbuffer, 4);
380381 if (errno != 0)
381382 {
382383 return -1;
383384 }
384385
385 rplay_audio_volume = rplay_audio_get_volume ();
386 rplay_audio_volume = rplay_audio_get_volume();
386387
387388 return rplay_audio_volume;
388389 #endif /* not FAKE_VOLUME */
0 /* $Id: audio_sgi.h,v 1.2 1998/08/13 06:14:22 boyns Exp $ */
0 /* $Id: audio_sgi.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: audio_solaris.c,v 1.3 1998/09/03 06:08:48 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: audio_solaris.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #include "rplayd.h"
2626
2727 /*
6363
6464 static RPLAY_AUDIO_TABLE dbri_table[] =
6565 {
66 { 6615, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
67 { 6615, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
68 { 8000, RPLAY_FORMAT_ULAW , 8, 1 },
69 { 8000, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
70 { 8000, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
71 { 9600, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
72 { 9600, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
73 { 11025, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
74 { 11025, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
75 { 16000, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
76 { 16000, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
77 { 18900, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
78 { 18900, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
79 { 22050, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
80 { 22050, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
81 { 32000, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
82 { 32000, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
83 { 33075, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
84 { 33075, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
85 { 37800, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
86 { 37800, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
87 { 44100, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
88 { 44100, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
89 { 48000, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
90 { 48000, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
66 {6615, RPLAY_FORMAT_LINEAR_16, 16, 1},
67 {6615, RPLAY_FORMAT_LINEAR_16, 16, 2},
68 {8000, RPLAY_FORMAT_ULAW, 8, 1},
69 {8000, RPLAY_FORMAT_LINEAR_16, 16, 1},
70 {8000, RPLAY_FORMAT_LINEAR_16, 16, 2},
71 {9600, RPLAY_FORMAT_LINEAR_16, 16, 1},
72 {9600, RPLAY_FORMAT_LINEAR_16, 16, 2},
73 {11025, RPLAY_FORMAT_LINEAR_16, 16, 1},
74 {11025, RPLAY_FORMAT_LINEAR_16, 16, 2},
75 {16000, RPLAY_FORMAT_LINEAR_16, 16, 1},
76 {16000, RPLAY_FORMAT_LINEAR_16, 16, 2},
77 {18900, RPLAY_FORMAT_LINEAR_16, 16, 1},
78 {18900, RPLAY_FORMAT_LINEAR_16, 16, 2},
79 {22050, RPLAY_FORMAT_LINEAR_16, 16, 1},
80 {22050, RPLAY_FORMAT_LINEAR_16, 16, 2},
81 {32000, RPLAY_FORMAT_LINEAR_16, 16, 1},
82 {32000, RPLAY_FORMAT_LINEAR_16, 16, 2},
83 {33075, RPLAY_FORMAT_LINEAR_16, 16, 1},
84 {33075, RPLAY_FORMAT_LINEAR_16, 16, 2},
85 {37800, RPLAY_FORMAT_LINEAR_16, 16, 1},
86 {37800, RPLAY_FORMAT_LINEAR_16, 16, 2},
87 {44100, RPLAY_FORMAT_LINEAR_16, 16, 1},
88 {44100, RPLAY_FORMAT_LINEAR_16, 16, 2},
89 {48000, RPLAY_FORMAT_LINEAR_16, 16, 1},
90 {48000, RPLAY_FORMAT_LINEAR_16, 16, 2},
9191 {0, 0, 0, 0}
9292 };
9393
112112 * Return 0 on success and -1 on error.
113113 */
114114 int
115 rplay_audio_init ()
115 rplay_audio_init()
116116 {
117117 audio_info_t a;
118118 audio_device_t d;
119119
120120 if (rplay_audio_fd == -1)
121121 {
122 rplay_audio_open ();
122 rplay_audio_open();
123123 if (rplay_audio_fd == -1)
124124 {
125 report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n",
126 rplay_audio_device);
125 report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n",
126 rplay_audio_device);
127127 return -1;
128128 }
129129 }
130130
131 if (ioctl (rplay_audio_fd, AUDIO_GETDEV, &d) < 0)
132 {
133 report (REPORT_ERROR, "rplay_audio_init: AUDIO_GETDEV: %s\n",
134 sys_err_str (errno));
135 return -1;
136 }
137
138 if (strcmp (d.name, "SUNW,dbri") == 0)
139 {
140 report (REPORT_DEBUG, "%s device detected\n", d.name);
131 if (ioctl(rplay_audio_fd, AUDIO_GETDEV, &d) < 0)
132 {
133 report(REPORT_ERROR, "rplay_audio_init: AUDIO_GETDEV: %s\n",
134 sys_err_str(errno));
135 return -1;
136 }
137
138 if (strcmp(d.name, "SUNW,dbri") == 0)
139 {
140 report(REPORT_DEBUG, "%s device detected\n", d.name);
141141 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 11025;
142142 rplay_audio_precision = optional_precision ? optional_precision : 16;
143143 rplay_audio_channels = optional_channels ? optional_channels : 1;
146146 rplay_audio_port = optional_port ? optional_port : RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_SPEAKER;
147147 rplay_audio_table = dbri_table;
148148 }
149 else if (strcmp (d.name, "SUNW,CS4231") == 0)
150 {
151 report (REPORT_DEBUG, "%s device detected\n", d.name);
149 else if (strcmp(d.name, "SUNW,CS4231") == 0)
150 {
151 report(REPORT_DEBUG, "%s device detected\n", d.name);
152152 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 11025;
153153 rplay_audio_precision = optional_precision ? optional_precision : 16;
154154 rplay_audio_channels = optional_channels ? optional_channels : 1;
155155 rplay_audio_format = optional_format ? optional_format :
156156 rplay_audio_precision == 16 ? RPLAY_FORMAT_LINEAR_16 : RPLAY_FORMAT_LINEAR_8;
157157 rplay_audio_port = optional_port ? optional_port : RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_SPEAKER;
158 rplay_audio_table = dbri_table; /* use the dbri table */
159 }
160 else if (strcmp (d.name, "SUNW,am79c30") == 0)
161 {
162 report (REPORT_DEBUG, "%s device detected\n", d.name);
158 rplay_audio_table = dbri_table; /* use the dbri table */
159 }
160 else if (strcmp(d.name, "SUNW,am79c30") == 0)
161 {
162 report(REPORT_DEBUG, "%s device detected\n", d.name);
163163 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 8000;
164164 rplay_audio_precision = optional_precision ? optional_precision : 8;
165165 rplay_audio_channels = optional_channels ? optional_channels : 1;
167167 rplay_audio_port = optional_port ? optional_port : RPLAY_AUDIO_PORT_SPEAKER;
168168 rplay_audio_table = amd_table;
169169 }
170 else if (strcmp (d.name, "SUNW,sb16") == 0)
171 {
172 report (REPORT_DEBUG, "%s device detected\n", d.name);
170 else if (strcmp(d.name, "SUNW,sb16") == 0)
171 {
172 report(REPORT_DEBUG, "%s device detected\n", d.name);
173173 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 44100;
174174 rplay_audio_precision = optional_precision ? optional_precision : 16;
175175 rplay_audio_channels = optional_channels ? optional_channels : 2;
176176 rplay_audio_format = optional_format ? optional_format :
177177 rplay_audio_precision == 16 ? RPLAY_FORMAT_LINEAR_16 : RPLAY_FORMAT_LINEAR_8;
178178 rplay_audio_port = optional_port ? optional_port : RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_SPEAKER;
179 rplay_audio_table = dbri_table; /* use the dbri table */
179 rplay_audio_table = dbri_table; /* use the dbri table */
180180 }
181181 else
182182 {
183 report (REPORT_ERROR, "`%s' unknown audio device detected\n", d.name);
183 report(REPORT_ERROR, "`%s' unknown audio device detected\n", d.name);
184184 return -1;
185185 }
186186
191191 if (rplay_audio_format != RPLAY_FORMAT_ULAW
192192 && rplay_audio_format != RPLAY_FORMAT_LINEAR_8)
193193 {
194 report (REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n",
195 rplay_audio_precision, rplay_audio_format);
194 report(REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n",
195 rplay_audio_precision, rplay_audio_format);
196196 return -1;
197197 }
198198 break;
200200 case 16:
201201 if (rplay_audio_format != RPLAY_FORMAT_LINEAR_16)
202202 {
203 report (REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n",
204 rplay_audio_precision, rplay_audio_format);
203 report(REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n",
204 rplay_audio_precision, rplay_audio_format);
205205 return -1;
206206 }
207207 break;
208208
209209 default:
210 report (REPORT_ERROR, "rplay_audio_init: `%d' unsupported audio precision\n",
211 rplay_audio_precision);
210 report(REPORT_ERROR, "rplay_audio_init: `%d' unsupported audio precision\n",
211 rplay_audio_precision);
212212 return -1;
213213 }
214214
226226 break;
227227
228228 default:
229 report (REPORT_ERROR, "rplay_audio_init: unsupported audio format `%d'\n",
230 rplay_audio_format);
229 report(REPORT_ERROR, "rplay_audio_init: unsupported audio format `%d'\n",
230 rplay_audio_format);
231231 return -1;
232232 }
233233
234234 /* Audio port. */
235235 if (rplay_audio_port == RPLAY_AUDIO_PORT_NONE)
236236 {
237 a.play.port = ~0; /* see AUDIO_INITINFO in /usr/include/sys/audioio.h. */
237 a.play.port = ~0; /* see AUDIO_INITINFO in /usr/include/sys/audioio.h. */
238238 }
239239 else
240240 {
241241 a.play.port = 0;
242 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT))
242 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT))
243243 {
244244 #ifdef AUDIO_LINE_OUT
245 SET_BIT (a.play.port, AUDIO_LINE_OUT);
245 SET_BIT(a.play.port, AUDIO_LINE_OUT);
246246 #else
247 CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT);
247 CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT);
248248 #endif
249249 }
250 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE))
250 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE))
251251 {
252252 #ifdef AUDIO_HEADPHONE
253 SET_BIT (a.play.port, AUDIO_HEADPHONE);
253 SET_BIT(a.play.port, AUDIO_HEADPHONE);
254254 #else
255 CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE);
255 CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE);
256256 #endif
257257 }
258 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
258 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
259259 {
260260 #ifdef AUDIO_SPEAKER
261 SET_BIT (a.play.port, AUDIO_SPEAKER);
261 SET_BIT(a.play.port, AUDIO_SPEAKER);
262262 #endif
263263 /* Assume speaker is okay. */
264264 }
268268 a.play.precision = rplay_audio_precision;
269269 a.play.channels = rplay_audio_channels;
270270
271 if (ioctl (rplay_audio_fd, AUDIO_SETINFO, &a) < 0)
272 {
273 report (REPORT_ERROR, "rplay_audio_init: AUDIO_SETINFO: %s\n", sys_err_str (errno));
271 if (ioctl(rplay_audio_fd, AUDIO_SETINFO, &a) < 0)
272 {
273 report(REPORT_ERROR, "rplay_audio_init: AUDIO_SETINFO: %s\n", sys_err_str(errno));
274274 return -1;
275275 }
276276
283283 * Return 0 on success and -1 on error.
284284 */
285285 int
286 rplay_audio_open ()
286 rplay_audio_open()
287287 {
288288 int flags;
289289
290 rplay_audio_fd = open (rplay_audio_device, O_WRONLY | O_NDELAY, 0);
290 rplay_audio_fd = open(rplay_audio_device, O_WRONLY | O_NDELAY, 0);
291291 if (rplay_audio_fd < 0)
292292 {
293293 return -1;
294294 }
295295
296 if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0)
297 {
298 report (REPORT_ERROR,
299 "rplay_audio_open: close-on-exec %d\n",
300 sys_err_str(errno));
296 if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0)
297 {
298 report(REPORT_ERROR,
299 "rplay_audio_open: close-on-exec %d\n",
300 sys_err_str(errno));
301301 /* return -1; */
302302 }
303303
304 if (rplay_audio_init () < 0)
304 if (rplay_audio_init() < 0)
305305 {
306306 return -1;
307307 }
309309 /*
310310 * Make sure the audio device writes are non-blocking.
311311 */
312 flags = fcntl (rplay_audio_fd, F_GETFL, 0);
312 flags = fcntl(rplay_audio_fd, F_GETFL, 0);
313313 if (flags < 0)
314314 {
315315 return -1;
316316 }
317317 flags |= FNDELAY;
318 if (fcntl (rplay_audio_fd, F_SETFL, flags) < 0)
318 if (fcntl(rplay_audio_fd, F_SETFL, flags) < 0)
319319 {
320320 return -1;
321321 }
329329 * Return 1 for true and 0 for false.
330330 */
331331 int
332 rplay_audio_isopen ()
332 rplay_audio_isopen()
333333 {
334334 return rplay_audio_fd != -1;
335335 }
340340 * Return 0 on success and -1 on error.
341341 */
342342 int
343 rplay_audio_flush ()
343 rplay_audio_flush()
344344 {
345345 if (rplay_audio_fd != -1)
346346 {
347 ioctl (rplay_audio_fd, AUDIO_DRAIN, 0);
347 ioctl(rplay_audio_fd, AUDIO_DRAIN, 0);
348348 }
349349
350350 return 0;
357357 */
358358 #ifdef __STDC__
359359 int
360 rplay_audio_write (char *buf, int nbytes)
360 rplay_audio_write(char *buf, int nbytes)
361361 #else
362362 int
363 rplay_audio_write (buf, nbytes)
363 rplay_audio_write(buf, nbytes)
364364 char *buf;
365365 int nbytes;
366366 #endif
373373
374374 for (p = buf; nleft > 0; nleft -= n, p += n)
375375 {
376 n = write (rplay_audio_fd, p, nleft);
376 n = write(rplay_audio_fd, p, nleft);
377377 if (n < 0)
378378 {
379379 if (errno == EWOULDBLOCK)
401401 * Return 0 on success and -1 on error.
402402 */
403403 int
404 rplay_audio_close ()
404 rplay_audio_close()
405405 {
406406 if (rplay_audio_fd != -1)
407407 {
408 close (rplay_audio_fd);
408 close(rplay_audio_fd);
409409 }
410410
411411 rplay_audio_fd = -1;
419419 * Return 0-255 or -1 on error.
420420 */
421421 int
422 rplay_audio_get_volume ()
422 rplay_audio_get_volume()
423423 {
424424 #ifdef FAKE_VOLUME
425425 return rplay_audio_volume;
428428
429429 if (rplay_audio_fd < 0)
430430 {
431 rplay_audio_open ();
431 rplay_audio_open();
432432 }
433433 if (rplay_audio_fd < 0)
434434 {
435435 return -1;
436436 }
437 if (ioctl (rplay_audio_fd, AUDIO_GETINFO, &a) < 0)
437 if (ioctl(rplay_audio_fd, AUDIO_GETINFO, &a) < 0)
438438 {
439439 return -1;
440440 }
453453 */
454454 #ifdef __STDC__
455455 int
456 rplay_audio_set_volume (int volume)
456 rplay_audio_set_volume(int volume)
457457 #else
458458 int
459 rplay_audio_set_volume (volume)
459 rplay_audio_set_volume(volume)
460460 int volume;
461461 #endif
462462 {
479479
480480 if (rplay_audio_fd < 0)
481481 {
482 rplay_audio_open ();
482 rplay_audio_open();
483483 }
484484 if (rplay_audio_fd < 0)
485485 {
488488
489489 AUDIO_INITINFO(&a);
490490 a.play.gain = volume;
491 if (ioctl (rplay_audio_fd, AUDIO_SETINFO, &a) < 0)
492 {
493 return -1;
494 }
495
496 rplay_audio_volume = rplay_audio_get_volume ();
491 if (ioctl(rplay_audio_fd, AUDIO_SETINFO, &a) < 0)
492 {
493 return -1;
494 }
495
496 rplay_audio_volume = rplay_audio_get_volume();
497497
498498 return rplay_audio_volume;
499499 #endif /* not FAKE_VOLUME */
0 /* $Id: audio_solaris.h,v 1.2 1998/08/13 06:14:25 boyns Exp $ */
0 /* $Id: audio_solaris.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: audio_sun.c,v 1.3 1998/09/03 06:08:49 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: audio_sun.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #include "rplayd.h"
2626
2727 /*
6363
6464 static RPLAY_AUDIO_TABLE dbri_table[] =
6565 {
66 { 6615, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
67 { 6615, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
68 { 8000, RPLAY_FORMAT_ULAW , 8, 1 },
69 { 8000, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
70 { 8000, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
71 { 9600, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
72 { 9600, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
73 { 11025, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
74 { 11025, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
75 { 16000, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
76 { 16000, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
77 { 18900, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
78 { 18900, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
79 { 22050, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
80 { 22050, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
81 { 32000, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
82 { 32000, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
83 { 33075, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
84 { 33075, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
85 { 37800, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
86 { 37800, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
87 { 44100, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
88 { 44100, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
89 { 48000, RPLAY_FORMAT_LINEAR_16 , 16, 1 },
90 { 48000, RPLAY_FORMAT_LINEAR_16 , 16, 2 },
66 {6615, RPLAY_FORMAT_LINEAR_16, 16, 1},
67 {6615, RPLAY_FORMAT_LINEAR_16, 16, 2},
68 {8000, RPLAY_FORMAT_ULAW, 8, 1},
69 {8000, RPLAY_FORMAT_LINEAR_16, 16, 1},
70 {8000, RPLAY_FORMAT_LINEAR_16, 16, 2},
71 {9600, RPLAY_FORMAT_LINEAR_16, 16, 1},
72 {9600, RPLAY_FORMAT_LINEAR_16, 16, 2},
73 {11025, RPLAY_FORMAT_LINEAR_16, 16, 1},
74 {11025, RPLAY_FORMAT_LINEAR_16, 16, 2},
75 {16000, RPLAY_FORMAT_LINEAR_16, 16, 1},
76 {16000, RPLAY_FORMAT_LINEAR_16, 16, 2},
77 {18900, RPLAY_FORMAT_LINEAR_16, 16, 1},
78 {18900, RPLAY_FORMAT_LINEAR_16, 16, 2},
79 {22050, RPLAY_FORMAT_LINEAR_16, 16, 1},
80 {22050, RPLAY_FORMAT_LINEAR_16, 16, 2},
81 {32000, RPLAY_FORMAT_LINEAR_16, 16, 1},
82 {32000, RPLAY_FORMAT_LINEAR_16, 16, 2},
83 {33075, RPLAY_FORMAT_LINEAR_16, 16, 1},
84 {33075, RPLAY_FORMAT_LINEAR_16, 16, 2},
85 {37800, RPLAY_FORMAT_LINEAR_16, 16, 1},
86 {37800, RPLAY_FORMAT_LINEAR_16, 16, 2},
87 {44100, RPLAY_FORMAT_LINEAR_16, 16, 1},
88 {44100, RPLAY_FORMAT_LINEAR_16, 16, 2},
89 {48000, RPLAY_FORMAT_LINEAR_16, 16, 1},
90 {48000, RPLAY_FORMAT_LINEAR_16, 16, 2},
9191 {0, 0, 0, 0}
9292 };
9393
112112 * Return 0 on success and -1 on error.
113113 */
114114 int
115 rplay_audio_init ()
115 rplay_audio_init()
116116 {
117117 int d;
118118 audio_info_t a;
119119
120120 if (rplay_audio_fd == -1)
121121 {
122 rplay_audio_open ();
122 rplay_audio_open();
123123 if (rplay_audio_fd == -1)
124124 {
125 report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n",
126 rplay_audio_device);
125 report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n",
126 rplay_audio_device);
127127 return -1;
128128 }
129129 }
133133 */
134134 #ifdef AUDIO_GETDEV
135135 #ifdef AUDIO_DEV_SPEAKERBOX
136 if (ioctl (rplay_audio_fd, AUDIO_GETDEV, &d) < 0)
137 {
138 report (REPORT_ERROR, "rplay_audio_init: AUDIO_GETDEV: %s\n", sys_err_str (errno));
136 if (ioctl(rplay_audio_fd, AUDIO_GETDEV, &d) < 0)
137 {
138 report(REPORT_ERROR, "rplay_audio_init: AUDIO_GETDEV: %s\n", sys_err_str(errno));
139139 return -1;
140140 }
141141
142142 if (d == AUDIO_DEV_SPEAKERBOX || d == AUDIO_DEV_CODEC)
143143 {
144 report (REPORT_DEBUG, "dbri device detected\n");
144 report(REPORT_DEBUG, "dbri device detected\n");
145145 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 11025;
146146 rplay_audio_precision = optional_precision ? optional_precision : 16;
147147 rplay_audio_channels = optional_channels ? optional_channels : 1;
152152 }
153153 else if (d == AUDIO_DEV_AMD)
154154 {
155 report (REPORT_DEBUG, "amd device detected\n");
155 report(REPORT_DEBUG, "amd device detected\n");
156156 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 8000;
157157 rplay_audio_precision = optional_precision ? optional_precision : 8;
158158 rplay_audio_channels = optional_channels ? optional_channels : 1;
166166 #endif
167167 else if (d == AUDIO_DEV_CS4231)
168168 {
169 report (REPORT_DEBUG, "cs4231 device detected\n");
169 report(REPORT_DEBUG, "cs4231 device detected\n");
170170 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 11025;
171171 rplay_audio_precision = optional_precision ? optional_precision : 16;
172172 rplay_audio_channels = optional_channels ? optional_channels : 1;
179179 #endif /* not AUDIO_DEV_SPEAKERBOX */
180180 #endif /* not AUDIO_GETDEV */
181181 {
182 report (REPORT_DEBUG, "assuming amd device\n");
182 report(REPORT_DEBUG, "assuming amd device\n");
183183 rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 8000;
184184 rplay_audio_precision = optional_precision ? optional_precision : 8;
185185 rplay_audio_channels = optional_channels ? optional_channels : 1;
195195 if (rplay_audio_format != RPLAY_FORMAT_ULAW
196196 && rplay_audio_format != RPLAY_FORMAT_LINEAR_8)
197197 {
198 report (REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n",
199 rplay_audio_precision, rplay_audio_format);
198 report(REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n",
199 rplay_audio_precision, rplay_audio_format);
200200 return -1;
201201 }
202202 break;
204204 case 16:
205205 if (rplay_audio_format != RPLAY_FORMAT_LINEAR_16)
206206 {
207 report (REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n",
208 rplay_audio_precision, rplay_audio_format);
207 report(REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n",
208 rplay_audio_precision, rplay_audio_format);
209209 return -1;
210210 }
211211 break;
212212
213213 default:
214 report (REPORT_ERROR, "rplay_audio_init: `%d' unsupported audio precision\n",
215 rplay_audio_precision);
214 report(REPORT_ERROR, "rplay_audio_init: `%d' unsupported audio precision\n",
215 rplay_audio_precision);
216216 return -1;
217217 }
218218
230230 break;
231231
232232 default:
233 report (REPORT_ERROR, "rplay_audio_init: unsupported audio format `%d'\n",
234 rplay_audio_format);
233 report(REPORT_ERROR, "rplay_audio_init: unsupported audio format `%d'\n",
234 rplay_audio_format);
235235 return -1;
236236 }
237237
238238 /* Audio port. */
239239 if (rplay_audio_port == RPLAY_AUDIO_PORT_NONE)
240240 {
241 a.play.port = ~0; /* see AUDIO_INITINFO in /usr/include/sun/audioio.h. */
241 a.play.port = ~0; /* see AUDIO_INITINFO in /usr/include/sun/audioio.h. */
242242 }
243243 else
244244 {
245245 a.play.port = 0;
246 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT))
246 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT))
247247 {
248248 #ifdef AUDIO_LINE_OUT
249 SET_BIT (a.play.port, AUDIO_LINE_OUT);
249 SET_BIT(a.play.port, AUDIO_LINE_OUT);
250250 #else
251 CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT);
251 CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT);
252252 #endif
253253 }
254 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE))
254 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE))
255255 {
256256 #ifdef AUDIO_HEADPHONE
257 SET_BIT (a.play.port, AUDIO_HEADPHONE);
257 SET_BIT(a.play.port, AUDIO_HEADPHONE);
258258 #else
259 CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE);
259 CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE);
260260 #endif
261261 }
262 if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
262 if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER))
263263 {
264264 #ifdef AUDIO_SPEAKER
265 SET_BIT (a.play.port, AUDIO_SPEAKER);
265 SET_BIT(a.play.port, AUDIO_SPEAKER);
266266 #endif
267267 /* Assume speaker is okay. */
268268 }
272272 a.play.precision = rplay_audio_precision;
273273 a.play.channels = rplay_audio_channels;
274274
275 if (ioctl (rplay_audio_fd, AUDIO_SETINFO, &a) < 0)
276 {
277 report (REPORT_ERROR, "rplay_audio_init: AUDIO_SETINFO: %s\n", sys_err_str (errno));
275 if (ioctl(rplay_audio_fd, AUDIO_SETINFO, &a) < 0)
276 {
277 report(REPORT_ERROR, "rplay_audio_init: AUDIO_SETINFO: %s\n", sys_err_str(errno));
278278 return -1;
279279 }
280280
287287 * Return 0 on success and -1 on error.
288288 */
289289 int
290 rplay_audio_open ()
290 rplay_audio_open()
291291 {
292292 int flags;
293293
294 rplay_audio_fd = open (rplay_audio_device, O_WRONLY | O_NDELAY, 0);
294 rplay_audio_fd = open(rplay_audio_device, O_WRONLY | O_NDELAY, 0);
295295 if (rplay_audio_fd < 0)
296296 {
297297 return -1;
298298 }
299299
300 if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0)
301 {
302 report (REPORT_ERROR,
303 "rplay_audio_open: close-on-exec %d\n",
304 sys_err_str(errno));
300 if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0)
301 {
302 report(REPORT_ERROR,
303 "rplay_audio_open: close-on-exec %d\n",
304 sys_err_str(errno));
305305 /* return -1; */
306306 }
307307
308 if (rplay_audio_init () < 0)
308 if (rplay_audio_init() < 0)
309309 {
310310 return -1;
311311 }
313313 /*
314314 * Make sure the audio device writes are non-blocking.
315315 */
316 flags = fcntl (rplay_audio_fd, F_GETFL, 0);
316 flags = fcntl(rplay_audio_fd, F_GETFL, 0);
317317 if (flags < 0)
318318 {
319319 return -1;
320320 }
321321 flags |= FNDELAY;
322 if (fcntl (rplay_audio_fd, F_SETFL, flags) < 0)
322 if (fcntl(rplay_audio_fd, F_SETFL, flags) < 0)
323323 {
324324 return -1;
325325 }
333333 * Return 1 for true and 0 for false.
334334 */
335335 int
336 rplay_audio_isopen ()
336 rplay_audio_isopen()
337337 {
338338 return rplay_audio_fd != -1;
339339 }
344344 * Return 0 on success and -1 on error.
345345 */
346346 int
347 rplay_audio_flush ()
347 rplay_audio_flush()
348348 {
349349 if (rplay_audio_fd != -1)
350350 {
351 ioctl (rplay_audio_fd, AUDIO_DRAIN, 0);
351 ioctl(rplay_audio_fd, AUDIO_DRAIN, 0);
352352 }
353353
354354 return 0;
361361 */
362362 #ifdef __STDC__
363363 int
364 rplay_audio_write (char *buf, int nbytes)
364 rplay_audio_write(char *buf, int nbytes)
365365 #else
366366 int
367 rplay_audio_write (buf, nbytes)
367 rplay_audio_write(buf, nbytes)
368368 char *buf;
369369 int nbytes;
370370 #endif
377377
378378 for (p = buf; nleft > 0; nleft -= n, p += n)
379379 {
380 n = write (rplay_audio_fd, p, nleft);
380 n = write(rplay_audio_fd, p, nleft);
381381 if (n < 0)
382382 {
383383 if (errno == EWOULDBLOCK)
405405 * Return 0 on success and -1 on error.
406406 */
407407 int
408 rplay_audio_close ()
408 rplay_audio_close()
409409 {
410410 if (rplay_audio_fd != -1)
411411 {
412 close (rplay_audio_fd);
412 close(rplay_audio_fd);
413413 }
414414
415415 rplay_audio_fd = -1;
423423 * Return 0-255 or -1 on error.
424424 */
425425 int
426 rplay_audio_get_volume ()
426 rplay_audio_get_volume()
427427 {
428428 #ifdef FAKE_VOLUME
429429 return rplay_audio_volume;
432432
433433 if (rplay_audio_fd < 0)
434434 {
435 rplay_audio_open ();
435 rplay_audio_open();
436436 }
437437 if (rplay_audio_fd < 0)
438438 {
439439 return -1;
440440 }
441 if (ioctl (rplay_audio_fd, AUDIO_GETINFO, &a) < 0)
441 if (ioctl(rplay_audio_fd, AUDIO_GETINFO, &a) < 0)
442442 {
443443 return -1;
444444 }
457457 */
458458 #ifdef __STDC__
459459 int
460 rplay_audio_set_volume (int volume)
460 rplay_audio_set_volume(int volume)
461461 #else
462462 int
463 rplay_audio_set_volume (volume)
463 rplay_audio_set_volume(volume)
464464 int volume;
465465 #endif
466466 {
483483
484484 if (rplay_audio_fd < 0)
485485 {
486 rplay_audio_open ();
486 rplay_audio_open();
487487 }
488488 if (rplay_audio_fd < 0)
489489 {
492492
493493 AUDIO_INITINFO(&a);
494494 a.play.gain = volume;
495 if (ioctl (rplay_audio_fd, AUDIO_SETINFO, &a) < 0)
496 {
497 return -1;
498 }
499
500 rplay_audio_volume = rplay_audio_get_volume ();
495 if (ioctl(rplay_audio_fd, AUDIO_SETINFO, &a) < 0)
496 {
497 return -1;
498 }
499
500 rplay_audio_volume = rplay_audio_get_volume();
501501
502502 return rplay_audio_volume;
503503 #endif /* not FAKE_VOLUME */
0 /* $Id: audio_sun.h,v 1.2 1998/08/13 06:14:27 boyns Exp $ */
0 /* $Id: audio_sun.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: buffer.c,v 1.2 1998/08/13 06:13:40 boyns Exp $ */
0 /* $Id: buffer.c,v 1.4 1999/03/10 07:58:02 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
3636
3737 #ifdef __STDC__
3838 BUFFER *
39 buffer_create (void)
40 #else
41 BUFFER *
42 buffer_create ()
39 buffer_create(void)
40 #else
41 BUFFER *
42 buffer_create()
4343 #endif
4444 {
4545 BUFFER *b;
4646
4747 if (buffers == NULL)
4848 {
49 b = (BUFFER *) malloc (sizeof (BUFFER));
49 b = (BUFFER *) malloc(sizeof(BUFFER));
5050 if (b == NULL)
5151 {
52 report (REPORT_ERROR, "buffer_create: out of memory\n");
53 done (1);
52 report(REPORT_ERROR, "buffer_create: out of memory\n");
53 done(1);
5454 }
5555 b->id = ++next_id;
5656 }
7272
7373 #ifdef __STDC__
7474 void
75 buffer_destroy (BUFFER *b)
76 #else
77 void
78 buffer_destroy (b)
75 buffer_destroy(BUFFER *b)
76 #else
77 void
78 buffer_destroy(b)
7979 BUFFER *b;
8080 #endif
8181 {
8888 {
8989 /* Always put REUSE buffers on the free list. This will
9090 probably cause rplayd to grow bigger, but it prevents
91 problems with calling free () inside the timer
91 problems with calling free() inside the timer
9292 interrupt. */
9393 nbuffers++;
9494 b->next = buffers;
9797 else
9898 {
9999 /* Free the buffer. */
100 free ((char *) b);
100 free((char *) b);
101101 }
102102 }
103103
106106 */
107107 #ifdef __STDC__
108108 BUFFER *
109 buffer_alloc (int nbytes, int type)
110 #else
111 BUFFER *
112 buffer_alloc (nbytes, type)
109 buffer_alloc(int nbytes, int type)
110 #else
111 BUFFER *
112 buffer_alloc(nbytes, type)
113113 int nbytes;
114114 int type;
115115 #endif
118118
119119 do
120120 {
121 *next = buffer_create ();
121 *next = buffer_create();
122122 nbytes -= BUFFER_SIZE;
123123 (*next)->status = type;
124124 next = &(*next)->next;
132132
133133 #ifdef __STDC__
134134 void
135 buffer_dealloc (BUFFER *b, int force)
136 #else
137 void
138 buffer_dealloc (b, force)
135 buffer_dealloc(BUFFER *b, int force)
136 #else
137 void
138 buffer_dealloc(b, force)
139139 BUFFER *b;
140140 int force;
141141 #endif
149149 {
150150 b->status = BUFFER_FREE;
151151 }
152 buffer_destroy (b);
152 buffer_destroy(b);
153153 b = next;
154154 }
155155 }
156156
157157 #ifdef __STDC__
158158 void
159 buffer_cleanup (void)
160 #else
161 void
162 buffer_cleanup ()
163 #endif
164 {
165 BUFFER *b;
166
167 report (REPORT_DEBUG, "cleaning up buffers - %d bytes\n", nbuffers * BUFFER_SIZE);
159 buffer_cleanup(void)
160 #else
161 void
162 buffer_cleanup()
163 #endif
164 {
165 BUFFER *b;
166
167 report(REPORT_DEBUG, "cleaning up buffers - %d bytes\n", nbuffers * BUFFER_SIZE);
168168
169169 while (buffers)
170170 {
171171 b = buffers;
172172 buffers = buffers->next;
173 free ((char *) b);
173 free((char *) b);
174174 }
175175
176176 buffers = NULL;
177177 nbuffers = 0;
178178 next_id = 0;
179179 }
180
181 #ifdef __STDC__
182 int
183 buffer_nbytes(BUFFER *b)
184 #else
185 int
186 buffer_nbytes(b)
187 BUFFER *b;
188 #endif
189 {
190 int n = 0;
191
192 while (b)
193 {
194 n += b->nbytes;
195 b = b->next;
196 }
197
198 return n;
199 }
0 /* $Id: buffer.h,v 1.2 1998/08/13 06:13:41 boyns Exp $ */
0 /* $Id: buffer.h,v 1.3 1999/03/10 07:58:02 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
3737 */
3838 #define BUFFER_MAX_FREE 64
3939
40 #define BUFFER_FREE 0 /* temporary buffer - put on free list or destroyed */
40 #define BUFFER_FREE 0 /* temporary buffer - put on free list or destroy */
4141 #define BUFFER_KEEP 1 /* permanent buffer - not put on free list */
4242 #define BUFFER_REUSE 2 /* temporary buffer - always put on free list */
4343
0 /* $Id: cache.c,v 1.2 1998/08/13 06:13:42 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: cache.c,v 1.4 1999/03/10 07:58:02 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
5858 */
5959 #ifdef __STDC__
6060 void
61 cache_init (char *dir_name)
61 cache_init(char *dir_name)
6262 #else
6363 void
64 cache_init (dir_name)
64 cache_init(dir_name)
6565 char *dir_name;
6666 #endif
6767 {
6868 struct stat st;
6969
70 strcpy (cache_directory, dir_name);
71 if (stat (cache_directory, &st) < 0)
72 {
73 report (REPORT_DEBUG, "creating cache directory `%s'\n", cache_directory);
74 if (mkdir (cache_directory, 0777) < 0)
75 {
76 report (REPORT_ERROR, "cache_init: cannot create cache directory '%s'\n", cache_directory);
77 }
78 }
79 else if (!S_ISDIR (st.st_mode))
80 {
81 report (REPORT_ERROR, "cache_init: %s not a directory\n", cache_directory);
82 done (1);
70 strcpy(cache_directory, dir_name);
71 if (stat(cache_directory, &st) < 0)
72 {
73 report(REPORT_DEBUG, "creating cache directory `%s'\n", cache_directory);
74 if (mkdir(cache_directory, 0777) < 0)
75 {
76 report(REPORT_ERROR, "cache_init: cannot create cache directory '%s'\n", cache_directory);
77 }
78 }
79 else if (!S_ISDIR(st.st_mode))
80 {
81 report(REPORT_ERROR, "cache_init: %s not a directory\n", cache_directory);
82 done(1);
8383 }
8484 }
8585
8787 * return the name of the first cache entry
8888 */
8989 char *
90 cache_first ()
90 cache_first()
9191 {
9292 if (cache_dir)
9393 {
94 rewinddir (cache_dir);
94 rewinddir(cache_dir);
9595 }
9696 else
9797 {
98 cache_dir = opendir (cache_directory);
98 cache_dir = opendir(cache_directory);
9999 if (cache_dir == NULL)
100100 {
101 report (REPORT_ERROR, "cache_first: opendir %s: %s\n", cache_directory, sys_err_str (errno));
101 report(REPORT_ERROR, "cache_first: opendir %s: %s\n", cache_directory, sys_err_str(errno));
102102 return NULL;
103103 }
104104 }
105105
106 return cache_next ();
106 return cache_next();
107107 }
108108
109109 /*
110110 * return the name of the next cache entry
111111 */
112112 char *
113 cache_next ()
113 cache_next()
114114 {
115115 struct dirent *dp;
116116
117117 do
118118 {
119 dp = readdir (cache_dir);
119 dp = readdir(cache_dir);
120120 if (dp == NULL)
121121 {
122 closedir (cache_dir);
122 closedir(cache_dir);
123123 cache_dir = NULL;
124124 return "";
125125 }
126126 }
127 while (strcmp (dp->d_name, ".") == 0 || strcmp (dp->d_name, "..") == 0);
128
129 SNPRINTF (SIZE(cache_path,sizeof(cache_path)), "%s/%s", cache_directory, dp->d_name);
127 while (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0);
128
129 SNPRINTF(SIZE(cache_path, sizeof(cache_path)), "%s/%s", cache_directory, dp->d_name);
130130
131131 return cache_path;
132132 }
135135 * calculate the size of the cache
136136 */
137137 int
138 cache_size ()
138 cache_size()
139139 {
140140 struct stat st;
141141 int size = 0;
142142 char *file;
143143
144 for (file = cache_first (); file && *file; file = cache_next ())
145 {
146 if (stat (file, &st) < 0)
147 {
148 report (REPORT_ERROR, "cache_size: stat %s: %s\n", file, sys_err_str (errno));
144 for (file = cache_first(); file && *file; file = cache_next())
145 {
146 if (stat(file, &st) < 0)
147 {
148 report(REPORT_ERROR, "cache_size: stat %s: %s\n", file, sys_err_str(errno));
149149 return -1;
150150 }
151151 size += (int) st.st_size;
158158 * load files that are already in the cache
159159 */
160160 void
161 cache_read ()
161 cache_read()
162162 {
163163 char *file;
164164
165 for (file = cache_first (); file && *file; file = cache_next ())
166 {
167 sound_insert (file, SOUND_READY, SOUND_FILE);
165 for (file = cache_first(); file && *file; file = cache_next())
166 {
167 sound_insert(file, SOUND_READY, SOUND_FILE);
168168 }
169169 }
170170
175175 */
176176 #ifdef __STDC__
177177 char *
178 cache_name (char *sound)
178 cache_name(char *sound)
179179 #else
180180 char *
181 cache_name (sound)
181 cache_name(sound)
182182 char *sound;
183183 #endif
184184 {
185185 static char _cache_path[MAXPATHLEN];
186186
187 SNPRINTF (SIZE(_cache_path,sizeof(_cache_path)), "%s/%s", cache_directory, sound);
187 SNPRINTF(SIZE(_cache_path, sizeof(_cache_path)), "%s/%s", cache_directory, sound);
188188
189189 return _cache_path;
190190 }
194194 */
195195 #ifdef __STDC__
196196 int
197 cache_free (int size)
198 #else
199 int
200 cache_free (size)
197 cache_free(int size)
198 #else
199 int
200 cache_free(size)
201201 int size;
202202 #endif
203203 {
214214
215215 if (size > cache_max_size)
216216 {
217 report (REPORT_DEBUG, "%d bytes cannot fit in the cache\n", size);
218 return -1;
219 }
220
221 curr_size = cache_size ();
222
223 report (REPORT_DEBUG, "sound_count = %d, current cache size = %d bytes\n", sound_count, curr_size);
217 report(REPORT_DEBUG, "%d bytes cannot fit in the cache\n", size);
218 return -1;
219 }
220
221 curr_size = cache_size();
222
223 report(REPORT_DEBUG, "sound_count = %d, current cache size = %d bytes\n", sound_count, curr_size);
224224
225225 if (size + curr_size <= cache_max_size)
226226 {
234234
235235 for (;;)
236236 {
237 report (REPORT_DEBUG, "removing cache entries (limit = %d)\n", limit);
238
239 for (file = cache_first (); file && *file; file = cache_next ())
240 {
241 s = sound_lookup (file, SOUND_DONT_COUNT, NULL);
237 report(REPORT_DEBUG, "removing cache entries (limit = %d)\n", limit);
238
239 for (file = cache_first(); file && *file; file = cache_next())
240 {
241 s = sound_lookup(file, SOUND_DONT_COUNT, NULL);
242242 if (s == NULL || s->status != SOUND_READY)
243243 {
244244 continue;
245245 }
246246 if (s->count < limit)
247247 {
248 if (stat (file, &st) < 0)
248 if (stat(file, &st) < 0)
249249 {
250 report (REPORT_ERROR, "cache_free: stat %s: %s\n", file, sys_err_str (errno));
250 report(REPORT_ERROR, "cache_free: stat %s: %s\n", file, sys_err_str(errno));
251251 continue;
252252 }
253253 curr_size -= (int) st.st_size;
254 spool_remove (s);
255 sound_delete (s, 1);
256 report (REPORT_DEBUG, "removed %s size=%d count=%d\n", file, st.st_size, s->count);
254 spool_remove(s);
255 sound_delete(s, 1);
256 report(REPORT_DEBUG, "removed %s size=%d count=%d\n", file, st.st_size, s->count);
257257 }
258258 }
259259
263263 }
264264 else if (limit == sound_count)
265265 {
266 report (REPORT_ERROR, "cache_free: cannot make room for %d bytes in the cache\n", size);
266 report(REPORT_ERROR, "cache_free: cannot make room for %d bytes in the cache\n", size);
267267 return -1;
268268 }
269269 else
270270 {
271271 n = limit / 4;
272272 limit += n ? n : 1;
273 limit = MIN (limit, sound_count);
273 limit = MIN(limit, sound_count);
274274 }
275275 }
276276
282282 */
283283 #ifdef __STDC__
284284 int
285 cache_create (char *name, int size)
286 #else
287 int
288 cache_create (name, size)
285 cache_create(char *name, int size)
286 #else
287 int
288 cache_create(name, size)
289289 char *name;
290290 int size;
291291 #endif
292292 {
293293 int fd;
294294
295 fd = open (name, O_RDWR | O_CREAT, 0666);
295 fd = open(name, O_RDWR | O_CREAT, 0666);
296296 if (fd < 0)
297297 {
298 report (REPORT_ERROR, "cache_create: open: %s\n", sys_err_str (errno));
299 return -1;
300 }
301
302 if (lseek (fd, size - 1, SEEK_SET) < 0)
303 {
304 report (REPORT_ERROR, "cache_create: lseek: %d %s\n", sys_err_str (errno));
298 report(REPORT_ERROR, "cache_create: open: %s\n", sys_err_str(errno));
299 return -1;
300 }
301
302 if (lseek(fd, size - 1, SEEK_SET) < 0)
303 {
304 report(REPORT_ERROR, "cache_create: lseek: %d %s\n", sys_err_str(errno));
305305 return -1;
306306 }
307307
308308 restart:
309 if (write (fd, "", 1) != 1)
309 if (write(fd, "", 1) != 1)
310310 {
311311 if (errno == EINTR || errno == EAGAIN)
312312 {
313313 goto restart;
314314 }
315 report (REPORT_ERROR, "cache_create: write: %s\n", sys_err_str (errno));
316 return -1;
317 }
318
319 if (lseek (fd, 0, SEEK_SET) < 0)
320 {
321 report (REPORT_ERROR, "cache_create: lseek: 0 %s\n", sys_err_str (errno));
322 unlink (name);
315 report(REPORT_ERROR, "cache_create: write: %s\n", sys_err_str(errno));
316 return -1;
317 }
318
319 if (lseek(fd, 0, SEEK_SET) < 0)
320 {
321 report(REPORT_ERROR, "cache_create: lseek: 0 %s\n", sys_err_str(errno));
322 unlink(name);
323323 return -1;
324324 }
325325
328328
329329 /* Optionally remove the cache directory and all its contents. */
330330 void
331 cache_cleanup ()
331 cache_cleanup()
332332 {
333333 int size;
334334 char *file;
335335
336 if (*cache_directory == '\0') /* cache_init wasn't called */
336 if (*cache_directory == '\0') /* cache_init wasn't called */
337337 {
338338 return;
339339 }
340
341 size = cache_size ();
340
341 size = cache_size();
342342 if (size == 0 || cache_remove)
343343 {
344 report (REPORT_DEBUG, "cleaning `%s'\n", cache_directory);
345 for (file = cache_first (); file && *file; file = cache_next ())
346 {
347 if (unlink (file) < 0)
344 report(REPORT_DEBUG, "cleaning `%s'\n", cache_directory);
345 for (file = cache_first(); file && *file; file = cache_next())
346 {
347 if (unlink(file) < 0)
348348 {
349 report (REPORT_ERROR, "cache_cleanup: unlink %s: %s\n",
350 file, sys_err_str (errno));
349 report(REPORT_ERROR, "cache_cleanup: unlink %s: %s\n",
350 file, sys_err_str(errno));
351351 }
352352 }
353
354 if (rmdir (cache_directory) < 0)
355 {
356 report (REPORT_ERROR, "cache_cleanup: rmdir %s: %s\n",
357 cache_directory, sys_err_str (errno));
358 }
359 }
360 }
353
354 if (rmdir(cache_directory) < 0)
355 {
356 report(REPORT_ERROR, "cache_cleanup: rmdir %s: %s\n",
357 cache_directory, sys_err_str(errno));
358 }
359 }
360 }
0 /* $Id: cache.h,v 1.2 1998/08/13 06:13:43 boyns Exp $ */
0 /* $Id: cache.h,v 1.3 1999/03/10 07:58:02 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: cdrom.c,v 1.2 1998/08/13 06:13:44 boyns Exp $ */
0 /* $Id: cdrom.c,v 1.4 1999/03/10 07:58:02 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
2323
2424
2525 /* A lot of the CDDA code is based on read_cdda 1.01 by Jim Mintha
26 (mintha@geog.ubc.ca) which seems to have borrowed code from Workman
27 sources written by Steven Grimm (koreth@hyperion.com). */
26 (mintha@geog.ubc.ca) which seems to have borrowed code from Workman
27 sources written by Steven Grimm (koreth@hyperion.com). */
2828
2929 #ifdef HAVE_CONFIG_H
3030 #include "config.h"
3939
4040 CDROM_TABLE cdrom_table[MAX_CDROMS] =
4141 {
42 #if defined (sun) && defined (SVR4) /* Solaris 2.x */
43 { "cdrom:", "/vol/dev/aliases/cdrom0", 0, 0 },
44 { "cdrom0:", "/vol/dev/aliases/cdrom0", 0, 0 },
45 { "cdrom1:", "/vol/dev/aliases/cdrom1", 0, 0 },
46 { "cdrom2:", "/vol/dev/aliases/cdrom2", 0, 0 },
47 { "cdrom3:", "/vol/dev/aliases/cdrom3", 0, 0 },
48 #else /* not solaris */
42 #if defined (sun) && defined (SVR4) /* Solaris 2.x */
43 {"cdrom:", "/vol/dev/aliases/cdrom0", 0, 0},
44 {"cdrom0:", "/vol/dev/aliases/cdrom0", 0, 0},
45 {"cdrom1:", "/vol/dev/aliases/cdrom1", 0, 0},
46 {"cdrom2:", "/vol/dev/aliases/cdrom2", 0, 0},
47 {"cdrom3:", "/vol/dev/aliases/cdrom3", 0, 0},
48 #else /* not solaris */
4949 #if defined (linux)
50 { "cdrom:", "/dev/cdrom", 0, 0 },
51 { "cdrom0:", "/dev/cdrom0", 0, 0 },
52 { "cdrom1:", "/dev/cdrom1", 0, 0 },
53 { "cdrom2:", "/dev/cdrom2", 0, 0 },
54 { "cdrom3:", "/dev/cdrom3", 0, 0 },
55 #endif /* linux */
56 #endif
50 {"cdrom:", "/dev/cdrom", 0, 0},
51 {"cdrom0:", "/dev/cdrom0", 0, 0},
52 {"cdrom1:", "/dev/cdrom1", 0, 0},
53 {"cdrom2:", "/dev/cdrom2", 0, 0},
54 {"cdrom3:", "/dev/cdrom3", 0, 0},
55 #endif /* linux */
56 #endif
5757 };
5858
5959 typedef struct
7474 /* Internal prototypes. */
7575 #ifdef HAVE_CDDA
7676 #ifdef __STDC__
77 static void cdda_cdrom_reader (CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd);
78 #else
79 static void cdda_cdrom_reader (/* CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd */);
77 static void cdda_cdrom_reader(CDROM_TABLE * cdt, int starting_track, int ending_track, int output_fd);
78 #else
79 static void cdda_cdrom_reader( /* CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd */ );
8080 #endif
8181 #endif /* HAVE_CDDA */
8282
8383 #ifdef linux
8484 #ifdef __STDC__
85 static void linux_cdrom_reader (CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd);
86 #else
87 static void linux_cdrom_reader (/* CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd */);
85 static void linux_cdrom_reader(CDROM_TABLE * cdt, int starting_track, int ending_track, int output_fd);
86 #else
87 static void linux_cdrom_reader( /* CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd */ );
8888 #endif
8989 #endif /* linux */
9090
9191 /* starting_track and ending_track can be 0 which means first and last */
9292 #ifdef __STDC__
9393 void
94 cdrom_reader (int index, int starting_track, int ending_track, int output_fd)
94 cdrom_reader(int index, int starting_track, int ending_track, int output_fd)
9595 #else
9696 void
97 cdrom_reader (index, starting_track, ending_track, output_fd)
97 cdrom_reader(index, starting_track, ending_track, output_fd)
9898 int index;
9999 int starting_track;
100100 int ending_track;
101101 int output_fd;
102 #endif
102 #endif
103103 {
104104 CDROM_TABLE *cdt;
105105
106106 cdt = &cdrom_table[index];
107
108 report (REPORT_DEBUG, "cdrom_reader: %s%s tracks %d..%d\n",
109 cdt->name, cdt->device, starting_track, ending_track);
110
111 rplay_audio_close (); /* prevent device busy problems */
107
108 report(REPORT_DEBUG, "cdrom_reader: %s%s tracks %d..%d\n",
109 cdt->name, cdt->device, starting_track, ending_track);
110
111 rplay_audio_close(); /* prevent device busy problems */
112112
113113 #ifdef HAVE_CDDA
114 cdda_cdrom_reader (cdt, starting_track, ending_track, output_fd);
114 cdda_cdrom_reader(cdt, starting_track, ending_track, output_fd);
115115 #else
116116 #ifdef linux
117 linux_cdrom_reader (cdt, starting_track, ending_track, output_fd);
118 #endif /* linux */
117 linux_cdrom_reader(cdt, starting_track, ending_track, output_fd);
118 #endif /* linux */
119119 #endif /* HAVE_CDDA */
120120
121121 /* Add more cdrom readers here. */
122
123 exit (0);
122
123 exit(0);
124124 }
125125
126126
135135 #define CDDA_BLOCK_SIZE 2368
136136 #define CDDA_BLOCK_IGNORE 16
137137
138 static int cdda_open (CDROM_INFO *info);
139 static int cdda_read (CDROM_INFO *info);
140 static int cdda_close (CDROM_INFO *info);
141 static int internal_cdda_init (CDROM_INFO *info);
142 static int internal_cdda_read (CDROM_INFO *info);
143 static int internal_cdda_toc (CDROM_INFO *info);
138 static int cdda_open(CDROM_INFO * info);
139 static int cdda_read(CDROM_INFO * info);
140 static int cdda_close(CDROM_INFO * info);
141 static int internal_cdda_init(CDROM_INFO * info);
142 static int internal_cdda_read(CDROM_INFO * info);
143 static int internal_cdda_toc(CDROM_INFO * info);
144144
145145 #ifdef __STDC__
146146 static void
147 cdda_cdrom_reader (CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd)
147 cdda_cdrom_reader(CDROM_TABLE * cdt, int starting_track, int ending_track, int output_fd)
148148 #else
149149 static void
150 cdda_cdrom_reader (cdt, starting_track, ending_track, output_fd)
150 cdda_cdrom_reader(cdt, starting_track, ending_track, output_fd)
151151 CDROM_TABLE *cdt;
152152 int starting_track;
153153 int ending_track;
154154 int output_fd;
155 #endif
155 #endif
156156 {
157157 CDROM_INFO info;
158158 int n, i;
159159 char *p;
160
160
161161 info.device = cdt->device;
162162 info.starting_track = starting_track;
163163 info.ending_track = ending_track;
165165 info.fd = -1;
166166 info.buffer = NULL;
167167
168 if (cdda_open (&info) < 0)
168 if (cdda_open(&info) < 0)
169169 {
170170 return;
171171 }
172172
173173 for (;;)
174174 {
175 n = cdda_read (&info);
175 n = cdda_read(&info);
176176 if (n <= 0)
177177 {
178178 break;
181181 p = info.buffer;
182182 for (i = 0; i < info.num_blocks; i++)
183183 {
184 write (output_fd, p, CDDA_BLOCK_SIZE - CDDA_BLOCK_IGNORE);
184 write(output_fd, p, CDDA_BLOCK_SIZE - CDDA_BLOCK_IGNORE);
185185 p += CDDA_BLOCK_SIZE;
186186 }
187187 }
188188
189 cdda_close (&info);
190 }
191
192 #ifdef __STDC__
193 static int
194 cdda_open (CDROM_INFO *info)
195 #else
196 static int
197 cdda_open (info)
189 cdda_close(&info);
190 }
191
192 #ifdef __STDC__
193 static int
194 cdda_open(CDROM_INFO * info)
195 #else
196 static int
197 cdda_open(info)
198198 CDROM_INFO *info;
199 #endif
199 #endif
200200 {
201201 if (info->fd < 0)
202202 {
203 if (internal_cdda_init (info) < 0)
203 if (internal_cdda_init(info) < 0)
204204 {
205205 return -1;
206206 }
207207 }
208208
209 return internal_cdda_toc (info);
210 }
211
212 #ifdef __STDC__
213 static int
214 cdda_read (CDROM_INFO *info)
215 #else
216 static int
217 cdda_read (info)
209 return internal_cdda_toc(info);
210 }
211
212 #ifdef __STDC__
213 static int
214 cdda_read(CDROM_INFO * info)
215 #else
216 static int
217 cdda_read(info)
218218 CDROM_INFO *info;
219 #endif
219 #endif
220220 {
221221 int n;
222222
223 n = internal_cdda_read (info);
223 n = internal_cdda_read(info);
224224 if (n < 0)
225225 {
226226 return -1;
231231
232232 #ifdef __STDC__
233233 static int
234 cdda_close (CDROM_INFO *info)
235 #else
236 static int
237 cdda_close (info)
234 cdda_close(CDROM_INFO * info)
235 #else
236 static int
237 cdda_close(info)
238238 CDROM_INFO *info;
239 #endif
240 {
241 close (info->fd);
239 #endif
240 {
241 close(info->fd);
242242 info->fd = -1;
243243 if (info->buffer)
244244 {
245 free ((char *) info->buffer);
245 free((char *) info->buffer);
246246 }
247247 info->buffer = NULL;
248248 return 0;
263263
264264 #ifdef __STDC__
265265 static int
266 internal_cdda_init (CDROM_INFO *info)
267 #else
268 static int
269 internal_cdda_init (info)
266 internal_cdda_init(CDROM_INFO * info)
267 #else
268 static int
269 internal_cdda_init(info)
270270 CDROM_INFO *info;
271 #endif
271 #endif
272272 {
273273 struct cdrom_cdda cdda;
274274
275 info->fd = open (info->device, 0);
275 info->fd = open(info->device, 0);
276276 if (info->fd < 0)
277277 {
278 perror (info->device);
279 return -1;
280 }
281
282 info->buffer = (char *) malloc (info->num_blocks * CDDABLKSIZE + CDDABLKSIZE);
278 perror(info->device);
279 return -1;
280 }
281
282 info->buffer = (char *) malloc(info->num_blocks * CDDABLKSIZE + CDDABLKSIZE);
283283 if (info->buffer == NULL)
284284 {
285 fprintf (stderr, "malloc: out of memory\n");
285 fprintf(stderr, "malloc: out of memory\n");
286286 return -1;
287287 }
288288
293293 cdda.cdda_data = info->buffer;
294294 cdda.cdda_subcode = CDROM_DA_SUBQ;
295295
296 if (ioctl (info->fd, CDROMCDDA, &cdda) < 0)
297 {
298 perror ("ioctl: CDROMCDDA");
299 free ((char *) info->buffer);
296 if (ioctl(info->fd, CDROMCDDA, &cdda) < 0)
297 {
298 perror("ioctl: CDROMCDDA");
299 free((char *) info->buffer);
300300 info->buffer = NULL;
301 close (info->fd);
301 close(info->fd);
302302 return -1;
303303 }
304304
307307
308308 #ifdef __STDC__
309309 static int
310 internal_cdda_read (CDROM_INFO *info)
311 #else
312 static int
313 internal_cdda_read (info)
310 internal_cdda_read(CDROM_INFO * info)
311 #else
312 static int
313 internal_cdda_read(info)
314314 CDROM_INFO *info;
315 #endif
315 #endif
316316 {
317317 struct cdrom_cdda cdda;
318318 int blk;
332332 {
333333 cdda.cdda_length = info->num_blocks;
334334 }
335
335
336336 cdda.cdda_data = info->buffer;
337337 cdda.cdda_subcode = CDROM_DA_SUBQ;
338338
339 if (ioctl (info->fd, CDROMCDDA, &cdda) < 0)
339 if (ioctl(info->fd, CDROMCDDA, &cdda) < 0)
340340 {
341341 if (errno == ENXIO)
342342 {
343 perror ("ioctl: CDROMCDDA: CD ejected");
343 perror("ioctl: CDROMCDDA: CD ejected");
344344 return -1;
345345 }
346346
349349 return 0;
350350 }
351351
352 if (ioctl (info->fd, CDROMCDDA, &cdda) < 0)
353 {
354 if (ioctl (info->fd, CDROMCDDA, &cdda) < 0)
352 if (ioctl(info->fd, CDROMCDDA, &cdda) < 0)
353 {
354 if (ioctl(info->fd, CDROMCDDA, &cdda) < 0)
355355 {
356 if (ioctl (info->fd, CDROMCDDA, &cdda) < 0)
356 if (ioctl(info->fd, CDROMCDDA, &cdda) < 0)
357357 {
358 perror ("ioctl: CDROMCDDA");
358 perror("ioctl: CDROMCDDA");
359359 return -1;
360360 }
361361 }
369369
370370 #ifdef __STDC__
371371 static int
372 internal_cdda_toc (CDROM_INFO *info)
373 #else
374 static int
375 internal_cdda_toc (info)
372 internal_cdda_toc(CDROM_INFO * info)
373 #else
374 static int
375 internal_cdda_toc(info)
376376 CDROM_INFO *info;
377 #endif
377 #endif
378378 {
379379 struct cdrom_tochdr hdr;
380380 struct cdrom_tocentry entry;
381381 int i;
382382
383 if (ioctl (info->fd, CDROMREADTOCHDR, &hdr) < 0)
384 {
385 perror ("ioctl: CDROMREADTOCHDR");
383 if (ioctl(info->fd, CDROMREADTOCHDR, &hdr) < 0)
384 {
385 perror("ioctl: CDROMREADTOCHDR");
386386 return -1;
387387 }
388388
403403 entry.cdte_track = i;
404404 entry.cdte_format = CDROM_MSF;
405405
406 if (ioctl (info->fd, CDROMREADTOCENTRY, &entry) < 0)
407 {
408 perror ("ioctl: CDROMREADTOCENTRY");
406 if (ioctl(info->fd, CDROMREADTOCENTRY, &entry) < 0)
407 {
408 perror("ioctl: CDROMREADTOCENTRY");
409409 return -1;
410410 }
411411
425425 entry.cdte_track = CDROM_LEADOUT;
426426 entry.cdte_format = CDROM_MSF;
427427
428 if (ioctl (info->fd, CDROMREADTOCENTRY, &entry) < 0)
429 {
430 perror ("ioctl: CDROMREADTOCENTRY");
428 if (ioctl(info->fd, CDROMREADTOCENTRY, &entry) < 0)
429 {
430 perror("ioctl: CDROMREADTOCENTRY");
431431 return -1;
432432 }
433433
440440 /* Move back two seconds - don't know why but works */
441441 info->starting_block -= 150;
442442 info->ending_block -= 150;
443
443
444444 info->current_block = info->starting_block;
445445
446446 return 0;
456456
457457 #ifdef __STDC__
458458 static int
459 linux_read_toc (CDROM_INFO *info)
460 #else
461 static int
462 linux_read_toc (info)
459 linux_read_toc(CDROM_INFO * info)
460 #else
461 static int
462 linux_read_toc(info)
463463 CDROM_INFO *info;
464 #endif
464 #endif
465465 {
466466 struct cdrom_tochdr hdr;
467467 struct cdrom_tocentry entry;
468468 int i;
469469
470 if (ioctl (info->fd, CDROMREADTOCHDR, &hdr) < 0)
471 {
472 perror ("ioctl: CDROMREADTOCHDR");
470 if (ioctl(info->fd, CDROMREADTOCHDR, &hdr) < 0)
471 {
472 perror("ioctl: CDROMREADTOCHDR");
473473 return -1;
474474 }
475475
490490 entry.cdte_track = i;
491491 entry.cdte_format = CDROM_MSF;
492492
493 if (ioctl (info->fd, CDROMREADTOCENTRY, &entry) < 0)
494 {
495 perror ("ioctl: CDROMREADTOCENTRY");
493 if (ioctl(info->fd, CDROMREADTOCENTRY, &entry) < 0)
494 {
495 perror("ioctl: CDROMREADTOCENTRY");
496496 return -1;
497497 }
498498
512512 entry.cdte_track = CDROM_LEADOUT;
513513 entry.cdte_format = CDROM_MSF;
514514
515 if (ioctl (info->fd, CDROMREADTOCENTRY, &entry) < 0)
516 {
517 perror ("ioctl: CDROMREADTOCENTRY");
515 if (ioctl(info->fd, CDROMREADTOCENTRY, &entry) < 0)
516 {
517 perror("ioctl: CDROMREADTOCENTRY");
518518 return -1;
519519 }
520520
527527 /* Move back two seconds - don't know why but works */
528528 info->starting_block -= 150;
529529 info->ending_block -= 150;
530
530
531531 info->current_block = info->starting_block;
532532
533533 return 0;
535535
536536 #ifdef __STDC__
537537 static void
538 linux_cdrom_reader (CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd)
538 linux_cdrom_reader(CDROM_TABLE * cdt, int starting_track, int ending_track, int output_fd)
539539 #else
540540 static void
541 linux_cdrom_reader (cdt, starting_track, ending_track, output_fd)
541 linux_cdrom_reader(cdt, starting_track, ending_track, output_fd)
542542 CDROM_TABLE *cdt;
543543 int starting_track;
544544 int ending_track;
545545 int output_fd;
546 #endif
546 #endif
547547 {
548548 CDROM_INFO info;
549549 int n, i;
550550 char *p;
551
551
552552 info.device = cdt->device;
553553 info.starting_track = starting_track;
554554 info.ending_track = ending_track;
556556 info.fd = -1;
557557 info.buffer = NULL;
558558
559 info.fd = open (info.device, 0);
559 info.fd = open(info.device, 0);
560560 if (info.fd < 0)
561561 {
562 perror (info.device);
562 perror(info.device);
563563 return;
564564 }
565565
566 info.buffer = (char *) malloc (info.num_blocks * CD_FRAMESIZE_RAW + CD_FRAMESIZE_RAW);
566 info.buffer = (char *) malloc(info.num_blocks * CD_FRAMESIZE_RAW + CD_FRAMESIZE_RAW);
567567 if (info.buffer == NULL)
568568 {
569 fprintf (stderr, "malloc: out of memory\n");
569 fprintf(stderr, "malloc: out of memory\n");
570570 return;
571571 }
572572
573 linux_read_toc (&info);
573 linux_read_toc(&info);
574574
575575 /* printf ("start track=%d block=%d\n", info.starting_track, info.starting_block); */
576576 /* printf ("end track=%d block=%d\n", info.ending_track, info.ending_block); */
592592 for (i = 0; i < max_retries; i++)
593593 {
594594 struct cdrom_read_audio audio;
595
595
596596 audio.addr_format = CDROM_LBA;
597597 audio.addr.lba = info.current_block;
598598 audio.nframes = frames;
599599 audio.buf = info.buffer;
600600
601 if (ioctl (info.fd, CDROMREADAUDIO, &audio) >= 0)
601 if (ioctl(info.fd, CDROMREADAUDIO, &audio) >= 0)
602602 {
603603 break;
604604 }
605605 }
606606 if (i == max_retries)
607607 {
608 perror (info.device);
608 perror(info.device);
609609 break;
610610 }
611
612 if (write (output_fd, info.buffer, CD_FRAMESIZE_RAW * frames) < 0)
611
612 if (write(output_fd, info.buffer, CD_FRAMESIZE_RAW * frames) < 0)
613613 {
614614 break;
615615 }
616616
617617 info.current_block += frames;
618618 }
619
620 free (info.buffer);
621 close (info.fd);
619
620 free(info.buffer);
621 close(info.fd);
622622 }
623623
624624 #endif /* linux */
0 /* $Id: cdrom.h,v 1.2 1998/08/13 06:13:45 boyns Exp $ */
0 /* $Id: cdrom.h,v 1.3 1999/03/10 07:58:02 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: command.c,v 1.2 1998/08/13 06:13:46 boyns Exp $ */
0 /* $Id: command.c,v 1.6 1999/03/10 07:58:02 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifdef HAVE_CONFIG_H
2624 #include "config.h"
7068 COMMAND;
7169
7270 #ifdef __STDC__
73 static int do_command (CONNECTION *c, int argc, char **argv);
74 static int command_quit (CONNECTION *c, int argc, char **argv);
75 static int command_unknown (CONNECTION *c, int argc, char **argv);
76 static int command_help (CONNECTION *c, int argc, char **argv);
77 static int command_get (CONNECTION *c, int argc, char **argv);
78 static int command_put (CONNECTION *c, int argc, char **argv);
79 static int command_list (CONNECTION *c, int argc, char **argv);
80 static int command_find (CONNECTION *c, int argc, char **argv);
81 static int command_execute (CONNECTION *c, int argc, char **argv);
82 static int command_access (CONNECTION *c, int argc, char **argv);
83 static int command_volume (CONNECTION *c, int argc, char **argv);
84 static int command_info (CONNECTION *c, int argc, char **argv);
85 static int command_version (CONNECTION *c, int argc, char **argv);
86 static int command_wait (CONNECTION *c, int argc, char **argv);
87 static int do_execute (CONNECTION *c, int argc, char **argv);
88 static int command_status (CONNECTION *c, int argc, char **argv);
89 static int command_application (CONNECTION *c, int argc, char **argv);
90 static int command_reset (CONNECTION *c, int argc, char **argv);
91 static int command_skip (CONNECTION *c, int argc, char **argv);
92 static int command_set (CONNECTION *c, int argc, char **argv);
93 static int command_modify (CONNECTION *c, int argc, char **argv);
94 #else
95 static int do_command ( /* CONNECTION *c, int argc, char **argv */ );
96 static int command_quit ( /* CONNECTION *c, int argc, char **argv */ );
97 static int command_unknown ( /* CONNECTION *c, int argc, char **argv */ );
98 static int command_help ( /* CONNECTION *c, int argc, char **argv */ );
99 static int command_get ( /* CONNECTION *c, int argc, char **argv */ );
100 static int command_put ( /* CONNECTION *c, int argc, char **argv */ );
101 static int command_list ( /* CONNECTION *c, int argc, char **argv */ );
102 static int command_find ( /* CONNECTION *c, int argc, char **argv */ );
103 static int command_execute ( /* CONNECTION *c, int argc, char **argv */ );
104 static int command_access ( /* CONNECTION *c, int argc, char **argv */ );
105 static int command_volume ( /* CONNECTION *c, int argc, char **argv */ );
106 static int command_info ( /* CONNECTION *c, int argc, char **argv */ );
107 static int command_version ( /* CONNECTION *c, int argc, char **argv */ );
108 static int command_wait ( /* CONNECTION *c, int argc, char **argv */ );
109 static int do_execute ( /* CONNECTION *c, int argc, char **argv */ );
110 static int command_status ( /* CONNECTION *c, int argc, char **argv */ );
111 static int command_application ( /* CONNECTION *c, int argc, char **argv */ );
112 static int command_reset ( /* CONNECTION *c, int argc, char **argv */ );
113 static int command_skip ( /* CONNECTION *c, int argc, char **argv */ );
114 static int command_set ( /* CONNECTION *c, int argc, char **argv */ );
115 static int command_modify ( /* CONNECTION *c, int argc, char **argv */ );
71 static int do_command(CONNECTION *c, int argc, char **argv);
72 static int command_quit(CONNECTION *c, int argc, char **argv);
73 static int command_unknown(CONNECTION *c, int argc, char **argv);
74 static int command_help(CONNECTION *c, int argc, char **argv);
75 static int command_get(CONNECTION *c, int argc, char **argv);
76 static int command_put(CONNECTION *c, int argc, char **argv);
77 static int command_list(CONNECTION *c, int argc, char **argv);
78 static int command_find(CONNECTION *c, int argc, char **argv);
79 static int command_execute(CONNECTION *c, int argc, char **argv);
80 static int command_access(CONNECTION *c, int argc, char **argv);
81 static int command_volume(CONNECTION *c, int argc, char **argv);
82 static int command_info(CONNECTION *c, int argc, char **argv);
83 static int command_version(CONNECTION *c, int argc, char **argv);
84 static int command_wait(CONNECTION *c, int argc, char **argv);
85 static int do_execute(CONNECTION *c, int argc, char **argv);
86 static int command_status(CONNECTION *c, int argc, char **argv);
87 static int command_application(CONNECTION *c, int argc, char **argv);
88 static int command_reset(CONNECTION *c, int argc, char **argv);
89 static int command_skip(CONNECTION *c, int argc, char **argv);
90 static int command_set(CONNECTION *c, int argc, char **argv);
91 static int command_modify(CONNECTION *c, int argc, char **argv);
92 static int command_monitor(CONNECTION *c, int argc, char **argv);
93 #else
94 static int do_command( /* CONNECTION *c, int argc, char **argv */ );
95 static int command_quit( /* CONNECTION *c, int argc, char **argv */ );
96 static int command_unknown( /* CONNECTION *c, int argc, char **argv */ );
97 static int command_help( /* CONNECTION *c, int argc, char **argv */ );
98 static int command_get( /* CONNECTION *c, int argc, char **argv */ );
99 static int command_put( /* CONNECTION *c, int argc, char **argv */ );
100 static int command_list( /* CONNECTION *c, int argc, char **argv */ );
101 static int command_find( /* CONNECTION *c, int argc, char **argv */ );
102 static int command_execute( /* CONNECTION *c, int argc, char **argv */ );
103 static int command_access( /* CONNECTION *c, int argc, char **argv */ );
104 static int command_volume( /* CONNECTION *c, int argc, char **argv */ );
105 static int command_info( /* CONNECTION *c, int argc, char **argv */ );
106 static int command_version( /* CONNECTION *c, int argc, char **argv */ );
107 static int command_wait( /* CONNECTION *c, int argc, char **argv */ );
108 static int do_execute( /* CONNECTION *c, int argc, char **argv */ );
109 static int command_status( /* CONNECTION *c, int argc, char **argv */ );
110 static int command_application( /* CONNECTION *c, int argc, char **argv */ );
111 static int command_reset( /* CONNECTION *c, int argc, char **argv */ );
112 static int command_skip( /* CONNECTION *c, int argc, char **argv */ );
113 static int command_set( /* CONNECTION *c, int argc, char **argv */ );
114 static int command_modify( /* CONNECTION *c, int argc, char **argv */ );
115 static int command_monitor( /* CONNECTION *c, int argc, char **argv */ );
116116 #endif
117117
118118 #ifdef DEBUG
119 extern int command_die ( /* CONNECTION *c, int argc, char **argv */ );
119 extern int command_die( /* CONNECTION *c, int argc, char **argv */ );
120120 #endif
121121
122122 static COMMAND commands[] =
141141 {"list", 0, 1, "[connections|servers|sounds}", command_list},
142142 #endif /* AUTH */
143143 {"modify", 2, -1, "id [count|list-count|priority|sample-rate|volume] ...", command_modify},
144 {"monitor", -1, -1, "", command_monitor},
144145 {"pause", 1, -1, "id|sound ...", command_execute},
145146 {"play", 1, -1, "sound ...", command_execute},
146147 {"put", 2, -1, "id|sound size", command_put},
163164
164165 #ifdef __STDC__
165166 int
166 command (CONNECTION *c, char *buf)
167 command(CONNECTION *c, char *buf)
167168 #else
168169 int
169 command (c, buf)
170 command(c, buf)
170171 CONNECTION *c;
171172 char *buf;
172173 #endif
174175 char *argv[RPTP_MAX_ARGS], *p;
175176 int argc = 0, first = 1;
176177
177 report (REPORT_INFO, "%s command=\"%s\"\n", inet_ntoa (c->sin.sin_addr), buf);
178 strncpy (command_buffer, buf, sizeof(command_buffer));
179
180 while ((p = strtok (first ? buf : NULL, " \t")))
178 report(REPORT_INFO, "%s command=\"%s\"\n", inet_ntoa(c->sin.sin_addr), buf);
179 strncpy(command_buffer, buf, sizeof(command_buffer));
180
181 while ((p = strtok(first ? buf : NULL, " \t")))
181182 {
182183 argv[argc++] = p;
183184 first = 0;
185 if (argc == RPTP_MAX_ARGS - 1)
186 {
187 break;
188 }
184189 }
185190 argv[argc] = NULL;
186191
190195 }
191196 else
192197 {
193 return do_command (c, argc, argv);
194 }
195 }
196
197 #ifdef __STDC__
198 static int
199 do_command (CONNECTION *c, int argc, char **argv)
200 #else
201 static int
202 do_command (c, argc, argv)
198 return do_command(c, argc, argv);
199 }
200 }
201
202 #ifdef __STDC__
203 static int
204 do_command(CONNECTION *c, int argc, char **argv)
205 #else
206 static int
207 do_command(c, argc, argv)
203208 CONNECTION *c;
204209 int argc;
205210 char **argv;
209214
210215 for (i = 0; i < NCOMMANDS; i++)
211216 {
212 if (strcmp (commands[i].name, argv[0]) == 0)
217 if (strcmp(commands[i].name, argv[0]) == 0)
213218 {
214219 if ((commands[i].min_args >= 0 && argc - 1 < commands[i].min_args)
215220 || (commands[i].max_args >= 0 && argc - 1 > commands[i].max_args))
216221 {
217 connection_reply (c, "%cerror=\"usage: %s %s\"",
218 RPTP_ERROR, commands[i].name, commands[i].usage);
222 connection_reply(c, "%cerror=\"usage: %s %s\"",
223 RPTP_ERROR, commands[i].name, commands[i].usage);
219224 return 0;
220225 }
221226 else
225230 }
226231 }
227232
228 return command_unknown (c, argc, argv);
229 }
230
231 #ifdef __STDC__
232 static int
233 command_quit (CONNECTION *c, int argc, char **argv)
234 #else
235 static int
236 command_quit (c, argc, argv)
233 return command_unknown(c, argc, argv);
234 }
235
236 #ifdef __STDC__
237 static int
238 command_quit(CONNECTION *c, int argc, char **argv)
239 #else
240 static int
241 command_quit(c, argc, argv)
237242 CONNECTION *c;
238243 int argc;
239244 char **argv;
245250
246251 #ifdef __STDC__
247252 static int
248 command_unknown (CONNECTION *c, int argc, char **argv)
249 #else
250 static int
251 command_unknown (c, argc, argv)
253 command_unknown(CONNECTION *c, int argc, char **argv)
254 #else
255 static int
256 command_unknown(c, argc, argv)
252257 CONNECTION *c;
253258 int argc;
254259 char **argv;
255260 #endif
256261 {
257262 char *client_data;
258
259 client_data = rptp_parse (command_buffer, "client-data");
263
264 client_data = rptp_parse(command_buffer, "client-data");
260265 if (!client_data)
261266 {
262267 client_data = default_client_data;
263268 }
264269
265 connection_reply (c, "%cerror=\"unknown command `%s'\" command=\"%s\" client-data=\"%s\"",
266 RPTP_ERROR, argv[0], argv[0], client_data);
267
270 connection_reply(c, "%cerror=\"unknown command `%s'\" command=\"%s\" client-data=\"%s\"",
271 RPTP_ERROR, argv[0], argv[0], client_data);
272
268273 return 0;
269274 }
270275
271276 #ifdef __STDC__
272277 static int
273 command_help (CONNECTION *c, int argc, char **argv)
274 #else
275 static int
276 command_help (c, argc, argv)
278 command_help(CONNECTION *c, int argc, char **argv)
279 #else
280 static int
281 command_help(c, argc, argv)
277282 CONNECTION *c;
278283 int argc;
279284 char **argv;
286291
287292 if (b == NULL)
288293 {
289 b = buffer_create ();
294 b = buffer_create();
290295 b->status = BUFFER_KEEP;
291 SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "%cmessage=\"command summary\" command=help\r\n", RPTP_OK);
296 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "%cmessage=\"command summary\" command=help\r\n", RPTP_OK);
297 b->nbytes += strlen(b->buf);
292298 for (i = 0; i < NCOMMANDS; i++)
293299 {
294 SNPRINTF (SIZE(fmt,sizeof(fmt)), "%-8s %s\r\n", commands[i].name, commands[i].usage);
295 SNPRINTF (SIZE(b->buf+strlen(b->buf),BUFFER_SIZE), fmt);
296 }
297 SNPRINTF (SIZE(b->buf+strlen(b->buf),BUFFER_SIZE), ".\r\n");
298 b->nbytes = strlen (b->buf);
299 }
300
301 e = event_create (EVENT_WRITE, b);
302 event_insert (c, e);
300 SNPRINTF(SIZE(fmt, sizeof(fmt)), "%-8s %s\r\n", commands[i].name, commands[i].usage);
301 SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), fmt);
302 b->nbytes += strlen(fmt);
303 }
304 SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), ".\r\n");
305 b->nbytes += 3;
306 }
307
308 e = event_create(EVENT_WRITE, b);
309 event_insert(c, e);
303310
304311 return 0;
305312 }
306313
307314 #ifdef __STDC__
308315 static int
309 command_get (CONNECTION *c, int argc, char **argv)
310 #else
311 static int
312 command_get (c, argc, argv)
316 command_get(CONNECTION *c, int argc, char **argv)
317 #else
318 static int
319 command_get(c, argc, argv)
313320 CONNECTION *c;
314321 int argc;
315322 char **argv;
320327 char *sound_name = NULL;
321328 int old_style = 0;
322329 char *client_data = default_client_data;
323
324 if (strchr (command_buffer, '='))
325 {
326 sound_name = rptp_parse (command_buffer, "sound");
327 client_data = rptp_parse (0, "client-data");
330
331 if (strchr(command_buffer, '='))
332 {
333 sound_name = rptp_parse(command_buffer, "sound");
334 client_data = rptp_parse(0, "client-data");
328335 if (!client_data)
329336 {
330337 client_data = default_client_data;
337344 }
338345
339346 #ifdef AUTH
340 if (!host_access (c->sin, HOST_READ))
341 {
342 report (REPORT_NOTICE, "%s get %s - read access denied\n",
343 inet_ntoa (c->sin.sin_addr),
344 argv[1]);
345 connection_reply (c, "%cerror=\"access denied\" command=get client-data=\"%s\"",
346 RPTP_ERROR, client_data);
347 if (!host_access(c->sin, HOST_READ))
348 {
349 report(REPORT_NOTICE, "%s get %s - read access denied\n",
350 inet_ntoa(c->sin.sin_addr),
351 argv[1]);
352 connection_reply(c, "%cerror=\"access denied\" command=get client-data=\"%s\"",
353 RPTP_ERROR, client_data);
347354 return 0;
348355 }
349356 #endif /* AUTH */
350357
351 s = sound_lookup (sound_name, SOUND_DONT_FIND, NULL);
358 s = sound_lookup(sound_name, SOUND_DONT_FIND, NULL);
352359 if (s == NULL || s->status != SOUND_READY)
353360 {
354 report (REPORT_NOTICE, "%s get %s - not found\n",
355 inet_ntoa (c->sin.sin_addr), sound_name);
356 connection_reply (c, "%cerror=\"%s not found\" command=get client-data=\"%s\"",
357 RPTP_ERROR, sound_name, client_data);
361 report(REPORT_NOTICE, "%s get %s - not found\n",
362 inet_ntoa(c->sin.sin_addr), sound_name);
363 connection_reply(c, "%cerror=\"%s not found\" command=get client-data=\"%s\"",
364 RPTP_ERROR, sound_name, client_data);
358365 }
359366 else if (s->type != SOUND_FILE)
360367 {
361 connection_reply (c, "%cerror=\"%s not a file\" command=get client-data=\"%s\"",
362 RPTP_ERROR, s->name, client_data);
368 connection_reply(c, "%cerror=\"%s not a file\" command=get client-data=\"%s\"",
369 RPTP_ERROR, s->name, client_data);
363370 }
364371 else
365372 {
366 e = event_create (EVENT_WRITE_SOUND, s);
373 e = event_create(EVENT_WRITE_SOUND, s);
367374 if (e == NULL)
368375 {
369 report (REPORT_NOTICE, "%s get %s - cannot open\n",
370 inet_ntoa (c->sin.sin_addr), s->name);
371 connection_reply (c, "%cerror=\"cannot open %s\" command=get client-data=\"%s\"",
372 RPTP_ERROR, s->name, client_data);
376 report(REPORT_NOTICE, "%s get %s - cannot open\n",
377 inet_ntoa(c->sin.sin_addr), s->name);
378 connection_reply(c, "%cerror=\"cannot open %s\" command=get client-data=\"%s\"",
379 RPTP_ERROR, s->name, client_data);
373380 }
374381 else
375382 {
376 report (REPORT_NOTICE, "%s get %s %d\n",
377 inet_ntoa (c->sin.sin_addr), s->name, s->size);
383 report(REPORT_NOTICE, "%s get %s %d\n",
384 inet_ntoa(c->sin.sin_addr), s->name, s->size);
378385 if (old_style)
379386 {
380 connection_reply (c, "%c%s %d", RPTP_OK, s->name, s->size);
387 connection_reply(c, "%c%s %d", RPTP_OK, s->name, s->size);
381388 }
382389 else
383390 {
384 connection_reply (c, "%csound=\"%s\" size=%d command=get client-data=\"%s\"",
385 RPTP_OK, s->name, s->size, client_data);
386 }
387 event_insert (c, e);
391 connection_reply(c, "%csound=\"%s\" size=%d command=get client-data=\"%s\"",
392 RPTP_OK, s->name, s->size, client_data);
393 }
394 event_insert(c, e);
388395 }
389396 }
390397
393400
394401 #ifdef __STDC__
395402 static int
396 command_put (CONNECTION *c, int argc, char **argv)
397 #else
398 static int
399 command_put (c, argc, argv)
403 command_put(CONNECTION *c, int argc, char **argv)
404 #else
405 static int
406 command_put(c, argc, argv)
400407 CONNECTION *c;
401408 int argc;
402409 char **argv;
410417 int old_style = 0;
411418 int spool_id = 0;
412419 char *client_data = default_client_data;
413
414 if (strchr (command_buffer, '='))
415 {
416 client_data = rptp_parse (command_buffer, "client-data");
420
421 if (strchr(command_buffer, '='))
422 {
423 client_data = rptp_parse(command_buffer, "client-data");
417424 if (!client_data)
418425 {
419426 client_data = default_client_data;
423430 {
424431 old_style++;
425432 }
426
433
427434 #ifdef AUTH
428 if (!host_access (c->sin, HOST_WRITE))
429 {
430 report (REPORT_NOTICE, "%s put %s - write access denied\n",
431 inet_ntoa (c->sin.sin_addr),
432 argv[1]);
433 connection_reply (c, "%cerror=\"access denied\" command=put client-data=\"%s\"",
434 RPTP_ERROR, client_data);
435 if (!host_access(c->sin, HOST_WRITE))
436 {
437 report(REPORT_NOTICE, "%s put %s - write access denied\n",
438 inet_ntoa(c->sin.sin_addr),
439 argv[1]);
440 connection_reply(c, "%cerror=\"access denied\" command=put client-data=\"%s\"",
441 RPTP_ERROR, client_data);
435442 return 0;
436443 }
437444 #endif /* AUTH */
439446 if (!old_style)
440447 {
441448 char *p;
442
443 sound_name = rptp_parse (0, "sound");
444
445 p = rptp_parse (0, "size");
449
450 sound_name = rptp_parse(0, "sound");
451
452 p = rptp_parse(0, "size");
446453 if (!p)
447454 {
448 connection_reply (c, "%cerror=\"missing `size=<value>'\" command=put client-data=\"%s\"",
449 RPTP_ERROR, client_data);
455 connection_reply(c, "%cerror=\"missing `size=<value>'\" command=put client-data=\"%s\"",
456 RPTP_ERROR, client_data);
450457 return 0;
451458 }
452 sound_size = atoi (p);
453
454 p = rptp_parse (0, "id");
459 sound_size = atoi(p);
460
461 p = rptp_parse(0, "id");
455462 if (p && *p && p[0] == '#')
456463 {
457 spool_id = atoi (p+1);
458 }
459 else
460 {
461 connection_reply (c, "%cerror=\"invalid `id'\" command=put client-data=\"%s\"",
462 RPTP_ERROR, client_data);
464 spool_id = atoi(p + 1);
465 }
466 }
467 else
468 /* old-style */
469 {
470 sound_name = argv[1];
471 sound_size = atoi(argv[2]);
472 old_style++;
473 }
474
475 if (spool_id)
476 {
477 SPOOL *sp;
478 #ifdef HAVE_HELPERS
479 HELPER *hp;
480 #endif
481
482 sp = spool_find(spool_id);
483 if (!sp)
484 {
485 connection_reply(c, "%cerror=\"`%d' no such spool id\" command=put client-data=\"%s\"",
486 RPTP_ERROR, spool_id, client_data);
463487 return 0;
464488 }
465 }
466 else /* old-style */
467 {
468 sound_name = argv[1];
469 sound_size = atoi (argv[2]);
470 old_style++;
471 }
472
473 if (spool_id)
474 {
475 SPOOL *sp;
476 #ifdef HAVE_HELPERS
477 HELPER *hp;
478 #endif
479
480 sp = spool_find (spool_id);
481 if (!sp)
482 {
483 connection_reply (c, "%cerror=\"`%d' no such spool id\" command=put client-data=\"%s\"",
484 RPTP_ERROR, spool_id, client_data);
489 else if (sp->sound[sp->curr_sound]->type != SOUND_FLOW)
490 {
491 connection_reply(c, "%cerror=\"`%d' spool id is not a flow\" command=put client-data=\"%s\"",
492 RPTP_ERROR, spool_id, client_data);
485493 return 0;
486494 }
487 else if (sp->sound[sp->curr_sound]->type != SOUND_FLOW)
488 {
489 connection_reply (c, "%cerror=\"`%d' spool id is not a flow\" command=put client-data=\"%s\"",
490 RPTP_ERROR, spool_id, client_data);
491 return 0;
492 }
493
494 connection_reply (c, "%cid=#%d size=%d command=put client-data=\"%s\"",
495 RPTP_OK, spool_id, sound_size, client_data);
496
497 #ifdef HAVE_HELPERS
495
496 connection_reply(c, "%cid=#%d size=%d command=put client-data=\"%s\"",
497 RPTP_OK, spool_id, sound_size, client_data);
498
499 #ifdef HAVE_HELPERS
498500 /* XXX - it isn't known yet whether or not this sound
499501 will need a helper. Check here too. */
500 hp = helper_lookup (sp->sound[sp->curr_sound]->path);
502 hp = helper_lookup(sp->sound[sp->curr_sound]->path);
501503 if (hp)
502504 {
503505 SOUND *s = sp->sound[sp->curr_sound];
504 e = event_create (EVENT_PIPE_FLOW, spool_id, s);
505 event_insert (c, e);
506 e = event_create(EVENT_PIPE_FLOW, spool_id, s);
507 event_insert(c, e);
506508
507509 s->status = SOUND_READY;
508 sound_map (s);
509 spool_ready (s);
510 sound_map(s);
511 spool_ready(s);
510512 }
511513 else
512 #endif /* HAVE_HELPERS */
513 {
514 e = event_create (EVENT_READ_FLOW, spool_id, sound_size);
515 event_insert (c, e);
514 #endif /* HAVE_HELPERS */
515 {
516 e = event_create(EVENT_READ_FLOW, spool_id, sound_size);
517 event_insert(c, e);
516518 }
517519
518520 return 0;
520522 else
521523 {
522524 /* strip pathnames -- files can only be put in the cache directory */
523 p = strrchr (sound_name, '/');
525 p = strrchr(sound_name, '/');
524526 if (p)
525527 {
526528 sound_name = p + 1;
527529 }
528 name = cache_name (sound_name);
529
530 s = sound_lookup (name, SOUND_DONT_FIND, NULL);
530 name = cache_name(sound_name);
531
532 s = sound_lookup(name, SOUND_DONT_FIND, NULL);
531533 if (s != NULL)
532534 {
533 connection_reply (c, "%cerror=\"%s already is in the cache\" command=put client-data=\"%s\"",
534 RPTP_ERROR, sound_name, client_data);
535 connection_reply(c, "%cerror=\"%s already is in the cache\" command=put client-data=\"%s\"",
536 RPTP_ERROR, sound_name, client_data);
535537 return 0;
536538 }
537539
538 if (cache_free (sound_size) < 0)
539 {
540 connection_reply (c, "%cerror=\"the cache is full\" command=put client-data=\"%s\"",
541 RPTP_ERROR, client_data);
540 if (cache_free(sound_size) < 0)
541 {
542 connection_reply(c, "%cerror=\"the cache is full\" command=put client-data=\"%s\"",
543 RPTP_ERROR, client_data);
542544 }
543545 else
544546 {
545 fd = cache_create (name, sound_size);
547 fd = cache_create(name, sound_size);
546548 if (fd < 0)
547549 {
548 connection_reply (c, "%cerror=\"cache error\" command=put client-data=\"%s\"",
549 RPTP_ERROR, client_data);
550 connection_reply(c, "%cerror=\"cache error\" command=put client-data=\"%s\"",
551 RPTP_ERROR, client_data);
550552 }
551553 else
552554 {
553 report (REPORT_NOTICE, "%s put %s %d\n",
554 inet_ntoa (c->sin.sin_addr), sound_name, sound_size);
555 s = sound_insert (name, SOUND_NOT_READY, SOUND_FILE);
555 report(REPORT_NOTICE, "%s put %s %d\n",
556 inet_ntoa(c->sin.sin_addr), sound_name, sound_size);
557 s = sound_insert(name, SOUND_NOT_READY, SOUND_FILE);
556558 if (old_style)
557559 {
558 connection_reply (c, "%c%s %d", RPTP_OK, sound_name, sound_size);
560 connection_reply(c, "%c%s %d", RPTP_OK, sound_name, sound_size);
559561 }
560562 else
561563 {
562 connection_reply (c, "%csound=\"%s\" size=%d command=put client-data=\"%s\"",
563 RPTP_OK, sound_name, sound_size, client_data);
564 connection_reply(c, "%csound=\"%s\" size=%d command=put client-data=\"%s\"",
565 RPTP_OK, sound_name, sound_size, client_data);
564566 }
565 e = event_create (EVENT_READ_SOUND, fd, buffer_create (), sound_size, s);
566 event_insert (c, e);
567 }
568 }
569
567 e = event_create(EVENT_READ_SOUND, fd, buffer_create(), sound_size, s);
568 event_insert(c, e);
569 }
570 }
571
570572 return 0;
571573 }
572574 }
573575
574576 #ifdef __STDC__
575577 static int
576 command_list (CONNECTION *c, int argc, char **argv)
577 #else
578 static int
579 command_list (c, argc, argv)
578 command_list(CONNECTION *c, int argc, char **argv)
579 #else
580 static int
581 command_list(c, argc, argv)
580582 CONNECTION *c;
581583 int argc;
582584 char **argv;
585587 EVENT *e;
586588 char *client_data = default_client_data;
587589 BUFFER *b;
588
589 if (strchr (command_buffer, '='))
590 {
591 client_data = rptp_parse (command_buffer, "client-data");
590
591 if (strchr(command_buffer, '='))
592 {
593 client_data = rptp_parse(command_buffer, "client-data");
592594 if (!client_data)
593595 {
594596 client_data = default_client_data;
595597 }
596598 }
597599
598 if (argv[1] == NULL || strcmp (argv[1], "sounds") == 0)
599 {
600 b = sound_list_create ();
600 if (argv[1] == NULL || strcmp(argv[1], "sounds") == 0)
601 {
602 b = sound_list_create();
601603 if (b)
602604 {
603 e = event_create (EVENT_WRITE, b);
604 event_insert (c, e);
605 e = event_create(EVENT_WRITE, b);
606 event_insert(c, e);
605607 }
606608 else
607609 {
608 connection_reply (c, "%cerror=\"no sounds available\" command=list client-data=\"%s\"",
609 RPTP_ERROR, client_data);
610 }
611 }
612 else if (strcmp (argv[1], "connections") == 0)
613 {
614 b = connection_list_create ();
610 connection_reply(c, "%cerror=\"no sounds available\" command=list client-data=\"%s\"",
611 RPTP_ERROR, client_data);
612 }
613 }
614 else if (strcmp(argv[1], "connections") == 0)
615 {
616 b = connection_list_create();
615617 if (b)
616618 {
617 e = event_create (EVENT_WRITE, b);
618 event_insert (c, e);
619 e = event_create(EVENT_WRITE, b);
620 event_insert(c, e);
619621 }
620622 else
621623 {
622 connection_reply (c, "%cerror=\"no connections available\" command=list client-data=\"%s\"",
623 RPTP_ERROR, client_data);
624 }
625 }
626 else if (strcmp (argv[1], "servers") == 0)
624 connection_reply(c, "%cerror=\"no connections available\" command=list client-data=\"%s\"",
625 RPTP_ERROR, client_data);
626 }
627 }
628 else if (strcmp(argv[1], "servers") == 0)
627629 {
628630 if (server_list)
629631 {
630 e = event_create (EVENT_WRITE, server_list);
631 event_insert (c, e);
632 e = event_create(EVENT_WRITE, server_list);
633 event_insert(c, e);
632634 }
633635 else
634636 {
635 connection_reply (c, "%cerror=\"no servers available\" command=list client-data=\"%s\"",
636 RPTP_ERROR, client_data);
637 }
638 }
639 else if (strcmp (argv[1], "spool") == 0)
640 {
641 b = spool_list_create ();
637 connection_reply(c, "%cerror=\"no servers available\" command=list client-data=\"%s\"",
638 RPTP_ERROR, client_data);
639 }
640 }
641 else if (strcmp(argv[1], "spool") == 0)
642 {
643 b = spool_list_create();
642644 if (b)
643645 {
644 e = event_create (EVENT_WRITE, b);
645 event_insert (c, e);
646 e = event_create(EVENT_WRITE, b);
647 event_insert(c, e);
646648 }
647649 else
648650 {
649 connection_reply (c, "%cerror=\"no spool available\" command=list client-data=\"%s\"",
650 RPTP_ERROR, client_data);
651 connection_reply(c, "%cerror=\"no spool available\" command=list client-data=\"%s\"",
652 RPTP_ERROR, client_data);
651653 }
652654 }
653655 #ifdef AUTH
654 else if (strcmp (argv[1], "hosts") == 0)
656 else if (strcmp(argv[1], "hosts") == 0)
655657 {
656658 b = host_list;
657659 if (b)
658660 {
659 e = event_create (EVENT_WRITE, b);
660 event_insert (c, e);
661 e = event_create(EVENT_WRITE, b);
662 event_insert(c, e);
661663 }
662664 else
663665 {
664 connection_reply (c, "%cerror=\"no hosts available\" command=list client-data=\"%s\"",
665 RPTP_ERROR, client_data);
666 connection_reply(c, "%cerror=\"no hosts available\" command=list client-data=\"%s\"",
667 RPTP_ERROR, client_data);
666668 }
667669 }
668670 #endif /* AUTH */
669671 else
670672 {
671 connection_reply (c, "%cerror=\"cannot list `%s'\" command=list client-data=\"%s\"",
672 RPTP_ERROR, argv[1], client_data);
673 connection_reply(c, "%cerror=\"cannot list `%s'\" command=list client-data=\"%s\"",
674 RPTP_ERROR, argv[1], client_data);
673675 }
674676
675677 return 0;
677679
678680 #ifdef __STDC__
679681 static int
680 command_find (CONNECTION *c, int argc, char **argv)
681 #else
682 static int
683 command_find (c, argc, argv)
682 command_find(CONNECTION *c, int argc, char **argv)
683 #else
684 static int
685 command_find(c, argc, argv)
684686 CONNECTION *c;
685687 int argc;
686688 char **argv;
690692 char *sound_name = NULL;
691693 int old_style = 0;
692694 char *client_data = default_client_data;
693
694 if (strchr (command_buffer, '='))
695 {
696 sound_name = rptp_parse (command_buffer, "sound");
697 client_data = rptp_parse (0, "client-data");
695
696 if (strchr(command_buffer, '='))
697 {
698 sound_name = rptp_parse(command_buffer, "sound");
699 client_data = rptp_parse(0, "client-data");
698700 if (!client_data)
699701 {
700702 client_data = default_client_data;
706708 old_style++;
707709 }
708710
709 s = sound_lookup (sound_name, SOUND_DONT_FIND, NULL);
711 s = sound_lookup(sound_name, SOUND_DONT_FIND, NULL);
710712 if (s == NULL || s->status != SOUND_READY)
711713 {
712 report (REPORT_NOTICE, "%s find %s - not found\n",
713 inet_ntoa (c->sin.sin_addr), sound_name);
714 connection_reply (c, "%cerror=\"%s not found\" command=find client-data=\"%s\"",
715 RPTP_ERROR, sound_name, client_data);
714 report(REPORT_NOTICE, "%s find %s - not found\n",
715 inet_ntoa(c->sin.sin_addr), sound_name);
716 connection_reply(c, "%cerror=\"%s not found\" command=find client-data=\"%s\"",
717 RPTP_ERROR, sound_name, client_data);
716718 }
717719 else
718720 {
719 report (REPORT_NOTICE, "%s find %s %d\n",
720 inet_ntoa (c->sin.sin_addr), sound_name, s->size);
721 report(REPORT_NOTICE, "%s find %s %d\n",
722 inet_ntoa(c->sin.sin_addr), sound_name, s->size);
721723 if (old_style)
722724 {
723 connection_reply (c, "%c%s %d", RPTP_OK, s->name, s->size);
725 connection_reply(c, "%c%s %d", RPTP_OK, s->name, s->size);
724726 }
725727 else
726728 {
727 connection_reply (c, "%csound=\"%s\" size=%d command=find client-data=\"%s\"",
728 RPTP_OK, s->name, s->size, client_data);
729 connection_reply(c, "%csound=\"%s\" size=%d command=find client-data=\"%s\"",
730 RPTP_OK, s->name, s->size, client_data);
729731 }
730732 }
731733
734736
735737 #ifdef __STDC__
736738 static int
737 command_access (CONNECTION *c, int argc, char **argv)
738 #else
739 static int
740 command_access (c, argc, argv)
739 command_access(CONNECTION *c, int argc, char **argv)
740 #else
741 static int
742 command_access(c, argc, argv)
741743 CONNECTION *c;
742744 int argc;
743745 char **argv;
745747 {
746748 char buf[4];
747749 char *client_data = default_client_data;
748
749 if (strchr (command_buffer, '='))
750 {
751 client_data = rptp_parse (command_buffer, "client-data");
750
751 if (strchr(command_buffer, '='))
752 {
753 client_data = rptp_parse(command_buffer, "client-data");
752754 if (!client_data)
753755 {
754756 client_data = default_client_data;
755757 }
756758 }
757
759
758760 buf[0] = '\0';
759761 #ifdef AUTH
760 if (host_access (c->sin, HOST_READ))
761 {
762 strcat (buf, "r");
763 }
764 if (host_access (c->sin, HOST_WRITE))
765 {
766 strcat (buf, "w");
767 }
768 if (host_access (c->sin, HOST_EXECUTE))
769 {
770 strcat (buf, "x");
762 if (host_access(c->sin, HOST_READ))
763 {
764 strcat(buf, "r");
765 }
766 if (host_access(c->sin, HOST_WRITE))
767 {
768 strcat(buf, "w");
769 }
770 if (host_access(c->sin, HOST_EXECUTE))
771 {
772 strcat(buf, "x");
771773 }
772774 #else /* AUTH */
773 strcat (buf, "rwx");
775 strcat(buf, "rwx");
774776 #endif /* AUTH */
775777
776 connection_reply (c, "%caccess=%s command=access client-data=\"%s\"",
777 RPTP_OK, buf, client_data);
778 connection_reply(c, "%caccess=%s command=access client-data=\"%s\"",
779 RPTP_OK, buf, client_data);
778780
779781 return 0;
780782 }
781783
782784 #ifdef __STDC__
783785 static int
784 command_execute (CONNECTION *c, int argc, char **argv)
785 #else
786 static int
787 command_execute (c, argc, argv)
786 command_execute(CONNECTION *c, int argc, char **argv)
787 #else
788 static int
789 command_execute(c, argc, argv)
788790 CONNECTION *c;
789791 int argc;
790792 char **argv;
791793 #endif
792794 {
793795 SPOOL *sp;
794 int id = do_execute (c, argc, argv);
796 int id = do_execute(c, argc, argv);
795797
796798 if (id > 0)
797799 {
798 sp = spool_find (id);
799 connection_reply (c, "%cid=#%d sound=\"%s\" command=%s client-data=\"%s\" list-name=\"%s\"",
800 RPTP_OK, id,
801 sp->curr_attrs->sound,
802 argv[0],
803 sp->curr_attrs->client_data,
804 sp->rp->list_name);
800 sp = spool_find(id);
801 connection_reply(c, "%cid=#%d sound=\"%s\" command=%s client-data=\"%s\" list-name=\"%s\"",
802 RPTP_OK, id,
803 sp->curr_attrs->sound,
804 argv[0],
805 sp->curr_attrs->client_data,
806 sp->rp->list_name);
805807 }
806808
807809 return 0;
813815 */
814816 #ifdef __STDC__
815817 static int
816 do_execute (CONNECTION *c, int argc, char **argv)
817 #else
818 static int
819 do_execute (c, argc, argv)
818 do_execute(CONNECTION *c, int argc, char **argv)
819 #else
820 static int
821 do_execute(c, argc, argv)
820822 CONNECTION *c;
821823 int argc;
822824 char **argv;
827829 RPLAY *rp;
828830 int volume, list_count, count, priority, sample_rate;
829831 int do_random = 0;
830 int do_search = 1; /* search by default */
832 int do_search = 1; /* search by default */
831833 int input = SOUND_FILE;
832834 int input_offset = 0;
833835 int input_format = 0;
835837 int input_sample_rate = 0;
836838 float input_precision = 0;
837839 int input_channels = 0;
838 int input_storage = SOUND_STORAGE_NONE; /* Don't store flows by default. */
840 int input_storage = SOUND_STORAGE_NONE; /* Don't store flows by default. */
839841 char *client_data = default_client_data;
840842 char *list_name = NULL;
841
842 if (strcmp (argv[0], "play") == 0)
843
844 if (strcmp(argv[0], "play") == 0)
843845 {
844846 command = RPLAY_PLAY;
845847 }
846 else if (strcmp (argv[0], "stop") == 0)
848 else if (strcmp(argv[0], "stop") == 0)
847849 {
848850 command = RPLAY_STOP;
849851 }
850 else if (strcmp (argv[0], "pause") == 0)
852 else if (strcmp(argv[0], "pause") == 0)
851853 {
852854 command = RPLAY_PAUSE;
853855 }
854 else if (strcmp (argv[0], "continue") == 0)
856 else if (strcmp(argv[0], "continue") == 0)
855857 {
856858 command = RPLAY_CONTINUE;
857859 }
858 else if (strcmp (argv[0], "done") == 0)
860 else if (strcmp(argv[0], "done") == 0)
859861 {
860862 command = RPLAY_DONE;
861863 }
862864
863 if (strchr (command_buffer, '='))
864 {
865 client_data = rptp_parse (command_buffer, "client-data");
865 if (strchr(command_buffer, '='))
866 {
867 client_data = rptp_parse(command_buffer, "client-data");
866868 if (!client_data)
867869 {
868870 client_data = default_client_data;
872874 {
873875 old_style++;
874876 }
875
877
876878 #ifdef AUTH
877 if (!host_access (c->sin, HOST_EXECUTE))
878 {
879 report (REPORT_NOTICE, "%s %s access denied\n", argv[0],
880 inet_ntoa (c->sin.sin_addr));
881 connection_reply (c, "%cerror=\"access denied\" command=%s client-data=\"%s\"",
882 RPTP_ERROR, argv[0], client_data);
879 if (!host_access(c->sin, HOST_EXECUTE))
880 {
881 report(REPORT_NOTICE, "%s %s access denied\n", argv[0],
882 inet_ntoa(c->sin.sin_addr));
883 connection_reply(c, "%cerror=\"access denied\" command=%s client-data=\"%s\"",
884 RPTP_ERROR, argv[0], client_data);
883885 return -1;
884886 }
885887 #endif /* AUTH */
886888
887 rp = rplay_create (command);
889 rp = rplay_create(command);
888890 if (rp == NULL)
889891 {
890 connection_reply (c, "%cerror=\"%s failed\" command=%s client_data=\"%s\"",
891 RPTP_ERROR, argv[0], argv[0], client_data);
892 connection_reply(c, "%cerror=\"%s failed\" command=%s client_data=\"%s\"",
893 RPTP_ERROR, argv[0], argv[0], client_data);
892894 return -1;
893895 }
894896
902904 {
903905 char *name, *value;
904906
905 rptp_parse (command_buffer, 0);
906 while (name = rptp_parse (0, 0))
907 {
908 value = rptp_parse (0, name);
907 rptp_parse(command_buffer, 0);
908 while (name = rptp_parse(0, 0))
909 {
910 value = rptp_parse(0, name);
909911
910912 if (!value || !*value)
911913 {
912914 continue;
913915 }
914 else if (strcmp (name, "sound") == 0
915 || (command != RPLAY_PLAY && strcmp (name, "id") == 0))
916 {
917 val = rplay_set (rp, RPLAY_APPEND,
918 RPLAY_SOUND, value,
919 RPLAY_VOLUME, volume,
920 RPLAY_COUNT, count,
921 RPLAY_SAMPLE_RATE, sample_rate,
922 RPLAY_RPTP_SEARCH, do_search,
923 RPLAY_CLIENT_DATA, client_data,
924 NULL);
916 else if (strcmp(name, "sound") == 0
917 || (command != RPLAY_PLAY && strcmp(name, "id") == 0))
918 {
919 val = rplay_set(rp, RPLAY_APPEND,
920 RPLAY_SOUND, value,
921 RPLAY_VOLUME, volume,
922 RPLAY_COUNT, count,
923 RPLAY_SAMPLE_RATE, sample_rate,
924 RPLAY_RPTP_SEARCH, do_search,
925 RPLAY_CLIENT_DATA, client_data,
926 NULL);
925927 if (val < 0)
926928 {
927 connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
928 RPTP_ERROR, argv[0], argv[0], client_data);
929 connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
930 RPTP_ERROR, argv[0], argv[0], client_data);
929931 return -1;
930932 }
931933 }
932 else if (strcmp (name, "client-data") == 0)
934 else if (strcmp(name, "client-data") == 0)
933935 {
934936 client_data = value;
935937 }
936 else if (strcmp (name, "volume") == 0)
937 {
938 volume = atoi (value);
939 }
940 else if (strcmp (name, "count") == 0)
941 {
942 count = atoi (value);
943 }
944 else if (strcmp (name, "list-count") == 0)
945 {
946 list_count = atoi (value);
947 }
948 else if (strcmp (name, "priority") == 0)
949 {
950 priority = atoi (value);
951 }
952 else if (strcmp (name, "sample-rate") == 0)
953 {
954 sample_rate = atoi (value);
955 }
956 else if (strcmp (name, "search") == 0
957 || strcmp (name, "rptp-search") == 0)
958 {
959 do_search = is_true (value);
960 }
961 else if (strcmp (name, "random") == 0)
962 {
963 do_random = is_true (value);
964 }
965 else if (strcmp (name, "list-name") == 0)
938 else if (strcmp(name, "volume") == 0)
939 {
940 volume = atoi(value);
941 }
942 else if (strcmp(name, "count") == 0)
943 {
944 count = atoi(value);
945 }
946 else if (strcmp(name, "list-count") == 0)
947 {
948 list_count = atoi(value);
949 }
950 else if (strcmp(name, "priority") == 0)
951 {
952 priority = atoi(value);
953 }
954 else if (strcmp(name, "sample-rate") == 0)
955 {
956 sample_rate = atoi(value);
957 }
958 else if (strcmp(name, "search") == 0
959 || strcmp(name, "rptp-search") == 0)
960 {
961 do_search = is_true(value);
962 }
963 else if (strcmp(name, "random") == 0)
964 {
965 do_random = is_true(value);
966 }
967 else if (strcmp(name, "list-name") == 0)
966968 {
967969 list_name = value;
968970 }
969 else if (strcmp (name, "input") == 0)
970 {
971 input = string_to_input (value);
972 }
973 else if (strcmp (name, "input-offset") == 0)
974 {
975 input_offset = atoi (value);
976 }
977 else if (strcmp (name, "input-format") == 0)
978 {
979 input_format = string_to_audio_format (value);
980 }
981 else if (strcmp (name, "input-byte-order") == 0)
982 {
983 input_byte_order = string_to_byte_order (value);
984 }
985 else if (strcmp (name, "input-sample-rate") == 0)
986 {
987 input_sample_rate = atoi (value);
988 }
989 else if (strcmp (name, "input-bits") == 0)
990 {
991 input_precision = atof (value);
992 }
993 else if (strcmp (name, "input-channels") == 0)
994 {
995 input_channels = atoi (value);
996 }
997 else if (strcmp (name, "input-storage") == 0)
998 {
999 input_storage = string_to_storage (value);
1000 }
1001 }
1002 }
1003 else /* old-style */
971 else if (strcmp(name, "input") == 0)
972 {
973 input = string_to_input(value);
974 }
975 else if (strcmp(name, "input-offset") == 0)
976 {
977 input_offset = atoi(value);
978 }
979 else if (strcmp(name, "input-format") == 0)
980 {
981 input_format = string_to_audio_format(value);
982 }
983 else if (strcmp(name, "input-byte-order") == 0)
984 {
985 input_byte_order = string_to_byte_order(value);
986 }
987 else if (strcmp(name, "input-sample-rate") == 0)
988 {
989 input_sample_rate = atoi(value);
990 }
991 else if (strcmp(name, "input-bits") == 0)
992 {
993 input_precision = atof(value);
994 }
995 else if (strcmp(name, "input-channels") == 0)
996 {
997 input_channels = atoi(value);
998 }
999 else if (strcmp(name, "input-storage") == 0)
1000 {
1001 input_storage = string_to_storage(value);
1002 }
1003 else if (strcmp(name, "input-info") == 0)
1004 {
1005 char *p = strtok(value, ",");
1006 if (p) input_format = string_to_audio_format(p);
1007
1008 p = strtok(NULL, ",");
1009 if (p) input_sample_rate = atoi(p);
1010
1011 p = strtok(NULL, ",");
1012 if (p) input_precision = atoi(p);
1013
1014 p = strtok(NULL, ",");
1015 if (p) input_channels = atoi(p);
1016
1017 p = strtok(NULL, ",");
1018 if (p) input_byte_order = string_to_byte_order(p);
1019
1020 p = strtok(NULL, ",");
1021 if (p) input_offset = atoi(p);
1022 }
1023 }
1024 }
1025 else
1026 /* old-style */
10041027 {
10051028 extern char *optarg;
10061029 extern int optind;
10071030
10081031 optind = 0;
1009 while ((n = getopt (argc, argv, "+P:R:N:n:v:")) != -1)
1032 while ((n = getopt(argc, argv, "+P:R:N:n:v:")) != -1)
10101033 {
10111034 switch (n)
10121035 {
10131036 case 'v':
1014 volume = atoi (optarg);
1037 volume = atoi(optarg);
10151038 break;
10161039
10171040 case 'n':
1018 count = atoi (optarg);
1041 count = atoi(optarg);
10191042 break;
10201043
10211044 case 'N':
1022 list_count = atoi (optarg);
1045 list_count = atoi(optarg);
10231046 break;
10241047
10251048 case 'P':
1026 priority = atoi (optarg);
1049 priority = atoi(optarg);
10271050 break;
10281051
10291052 case 'R':
1030 sample_rate = atoi (optarg);
1053 sample_rate = atoi(optarg);
10311054 break;
10321055
10331056 default:
10401063 {
10411064 for (i = 0; i < NCOMMANDS; i++)
10421065 {
1043 if (strcmp (commands[i].name, argv[0]) == 0)
1066 if (strcmp(commands[i].name, argv[0]) == 0)
10441067 {
1045 connection_reply (c, "%cerror=\"usage: %s %s\" command=%s",
1046 RPTP_ERROR, commands[i].name, commands[i].usage,
1047 argv[0]);
1068 connection_reply(c, "%cerror=\"usage: %s %s\" command=%s",
1069 RPTP_ERROR, commands[i].name, commands[i].usage,
1070 argv[0]);
10481071 return -1;
10491072 }
10501073 }
10521075
10531076 while (argv[optind] != NULL)
10541077 {
1055 val = rplay_set (rp, RPLAY_APPEND,
1056 RPLAY_SOUND, argv[optind++],
1057 RPLAY_VOLUME, volume,
1058 RPLAY_COUNT, count,
1059 RPLAY_SAMPLE_RATE, sample_rate,
1060 RPLAY_RPTP_SEARCH, do_search,
1061 NULL);
1078 val = rplay_set(rp, RPLAY_APPEND,
1079 RPLAY_SOUND, argv[optind++],
1080 RPLAY_VOLUME, volume,
1081 RPLAY_COUNT, count,
1082 RPLAY_SAMPLE_RATE, sample_rate,
1083 RPLAY_RPTP_SEARCH, do_search,
1084 NULL);
10621085 if (val < 0)
10631086 {
1064 connection_reply (c, "%cerror=\"%s failed\" command=%s",
1065 RPTP_ERROR, argv[0], argv[0]);
1087 connection_reply(c, "%cerror=\"%s failed\" command=%s",
1088 RPTP_ERROR, argv[0], argv[0]);
10661089 return -1;
10671090 }
10681091 }
10691092 }
10701093
1071 if (rplay_set (rp, RPLAY_LIST_COUNT, list_count, NULL) < 0)
1072 {
1073 connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1074 RPTP_ERROR, argv[0], argv[0], client_data);
1094 if (rplay_set(rp, RPLAY_LIST_COUNT, list_count, NULL) < 0)
1095 {
1096 connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1097 RPTP_ERROR, argv[0], argv[0], client_data);
10751098 return -1;
10761099 }
10771100
1078 if (rplay_set (rp, RPLAY_PRIORITY, priority, NULL) < 0)
1079 {
1080 connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1081 RPTP_ERROR, argv[0], argv[0], client_data);
1101 if (rplay_set(rp, RPLAY_PRIORITY, priority, NULL) < 0)
1102 {
1103 connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1104 RPTP_ERROR, argv[0], argv[0], client_data);
10821105 return -1;
10831106 }
10841107
1085 if (do_random && rplay_set (rp, RPLAY_RANDOM_SOUND, NULL) < 0)
1086 {
1087 connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1088 RPTP_ERROR, argv[0], argv[0], client_data);
1108 if (do_random && rplay_set(rp, RPLAY_RANDOM_SOUND, NULL) < 0)
1109 {
1110 connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1111 RPTP_ERROR, argv[0], argv[0], client_data);
10891112 return -1;
10901113 }
10911114
1092 if (list_name && rplay_set (rp, RPLAY_LIST_NAME, list_name, NULL) < 0)
1093 {
1094 connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1095 RPTP_ERROR, argv[0], argv[0], client_data);
1115 if (list_name && rplay_set(rp, RPLAY_LIST_NAME, list_name, NULL) < 0)
1116 {
1117 connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1118 RPTP_ERROR, argv[0], argv[0], client_data);
10961119 return -1;
10971120 }
1098
1121
10991122 /* Flows */
11001123 if (input == SOUND_FLOW && command == RPLAY_PLAY)
11011124 {
11061129 #ifdef AUTH
11071130 /* Flows require `write' access along with the previously
11081131 checked `execute' access. */
1109 if (!host_access (c->sin, HOST_WRITE))
1110 {
1111 report (REPORT_NOTICE, "%s %s access denied\n", argv[0],
1112 inet_ntoa (c->sin.sin_addr));
1113 connection_reply (c, "%cerror=\"access denied\" command=%s client-data=\"%s\"",
1114 RPTP_ERROR, argv[0], client_data);
1132 if (!host_access(c->sin, HOST_WRITE))
1133 {
1134 report(REPORT_NOTICE, "%s %s access denied\n", argv[0],
1135 inet_ntoa(c->sin.sin_addr));
1136 connection_reply(c, "%cerror=\"access denied\" command=%s client-data=\"%s\"",
1137 RPTP_ERROR, argv[0], client_data);
11151138 return -1;
11161139 }
11171140 #endif /* AUTH */
1118
1141
11191142 /* Generate a unique sound name. */
1120 sound_name = (char *) rplay_get (rp, RPLAY_SOUND, 0);
1143 sound_name = (char *) rplay_get(rp, RPLAY_SOUND, 0);
11211144 if (!sound_name)
11221145 {
1123 connection_reply (c, "%cerror=\"missing required `sound' attribute\" command=%s client-data=\"%s\"",
1124 RPTP_ERROR, argv[0], client_data);
1146 connection_reply(c, "%cerror=\"missing required `sound' attribute\" command=%s client-data=\"%s\"",
1147 RPTP_ERROR, argv[0], client_data);
11251148 return -1;
11261149 }
1127 p = strrchr (sound_name, '/');
1150 p = strrchr(sound_name, '/');
11281151 if (p)
11291152 {
11301153 sound_name = p + 1;
11341157 {
11351158 if (i)
11361159 {
1137 SNPRINTF (SIZE(buf,sizeof(buf)), "rplay%d-%s", i, sound_name);
1160 SNPRINTF(SIZE(buf, sizeof(buf)), "rplay%d-%s", i, sound_name);
11381161 }
11391162 else
11401163 {
1141 SNPRINTF (SIZE(buf,sizeof(buf)), sound_name);
1164 SNPRINTF(SIZE(buf, sizeof(buf)), sound_name);
11421165 }
11431166 i++;
11441167 }
1145 while (sound_lookup (buf, SOUND_DONT_FIND, NULL));
1146
1147 sound_name = cache_name (buf);
1148 rplay_set (rp, RPLAY_CHANGE, 0,
1149 RPLAY_SOUND, sound_name,
1150 RPLAY_RPTP_SEARCH, FALSE, /* never search */
1151 NULL);
1152 s = sound_insert (sound_name, SOUND_NOT_READY, SOUND_FLOW);
1168 while (sound_lookup(buf, SOUND_DONT_FIND, NULL));
1169
1170 sound_name = cache_name(buf);
1171 rplay_set(rp, RPLAY_CHANGE, 0,
1172 RPLAY_SOUND, sound_name,
1173 RPLAY_RPTP_SEARCH, FALSE, /* never search */
1174 NULL);
1175 s = sound_insert(sound_name, SOUND_NOT_READY, SOUND_FLOW);
11531176 if (!s)
11541177 {
1155 connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1156 RPTP_ERROR, argv[0], argv[0], client_data);
1178 connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1179 RPTP_ERROR, argv[0], argv[0], client_data);
11571180 return -1;
11581181 }
11591182
11671190 s->storage = input_storage;
11681191
11691192 /* Grab a spool entry. */
1170 spool_id = rplayd_play (rp, c->sin);
1193 spool_id = rplayd_play(rp, c->sin);
11711194 if (spool_id < 0)
11721195 {
1173 connection_reply (c, "%cerror=\"spool full\" command=%s client-data=\"%s\"",
1174 RPTP_ERROR, argv[0], client_data);
1175 sound_delete (s, 0);
1196 connection_reply(c, "%cerror=\"spool full\" command=%s client-data=\"%s\"",
1197 RPTP_ERROR, argv[0], client_data);
1198 sound_delete(s, 0);
11761199 return -1;
11771200 }
11781201
1179 connection_reply (c, "%cid=#%d sound=\"%s\" command=%s client-data=\"%s\"",
1180 RPTP_OK, spool_id, buf, argv[0], client_data);
1181
1202 connection_reply(c, "%cid=#%d sound=\"%s\" command=%s client-data=\"%s\"",
1203 RPTP_OK, spool_id, buf, argv[0], client_data);
1204
11821205 return 0;
11831206 }
11841207 else
11861209 switch (command)
11871210 {
11881211 case RPLAY_PLAY:
1189 val = rplayd_play (rp, c->sin);
1212 val = rplayd_play(rp, c->sin);
11901213 break;
11911214
11921215 case RPLAY_STOP:
1193 val = rplayd_stop (rp, c->sin);
1216 val = rplayd_stop(rp, c->sin);
11941217 break;
11951218
11961219 case RPLAY_PAUSE:
1197 val = rplayd_pause (rp, c->sin);
1220 val = rplayd_pause(rp, c->sin);
11981221 break;
11991222
12001223 case RPLAY_CONTINUE:
1201 val = rplayd_continue (rp, c->sin);
1224 val = rplayd_continue(rp, c->sin);
12021225 break;
12031226
12041227 case RPLAY_DONE:
1205 val = rplayd_done (rp, c->sin);
1228 val = rplayd_done(rp, c->sin);
12061229 break;
12071230 }
12081231
12091232 if (val == 0)
12101233 {
1211 connection_reply (c, "%cmessage=\"%s successful\" command=%s client-data=\"%s\"",
1212 RPTP_OK, argv[0], argv[0], client_data);
1234 connection_reply(c, "%cmessage=\"%s successful\" command=%s client-data=\"%s\"",
1235 RPTP_OK, argv[0], argv[0], client_data);
12131236 }
12141237 else if (val < 0)
12151238 {
1216 connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1217 RPTP_ERROR, argv[0], argv[0], client_data);
1239 connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"",
1240 RPTP_ERROR, argv[0], argv[0], client_data);
12181241 }
12191242
12201243 return val;
12241247 /* OBSOLETE */
12251248 #ifdef __STDC__
12261249 static int
1227 command_volume (CONNECTION *c, int argc, char **argv)
1228 #else
1229 static int
1230 command_volume (c, argc, argv)
1250 command_volume(CONNECTION *c, int argc, char **argv)
1251 #else
1252 static int
1253 command_volume(c, argc, argv)
12311254 CONNECTION *c;
12321255 int argc;
12331256 char **argv;
12371260 int n;
12381261
12391262 #ifdef AUTH
1240 if (!host_access (c->sin, HOST_EXECUTE))
1241 {
1242 report (REPORT_NOTICE, "%s volume access denied\n",
1243 inet_ntoa (c->sin.sin_addr));
1244 connection_reply (c, "%cerror=\"access denied\" command=volume", RPTP_ERROR);
1263 if (!host_access(c->sin, HOST_EXECUTE))
1264 {
1265 report(REPORT_NOTICE, "%s volume access denied\n",
1266 inet_ntoa(c->sin.sin_addr));
1267 connection_reply(c, "%cerror=\"access denied\" command=volume", RPTP_ERROR);
12451268 return 0;
12461269 }
12471270 #endif /* AUTH */
12481271
12491272 if (argv[1] == NULL)
12501273 {
1251 volume = rplay_audio_get_volume ();
1274 volume = rplay_audio_get_volume();
12521275 if (volume >= 0)
12531276 {
1254 connection_reply (c, "%c%d", RPTP_OK, volume);
1277 connection_reply(c, "%c%d", RPTP_OK, volume);
12551278 }
12561279 else
12571280 {
1258 connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
1281 connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
12591282 }
12601283 }
12611284 else if (*argv[1] == '+')
12621285 {
1263 volume = rplay_audio_get_volume ();
1286 volume = rplay_audio_get_volume();
12641287 if (volume < 0)
12651288 {
1266 connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
1267 }
1268
1269 volume += atoi (argv[1] + 1);
1270 n = rplay_audio_set_volume (volume);
1289 connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
1290 }
1291
1292 volume += atoi(argv[1] + 1);
1293 n = rplay_audio_set_volume(volume);
12711294 if (n >= 0)
12721295 {
1273 connection_reply (c, "%c%d", RPTP_OK, n);
1274 connection_notify (0, NOTIFY_VOLUME, n);
1296 connection_reply(c, "%c%d", RPTP_OK, n);
1297 connection_notify(0, NOTIFY_VOLUME, n);
12751298 }
12761299 else
12771300 {
1278 connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
1301 connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
12791302 }
12801303 }
12811304 else if (*argv[1] == '-')
12821305 {
1283 volume = rplay_audio_get_volume ();
1306 volume = rplay_audio_get_volume();
12841307 if (volume < 0)
12851308 {
1286 connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
1287 }
1288
1289 volume -= atoi (argv[1] + 1);
1290 n = rplay_audio_set_volume (volume);
1309 connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
1310 }
1311
1312 volume -= atoi(argv[1] + 1);
1313 n = rplay_audio_set_volume(volume);
12911314 if (n >= 0)
12921315 {
1293 connection_reply (c, "%c%d", RPTP_OK, n);
1294 connection_notify (0, NOTIFY_VOLUME, n);
1316 connection_reply(c, "%c%d", RPTP_OK, n);
1317 connection_notify(0, NOTIFY_VOLUME, n);
12951318 }
12961319 else
12971320 {
1298 connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
1321 connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
12991322 }
13001323 }
13011324 else
13021325 {
1303 volume = atoi (argv[1]);
1304 n = rplay_audio_set_volume (volume);
1326 volume = atoi(argv[1]);
1327 n = rplay_audio_set_volume(volume);
13051328 if (n >= 0)
13061329 {
1307 connection_reply (c, "%c%d", RPTP_OK, n);
1308 connection_notify (0, NOTIFY_VOLUME, n);
1330 connection_reply(c, "%c%d", RPTP_OK, n);
1331 connection_notify(0, NOTIFY_VOLUME, n);
13091332 }
13101333 else
13111334 {
1312 connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
1335 connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR);
13131336 }
13141337 }
13151338
13181341
13191342 #ifdef __STDC__
13201343 static int
1321 command_info (CONNECTION *c, int argc, char **argv)
1322 #else
1323 static int
1324 command_info (c, argc, argv)
1344 command_info(CONNECTION *c, int argc, char **argv)
1345 #else
1346 static int
1347 command_info(c, argc, argv)
13251348 CONNECTION *c;
13261349 int argc;
13271350 char **argv;
13301353 SOUND *s;
13311354 char *sound_name = NULL;
13321355 char *client_data = default_client_data;
1333
1356
13341357 #ifdef AUTH
1335 if (!host_access (c->sin, HOST_READ))
1336 {
1337 report (REPORT_NOTICE, "%s info %s - read access denied\n",
1338 inet_ntoa (c->sin.sin_addr), argv[1]);
1339 connection_reply (c, "%cerror=\"access denied\" command=info client-data=\"%s\"",
1340 RPTP_ERROR, client_data);
1358 if (!host_access(c->sin, HOST_READ))
1359 {
1360 report(REPORT_NOTICE, "%s info %s - read access denied\n",
1361 inet_ntoa(c->sin.sin_addr), argv[1]);
1362 connection_reply(c, "%cerror=\"access denied\" command=info client-data=\"%s\"",
1363 RPTP_ERROR, client_data);
13411364 return 0;
13421365 }
13431366 #endif /* AUTH */
13441367
1345 if (strchr (command_buffer, '='))
1346 {
1347 sound_name = rptp_parse (command_buffer, "sound");
1348 client_data = rptp_parse (0, "client-data");
1368 if (strchr(command_buffer, '='))
1369 {
1370 sound_name = rptp_parse(command_buffer, "sound");
1371 client_data = rptp_parse(0, "client-data");
13491372 if (!client_data)
13501373 {
13511374 client_data = default_client_data;
13571380 }
13581381
13591382 /* s = sound_lookup (sound_name, SOUND_CREATE, NULL); */
1360 s = sound_lookup (sound_name, SOUND_LOAD, NULL);
1383 s = sound_lookup(sound_name, SOUND_LOAD, NULL);
13611384 if (s == NULL || s->status != SOUND_READY)
13621385 {
1363 report (REPORT_NOTICE, "%s info %s - not found\n",
1364 inet_ntoa (c->sin.sin_addr), sound_name);
1365 connection_reply (c, "%cerror=\"%s not found\" command=info client-data=\"%s\"",
1366 RPTP_ERROR, sound_name, client_data);
1386 report(REPORT_NOTICE, "%s info %s - not found\n",
1387 inet_ntoa(c->sin.sin_addr), sound_name);
1388 connection_reply(c, "%cerror=\"%s not found\" command=info client-data=\"%s\"",
1389 RPTP_ERROR, sound_name, client_data);
13671390 }
13681391 else
13691392 {
1370 connection_reply (c, "\
1393 connection_reply(c, "\
13711394 %csound=\"%s\" size=%d bits=%g sample-rate=%d channels=%d format=%s byte-order=%s input=%s seconds=%.2f command=info client-data=\"%s\"",
1372 RPTP_OK,
1373 s->name,
1374 s->size,
1375 s->input_precision,
1376 s->sample_rate,
1377 s->channels,
1378 audio_format_to_string (s->format),
1379 byte_order_to_string (s->byte_order),
1380 input_to_string (s->type),
1381 s->sample_rate && s->samples ? (double) s->samples / s->sample_rate : 0,
1382 client_data);
1395 RPTP_OK,
1396 s->name,
1397 s->size,
1398 s->input_precision,
1399 s->sample_rate,
1400 s->channels,
1401 audio_format_to_string(s->format),
1402 byte_order_to_string(s->byte_order),
1403 input_to_string(s->type),
1404 s->sample_rate && s->samples ? (double) s->samples / s->sample_rate : 0,
1405 client_data);
13831406 }
13841407
13851408 return 0;
13871410
13881411 #ifdef __STDC__
13891412 static int
1390 command_version (CONNECTION *c, int argc, char **argv)
1391 #else
1392 static int
1393 command_version (c, argc, argv)
1413 command_version(CONNECTION *c, int argc, char **argv)
1414 #else
1415 static int
1416 command_version(c, argc, argv)
13941417 CONNECTION *c;
13951418 int argc;
13961419 char **argv;
13971420 #endif
13981421 {
13991422 char *client_data;
1400
1401 client_data = rptp_parse (command_buffer, "client-data");
1423
1424 client_data = rptp_parse(command_buffer, "client-data");
14021425 if (!client_data)
14031426 {
14041427 client_data = default_client_data;
14051428 }
1406
1407 connection_reply (c, "%cversion=%s command=version client-data=\"%s\"",
1408 RPTP_OK, RPLAY_VERSION, client_data);
1429
1430 connection_reply(c, "%cversion=%s command=version client-data=\"%s\"",
1431 RPTP_OK, RPLAY_VERSION, client_data);
14091432
14101433 return 0;
14111434 }
14121435
14131436 #ifdef __STDC__
14141437 static void
1415 do_events (char *event_string, int *mask, int *spool_id)
1438 do_events(char *event_string, int *mask, int *spool_id)
14161439 #else
14171440 static void
1418 do_events (event_string, mask, spool_id)
1441 do_events(event_string, mask, spool_id)
14191442 char *event_string;
14201443 int *mask;
14211444 int *spool_id;
14271450 int operator, bit;
14281451
14291452 *spool_id = 0;
1430
1431 strncpy (buf, event_string, sizeof(buf));
1432
1433 while (p = strtok (first ? buf : NULL, ",| "))
1453
1454 strncpy(buf, event_string, sizeof(buf));
1455
1456 while (p = strtok(first ? buf : NULL, ",| "))
14341457 {
14351458 first = 0;
14361459 bit = 0;
14371460 operator = 0;
1438
1461
14391462 if (*p == '+')
14401463 {
14411464 operator = 0;
14461469 operator = 1;
14471470 p++;
14481471 }
1449
1450 if (strcmp (p, "all") == 0 || strcmp (p, "any") == 0)
1472
1473 if (strcmp(p, "all") == 0 || strcmp(p, "any") == 0)
14511474 {
14521475 bit = NOTIFY_ANY;
14531476 }
1454 else if (strcmp (p, "none") == 0)
1477 else if (strcmp(p, "none") == 0)
14551478 {
14561479 *mask = 0;
14571480 }
1458 else if (strcmp (p, "play") == 0)
1481 else if (strcmp(p, "play") == 0)
14591482 {
14601483 bit = NOTIFY_PLAY;
14611484 }
1462 else if (strcmp (p, "stop") == 0)
1485 else if (strcmp(p, "stop") == 0)
14631486 {
14641487 bit = NOTIFY_STOP;
14651488 }
1466 else if (strcmp (p, "pause") == 0)
1489 else if (strcmp(p, "pause") == 0)
14671490 {
14681491 bit = NOTIFY_PAUSE;
14691492 }
1470 else if (strcmp (p, "continue") == 0)
1493 else if (strcmp(p, "continue") == 0)
14711494 {
14721495 bit = NOTIFY_CONTINUE;
14731496 }
1474 else if (strcmp (p, "volume") == 0)
1497 else if (strcmp(p, "volume") == 0)
14751498 {
14761499 bit = NOTIFY_VOLUME;
14771500 }
1478 else if (strcmp (p, "done") == 0)
1501 else if (strcmp(p, "done") == 0)
14791502 {
14801503 bit = NOTIFY_DONE;
14811504 }
1482 else if (strcmp (p, "skip") == 0)
1505 else if (strcmp(p, "skip") == 0)
14831506 {
14841507 bit = NOTIFY_SKIP;
14851508 }
1486 else if (strcmp (p, "state") == 0)
1509 else if (strcmp(p, "state") == 0)
14871510 {
14881511 bit = NOTIFY_STATE;
14891512 }
1490 else if (strcmp (p, "flow") == 0)
1513 else if (strcmp(p, "flow") == 0)
14911514 {
14921515 bit = NOTIFY_FLOW;
14931516 }
14941517 else if (p[0] == '#')
14951518 {
1496 *spool_id = atoi (p+1);
1497 }
1498 else if (strcmp (p, "modify") == 0)
1519 *spool_id = atoi(p + 1);
1520 }
1521 else if (strcmp(p, "modify") == 0)
14991522 {
15001523 bit = NOTIFY_MODIFY;
15011524 }
1502 else if (strcmp (p, "level") == 0)
1525 else if (strcmp(p, "level") == 0)
15031526 {
15041527 bit = NOTIFY_LEVEL;
15051528 }
1506 else if (strcmp (p, "position") == 0)
1529 else if (strcmp(p, "position") == 0)
15071530 {
15081531 bit = NOTIFY_POSITION;
15091532 }
1510
1533
15111534 if (operator == 0)
15121535 {
1513 SET_BIT (*mask, bit);
1536 SET_BIT(*mask, bit);
15141537 }
15151538 else
15161539 {
1517 CLR_BIT (*mask, bit);
1540 CLR_BIT(*mask, bit);
15181541 }
15191542 }
15201543
15231546 spool entry. */
15241547 if (*spool_id && !*mask)
15251548 {
1526 SET_BIT (*mask, NOTIFY_SPOOL);
1527 }
1528 }
1529
1530 #ifdef __STDC__
1531 static int
1532 command_wait (CONNECTION *c, int argc, char **argv)
1533 #else
1534 static int
1535 command_wait (c, argc, argv)
1549 SET_BIT(*mask, NOTIFY_SPOOL);
1550 }
1551 }
1552
1553 #ifdef __STDC__
1554 static int
1555 command_wait(CONNECTION *c, int argc, char **argv)
1556 #else
1557 static int
1558 command_wait(c, argc, argv)
15361559 CONNECTION *c;
15371560 int argc;
15381561 char **argv;
15401563 {
15411564 EVENT *e;
15421565 char *client_data;
1543
1544 client_data = rptp_parse (command_buffer, "client-data");
1566
1567 client_data = rptp_parse(command_buffer, "client-data");
15451568 if (!client_data)
15461569 {
15471570 client_data = default_client_data;
15481571 }
1549
1572
15501573 /* `wait' - wait for anything */
15511574 if (argc == 1)
15521575 {
1553 e = event_create (EVENT_NOTIFY);
1554 SET_BIT (e->wait_mask, NOTIFY_ANY);
1555 event_insert (c, e);
1576 e = event_create(EVENT_NOTIFY);
1577 SET_BIT(e->wait_mask, NOTIFY_ANY);
1578 event_insert(c, e);
15561579 return 0;
15571580 }
15581581 /* `wait id=#spool-id' or `wait event=event,event,event' */
1559 else if (argc == 2 && strchr (argv[1], '='))
1582 else if (argc == 2 && strchr(argv[1], '='))
15601583 {
15611584 char *value;
15621585
1563 value = rptp_parse (argv[1], "id");
1586 value = rptp_parse(argv[1], "id");
15641587 if (value && *value)
15651588 {
1566 e = event_create (EVENT_NOTIFY);
1567 SET_BIT (e->wait_mask, NOTIFY_DONE);
1568 e->id = atoi (value + 1);
1569 event_insert (c, e);
1589 e = event_create(EVENT_NOTIFY);
1590 SET_BIT(e->wait_mask, NOTIFY_DONE);
1591 e->id = atoi(value + 1);
1592 event_insert(c, e);
15701593 return 0;
15711594 }
15721595
1573 value = rptp_parse (argv[1], "event");
1596 value = rptp_parse(argv[1], "event");
15741597 if (value && *value)
15751598 {
1576 e = event_create (EVENT_NOTIFY);
1577 do_events (value, &e->wait_mask, &e->id);
1578 event_insert (c, e);
1599 e = event_create(EVENT_NOTIFY);
1600 do_events(value, &e->wait_mask, &e->id);
1601 event_insert(c, e);
15791602 return 0;
15801603 }
15811604
1582 connection_reply (c, "%cerror=\"unknown wait attribute `%s'\" command=wait client-data=\"%s\"",
1583 RPTP_ERROR, argv[1], client_data);
1605 connection_reply(c, "%cerror=\"unknown wait attribute `%s'\" command=wait client-data=\"%s\"",
1606 RPTP_ERROR, argv[1], client_data);
15841607 return 0;
15851608 }
15861609 /* `wait play ...' */
1587 else if (strcmp (argv[1], "play") == 0)
1610 else if (strcmp(argv[1], "play") == 0)
15881611 {
15891612 int id;
15901613
1591 id = do_execute (c, argc - 1, argv + 1);
1614 id = do_execute(c, argc - 1, argv + 1);
15921615 if (id > 0)
15931616 {
1594 e = event_create (EVENT_NOTIFY);
1595 SET_BIT (e->wait_mask, NOTIFY_DONE);
1617 e = event_create(EVENT_NOTIFY);
1618 SET_BIT(e->wait_mask, NOTIFY_DONE);
15961619 e->id = id;
1597 event_insert (c, e);
1620 event_insert(c, e);
15981621 }
15991622
16001623 return 0;
16021625 else
16031626 {
16041627 /* XXX: Need to fix command_buffer */
1605 int i;
1628 int i, n;
16061629 command_buffer[0] = '\0';
1630 n = 0;
16071631 for (i = 1; i < argc; i++)
16081632 {
1609 SNPRINTF (SIZE(command_buffer+strlen(command_buffer),sizeof(command_buffer)), argv[i]);
1633 SNPRINTF(SIZE(command_buffer + n, sizeof(command_buffer) - n), argv[i]);
1634 n += strlen(argv[i]);
16101635 if (i + 1 != argc)
16111636 {
1612 SNPRINTF (SIZE(command_buffer+strlen(command_buffer),sizeof(command_buffer)), " ");
1613 }
1614 }
1615
1616 return do_command (c, argc - 1, argv + 1);
1617 }
1618 }
1619
1620 #ifdef __STDC__
1621 static int
1622 command_status (CONNECTION *c, int argc, char **argv)
1623 #else
1624 static int
1625 command_status (c, argc, argv)
1637 SNPRINTF(SIZE(command_buffer + n, sizeof(command_buffer) - n), " ");
1638 n++;
1639 }
1640 }
1641
1642 return do_command(c, argc - 1, argv + 1);
1643 }
1644 }
1645
1646 #ifdef __STDC__
1647 static int
1648 command_status(CONNECTION *c, int argc, char **argv)
1649 #else
1650 static int
1651 command_status(c, argc, argv)
16261652 CONNECTION *c;
16271653 int argc;
16281654 char **argv;
16301656 {
16311657 EVENT *e;
16321658
1633 e = event_create (EVENT_WRITE, rplayd_status ());
1634 event_insert (c, e);
1659 e = event_create(EVENT_WRITE, rplayd_status());
1660 event_insert(c, e);
16351661
16361662 return 0;
16371663 }
16391665 /* OBSOLETE */
16401666 #ifdef __STDC__
16411667 static int
1642 command_application (CONNECTION *c, int argc, char **argv)
1643 #else
1644 static int
1645 command_application (c, argc, argv)
1668 command_application(CONNECTION *c, int argc, char **argv)
1669 #else
1670 static int
1671 command_application(c, argc, argv)
16461672 CONNECTION *c;
16471673 int argc;
16481674 char **argv;
16491675 #endif
16501676 {
1651 int i;
1677 int i, n;
16521678 char buf[RPTP_MAX_LINE];
16531679
16541680 buf[0] = '\0';
1681 n = 0;
16551682 for (i = 1; i < argc; i++)
16561683 {
1657 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), argv[i]);
1684 SNPRINTF(SIZE(buf + n, sizeof(buf) - n), argv[i]);
1685 n += strlen(argv[i]);
16581686 if (i + 1 != argc)
16591687 {
1660 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), " ");
1688 SNPRINTF(SIZE(buf + n, sizeof(buf) - n), " ");
1689 n++;
16611690 }
16621691 }
16631692
16641693 if (c->application)
16651694 {
1666 free (c->application);
1667 }
1668
1669 c->application = strdup (buf);
1670
1671 connection_reply (c, "%c%s", RPTP_OK, c->application);
1695 free(c->application);
1696 }
1697
1698 c->application = strdup(buf);
1699
1700 connection_reply(c, "%c%s", RPTP_OK, c->application);
16721701
16731702 return 0;
16741703 }
16761705 #ifdef DEBUG
16771706 #ifdef __STDC__
16781707 static int
1679 command_die (CONNECTION *c, int argc, char **argv)
1680 #else
1681 static int
1682 command_die (c, argc, argv)
1708 command_die(CONNECTION *c, int argc, char **argv)
1709 #else
1710 static int
1711 command_die(c, argc, argv)
16831712 CONNECTION *c;
16841713 int argc;
16851714 char **argv;
16861715 #endif
16871716 {
1688 report (REPORT_DEBUG, "time to die...\n");
1689 connection_close (c);
1690 done (0);
1717 report(REPORT_DEBUG, "time to die...\n");
1718 connection_close(c);
1719 done(0);
16911720 return -1; /* not reached */
16921721 }
16931722 #endif /* DEBUG */
16941723
16951724 #ifdef __STDC__
16961725 static int
1697 command_reset (CONNECTION *c, int argc, char **argv)
1698 #else
1699 static int
1700 command_reset (c, argc, argv)
1726 command_reset(CONNECTION *c, int argc, char **argv)
1727 #else
1728 static int
1729 command_reset(c, argc, argv)
17011730 CONNECTION *c;
17021731 int argc;
17031732 char **argv;
17041733 #endif
17051734 {
17061735 char *client_data;
1707
1708 client_data = rptp_parse (command_buffer, "client-data");
1736
1737 client_data = rptp_parse(command_buffer, "client-data");
17091738 if (!client_data)
17101739 {
17111740 client_data = default_client_data;
17121741 }
17131742
17141743 #ifdef AUTH
1715 if (!host_access (c->sin, HOST_EXECUTE))
1716 {
1717 report (REPORT_NOTICE, "%s reset access denied\n", inet_ntoa (c->sin.sin_addr));
1718 connection_reply (c, "%cerror=\"access denied\" command=reset client-data=\"%s\"",
1719 RPTP_ERROR, client_data);
1744 if (!host_access(c->sin, HOST_EXECUTE))
1745 {
1746 report(REPORT_NOTICE, "%s reset access denied\n", inet_ntoa(c->sin.sin_addr));
1747 connection_reply(c, "%cerror=\"access denied\" command=reset client-data=\"%s\"",
1748 RPTP_ERROR, client_data);
17201749 return 0;
17211750 }
17221751 #endif /* AUTH */
17231752
1724 need_reset ();
1725
1726 connection_reply (c, "%cmessage=\"reset successful\" command=reset client-data=\"%s\"",
1727 RPTP_OK, client_data);
1753 need_reset();
1754
1755 connection_reply(c, "%cmessage=\"reset successful\" command=reset client-data=\"%s\"",
1756 RPTP_OK, client_data);
17281757
17291758 return 0;
17301759 }
17311760
17321761 #ifdef __STDC__
17331762 static int
1734 command_skip (CONNECTION *c, int argc, char **argv)
1735 #else
1736 static int
1737 command_skip (c, argc, argv)
1763 command_skip(CONNECTION *c, int argc, char **argv)
1764 #else
1765 static int
1766 command_skip(c, argc, argv)
17381767 CONNECTION *c;
17391768 int argc;
17401769 char **argv;
17451774 int nskipped = 0;
17461775 char *p;
17471776 char *client_data;
1748
1749 client_data = rptp_parse (command_buffer, "client-data");
1777
1778 client_data = rptp_parse(command_buffer, "client-data");
17501779 if (!client_data)
17511780 {
17521781 client_data = default_client_data;
17531782 }
17541783
17551784 #ifdef AUTH
1756 if (!host_access (c->sin, HOST_EXECUTE))
1757 {
1758 report (REPORT_NOTICE, "%s skip access denied\n", inet_ntoa (c->sin.sin_addr));
1759 connection_reply (c, "%cerror=\"access denied\" command=skip client-data=\"%s\"",
1760 RPTP_ERROR, client_data);
1785 if (!host_access(c->sin, HOST_EXECUTE))
1786 {
1787 report(REPORT_NOTICE, "%s skip access denied\n", inet_ntoa(c->sin.sin_addr));
1788 connection_reply(c, "%cerror=\"access denied\" command=skip client-data=\"%s\"",
1789 RPTP_ERROR, client_data);
17611790 return 0;
17621791 }
17631792 #endif /* AUTH */
17641793
1765 p = rptp_parse (0, "id");
1794 p = rptp_parse(0, "id");
17661795 if (p)
17671796 {
1768 id = atoi (p + 1);
1769 }
1770 p = rptp_parse (0, "count");
1797 id = atoi(p + 1);
1798 }
1799 p = rptp_parse(0, "count");
17711800 if (p)
17721801 {
1773 count = atoi (p);
1802 count = atoi(p);
17741803 }
17751804
17761805 for (sp = spool; sp; sp = sp->next)
17771806 {
17781807 if (!id || sp->id == id)
17791808 {
1780 spool_skip (sp, count);
1809 spool_skip(sp, count);
17811810 nskipped++;
17821811 }
17831812 }
17841813
17851814 if (nskipped)
17861815 {
1787 connection_reply (c, "%cmessage=\"skipped\" command=skip client-data=\"%s\"",
1788 RPTP_OK, client_data);
1816 connection_reply(c, "%cmessage=\"skipped\" command=skip client-data=\"%s\"",
1817 RPTP_OK, client_data);
17891818 }
17901819 else
17911820 {
1792 connection_reply (c, "%cerror=\"skip failed\" command=skip client-data=\"%s\"",
1793 RPTP_ERROR, client_data);
1821 connection_reply(c, "%cerror=\"skip failed\" command=skip client-data=\"%s\"",
1822 RPTP_ERROR, client_data);
17941823 }
17951824
17961825 return 0;
17981827
17991828 #ifdef __STDC__
18001829 static int
1801 command_set (CONNECTION *c, int argc, char **argv)
1802 #else
1803 static int
1804 command_set (c, argc, argv)
1830 command_set(CONNECTION *c, int argc, char **argv)
1831 #else
1832 static int
1833 command_set(c, argc, argv)
18051834 CONNECTION *c;
18061835 int argc;
18071836 char **argv;
18181847 int notify_mask = 0;
18191848 int notify_id = 0;
18201849 char *client_data;
1821
1822 client_data = rptp_parse (command_buffer, "client-data");
1850 char buf[RPTP_MAX_LINE];
1851
1852 client_data = rptp_parse(command_buffer, "client-data");
18231853 if (!client_data)
18241854 {
18251855 client_data = default_client_data;
18261856 }
18271857
18281858 #ifdef AUTH
1829 if (!host_access (c->sin, HOST_EXECUTE))
1830 {
1831 report (REPORT_NOTICE, "%s set access denied\n", inet_ntoa (c->sin.sin_addr));
1832 connection_reply (c, "%cerror=\"access denied\" command=set client-data=\"%s\"",
1833 RPTP_ERROR, client_data);
1859 if (!host_access(c->sin, HOST_EXECUTE))
1860 {
1861 report(REPORT_NOTICE, "%s set access denied\n", inet_ntoa(c->sin.sin_addr));
1862 connection_reply(c, "%cerror=\"access denied\" command=set client-data=\"%s\"",
1863 RPTP_ERROR, client_data);
18341864 return 0;
18351865 }
18361866 #endif /* AUTH */
18371867
1838 b = buffer_create ();
1868 b = buffer_create();
18391869 b->buf[0] = RPTP_OK;
18401870 b->buf[1] = '\0';
1841
1842 rptp_parse (command_buffer, 0);
1843 while (name = rptp_parse (0, 0))
1844 {
1845 value = rptp_parse (0, name);
1846
1847 if (strcmp (name, "application") == 0) /* `application=value' */
1871 b->nbytes = 1;
1872
1873 rptp_parse(command_buffer, 0);
1874 while (name = rptp_parse(0, 0))
1875 {
1876 value = rptp_parse(0, name);
1877
1878 if (strcmp(name, "application") == 0) /* `application=value' */
18481879 {
18491880 if (value && *value)
18501881 {
18511882 if (c->application)
18521883 {
1853 free (c->application);
1884 free(c->application);
18541885 }
1855 c->application = strdup (value);
1856 }
1857 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "application=\"%s\"",
1886 c->application = strdup(value);
1887 }
1888 SNPRINTF(SIZE(buf, sizeof(buf)), "application=\"%s\"",
18581889 c->application ? c->application : "-1");
1859 }
1860 else if (strcmp (name, "notify") == 0) /* `notify=[event,...]' */
1890 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
1891 b->nbytes += strlen(buf);
1892 }
1893 else if (strcmp(name, "notify") == 0) /* `notify=[event,...]' */
18611894 {
18621895 if (value)
18631896 {
1864 do_events (value, &c->notify_mask, &c->notify_id);
1865 }
1866
1897 do_events(value, &c->notify_mask, &c->notify_id);
1898 }
1899
18671900 if (!c->notify_mask)
18681901 {
1869 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "notify=none");
1902 SNPRINTF(SIZE(buf, sizeof(buf)), "notify=none");
1903 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
1904 b->nbytes += strlen(buf);
18701905 }
18711906 else
18721907 {
1873 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "notify=\"%s\"", value);
1908 SNPRINTF(SIZE(buf, sizeof(buf)), "notify=\"%s\"", value);
1909 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
1910 b->nbytes += strlen(buf);
18741911 notify_enabled++;
18751912 }
18761913 }
1877 else if (strcmp (name, "volume") == 0) /* `volume=[+|-]value' */
1878 {
1879 int volume = rplay_audio_get_volume ();
1914 else if (strcmp(name, "volume") == 0) /* `volume=[+|-]value' */
1915 {
1916 int volume = rplay_audio_get_volume();
18801917
18811918 if (value && *value)
18821919 {
18831920 switch (value[0])
18841921 {
18851922 case '+':
1886 volume += atoi (value + 1);
1923 volume += atoi(value + 1);
18871924 break;
18881925
18891926 case '-':
1890 volume -= atoi (value + 1);
1927 volume -= atoi(value + 1);
18911928 break;
18921929
18931930 case '*':
1894 volume *= atoi (value + 1);
1931 volume *= atoi(value + 1);
18951932 break;
18961933
18971934 case '/':
1898 volume /= atoi (value + 1);
1935 volume /= atoi(value + 1);
18991936 break;
19001937
19011938 default:
1902 volume = atoi (value);
1939 volume = atoi(value);
19031940 }
19041941
1905 volume = rplay_audio_set_volume (volume);
1942 volume = rplay_audio_set_volume(volume);
19061943 }
19071944
19081945 if (volume >= 0)
19091946 {
1910 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "volume=%d", volume);
1947 SNPRINTF(SIZE(buf, sizeof(buf)), "volume=%d", volume);
1948 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
1949 b->nbytes += strlen(buf);
19111950 volume_changed++;
19121951 }
19131952 else
19141953 {
1915 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "volume=-1");
1916 }
1917 }
1918 else if (strcmp (name, "priority-threshold") == 0) /* `priority-threshold=value' */
1954 SNPRINTF(SIZE(buf, sizeof(buf)), "volume=-1");
1955 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
1956 b->nbytes += strlen(buf);
1957 }
1958 }
1959 else if (strcmp(name, "priority-threshold") == 0) /* `priority-threshold=value' */
19191960 {
19201961 if (value && *value)
19211962 {
1922 rplay_priority_threshold = atoi (value);
1963 rplay_priority_threshold = atoi(value);
19231964 if (rplay_priority_threshold < RPLAY_MIN_PRIORITY)
19241965 {
19251966 rplay_priority_threshold = RPLAY_MIN_PRIORITY;
19311972
19321973 priority_threshold_changed++;
19331974 }
1934 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "priority-threshold=%d",
1975 SNPRINTF(SIZE(buf, sizeof(buf)), "priority-threshold=%d",
19351976 rplay_priority_threshold);
1936 }
1937 else if (strcmp (name, "notify-rate") == 0) /* `notify-rate=value' */
1977 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
1978 b->nbytes += strlen(buf);
1979 }
1980 else if (strcmp(name, "notify-rate") == 0) /* `notify-rate=value' */
19381981 {
19391982 if (value && *value)
19401983 {
19411984 int i;
19421985 double rate;
1943
1944 rate = atof (value);
1945
1986
1987 rate = atof(value);
1988
19461989 for (i = 0; i < NOTIFY_RATE_MAX; i++)
19471990 {
19481991 c->notify_rate[i].rate = rate;
19491992 c->notify_rate[i].next = 0.0;
19501993 }
19511994 }
1952
1953 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "level-notify-rate=%.2f position-notify-rate=%.2f",
1995
1996 SNPRINTF(SIZE(buf, sizeof(buf)), "level-notify-rate=%.2f position-notify-rate=%.2f",
19541997 c->notify_rate[NOTIFY_RATE_LEVEL].rate,
19551998 c->notify_rate[NOTIFY_RATE_POSITION].rate);
1956 }
1957 else if (strcmp (name, "level-notify-rate") == 0)
1999 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2000 b->nbytes += strlen(buf);
2001 }
2002 else if (strcmp(name, "level-notify-rate") == 0)
19582003 {
19592004 if (value && *value)
19602005 {
1961 c->notify_rate[NOTIFY_RATE_LEVEL].rate = atof (value);
2006 c->notify_rate[NOTIFY_RATE_LEVEL].rate = atof(value);
19622007 c->notify_rate[NOTIFY_RATE_LEVEL].next = 0.0;
19632008 }
19642009
1965 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "level-notify-rate=%.2f",
2010 SNPRINTF(SIZE(buf, sizeof(buf)), "level-notify-rate=%.2f",
19662011 c->notify_rate[NOTIFY_RATE_LEVEL].rate);
1967 }
1968 else if (strcmp (name, "position-notify-rate") == 0)
2012 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2013 b->nbytes += strlen(buf);
2014 }
2015 else if (strcmp(name, "position-notify-rate") == 0)
19692016 {
19702017 if (value && *value)
19712018 {
1972 c->notify_rate[NOTIFY_RATE_POSITION].rate = atof (value);
2019 c->notify_rate[NOTIFY_RATE_POSITION].rate = atof(value);
19732020 c->notify_rate[NOTIFY_RATE_POSITION].next = 0.0;
19742021 }
19752022
1976 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "position-notify-rate=%.2f",
2023 SNPRINTF(SIZE(buf, sizeof(buf)), "position-notify-rate=%.2f",
19772024 c->notify_rate[NOTIFY_RATE_POSITION].rate);
1978 }
1979 else if (strcmp (name, "audio-port") == 0)
2025 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2026 b->nbytes += strlen(buf);
2027 }
2028 else if (strcmp(name, "audio-port") == 0)
19802029 {
19812030 int n;
1982
2031
19832032 optional_port = rplay_audio_port;
1984
1985 if (strstr (value, "none"))
2033
2034 if (strstr(value, "none"))
19862035 {
19872036 optional_port = 0;
19882037 }
1989 if (strstr (value, "speaker"))
1990 {
1991 SET_BIT (optional_port, RPLAY_AUDIO_PORT_SPEAKER);
1992 }
1993 if (strstr (value, "headphone"))
1994 {
1995 SET_BIT (optional_port, RPLAY_AUDIO_PORT_HEADPHONE);
1996 }
1997 if (strstr (value, "lineout"))
1998 {
1999 SET_BIT (optional_port, RPLAY_AUDIO_PORT_LINEOUT);
2038 if (strstr(value, "speaker"))
2039 {
2040 SET_BIT(optional_port, RPLAY_AUDIO_PORT_SPEAKER);
2041 }
2042 if (strstr(value, "headphone"))
2043 {
2044 SET_BIT(optional_port, RPLAY_AUDIO_PORT_HEADPHONE);
2045 }
2046 if (strstr(value, "lineout"))
2047 {
2048 SET_BIT(optional_port, RPLAY_AUDIO_PORT_LINEOUT);
20002049 }
20012050
20022051 if (optional_port != rplay_audio_port)
20032052 {
2004 n = rplay_audio_init ();
2053 n = rplay_audio_init();
20052054 if (n >= 0)
20062055 {
20072056 audio_port_changed++;
20112060 {
20122061 n = 0;
20132062 }
2014
2063
20152064 if (n < 0)
20162065 {
2017 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "audio-port=-1");
2066 SNPRINTF(SIZE(buf, sizeof(buf)), "audio-port=-1");
2067 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2068 b->nbytes += strlen(buf);
20182069 }
20192070 else
20202071 {
2021 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "audio-port=%s", value);
2022 }
2023 }
2024 else if (strcmp (name, "audio-info") == 0)
2072 SNPRINTF(SIZE(buf, sizeof(buf)), "audio-port=%s", value);
2073 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2074 b->nbytes += strlen(buf);
2075 }
2076 }
2077 else if (strcmp(name, "audio-info") == 0)
20252078 {
20262079 char info[1024], *p;
20272080 SPOOL *sp, *sp_next;
20312084 for (sp = spool; sp; sp = sp_next)
20322085 {
20332086 sp_next = sp->next;
2034 spool_stop (sp);
2035 }
2036
2087 spool_stop(sp);
2088 }
2089
20372090 /* Example: ulaw,8000,8,1 */
2038 strncpy (info, value, sizeof(info));
2039 p = strtok (info, ", ");
2040 if (p) optional_format = string_to_audio_format (p);
2041 p = strtok (NULL, ",");
2042 if (p) optional_sample_rate = atoi (p);
2043 p = strtok (NULL, ",");
2044 if (p) optional_precision = atoi (p);
2045 p = strtok (NULL, ",");
2046 if (p) optional_channels = atoi (p);
2047
2048 #ifndef HAVE_OSS
2049 bufsize = rplay_audio_bufsize; /* XXX: force recalculation */
2091 strncpy(info, value, sizeof(info));
2092 p = strtok(info, ", ");
2093 if (p)
2094 optional_format = string_to_audio_format(p);
2095 p = strtok(NULL, ",");
2096 if (p)
2097 optional_sample_rate = atoi(p);
2098 p = strtok(NULL, ",");
2099 if (p)
2100 optional_precision = atoi(p);
2101 p = strtok(NULL, ",");
2102 if (p)
2103 optional_channels = atoi(p);
2104
2105 #ifndef HAVE_OSS
2106 bufsize = rplay_audio_bufsize; /* XXX: force recalculation */
20502107 rplay_audio_bufsize = 0;
2051 #endif /* !HAVE_OSS */
2108 #endif /* !HAVE_OSS */
20522109
20532110 rate = rplay_audio_rate;
20542111 rplay_audio_rate = 0;
2055
2056 if (rplayd_audio_init () < 0)
2057 {
2058 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "audio-info=-1");
2059 #ifndef HAVE_OSS
2112
2113 if (rplayd_audio_init() < 0)
2114 {
2115 SNPRINTF(SIZE(buf, sizeof(buf)), "audio-info=-1");
2116 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2117 b->nbytes += strlen(buf);
2118 #ifndef HAVE_OSS
20602119 rplay_audio_bufsize = bufsize;
2061 #endif /* !HAVE_OSS */
2120 #endif /* !HAVE_OSS */
20622121 rplay_audio_rate = rate;
20632122 }
20642123 else
20652124 {
2066 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "audio-info=%s", value);
2125 SNPRINTF(SIZE(buf, sizeof(buf)), "audio-info=%s", value);
2126 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2127 b->nbytes += strlen(buf);
2128 }
2129 }
2130 else if (strcmp(name, "audio-close") == 0)
2131 {
2132 if (value && *value)
2133 {
2134 extern int rplay_audio_timeout;
2135 rplay_audio_timeout = atoi(value);
2136 SNPRINTF(SIZE(buf, sizeof(buf)), "audio-close=%d", rplay_audio_timeout);
2137 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2138 b->nbytes += strlen(buf);
20672139 }
20682140 }
20692141 else
20702142 {
2071 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "%s=-1", name);
2072 }
2073
2074 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " ");
2075 }
2076
2077 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "command=set client-data=\"%s\"\r\n", client_data);
2078 b->nbytes = strlen (b->buf);
2079
2080 e = event_create (EVENT_WRITE, b);
2081 event_insert (c, e);
2143 SNPRINTF(SIZE(buf, sizeof(buf)), "%s=-1", name);
2144 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2145 b->nbytes += strlen(buf);
2146 }
2147
2148 SNPRINTF(SIZE(buf, sizeof(buf)), " ");
2149 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2150 b->nbytes += strlen(buf);
2151 }
2152
2153 SNPRINTF(SIZE(buf, sizeof(buf)), "command=set client-data=\"%s\"\r\n",
2154 client_data);
2155 strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes);
2156 b->nbytes += strlen(buf);
2157
2158 e = event_create(EVENT_WRITE, b);
2159 event_insert(c, e);
20822160
20832161 if (notify_enabled)
20842162 {
20882166 switch (sp->state)
20892167 {
20902168 case SPOOL_PLAY:
2091 connection_notify (c, NOTIFY_PLAY, sp);
2169 connection_notify(c, NOTIFY_PLAY, sp);
20922170 break;
20932171
20942172 case SPOOL_PAUSE:
2095 connection_notify (c, NOTIFY_PAUSE, sp);
2173 connection_notify(c, NOTIFY_PAUSE, sp);
20962174 break;
20972175 }
20982176 }
2099 connection_notify (c, NOTIFY_VOLUME, rplay_audio_volume);
2100
2101 e = event_create (EVENT_NOTIFY);
2102 event_insert (c, e);
2103 }
2177 connection_notify(c, NOTIFY_VOLUME, rplay_audio_volume);
2178
2179 e = event_create(EVENT_NOTIFY);
2180 event_insert(c, e);
2181 }
2182
21042183 if (volume_changed)
21052184 {
2106 connection_notify (0, NOTIFY_VOLUME, rplay_audio_volume);
2107 }
2185 connection_notify(0, NOTIFY_VOLUME, rplay_audio_volume);
2186 }
2187
21082188 if (priority_threshold_changed || audio_port_changed)
21092189 {
2110 connection_notify (0, NOTIFY_STATE);
2190 connection_notify(0, NOTIFY_STATE);
21112191 }
21122192
21132193 connection_want_level_notify = 0;
21142194 for (c = connections; c; c = c->next)
21152195 {
2116 if (BIT (c->notify_mask, NOTIFY_LEVEL)
2117 || (c->event && BIT (c->event->wait_mask, NOTIFY_LEVEL)))
2196 if (BIT(c->notify_mask, NOTIFY_LEVEL)
2197 || (c->event && BIT(c->event->wait_mask, NOTIFY_LEVEL)))
21182198 {
21192199 connection_want_level_notify++;
21202200 }
21252205
21262206 #ifdef __STDC__
21272207 static int
2128 command_modify (CONNECTION *c, int argc, char **argv)
2129 #else
2130 static int
2131 command_modify (c, argc, argv)
2208 command_modify(CONNECTION *c, int argc, char **argv)
2209 #else
2210 static int
2211 command_modify(c, argc, argv)
21322212 CONNECTION *c;
21332213 int argc;
21342214 char **argv;
21442224 int new_list_count = -1;
21452225 char *new_client_data = NULL;
21462226 int modified, total_modified = 0;
2227
2228 #ifdef AUTH
2229 if (!host_access(c->sin, HOST_EXECUTE))
2230 {
2231 report(REPORT_NOTICE, "%s modify access denied\n", inet_ntoa(c->sin.sin_addr));
2232 connection_reply(c, "%cerror=\"access denied\" command=modify", RPTP_ERROR);
2233 return 0;
2234 }
2235 #endif /* AUTH */
2236
2237 p = rptp_parse(command_buffer, "id");
2238 if (!p || !*p)
2239 {
2240 connection_reply(c, "%cerror=\"missing `id'\" command=modify", RPTP_ERROR);
2241 return 0;
2242 }
2243 id = atoi(p + 1);
2244
2245 p = rptp_parse(0, "count");
2246 if (p)
2247 {
2248 new_count = atoi(p);
2249 }
2250
2251 p = rptp_parse(0, "list-count");
2252 if (p)
2253 {
2254 new_list_count = atoi(p);
2255 }
2256
2257 p = rptp_parse(0, "priority");
2258 if (p)
2259 {
2260 new_priority = atoi(p);
2261 }
2262
2263 p = rptp_parse(0, "sample-rate");
2264 if (p)
2265 {
2266 new_sample_rate = atoi(p);
2267 }
2268
2269 p = rptp_parse(0, "volume");
2270 if (p)
2271 {
2272 new_volume = atoi(p);
2273 }
2274
2275 p = rptp_parse(0, "client-data");
2276 if (p)
2277 {
2278 new_client_data = p;
2279 }
2280
2281 for (sp = spool; sp; sp = sp->next)
2282 {
2283 if (!id || sp->id == id)
2284 {
2285 modified = 0;
2286 if (new_count != -1)
2287 {
2288 spool_set_count(sp, new_count);
2289 modified++;
2290 }
2291 if (new_list_count != -1)
2292 {
2293 spool_set_list_count(sp, new_list_count);
2294 modified++;
2295 }
2296 if (new_priority != -1)
2297 {
2298 spool_set_priority(sp, new_priority);
2299 modified++;
2300 }
2301 if (new_sample_rate != -1)
2302 {
2303 spool_set_sample_rate(sp, new_sample_rate);
2304 modified++;
2305 }
2306 if (new_volume != -1)
2307 {
2308 spool_set_volume(sp, new_volume);
2309 modified++;
2310 }
2311 if (new_client_data)
2312 {
2313 spool_set_client_data(sp, new_client_data);
2314 modified++;
2315 }
2316
2317 if (modified)
2318 {
2319 connection_notify(c, NOTIFY_MODIFY, sp);
2320 total_modified++;
2321 }
2322 }
2323 }
2324
2325 if (total_modified)
2326 {
2327 connection_reply(c, "%cmessage=\"modified\" command=modify", RPTP_OK);
2328 }
2329 else
2330 {
2331 connection_reply(c, "%cerror=\"nothing modified\" command=modify", RPTP_ERROR);
2332 }
2333
2334 return 0;
2335 }
2336
2337 #ifdef __STDC__
2338 static int
2339 command_monitor(CONNECTION *c, int argc, char **argv)
2340 #else
2341 static int
2342 command_monitor(c, argc, argv)
2343 CONNECTION *c;
2344 int argc;
2345 char **argv;
2346 #endif
2347 {
2348 EVENT *e;
21472349
21482350 #ifdef AUTH
2149 if (!host_access (c->sin, HOST_EXECUTE))
2150 {
2151 report (REPORT_NOTICE, "%s modify access denied\n", inet_ntoa (c->sin.sin_addr));
2152 connection_reply (c, "%cerror=\"access denied\" command=modify", RPTP_ERROR);
2351 if (!host_access(c->sin, HOST_MONITOR))
2352 {
2353 report(REPORT_NOTICE, "%s monitor - monitor access denied\n",
2354 inet_ntoa(c->sin.sin_addr));
2355 connection_reply(c, "%cerror=\"access denied\" command=monitor",
2356 RPTP_ERROR);
21532357 return 0;
21542358 }
21552359 #endif /* AUTH */
21562360
2157 p = rptp_parse (command_buffer, "id");
2158 if (!p || !*p)
2159 {
2160 connection_reply (c, "%cerror=\"missing `id'\" command=modify", RPTP_ERROR);
2161 return 0;
2162 }
2163 id = atoi (p + 1);
2164
2165 p = rptp_parse (0, "count");
2166 if (p)
2167 {
2168 new_count = atoi (p);
2169 }
2170
2171 p = rptp_parse (0, "list-count");
2172 if (p)
2173 {
2174 new_list_count = atoi (p);
2175 }
2176
2177 p = rptp_parse (0, "priority");
2178 if (p)
2179 {
2180 new_priority = atoi (p);
2181 }
2182
2183 p = rptp_parse (0, "sample-rate");
2184 if (p)
2185 {
2186 new_sample_rate = atoi (p);
2187 }
2188
2189 p = rptp_parse (0, "volume");
2190 if (p)
2191 {
2192 new_volume = atoi (p);
2193 }
2194
2195 p = rptp_parse (0, "client-data");
2196 if (p)
2197 {
2198 new_client_data = p;
2199 }
2200
2201 for (sp = spool; sp; sp = sp->next)
2202 {
2203 if (!id || sp->id == id)
2204 {
2205 modified = 0;
2206 if (new_count != -1)
2207 {
2208 spool_set_count (sp, new_count);
2209 modified++;
2210 }
2211 if (new_list_count != -1)
2212 {
2213 spool_set_list_count (sp, new_list_count);
2214 modified++;
2215 }
2216 if (new_priority != -1)
2217 {
2218 spool_set_priority (sp, new_priority);
2219 modified++;
2220 }
2221 if (new_sample_rate != -1)
2222 {
2223 spool_set_sample_rate (sp, new_sample_rate);
2224 modified++;
2225 }
2226 if (new_volume != -1)
2227 {
2228 spool_set_volume (sp, new_volume);
2229 modified++;
2230 }
2231 if (new_client_data)
2232 {
2233 spool_set_client_data (sp, new_client_data);
2234 modified++;
2235 }
2236
2237 if (modified)
2238 {
2239 connection_notify (c, NOTIFY_MODIFY, sp);
2240 total_modified++;
2241 }
2242 }
2243 }
2244
2245 if (total_modified)
2246 {
2247 connection_reply (c, "%cmessage=\"modified\" command=modify", RPTP_OK);
2248 }
2249 else
2250 {
2251 connection_reply (c, "%cerror=\"nothing modified\" command=modify", RPTP_ERROR);
2252 }
2361 if (monitor_count == 0)
2362 {
2363 monitor_alloc();
2364 }
2365 monitor_count++;
2366
2367 connection_reply(c, "%caudio-info=\"%s,%d,%d,%d,%s\"", RPTP_OK,
2368 audio_format_to_string(rplay_audio_format),
2369 rplay_audio_sample_rate,
2370 rplay_audio_precision,
2371 rplay_audio_channels,
2372 byte_order_to_string(RPLAY_AUDIO_BYTE_ORDER));
2373 e = event_create(EVENT_WAIT_MONITOR);
2374 event_insert(c, e);
2375
2376 c->monitor = 1;
22532377
22542378 return 0;
22552379 }
0 /* $Id: command.h,v 1.2 1998/08/13 06:13:47 boyns Exp $ */
0 /* $Id: command.h,v 1.3 1999/03/10 07:58:02 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: connection.c,v 1.3 1998/10/12 16:03:20 boyns Exp $ */
0 /* $Id: connection.c,v 1.6 1999/03/10 07:58:03 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifdef HAVE_CONFIG_H
2624 #include "config.h"
5856
5957 #undef EVENT_DEBUG
6058 #ifdef EVENT_DEBUG
61 static void event_print (CONNECTION *c, char *message);
59 static void event_print(CONNECTION *c, char *message);
6260 #endif
6361
6462 /*
6765 */
6866 #ifdef __STDC__
6967 CONNECTION *
70 connection_create (int type)
68 connection_create(int type)
7169 #else
7270 CONNECTION *
73 connection_create (type)
71 connection_create(type)
7472 int type;
7573 #endif
7674 {
7775 CONNECTION *c;
7876 int i;
79
80 c = (CONNECTION *) malloc (sizeof (CONNECTION));
77
78 c = (CONNECTION *) malloc(sizeof(CONNECTION));
8179 if (c == NULL)
8280 {
83 report (REPORT_ERROR, "connection_create: out of memory\n");
84 done (1);
81 report(REPORT_ERROR, "connection_create: out of memory\n");
82 done(1);
8583 }
8684 c->type = type;
8785 c->fd = -1;
8886 c->event = NULL;
8987 c->ep = &c->event;
9088 c->server = NULL;
91 c->time = time (0);
89 c->time = time(0);
9290 c->application = NULL;
9391 c->notify_mask = 0;
9492 c->notify_id = 0;
9795 c->notify_rate[i].rate = 0.0;
9896 c->notify_rate[i].next = 0.0;
9997 }
98 c->monitor = 0;
10099
101100 /*
102101 * insert new connection into the connection list
122121 */
123122 #ifdef __STDC__
124123 void
125 connection_destroy (CONNECTION *c)
126 #else
127 void
128 connection_destroy (c)
124 connection_destroy(CONNECTION *c)
125 #else
126 void
127 connection_destroy(c)
129128 CONNECTION *c;
130129 #endif
131130 {
147146 }
148147 if (c->application)
149148 {
150 free (c->application);
151 }
152 free ((char *) c);
149 free(c->application);
150 }
151 free((char *) c);
153152
154153 connection_want_level_notify = 0;
155154 for (c = connections; c; c = c->next)
156155 {
157 if (BIT (c->notify_mask, NOTIFY_LEVEL)
158 || (c->event && BIT (c->event->wait_mask, NOTIFY_LEVEL)))
156 if (BIT(c->notify_mask, NOTIFY_LEVEL)
157 || (c->event && BIT(c->event->wait_mask, NOTIFY_LEVEL)))
159158 {
160159 connection_want_level_notify++;
161160 }
170169 */
171170 #ifdef __STDC__
172171 CONNECTION *
173 connection_server_open (SERVER *server, SOUND *sound)
172 connection_server_open(SERVER *server, SOUND *sound)
174173 #else
175174 CONNECTION *
176 connection_server_open (server, sound)
175 connection_server_open(server, sound)
177176 SERVER *server;
178177 SOUND *sound;
179178 #endif
194193 }
195194 if (c == NULL)
196195 {
197 c = connection_create (CONNECTION_SERVER);
196 c = connection_create(CONNECTION_SERVER);
198197 c->server = server;
199198 c->sin = server->sin;
200199 }
201200 if (c->fd == -1)
202201 {
203 c->fd = socket (AF_INET, SOCK_STREAM, 0);
202 c->fd = socket(AF_INET, SOCK_STREAM, 0);
204203 if (c->fd < 0)
205204 {
206 report (REPORT_ERROR, "connection_open_server: socket: %s\n", sys_err_str (errno));
207 done (1);
208 }
209 fd_nonblock (c->fd);
205 report(REPORT_ERROR, "connection_open_server: socket: %s\n", sys_err_str(errno));
206 done(1);
207 }
208 fd_nonblock(c->fd);
210209
211210 /*
212211 * ping the server
213212 */
214 connection_server_ping (c);
213 connection_server_ping(c);
215214
216215 /*
217216 * try to connect to the server immediately
218217 */
219 report (REPORT_DEBUG, "%s server connection attempt\n", inet_ntoa (c->server->sin.sin_addr));
220 n = connect (c->fd, (struct sockaddr *) &c->server->sin, sizeof (c->server->sin));
221 e = event_create (EVENT_CONNECT);
222 e->time = time (0);
223 event_insert (c, e);
218 report(REPORT_DEBUG, "%s server connection attempt\n", inet_ntoa(c->server->sin.sin_addr));
219 n = connect(c->fd, (struct sockaddr *) &c->server->sin, sizeof(c->server->sin));
220 e = event_create(EVENT_CONNECT);
221 e->time = time(0);
222 event_insert(c, e);
224223 }
225224
226225 /*
230229 {
231230 BUFFER *b;
232231
233 b = buffer_create ();
234 SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "find %s\r\n", sound->name);
235 b->nbytes = strlen (b->buf);
236 e = event_create (EVENT_WRITE_FIND, b, sound);
237 event_insert (c, e);
232 b = buffer_create();
233 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", sound->name);
234 b->nbytes = strlen(b->buf);
235 e = event_create(EVENT_WRITE_FIND, b, sound);
236 event_insert(c, e);
238237 }
239238
240239 return c;
242241
243242 #ifdef __STDC__
244243 void
245 connection_server_reopen (CONNECTION *c)
246 #else
247 void
248 connection_server_reopen (c)
244 connection_server_reopen(CONNECTION *c)
245 #else
246 void
247 connection_server_reopen(c)
249248 CONNECTION *c;
250249 #endif
251250 {
252251 EVENT *e;
253252 CONNECTION *server;
254253
255 close (c->fd);
254 close(c->fd);
256255 c->fd = -1;
257256 e = c->event;
258257 c->event = NULL;
259258 c->ep = &c->event;
260259
261 server = connection_server_open (c->server, NULL);
260 server = connection_server_open(c->server, NULL);
262261 if (server != c)
263262 {
264 report (REPORT_ERROR, "connection_server_reopen: server != c\n");
265 done (1);
266 }
267 event_insert (server, e);
263 report(REPORT_ERROR, "connection_server_reopen: server != c\n");
264 done(1);
265 }
266 event_insert(server, e);
268267 }
269268
270269 /*
272271 */
273272 #ifdef __STDC__
274273 void
275 connection_server_ping (CONNECTION *c)
276 #else
277 void
278 connection_server_ping (c)
274 connection_server_ping(CONNECTION *c)
275 #else
276 void
277 connection_server_ping(c)
279278 CONNECTION *c;
280279 #endif
281280 {
282281 struct sockaddr_in ping_addr;
283282
284 memcpy ((char *) &ping_addr, (char *) &c->server->sin, sizeof (ping_addr));
285 ping_addr.sin_port = htons (RPLAY_PORT);
286 rplay_ping_sockaddr_in (&ping_addr);
283 memcpy((char *) &ping_addr, (char *) &c->server->sin, sizeof(ping_addr));
284 ping_addr.sin_port = htons(RPLAY_PORT);
285 rplay_ping_sockaddr_in(&ping_addr);
287286 }
288287
289288 /*
291290 */
292291 #ifdef __STDC__
293292 void
294 connection_client_open (int sock_fd)
295 #else
296 void
297 connection_client_open (sock_fd)
293 connection_client_open(int sock_fd)
294 #else
295 void
296 connection_client_open(sock_fd)
298297 int sock_fd;
299298 #endif
300299 {
301300 struct sockaddr_in f;
302 int fd, flen = sizeof (f);
301 int fd, flen = sizeof(f);
303302 CONNECTION *c;
304303 EVENT *e;
305304 char line[RPTP_MAX_LINE];
306305
307 fd = accept (sock_fd, (struct sockaddr *) &f, &flen);
306 fd = accept(sock_fd, (struct sockaddr *) &f, &flen);
308307 if (fd < 0)
309308 {
310 report (REPORT_ERROR, "accept: %s\n", sys_err_str (errno));
309 report(REPORT_ERROR, "accept: %s\n", sys_err_str(errno));
311310 return;
312311 }
313312
314313 #ifdef DEBUG
315 report (REPORT_DEBUG, "%s client connection request\n", inet_ntoa (f.sin_addr));
314 report(REPORT_DEBUG, "%s client connection request\n", inet_ntoa(f.sin_addr));
316315 #endif
317316
318317 #ifdef AUTH
319318 /*
320319 * see if this host has any access
321320 */
322 if (!host_access (f, HOST_READ) && !host_access (f, HOST_WRITE)
323 && !host_access (f, HOST_WRITE))
324 {
325 report (REPORT_NOTICE, "%s RPTP access denied\n", inet_ntoa (f.sin_addr));
326 SNPRINTF (SIZE(line,sizeof(line)), "%cerror=\"connection refused\"\r\n", RPTP_ERROR);
327 write (fd, line, strlen (line));
328 close (fd);
321 if (!host_access(f, HOST_READ) && !host_access(f, HOST_WRITE)
322 && !host_access(f, HOST_WRITE))
323 {
324 report(REPORT_NOTICE, "%s RPTP access denied\n", inet_ntoa(f.sin_addr));
325 SNPRINTF(SIZE(line, sizeof(line)), "%cerror=\"connection refused\"\r\n", RPTP_ERROR);
326 write(fd, line, strlen(line));
327 close(fd);
329328 return;
330329 }
331330 #endif /* AUTH */
335334 */
336335 if (nconnections + 1 == RPTP_MAX_CONNECTIONS)
337336 {
338 SNPRINTF (SIZE(line,sizeof(line)), "%cerror=\"connection refused\"\r\n", RPTP_ERROR);
339 write (fd, line, strlen (line));
340 close (fd);
337 SNPRINTF(SIZE(line, sizeof(line)), "%cerror=\"connection refused\"\r\n", RPTP_ERROR);
338 write(fd, line, strlen(line));
339 close(fd);
341340 return;
342341 }
343342
344 c = connection_create (CONNECTION_CLIENT);
343 c = connection_create(CONNECTION_CLIENT);
345344 c->fd = fd;
346 fd_nonblock (c->fd);
345 fd_nonblock(c->fd);
347346 c->sin = f;
348347
349348 #if 1
350 report (REPORT_NOTICE, "%s client connection established\n", inet_ntoa (c->sin.sin_addr));
349 report(REPORT_NOTICE, "%s client connection established\n", inet_ntoa(c->sin.sin_addr));
351350 #endif
352351
353352 /* Greet the connection with the server's status. */
354 e = event_create (EVENT_WRITE, rplayd_status ());
355 event_insert (c, e);
353 e = event_create(EVENT_WRITE, rplayd_status());
354 event_insert(c, e);
356355 }
357356
358357 /*
363362 */
364363 #ifdef __STDC__
365364 void
366 connection_update (fd_set * read_fds, fd_set * write_fds)
367 #else
368 void
369 connection_update (read_fds, write_fds)
365 connection_update(fd_set * read_fds, fd_set * write_fds)
366 #else
367 void
368 connection_update(read_fds, write_fds)
370369 fd_set *read_fds;
371370 fd_set *write_fds;
372371 #endif
373372 {
374 int i, n;
373 int i, n, size;
375374 CONNECTION *c;
376375 struct timeval tv;
377376 fd_set rfds, wfds;
381380 SOUND *s;
382381 SPOOL *sp;
383382 fd_set cmask;
384
383
385384 if (read_fds == NULL && write_fds == NULL)
386385 {
387386 int nfds;
390389 tv.tv_usec = 0;
391390 rfds = read_mask;
392391 wfds = write_mask;
393 FD_CLR (rplay_fd, &rfds);
392 FD_CLR(rplay_fd, &rfds);
394393 #ifdef __hpux
395 nfds = select (FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0, &tv);
396 #else
397 nfds = select (FD_SETSIZE, &rfds, &wfds, 0, &tv);
394 nfds = select(FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0, &tv);
395 #else
396 nfds = select(FD_SETSIZE, &rfds, &wfds, 0, &tv);
398397 #endif
399398 if (nfds == 0)
400399 {
403402 }
404403 else if (nfds < 0)
405404 {
406 report (REPORT_ERROR, "connection_update: select: %s\n",
407 sys_err_str (errno));
408 done (1);
405 report(REPORT_ERROR, "connection_update: select: %s\n",
406 sys_err_str(errno));
407 done(1);
409408 }
410409 }
411410 else
417416 /*
418417 * Check for new RPTP connections.
419418 */
420 if (FD_ISSET (rptp_fd, &rfds))
421 {
422 connection_client_open (rptp_fd);
419 if (FD_ISSET(rptp_fd, &rfds))
420 {
421 connection_client_open(rptp_fd);
423422 }
424423 #ifdef OTHER_RPLAY_PORTS
425 if (FD_ISSET (other_rptp_fd, &rfds))
426 {
427 connection_client_open (other_rptp_fd);
428 }
429 #endif
430
431 t = time (0);
424 if (FD_ISSET(other_rptp_fd, &rfds))
425 {
426 connection_client_open(other_rptp_fd);
427 }
428 #endif
429
430 t = time(0);
432431
433432 /* It's not safe to simply traverse the connection list
434433 since connections can be closed during this loop.
449448 break;
450449 }
451450 FD_SET(c->fd, &cmask);
452
451
453452 /* connection has no events */
454453 if (c->event == NULL)
455454 {
459458 /*
460459 * read events
461460 */
462 if (FD_ISSET (c->fd, &rfds))
461 if (FD_ISSET(c->fd, &rfds))
463462 {
464463 c->time = t;
465464
467466 {
468467 case EVENT_READ_SOUND:
469468 restart:
470 n = read (c->fd, c->event->buffer->buf,
471 MIN (c->event->nleft, sizeof (c->event->buffer->buf)));
469 n = read(c->fd, c->event->buffer->buf,
470 MIN(c->event->nleft, sizeof(c->event->buffer->buf)));
472471 if (n < 0 && (errno == EINTR || errno == EAGAIN))
473472 {
474473 goto restart;
475474 }
476475 #ifdef DEBUG
477 report (REPORT_DEBUG, "- %s read %d (%d)\n",
478 inet_ntoa (c->sin.sin_addr),
479 n, c->event->nleft);
476 report(REPORT_DEBUG, "- %s read %d (%d)\n",
477 inet_ntoa(c->sin.sin_addr),
478 n, c->event->nleft);
480479 #endif
481480
482481 if (n <= 0)
483482 {
484 event_update (c);
483 event_update(c);
485484 }
486485 else
487486 {
488487 int r;
489488
490489 restart1:
491 r = write (c->event->fd, c->event->buffer->buf, n);
490 r = write(c->event->fd, c->event->buffer->buf, n);
492491 if (r < 0 && (errno == EINTR || errno == EAGAIN))
493492 {
494493 goto restart1;
498497 if (c->event->nleft == 0)
499498 {
500499 c->event->success++;
501 event_update (c);
500 event_update(c);
502501 }
503502 }
504503 break;
505504
506505 case EVENT_READ_FLOW:
507506 /* Find the spool entry. */
508 sp = spool_find (c->event->id);
507 sp = spool_find(c->event->id);
509508 if (!sp)
510509 {
511 if (c->event->nbytes == -1) /* single-put flow */
510 if (c->event->nbytes == -1) /* single-put flow */
512511 {
513 event_update (c);
512 event_update(c);
514513 break;
515514 }
516
515
517516 /* The spool entry no longer exists. The rest of
518517 this flow must be read -- the next `put' will
519518 fail. */
520 c->event->buffer = buffer_create ();
519 c->event->buffer = buffer_create();
521520 retry:
522 n = read (c->fd, c->event->buffer->buf,
523 MIN (BUFFER_SIZE, c->event->nleft));
521 n = read(c->fd, c->event->buffer->buf,
522 MIN(BUFFER_SIZE, c->event->nleft));
524523 if (n < 0 && (errno == EINTR || errno == EAGAIN))
525524 {
526525 goto retry;
527526 }
528527 #if 0
529 report (REPORT_DEBUG, "eating %d flow bytes (%d), id=#%d\n",
530 n, c->event->nleft, c->event->id);
531 #endif
532 buffer_destroy (c->event->buffer); /* Eat the flow. */
528 report(REPORT_DEBUG, "eating %d flow bytes (%d), id=#%d\n",
529 n, c->event->nleft, c->event->id);
530 #endif
531 buffer_destroy(c->event->buffer); /* Eat the flow. */
533532 c->event->buffer = NULL;
534533 if (n <= 0)
535534 {
536 event_update (c);
535 event_update(c);
537536 break;
538537 }
539538 c->event->nleft -= n;
540539 if (c->event->nleft <= 0)
541540 {
542541 c->event->success++;
543 event_update (c);
542 event_update(c);
544543 break;
545544 }
546545 break;
548547
549548 /* Pause the connection if the high_water_mark has been exceeded. */
550549 if (sp->si
551 && ((sp->si->water_mark - sp->si->offset) > sp->si->high_water_mark))
552 {
553 connection_notify (0, NOTIFY_FLOW, sp);
554 connection_flow_pause (sp);
550 && ((sp->si->water_mark - sp->si->offset) >= sp->si->high_water_mark))
551 {
552 connection_notify(0, NOTIFY_FLOW, sp);
553 connection_flow_pause(sp);
555554 break;
556555 }
557556
558557 /* Read data from the flow. single-put flows will always
559558 try to read BUFFER_SIZE. */
560 c->event->buffer = buffer_create ();
561 redo:
562 n = read (c->fd, c->event->buffer->buf,
563 MIN (BUFFER_SIZE,
564 c->event->nbytes == -1 ? BUFFER_SIZE : c->event->nleft));
559 c->event->buffer = buffer_create();
560
561 /* calculate the number of bytes to read without
562 going over the high_water_mark. */
563 #if 1
564 size = MIN(BUFFER_SIZE,
565 sp->si ? sp->si->high_water_mark - (sp->si->water_mark - sp->si->offset)
566 : BUFFER_SIZE);
567 #else
568 size = MIN(BUFFER_SIZE, c->event->nbytes == -1 ? BUFFER_SIZE : c->event->nleft);
569 #endif
570 redo:
571 n = read(c->fd, c->event->buffer->buf, size);
565572 if (n < 0 && (errno == EINTR || errno == EAGAIN))
566573 {
567574 goto redo;
568575 }
569 #if 0
570 report (REPORT_DEBUG, "- %s flow-read %d\n", inet_ntoa (c->sin.sin_addr), n);
571 #endif
572576 if (n <= 0)
573577 {
574578 /* End of a single-put flow */
575579 if (c->event->nbytes == -1)
576580 {
577 spool_done (sp);
578 connection_close (c);
581 spool_done(sp);
582 connection_close(c);
579583 }
580584 else
581585 {
582 event_update (c);
586 event_update(c);
583587 }
584588 break;
585589 }
586590
587591 /* Add the buffer to the sound's flow. */
588592 c->event->buffer->nbytes = n;
589 if (spool_flow_insert (sp, c->event->buffer) < 0)
590 {
591 c->event->buffer = NULL; /* efence */
593 if (spool_flow_insert(sp, c->event->buffer) < 0)
594 {
595 c->event->buffer = NULL; /* efence */
592596 break;
593597 }
594598 c->event->buffer = NULL;
602606 if (c->event->nbytes != -1 && c->event->nleft <= 0)
603607 {
604608 c->event->success++;
605 event_update (c);
609 event_update(c);
606610 }
607611 break;
608612
609613 case EVENT_NOTIFY:
610614 /* Replace the current notify event with a read_command. */
611 e = event_create (EVENT_READ_COMMAND, buffer_create ());
612 event_replace (c, e);
615 e = event_create(EVENT_READ_COMMAND, buffer_create());
616 event_replace(c, e);
613617 /* fall fall fall */
614618
615619 default:
616620 /* Read a command. */
617621 restart2:
618 n = recv (c->fd, c->event->ptr, c->event->nleft, MSG_PEEK);
622 n = recv(c->fd, c->event->ptr, c->event->nleft, MSG_PEEK);
619623 if (n < 0 && (errno == EINTR || errno == EAGAIN))
620624 {
621625 goto restart2;
622626 }
623627 #if 0
624 report (REPORT_DEBUG, "- %s recv %d (%d)\n",
625 inet_ntoa (c->sin.sin_addr),
626 n, c->event->nleft);
628 report(REPORT_DEBUG, "- %s recv %d (%d)\n",
629 inet_ntoa(c->sin.sin_addr),
630 n, c->event->nleft);
627631 #endif
628632 if (n <= 0)
629633 {
630 event_update (c);
634 event_update(c);
631635 }
632636 else
633637 {
648652 }
649653 }
650654 restart3:
651 n = read (c->fd, buf, i == n ? n : i + 1);
655 n = read(c->fd, buf, i == n ? n : i + 1);
652656 if (n < 0 && (errno == EINTR || errno == EAGAIN))
653657 {
654658 goto restart3;
656660 if (n <= 0)
657661 {
658662 c->event->success = 0;
659 event_update (c);
663 event_update(c);
660664 }
661665 else
662666 {
663667 c->event->ptr += n;
664668 c->event->nleft -= n;
665 if (c->event->success || c->event->nleft == 0)
666 {
667 event_update (c);
668 }
669 if (c->event->success || c->event->nleft == 0)
670 {
671 event_update(c);
672 }
669673 }
670674 }
671675 break;
674678 /*
675679 * write events
676680 */
677 else if (FD_ISSET (c->fd, &wfds))
681 else if (FD_ISSET(c->fd, &wfds))
678682 {
679683 c->time = t;
680684
681685 switch (c->event->type)
682686 {
683687 case EVENT_CONNECT:
684 event_update (c);
688 event_update(c);
685689 break;
686690
687691 default:
688 again:
689 n = write (c->fd, c->event->ptr, c->event->nleft);
690 #ifdef DEBUG
691 report (REPORT_DEBUG, "- %s write %d (%d)\n",
692 inet_ntoa (c->sin.sin_addr), n,
693 c->event->nleft);
692 again:
693 n = write(c->fd, c->event->ptr, c->event->nleft);
694 #if 0
695 report(REPORT_DEBUG, "- %s write %d (%d)\n",
696 inet_ntoa(c->sin.sin_addr), n,
697 c->event->nleft);
694698 #endif
695699 if (n <= 0)
696700 {
698702 {
699703 goto again;
700704 }
701 event_update (c);
705 event_update(c);
702706 }
703707 else
704708 {
709713 {
710714 if (c->event->type == EVENT_WRITE_SOUND)
711715 {
712 n = sound_fill (c->event->si, c->event->buffer, 1);
716 n = sound_fill(c->event->si, c->event->buffer, 1);
713717 if (n > 0)
714718 {
715719 c->event->nleft = c->event->buffer->nbytes;
718722 }
719723 else
720724 {
721 sound_close (c->event->si);
722 c->event->si = NULL; /* efence */
725 sound_close(c->event->si);
726 c->event->si = NULL; /* efence */
723727 c->event->success++;
724 event_update (c);
728 event_update(c);
725729 }
726730 }
727731 else
728732 {
729733 c->event->success++;
730 event_update (c);
734 event_update(c);
731735 }
732736 }
733737 }
742746 */
743747 #ifdef __STDC__
744748 void
745 connection_close (CONNECTION *c)
746 #else
747 void
748 connection_close (c)
749 connection_close(CONNECTION *c)
750 #else
751 void
752 connection_close(c)
749753 CONNECTION *c;
750754 #endif
751755 {
756760 switch (c->type)
757761 {
758762 case CONNECTION_CLIENT:
759 report (REPORT_NOTICE, "%s client connection closed\n", inet_ntoa (c->sin.sin_addr));
763 report(REPORT_NOTICE, "%s client connection closed\n", inet_ntoa(c->sin.sin_addr));
760764 break;
761765
762766 case CONNECTION_SERVER:
763 report (REPORT_NOTICE, "%s server connection closed\n", inet_ntoa (c->sin.sin_addr));
764 break;
765 }
766
767 FD_CLR (c->fd, &read_mask);
768 FD_CLR (c->fd, &write_mask);
769
770 close (c->fd);
767 report(REPORT_NOTICE, "%s server connection closed\n", inet_ntoa(c->sin.sin_addr));
768 break;
769 }
770
771 FD_CLR(c->fd, &read_mask);
772 FD_CLR(c->fd, &write_mask);
773
774 if (c->monitor)
775 {
776 monitor_count--;
777 }
778
779 close(c->fd);
771780
772781 /*
773782 * destroy any events that are left
782791 case EVENT_WRITE_GET:
783792 case EVENT_READ_GET_REPLY:
784793 case EVENT_READ_SOUND:
785 spool_remove (e->sound);
786 sound_delete (e->sound, 1);
794 spool_remove(e->sound);
795 sound_delete(e->sound, 1);
787796 break;
788797
789798 case EVENT_READ_FLOW:
791800 case EVENT_PIPE_FLOW:
792801 /* Dunno if this should happen: */
793802 #if 0
794 sp = spool_find (e->id);
803 sp = spool_find(e->id);
795804 s = sp->sound[sp->curr_sound];
796 spool_remove (s);
797 sound_delete (s, 0);
805 spool_remove(s);
806 sound_delete(s, 0);
798807 #endif
799808 break;
800809 }
801 event_destroy (e);
810 event_destroy(e);
802811 }
803812
804813 c->event = NULL;
805814 c->ep = &c->event;
806815
807 connection_destroy (c);
816 connection_destroy(c);
808817 }
809818
810819 /*
812821 */
813822 #ifdef __STDC__
814823 void
815 connection_update_fdset (CONNECTION *c)
816 #else
817 void
818 connection_update_fdset (c)
824 connection_update_fdset(CONNECTION *c)
825 #else
826 void
827 connection_update_fdset(c)
819828 CONNECTION *c;
820829 #endif
821830 {
822 FD_CLR (c->fd, &read_mask);
823 FD_CLR (c->fd, &write_mask);
831 FD_CLR(c->fd, &read_mask);
832 FD_CLR(c->fd, &write_mask);
824833
825834 if (c->event == NULL)
826835 {
836845 case EVENT_READ_GET_REPLY:
837846 case EVENT_NOTIFY:
838847 case EVENT_READ_FLOW:
839 FD_SET (c->fd, &read_mask);
848 case EVENT_WAIT_MONITOR:
849 FD_SET(c->fd, &read_mask);
840850 break;
841851
842852 case EVENT_WRITE:
845855 case EVENT_WRITE_GET:
846856 case EVENT_CONNECT:
847857 case EVENT_WRITE_TIMEOUT:
848 FD_SET (c->fd, &write_mask);
858 case EVENT_WRITE_MONITOR:
859 FD_SET(c->fd, &write_mask);
849860 break;
850861
851862 case EVENT_WAIT_FLOW:
854865 break;
855866
856867 default:
857 report (REPORT_ERROR, "connection_update_fdset: unknown event type '%d'\n", c->event->type);
858 done (1);
868 report(REPORT_ERROR, "connection_update_fdset: unknown event type '%d'\n", c->event->type);
869 done(1);
859870 }
860871 }
861872
864875 */
865876 #ifdef __STDC__
866877 void
867 connection_reply (CONNECTION *c, char *fmt,...)
868 #else
869 void
870 connection_reply (va_alist)
878 connection_reply(CONNECTION *c, char *fmt,...)
879 #else
880 void
881 connection_reply(va_alist)
871882 va_dcl
872883 #endif
873884 {
876887 BUFFER *b;
877888
878889 #ifdef __STDC__
879 va_start (args, fmt);
890 va_start(args, fmt);
880891 #else
881892 CONNECTION *c;
882893 char *fmt;
883 va_start (args);
884 c = va_arg (args, CONNECTION *);
885 fmt = va_arg (args, char *);
886 #endif
887
888 b = buffer_create ();
889
890 VSNPRINTF (SIZE(b->buf,BUFFER_SIZE), fmt, args);
891 va_end (args);
892 SNPRINTF (SIZE(b->buf+strlen(b->buf),BUFFER_SIZE), "\r\n");
893 b->nbytes += strlen (b->buf);
894
895 e = event_create (EVENT_WRITE, b);
896 event_first (c, e);
894 va_start(args);
895 c = va_arg(args, CONNECTION *);
896 fmt = va_arg(args, char *);
897 #endif
898
899 b = buffer_create();
900
901 VSNPRINTF(SIZE(b->buf, BUFFER_SIZE), fmt, args);
902 va_end(args);
903 b->nbytes = strlen(b->buf);
904 SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), "\r\n");
905 b->nbytes += 2;
906
907 e = event_create(EVENT_WRITE, b);
908 event_first(c, e);
897909 }
898910
899911 /*
900912 * close all connections
901913 */
902914 void
903 connection_cleanup ()
915 connection_cleanup()
904916 {
905917 CONNECTION *c, *c_next;
906918
907919 for (c = connections; c; c = c_next)
908920 {
909921 c_next = c->next;
910 connection_close (c);
922 connection_close(c);
911923 }
912924 }
913925
915927 * Check all connections to see if rplayd can enter idle mode.
916928 */
917929 int
918 connection_idle ()
930 connection_idle()
919931 {
920932 CONNECTION *c;
921933 int idle = 1;
922934
923935 for (c = connections; c && idle; c = c->next)
924936 {
925 if (c->event && c->event->type != EVENT_NOTIFY)
937 if (c->event && c->event->type != EVENT_NOTIFY
938 && !c->monitor)
926939 {
927940 idle = 0;
928941 }
935948 * timeout all idle connections
936949 */
937950 void
938 connection_check_timeout ()
951 connection_check_timeout()
939952 {
940953 time_t t;
941954 CONNECTION *c, *next;
945958 return;
946959 }
947960
948 t = time (0);
961 t = time(0);
949962 for (c = connections; c; c = next)
950963 {
951964 next = c->next;
952965 if (t - c->time >= rptp_timeout)
953966 {
954 connection_timeout (c);
967 connection_timeout(c);
955968 }
956969 }
957970 }
961974 */
962975 #ifdef __STDC__
963976 void
964 connection_timeout (CONNECTION *c)
965 #else
966 void
967 connection_timeout (c)
977 connection_timeout(CONNECTION *c)
978 #else
979 void
980 connection_timeout(c)
968981 CONNECTION *c;
969982 #endif
970983 {
979992 switch (c->event->type)
980993 {
981994 case EVENT_NOTIFY:
995 case EVENT_WAIT_MONITOR:
982996 return;
983997 }
984998 }
985999
9861000 if (c->type == CONNECTION_SERVER)
9871001 {
988 report (REPORT_DEBUG, "%s server connection timeout\n", inet_ntoa (c->sin.sin_addr));
989 connection_close (c);
1002 report(REPORT_DEBUG, "%s server connection timeout\n", inet_ntoa(c->sin.sin_addr));
1003 connection_close(c);
9901004 }
9911005 else
9921006 {
993 b = buffer_create ();
994 SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "%cmessage=\"Connection timed out after %d idle seconds.\"\r\n",
995 RPTP_TIMEOUT, rptp_timeout);
996 b->nbytes += strlen (b->buf);
997 e = event_create (EVENT_WRITE_TIMEOUT, b);
998 event_replace (c, e);
1007 b = buffer_create();
1008 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "%cmessage=\"Connection timed out after %d idle seconds.\"\r\n",
1009 RPTP_TIMEOUT, rptp_timeout);
1010 b->nbytes += strlen(b->buf);
1011 e = event_create(EVENT_WRITE_TIMEOUT, b);
1012 event_replace(c, e);
9991013 }
10001014 }
10011015
10041018 */
10051019 #ifdef __STDC__
10061020 void
1007 connection_server_forward_sound (CONNECTION *c, SOUND *s)
1008 #else
1009 void
1010 connection_server_forward_sound (c, s)
1021 connection_server_forward_sound(CONNECTION *c, SOUND *s)
1022 #else
1023 void
1024 connection_server_forward_sound(c, s)
10111025 CONNECTION *c;
10121026 SOUND *s;
10131027 #endif
10161030
10171031 if (c->server->next)
10181032 {
1019 server = connection_server_open (c->server->next, s);
1033 server = connection_server_open(c->server->next, s);
10201034 }
10211035 else
10221036 {
1023 spool_remove (s);
1024 sound_delete (s, 1);
1037 spool_remove(s);
1038 sound_delete(s, 1);
10251039 }
10261040 }
10271041
10301044 */
10311045 #ifdef __STDC__
10321046 void
1033 connection_server_forward (CONNECTION *c)
1034 #else
1035 void
1036 connection_server_forward (c)
1047 connection_server_forward(CONNECTION *c)
1048 #else
1049 void
1050 connection_server_forward(c)
10371051 CONNECTION *c;
10381052 #endif
10391053 {
10421056
10431057 if (c->server->next)
10441058 {
1045 server = connection_server_open (c->server->next, NULL);
1046 event_insert (server, c->event);
1059 server = connection_server_open(c->server->next, NULL);
1060 event_insert(server, c->event);
10471061 }
10481062 else
10491063 {
10571071 case EVENT_WRITE_GET:
10581072 case EVENT_READ_GET_REPLY:
10591073 case EVENT_READ_SOUND:
1060 spool_remove (e->sound);
1061 sound_delete (e->sound, 1);
1074 spool_remove(e->sound);
1075 sound_delete(e->sound, 1);
10621076 break;
10631077 }
1064 event_destroy (e);
1078 event_destroy(e);
10651079 }
10661080 }
10671081 c->event = NULL;
10691083 }
10701084
10711085 BUFFER *
1072 connection_list_create ()
1086 connection_list_create()
10731087 {
10741088 CONNECTION *c;
10751089 BUFFER *b, *connection_list;
1090 char line[RPTP_MAX_LINE];
10761091 char buf[RPTP_MAX_LINE];
1077 int n;
1092 int n, length;
10781093 time_t t;
10791094
1080 b = buffer_create ();
1095 b = buffer_create();
10811096 connection_list = b;
1082 SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "+message=\"connections\"\r\n");
1083 b->nbytes += strlen (b->buf);
1084
1085 t = time (0);
1097 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "+message=\"connections\"\r\n");
1098 b->nbytes += strlen(b->buf);
1099
1100 t = time(0);
10861101
10871102 for (c = connections; c; c = c->next)
10881103 {
1089 SNPRINTF (SIZE(buf,sizeof(buf)), "host=%s", inet_ntoa (c->sin.sin_addr));
1090 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), " type=");
1104 length = 0;
1105 line[0] = '\0';
1106
1107 SNPRINTF(SIZE(buf, sizeof(buf)), "host=%s", inet_ntoa(c->sin.sin_addr));
1108 strncat(line + length, buf, sizeof(line) - length);
1109 length += strlen(buf);
1110
1111 SNPRINTF(SIZE(buf, sizeof(buf)), " type=");
1112 strncat(line + length, buf, sizeof(line) - length);
1113 length += strlen(buf);
1114
1115 buf[0] = '\0';
10911116 switch (c->type)
10921117 {
10931118 case CONNECTION_SERVER:
1094 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "server");
1119 SNPRINTF(SIZE(buf, sizeof(buf)), "server");
10951120 break;
10961121
10971122 case CONNECTION_CLIENT:
1098 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "client");
1123 SNPRINTF(SIZE(buf, sizeof(buf)), "client");
10991124 break;
11001125 }
1126 strncat(line + length, buf, sizeof(line) - length);
1127 length += strlen(buf);
11011128
11021129 if (c->event != NULL)
11031130 {
1104 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), " what=");
1131 SNPRINTF(SIZE(buf, sizeof(buf)), " what=");
1132 strncat(line + length, buf, sizeof(line) - length);
1133 length += strlen(buf);
1134
1135 buf[0] = '\0';
11051136 switch (c->event->type)
11061137 {
11071138 case EVENT_READ_COMMAND:
1108 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "idle");
1139 SNPRINTF(SIZE(buf, sizeof(buf)), "idle");
11091140 break;
11101141
11111142 case EVENT_CONNECT:
11121143 case EVENT_READ_CONNECT_REPLY:
1113 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "connect");
1144 SNPRINTF(SIZE(buf, sizeof(buf)), "connect");
11141145 break;
11151146
11161147 case EVENT_WRITE_FIND:
11171148 case EVENT_READ_FIND_REPLY:
1118 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"find %s\"", c->event->sound->name);
1149 SNPRINTF(SIZE(buf, sizeof(buf)), "\"find %s\"", c->event->sound->name);
11191150 break;
11201151
11211152 case EVENT_WRITE_GET:
11221153 case EVENT_READ_GET_REPLY:
1123 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"get %s\"", c->event->sound->name);
1154 SNPRINTF(SIZE(buf, sizeof(buf)), "\"get %s\"", c->event->sound->name);
11241155 break;
11251156
11261157 case EVENT_READ_SOUND:
11271158 if (c->type == CONNECTION_SERVER)
1128 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"get %s (%d/%d)\"",
1129 c->event->sound->name,
1130 c->event->byte_offset,
1131 c->event->nbytes);
1159 SNPRINTF(SIZE(buf, sizeof(buf)), "\"get %s (%d/%d)\"",
1160 c->event->sound->name,
1161 c->event->byte_offset,
1162 c->event->nbytes);
11321163 else
1133 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"put %s (%d/%d)\"",
1134 c->event->sound->name,
1135 c->event->byte_offset,
1136 c->event->nbytes);
1164 SNPRINTF(SIZE(buf, sizeof(buf)), "\"put %s (%d/%d)\"",
1165 c->event->sound->name,
1166 c->event->byte_offset,
1167 c->event->nbytes);
11371168 break;
11381169
11391170 case EVENT_WRITE:
1140 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "write");
1171 SNPRINTF(SIZE(buf, sizeof(buf)), "write");
11411172 break;
11421173
11431174 case EVENT_WRITE_SOUND:
1144 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"get %s (%d/%d)\"",
1145 c->event->sound->name,
1146 c->event->byte_offset,
1147 c->event->nbytes);
1175 SNPRINTF(SIZE(buf, sizeof(buf)), "\"get %s (%d/%d)\"",
1176 c->event->sound->name,
1177 c->event->byte_offset,
1178 c->event->nbytes);
11481179 break;
11491180
11501181 case EVENT_NOTIFY:
11511182 if (c->notify_mask)
1152 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"notify %08x\"", c->notify_mask);
1183 SNPRINTF(SIZE(buf, sizeof(buf)), "\"notify %08x\"",
1184 c->notify_mask);
11531185 else
1154 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"wait %08x\"", c->event->wait_mask);
1186 SNPRINTF(SIZE(buf, sizeof(buf)), "\"wait %08x\"",
1187 c->event->wait_mask);
11551188 break;
11561189
11571190 case EVENT_READ_FLOW:
11581191 case EVENT_WAIT_FLOW:
1159 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"put #%d (%d/%d)\"",
1160 c->event->id,
1161 c->event->byte_offset,
1162 c->event->nbytes);
1192 SNPRINTF(SIZE(buf, sizeof(buf)), "\"put #%d (%d/%d)\"",
1193 c->event->id,
1194 c->event->byte_offset,
1195 c->event->nbytes);
11631196 break;
11641197
11651198 case EVENT_PIPE_FLOW:
1166 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"pipe #%d\"",
1167 c->event->id);
1199 SNPRINTF(SIZE(buf, sizeof(buf)), "\"pipe #%d\"",
1200 c->event->id);
11681201 break;
11691202 }
1203 strncat(line + length, buf, sizeof(line) - length);
1204 length += strlen(buf);
11701205 }
11711206
11721207 if (t - c->time)
11731208 {
1174 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), " idle=%s", time2string (t - c->time));
1209 SNPRINTF(SIZE(buf, sizeof(buf)), " idle=%s", time2string(t - c->time));
1210 strncat(line + length, buf, sizeof(line) - length);
1211 length += strlen(buf);
11751212 }
11761213
11771214 if (c->application)
11781215 {
1179 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), " application=\"%s\"", c->application);
1180 }
1181
1182 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "\r\n");
1183
1184 n = strlen (buf);
1185 if (b->nbytes + n > BUFFER_SIZE)
1186 {
1187 b->next = buffer_create ();
1216 SNPRINTF(SIZE(buf, sizeof(buf)), " application=\"%s\"", c->application);
1217 strncat(line + length, buf, sizeof(line) - length);
1218 length += strlen(buf);
1219 }
1220
1221 SNPRINTF(SIZE(buf, sizeof(buf)), "\r\n");
1222 strncat(line + length, buf, sizeof(line) - length);
1223 length += strlen(buf);
1224
1225 if (b->nbytes + length > BUFFER_SIZE)
1226 {
1227 b->next = buffer_create();
11881228 b = b->next;
11891229 }
1190 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), buf);
1191 b->nbytes += n;
1230
1231 strncat(b->buf + b->nbytes, line, BUFFER_SIZE - b->nbytes);
1232 b->nbytes += length;
11921233 }
11931234
11941235 if (b->nbytes + 3 > BUFFER_SIZE)
11951236 {
1196 b->next = buffer_create ();
1237 b->next = buffer_create();
11971238 b = b->next;
11981239 }
1199 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n");
1240
1241 strncat(b->buf + b->nbytes, ".\r\n", BUFFER_SIZE - b->nbytes);
12001242 b->nbytes += 3;
12011243
12021244 return connection_list;
12041246
12051247 #ifdef __STDC__
12061248 void
1207 connection_notify (CONNECTION *notify_connection, int notify_event,...)
1208 #else
1209 void
1210 connection_notify (va_alist)
1249 connection_notify(CONNECTION *notify_connection, int notify_event,...)
1250 #else
1251 void
1252 connection_notify(va_alist)
12111253 va_dcl
12121254 #endif
12131255 {
12241266 va_list args;
12251267
12261268 #ifdef __STDC__
1227 va_start (args, notify_event);
1269 va_start(args, notify_event);
12281270 #else
12291271 CONNECTION *notify_connection;
12301272 int notify_event;
1231 va_start (args);
1232 notify_connection = va_arg (args, CONNECTION *);
1233 notify_event = va_arg (args, int);
1273 va_start(args);
1274 notify_connection = va_arg(args, CONNECTION *);
1275 notify_event = va_arg(args, int);
12341276 #endif
12351277
12361278 /* Extract event parameters. */
12371279 switch (notify_event)
12381280 {
12391281 case NOTIFY_VOLUME: /* (int) */
1240 new_volume = va_arg (args, int);
1282 new_volume = va_arg(args, int);
12411283 break;
12421284
12431285 case NOTIFY_PLAY: /* (SPOOL *) */
12491291 case NOTIFY_FLOW:
12501292 case NOTIFY_MODIFY:
12511293 case NOTIFY_POSITION:
1252 sp = va_arg (args, SPOOL *);
1294 sp = va_arg(args, SPOOL *);
12531295 break;
12541296
12551297 case NOTIFY_STATE: /* none */
12561298 break;
1257
1299
12581300 case NOTIFY_LEVEL: /* int */
1259 force_notify = va_arg (args, int);
1260 break;
1261 }
1262
1263 va_end (args);
1264
1265 t = time (0);
1301 force_notify = va_arg(args, int);
1302 break;
1303 }
1304
1305 va_end(args);
1306
1307 t = time(0);
12661308
12671309 c = notify_connection ? notify_connection : connections;
12681310 for (; c; c = c->next)
12721314 break;
12731315 }
12741316
1275 if (BIT (c->notify_mask, notify_event)
1276 || (c->event && BIT (c->event->wait_mask, notify_event)))
1277 {
1278 strcpy (buf, "?event=");
1317 if (BIT(c->notify_mask, notify_event)
1318 || (c->event && BIT(c->event->wait_mask, notify_event)))
1319 {
1320 strcpy(buf, "?event=");
1321 length = strlen(buf);
12791322
12801323 switch (notify_event)
12811324 {
12881331 {
12891332 n--;
12901333 }
1291 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "done id=#%d sound=\"%s\" client-data=\"%s\"",
1292 sp->id, sp->sound[n]->name, sp->curr_attrs->client_data);
1334 SNPRINTF(SIZE(buf + length, sizeof(buf) - length),
1335 "done id=#%d sound=\"%s\" client-data=\"%s\"",
1336 sp->id, sp->sound[n]->name, sp->curr_attrs->client_data);
12931337 }
12941338 else
12951339 {
12981342 break;
12991343
13001344 case NOTIFY_VOLUME:
1301 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "volume volume=%d",
1345 SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "volume volume=%d",
13021346 new_volume);
13031347 break;
13041348
13071351 || (c->event && c->event->id == sp->id))
13081352 {
13091353 SOUND *s = sp->sound[sp->curr_sound];
1310
1311 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "play\
1354
1355 SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "play\
13121356 id=#%d sound=\"%s\" host=%s volume=%d priority=%d count=%d seconds=%.2f size=%d\
13131357 sample-rate=%d channels=%d bits=%g input=%s client-data=\"%s\"",
13141358 sp->id,
13151359 sp->curr_attrs->sound,
1316 inet_ntoa (sp->sin.sin_addr),
1360 inet_ntoa(sp->sin.sin_addr),
13171361 sp->curr_attrs->volume,
13181362 sp->rp->priority,
13191363 sp->curr_attrs->count,
13221366 sp->sample_rate,
13231367 s->channels,
13241368 s->input_precision,
1325 input_to_string (s->type),
1369 input_to_string(s->type),
13261370 sp->curr_attrs->client_data);
13271371 }
13281372 else
13351379 if ((!c->notify_id || c->notify_id == sp->id)
13361380 || (c->event && c->event->id == sp->id))
13371381 {
1338 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "stop id=#%d sound=\"%s\" client-data=\"%s\"",
1382 SNPRINTF(SIZE(buf + length, sizeof(buf) - length),
1383 "stop id=#%d sound=\"%s\" client-data=\"%s\"",
13391384 sp->id, sp->curr_attrs->sound, sp->curr_attrs->client_data);
13401385 }
13411386 else
13481393 if ((!c->notify_id || c->notify_id == sp->id)
13491394 || (c->event && c->event->id == sp->id))
13501395 {
1351 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "pause id=#%d sound=\"%s\" client-data=\"%s\"",
1396 SNPRINTF(SIZE(buf + length, sizeof(buf) - length),
1397 "pause id=#%d sound=\"%s\" client-data=\"%s\"",
13521398 sp->id, sp->curr_attrs->sound, sp->curr_attrs->client_data);
13531399 }
13541400 else
13611407 if ((!c->notify_id || c->notify_id == sp->id)
13621408 || (c->event && c->event->id == sp->id))
13631409 {
1364 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "continue id=#%d sound=\"%s\" client-data=\"%s\"",
1410 SNPRINTF(SIZE(buf + length, sizeof(buf) - length),
1411 "continue id=#%d sound=\"%s\" client-data=\"%s\"",
13651412 sp->id, sp->curr_attrs->sound, sp->curr_attrs->client_data);
13661413 }
13671414 else
13741421 if ((!c->notify_id || c->notify_id == sp->id)
13751422 || (c->event && c->event->id == sp->id))
13761423 {
1377 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "skip id=#%d sound=\"%s\" client-data=\"%s\"",
1424 SNPRINTF(SIZE(buf + length, sizeof(buf) - length),
1425 "skip id=#%d sound=\"%s\" client-data=\"%s\"",
13781426 sp->id, sp->curr_attrs->sound, sp->curr_attrs->client_data);
13791427 }
13801428 else
13841432 break;
13851433
13861434 case NOTIFY_STATE:
1387 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\
1388 state play=%d pause=%d volume=%d priority-threshold=%d audio-port=%s",
1435 SNPRINTF(SIZE(buf + length, sizeof(buf) - length),
1436 "state play=%d pause=%d volume=%d priority-threshold=%d audio-port=%s",
13891437 spool_nplaying, spool_npaused,
13901438 rplay_audio_volume, rplay_priority_threshold,
1391 audio_port_to_string (rplay_audio_port));
1439 audio_port_to_string(rplay_audio_port));
13921440 break;
13931441
13941442 case NOTIFY_FLOW:
13951443 if ((!c->notify_id || c->notify_id == sp->id)
13961444 || (c->event && c->event->id == sp->id))
13971445 {
1398 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\
1399 flow id=#%d sound=\"%s\" mark=%d low=%d high=%d client-data=\"%s\"",
1446 SNPRINTF(SIZE(buf + length, sizeof(buf) - length),
1447 "flow id=#%d sound=\"%s\" mark=%d low=%d high=%d client-data=\"%s\"",
14001448 sp->id,
14011449 sp->curr_attrs->sound,
14021450 sp->si->water_mark - sp->si->offset,
14141462 if ((!c->notify_id || c->notify_id == sp->id)
14151463 || (c->event && c->event->id == sp->id))
14161464 {
1417 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "modify \
1465 SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "modify \
14181466 id=#%d count=%d list-count=%d priority=%d sample-rate=%d volume=%d client-data=\"%s\"",
14191467 sp->id,
14201468 sp->curr_count,
14341482 if (c->notify_rate[NOTIFY_RATE_LEVEL].rate)
14351483 {
14361484 if (!force_notify
1437 && c->notify_rate[NOTIFY_RATE_LEVEL].next > timer_count)
1485 && c->notify_rate[NOTIFY_RATE_LEVEL].next > timer_count)
14381486 {
14391487 continue;
14401488 }
1441
1489
14421490 c->notify_rate[NOTIFY_RATE_LEVEL].next =
14431491 timer_count + c->notify_rate[NOTIFY_RATE_LEVEL].rate;
14441492 }
1445
1446 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "level volume=%d left=%d right=%d",
1493
1494 SNPRINTF(SIZE(buf + length, sizeof(buf) - length),
1495 "level volume=%d left=%d right=%d",
14471496 rplay_audio_volume,
1448 rplay_audio_left_level,
1497 rplay_audio_left_level,
14491498 rplay_audio_right_level);
14501499 break;
1451
1500
14521501 case NOTIFY_POSITION:
14531502 if ((!c->notify_id || c->notify_id == sp->id)
14541503 || (c->event && c->event->id == sp->id))
14611510 {
14621511 continue;
14631512 }
1464
1513
14651514 c->notify_rate[NOTIFY_RATE_POSITION].next =
14661515 timer_count + c->notify_rate[NOTIFY_RATE_POSITION].rate;
14671516 }
1468
1469 SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "position \
1517
1518 SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "position \
14701519 id=#%d position=%.2f remain=%.2f seconds=%.2f sample=%d samples=%d client-data=\"%s\"",
14711520 sp->id,
14721521 sp->sample_rate && s->samples ? sp->sample_index / sp->sample_rate : 0,
14821531 }
14831532 }
14841533
1485 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "\r\n");
1486 length = strlen (buf);
1534 length = strlen(buf);
1535 SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "\r\n");
1536 length = strlen(buf);
14871537
14881538 /* Build the head array with the necessary RPTP headers. */
14891539 n = 0;
1490 if (c->event && BIT (c->event->wait_mask, notify_event))
1540 if (c->event && BIT(c->event->wait_mask, notify_event))
14911541 {
14921542 head[n++] = RPTP_OK;
14931543 }
1494 if (BIT (c->notify_mask, notify_event))
1544 if (BIT(c->notify_mask, notify_event))
14951545 {
14961546 head[n++] = RPTP_NOTIFY;
14971547 }
15091559 if (e && e->type == EVENT_WRITE
15101560 && e->buffer->nbytes + length <= BUFFER_SIZE)
15111561 {
1512 strcpy (e->buffer->buf + e->buffer->nbytes, buf);
1562 strcpy(e->buffer->buf + e->buffer->nbytes, buf);
15131563 e->buffer->nbytes += length;
15141564 e->nbytes += length;
15151565 e->nleft += length;
15161566 }
15171567 else
15181568 {
1519 b = buffer_create ();
1520 strcpy (b->buf + b->nbytes, buf);
1569 b = buffer_create();
1570 strcpy(b->buf + b->nbytes, buf);
15211571 b->nbytes += length;
1522 e = event_create (EVENT_WRITE, b);
1572 e = event_create(EVENT_WRITE, b);
15231573 if (c->event && c->event->type == EVENT_NOTIFY)
15241574 {
1525 event_replace (c, e);
1575 event_replace(c, e);
15261576 }
15271577 else
15281578 {
1529 event_insert_before (c, e,
1530 EVENT_READ_COMMAND
1531 |EVENT_READ_SOUND
1532 |EVENT_READ_CONNECT_REPLY
1533 |EVENT_READ_FIND_REPLY
1534 |EVENT_READ_GET_REPLY
1535 |EVENT_READ_FLOW
1536 |EVENT_WAIT_FLOW
1537 |EVENT_PIPE_FLOW);
1579 event_insert_before(c, e,
1580 EVENT_READ_COMMAND
1581 | EVENT_READ_SOUND
1582 | EVENT_READ_CONNECT_REPLY
1583 | EVENT_READ_FIND_REPLY
1584 | EVENT_READ_GET_REPLY
1585 | EVENT_READ_FLOW
1586 | EVENT_WAIT_FLOW
1587 | EVENT_PIPE_FLOW);
15381588 }
15391589 }
15401590 }
15571607 prev_pause = spool_npaused;
15581608 prev_volume = rplay_audio_volume;
15591609 /* Recursion is your friend. */
1560 connection_notify (notify_connection, NOTIFY_STATE);
1610 connection_notify(notify_connection, NOTIFY_STATE);
15611611 }
15621612 break;
15631613
15681618
15691619 #ifdef __STDC__
15701620 void
1571 connection_flow_pause (SPOOL *sp)
1572 #else
1573 void
1574 connection_flow_pause (sp)
1621 connection_flow_pause(SPOOL *sp)
1622 #else
1623 void
1624 connection_flow_pause(sp)
15751625 SPOOL *sp;
15761626 #endif
15771627 {
15871637 e->type = EVENT_WAIT_FLOW;
15881638 if (c->event == e)
15891639 {
1590 connection_update_fdset (c);
1640 connection_update_fdset(c);
15911641 }
15921642 break;
15931643 }
15971647
15981648 #ifdef __STDC__
15991649 void
1600 connection_flow_continue (SPOOL *sp)
1601 #else
1602 void
1603 connection_flow_continue (sp)
1650 connection_flow_continue(SPOOL *sp)
1651 #else
1652 void
1653 connection_flow_continue(sp)
16041654 SPOOL *sp;
16051655 #endif
16061656 {
16071657 CONNECTION *c;
16081658 EVENT *e;
1609
1659
16101660 for (c = connections; c; c = c->next)
16111661 {
16121662 for (e = c->event; e; e = e->next)
16161666 e->type = EVENT_READ_FLOW;
16171667 if (c->event == e)
16181668 {
1619 connection_update_fdset (c);
1669 connection_update_fdset(c);
16201670 }
16211671 break;
16221672 }
16261676
16271677 #ifdef __STDC__
16281678 void
1629 event_update (CONNECTION *c)
1630 #else
1631 void
1632 event_update (c)
1679 connection_monitor_pause(CONNECTION *c)
1680 #else
1681 void
1682 connection_monitor_pause(c)
1683 CONNECTION *c;
1684 #endif
1685 {
1686 if (c->event && c->event->type == EVENT_WRITE_MONITOR)
1687 {
1688 c->event->type = EVENT_WAIT_MONITOR;
1689 connection_update_fdset(c);
1690 }
1691 }
1692
1693 void
1694 connection_monitor_continue()
1695 {
1696 CONNECTION *c;
1697 EVENT *e;
1698
1699 for (c = connections; c; c = c->next)
1700 {
1701 for (e = c->event; e; e = e->next)
1702 {
1703 if (e->type == EVENT_WAIT_MONITOR)
1704 {
1705 e->type = EVENT_WRITE_MONITOR;
1706 if (c->event == e)
1707 {
1708 connection_update_fdset(c);
1709 }
1710 break;
1711 }
1712 }
1713 }
1714 }
1715
1716 #ifdef __STDC__
1717 void
1718 event_update(CONNECTION *c)
1719 #else
1720 void
1721 event_update(c)
16331722 CONNECTION *c;
16341723 #endif
16351724 {
16511740 if (c->event->success)
16521741 {
16531742 if (c->event->start[0] != '\0'
1654 && isascii (c->event->start[0]))
1743 && isascii(c->event->start[0]))
16551744 {
1656 b = c->event->buffer; /* save the event's buffer */
1745 b = c->event->buffer; /* save the event's buffer */
16571746 c->event->buffer = NULL;
1658 event_delete (c, 0);
1659
1660 if (command (c, b->buf) != 0)
1661 {
1662 connection_close (c);
1663 }
1664 buffer_destroy (b);
1747 event_delete(c, 0);
1748
1749 if (command(c, b->buf) != 0)
1750 {
1751 connection_close(c);
1752 }
1753 buffer_destroy(b);
16651754 }
16661755 else
16671756 {
1668 event_delete (c, 1);
1757 event_delete(c, 1);
16691758 }
16701759 }
16711760 else
16721761 {
1673 connection_close (c);
1762 connection_close(c);
16741763 }
16751764 break;
16761765
16781767 /*
16791768 * check the time to delay between connect attempts
16801769 */
1681 t = time (0);
1770 t = time(0);
16821771 if (t - c->event->time < RPTP_PING_DELAY)
16831772 {
16841773 break;
16881777 /*
16891778 * check the socket to see if it is connected
16901779 */
1691 n = connect (c->fd, (struct sockaddr *) &c->server->sin, sizeof (c->server->sin));
1780 n = connect(c->fd, (struct sockaddr *) &c->server->sin, sizeof(c->server->sin));
16921781 if (n == 0 || errno == EISCONN)
16931782 {
16941783 /*
16951784 * got a connection
16961785 */
1697 report (REPORT_NOTICE, "%s server connection established\n", inet_ntoa (c->server->sin.sin_addr));
1786 report(REPORT_NOTICE, "%s server connection established\n", inet_ntoa(c->server->sin.sin_addr));
16981787 /*
16991788 * prepare to read the connect reply, this must replace the
17001789 * connect event
17011790 */
1702 e = event_create (EVENT_READ_CONNECT_REPLY, buffer_create ());
1703 event_replace (c, e);
1791 e = event_create(EVENT_READ_CONNECT_REPLY, buffer_create());
1792 event_replace(c, e);
17041793 }
17051794 else
17061795 {
17081797 * socket is not connected
17091798 */
17101799 c->event->nconnects++;
1711 report (REPORT_DEBUG, "%s server connection failed attempt #%d\n",
1712 inet_ntoa (c->server->sin.sin_addr),
1713 c->event->nconnects);
1800 report(REPORT_DEBUG, "%s server connection failed attempt #%d\n",
1801 inet_ntoa(c->server->sin.sin_addr),
1802 c->event->nconnects);
17141803 if (c->event->nconnects < RPTP_CONNECT_ATTEMPTS)
17151804 {
17161805 switch (errno)
17231812 /*
17241813 * ping the server again
17251814 */
1726 connection_server_ping (c);
1727
1728 FD_CLR (c->fd, &read_mask);
1729 FD_CLR (c->fd, &write_mask);
1730 close (c->fd);
1731 c->fd = socket (AF_INET, SOCK_STREAM, 0);
1732 fd_nonblock (c->fd);
1815 connection_server_ping(c);
1816
1817 FD_CLR(c->fd, &read_mask);
1818 FD_CLR(c->fd, &write_mask);
1819 close(c->fd);
1820 c->fd = socket(AF_INET, SOCK_STREAM, 0);
1821 fd_nonblock(c->fd);
17331822
17341823 /*
17351824 * try and connect again
17361825 */
1737 connect (c->fd, (struct sockaddr *) &c->server->sin, sizeof (c->server->sin));
1738 connection_update_fdset (c);
1826 connect(c->fd, (struct sockaddr *) &c->server->sin, sizeof(c->server->sin));
1827 connection_update_fdset(c);
17391828 return;
17401829
17411830 default:
17471836 * connection failed, remove connect event and forward all other
17481837 * events to the next server
17491838 */
1750 report (REPORT_NOTICE, "%s server connection failed\n", inet_ntoa (c->server->sin.sin_addr));
1751 event_delete (c, 1);
1752 connection_server_forward (c);
1753 connection_close (c);
1839 report(REPORT_NOTICE, "%s server connection failed\n", inet_ntoa(c->server->sin.sin_addr));
1840 event_delete(c, 1);
1841 connection_server_forward(c);
1842 connection_close(c);
17541843 }
17551844 break;
17561845
17591848 {
17601849 if (c->event->start[0] == RPTP_OK)
17611850 {
1762 event_delete (c, 1);
1851 event_delete(c, 1);
17631852 }
17641853 else
17651854 {
1766 event_delete (c, 1);
1767 connection_server_forward (c);
1768 connection_close (c);
1855 event_delete(c, 1);
1856 connection_server_forward(c);
1857 connection_close(c);
17691858 }
17701859 }
17711860 else
17721861 {
1773 report (REPORT_NOTICE, "cannot read connect reply from %s\n",
1774 inet_ntoa (c->server->sin.sin_addr));
1775 event_delete (c, 1);
1776 connection_server_forward (c);
1777 connection_close (c);
1862 report(REPORT_NOTICE, "cannot read connect reply from %s\n",
1863 inet_ntoa(c->server->sin.sin_addr));
1864 event_delete(c, 1);
1865 connection_server_forward(c);
1866 connection_close(c);
17781867 }
17791868 break;
17801869
17811870 case EVENT_WRITE_FIND:
17821871 if (c->event->success)
17831872 {
1784 e = event_create (EVENT_READ_FIND_REPLY, buffer_create (), c->event->sound);
1785 event_replace (c, e);
1873 e = event_create(EVENT_READ_FIND_REPLY, buffer_create(), c->event->sound);
1874 event_replace(c, e);
17861875 }
17871876 else
17881877 {
1789 connection_server_forward (c);
1790 connection_close (c);
1878 connection_server_forward(c);
1879 connection_close(c);
17911880 }
17921881 break;
17931882
17971886 switch (c->event->start[0])
17981887 {
17991888 case RPTP_OK:
1800 if (strchr (c->event->start, '='))
1801 {
1802 size = atoi (rptp_parse (c->event->start, "size"));
1889 if (strchr(c->event->start, '='))
1890 {
1891 size = atoi(rptp_parse(c->event->start, "size"));
18031892 }
18041893 else
18051894 /* old-style */
18061895 {
1807 p = strtok (c->event->start, " ");
1808 size = atoi (strtok (NULL, "\r\n"));
1896 p = strtok(c->event->start, " ");
1897 size = atoi(strtok(NULL, "\r\n"));
18091898 }
18101899 /*
18111900 * see if the sound will fit in the cache
18121901 */
1813 if (cache_free (size) < 0)
1902 if (cache_free(size) < 0)
18141903 {
18151904 /*
18161905 * the sound is too big for the cache
18171906 */
1818 spool_remove (c->event->sound);
1819 sound_delete (c->event->sound, 1);
1820 event_delete (c, 1);
1907 spool_remove(c->event->sound);
1908 sound_delete(c->event->sound, 1);
1909 event_delete(c, 1);
18211910 break;
18221911 }
1823 b = buffer_create ();
1824 SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "get %s\r\n", c->event->sound->name); /* old-style */
1825 b->nbytes = strlen (b->buf);
1826 e = event_create (EVENT_WRITE_GET, b, c->event->sound);
1827 event_replace (c, e);
1912 b = buffer_create();
1913 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "get %s\r\n", c->event->sound->name); /* old-style */
1914 b->nbytes = strlen(b->buf);
1915 e = event_create(EVENT_WRITE_GET, b, c->event->sound);
1916 event_replace(c, e);
18281917 break;
18291918
18301919 case RPTP_ERROR:
1831 report (REPORT_NOTICE, "%s server does not have %s\n",
1832 inet_ntoa (c->sin.sin_addr), c->event->sound->name);
1833 connection_server_forward_sound (c, c->event->sound);
1834 event_delete (c, 1);
1920 report(REPORT_NOTICE, "%s server does not have %s\n",
1921 inet_ntoa(c->sin.sin_addr), c->event->sound->name);
1922 connection_server_forward_sound(c, c->event->sound);
1923 event_delete(c, 1);
18351924 break;
18361925
18371926 case RPTP_TIMEOUT:
1838 report (REPORT_NOTICE, "%s server connection timed out\n",
1839 inet_ntoa (c->sin.sin_addr));
1840 b = buffer_create ();
1841 SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
1842 b->nbytes = strlen (b->buf);
1843 e = event_create (EVENT_WRITE_FIND, b, c->event->sound);
1844 event_replace (c, e);
1845 connection_server_reopen (c);
1927 report(REPORT_NOTICE, "%s server connection timed out\n",
1928 inet_ntoa(c->sin.sin_addr));
1929 b = buffer_create();
1930 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
1931 b->nbytes = strlen(b->buf);
1932 e = event_create(EVENT_WRITE_FIND, b, c->event->sound);
1933 event_replace(c, e);
1934 connection_server_reopen(c);
18461935 break;
18471936
18481937 default:
1849 report (REPORT_ERROR, "event_update: unknown find reply '%c'\n", c->event->start[0]);
1850 done (1);
1938 report(REPORT_ERROR, "event_update: unknown find reply '%c'\n", c->event->start[0]);
1939 done(1);
18511940 }
18521941 }
18531942 else
18541943 {
1855 report (REPORT_NOTICE, "cannot read find reply from %s\n", inet_ntoa (c->sin.sin_addr));
1856 b = buffer_create ();
1857 SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
1858 b->nbytes = strlen (b->buf);
1859 e = event_create (EVENT_WRITE_FIND, b, c->event->sound);
1860 event_replace (c, e);
1861 connection_server_forward (c);
1862 connection_close (c);
1944 report(REPORT_NOTICE, "cannot read find reply from %s\n", inet_ntoa(c->sin.sin_addr));
1945 b = buffer_create();
1946 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
1947 b->nbytes = strlen(b->buf);
1948 e = event_create(EVENT_WRITE_FIND, b, c->event->sound);
1949 event_replace(c, e);
1950 connection_server_forward(c);
1951 connection_close(c);
18631952 }
18641953 break;
18651954
18661955 case EVENT_WRITE_GET:
18671956 if (c->event->success)
18681957 {
1869 e = event_create (EVENT_READ_GET_REPLY, buffer_create (), c->event->sound);
1870 event_replace (c, e);
1958 e = event_create(EVENT_READ_GET_REPLY, buffer_create(), c->event->sound);
1959 event_replace(c, e);
18711960 }
18721961 else
18731962 {
1874 b = buffer_create ();
1875 SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
1876 b->nbytes = strlen (b->buf);
1877 e = event_create (EVENT_WRITE_FIND, b, c->event->sound);
1878 event_replace (c, e);
1879 connection_server_forward (c);
1880 connection_close (c);
1963 b = buffer_create();
1964 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
1965 b->nbytes = strlen(b->buf);
1966 e = event_create(EVENT_WRITE_FIND, b, c->event->sound);
1967 event_replace(c, e);
1968 connection_server_forward(c);
1969 connection_close(c);
18811970 }
18821971 break;
18831972
18891978 switch (c->event->start[0])
18901979 {
18911980 case RPTP_OK:
1892 if (strchr (c->event->start, '='))
1893 {
1894 sound_name = rptp_parse (c->event->start, "sound");
1895 size = atoi (rptp_parse (0, "size"));
1981 if (strchr(c->event->start, '='))
1982 {
1983 sound_name = rptp_parse(c->event->start, "sound");
1984 size = atoi(rptp_parse(0, "size"));
18961985 }
18971986 else
18981987 /* old-style */
18991988 {
1900 p = strtok (c->event->start, " ");
1989 p = strtok(c->event->start, " ");
19011990 p++;
19021991 sound_name = p;
1903 size = atoi (strtok (NULL, "\r\n"));
1904 }
1905
1906 free ((char *) c->event->sound->path);
1907 c->event->sound->path = strdup (cache_name (sound_name));
1992 size = atoi(strtok(NULL, "\r\n"));
1993 }
1994
1995 free((char *) c->event->sound->path);
1996 c->event->sound->path = strdup(cache_name(sound_name));
19081997 c->event->sound->name = c->event->sound->path[0] == '/' ?
1909 strrchr (c->event->sound->path, '/') + 1 :
1998 strrchr(c->event->sound->path, '/') + 1 :
19101999 c->event->sound->path;
1911 fd = cache_create (c->event->sound->path, size);
2000 fd = cache_create(c->event->sound->path, size);
19122001 if (fd < 0)
19132002 {
1914 spool_remove (c->event->sound);
1915 sound_delete (c->event->sound, 1);
1916 event_delete (c, 1);
2003 spool_remove(c->event->sound);
2004 sound_delete(c->event->sound, 1);
2005 event_delete(c, 1);
19172006 }
19182007 else
19192008 {
1920 e = event_create (EVENT_READ_SOUND, fd, buffer_create (),
1921 size, c->event->sound);
2009 e = event_create(EVENT_READ_SOUND, fd, buffer_create(),
2010 size, c->event->sound);
19222011 c->event->sound->status = SOUND_NOT_READY;
1923 event_replace (c, e);
2012 event_replace(c, e);
19242013 }
19252014 break;
19262015
19272016 case RPTP_ERROR:
1928 report (REPORT_NOTICE, "%s server does not have %s\n",
1929 inet_ntoa (c->sin.sin_addr), c->event->sound->name);
1930 connection_server_forward_sound (c, c->event->sound);
1931 event_delete (c, 1);
2017 report(REPORT_NOTICE, "%s server does not have %s\n",
2018 inet_ntoa(c->sin.sin_addr), c->event->sound->name);
2019 connection_server_forward_sound(c, c->event->sound);
2020 event_delete(c, 1);
19322021 break;
19332022
19342023 case RPTP_TIMEOUT:
1935 report (REPORT_NOTICE, "%s server connection timed out\n",
1936 inet_ntoa (c->sin.sin_addr));
1937 b = buffer_create ();
1938 SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "get %s\r\n", c->event->sound->name); /* old-style */
1939 b->nbytes = strlen (b->buf);
1940 e = event_create (EVENT_WRITE_GET, b, c->event->sound);
1941 event_replace (c, e);
1942 connection_server_reopen (c);
2024 report(REPORT_NOTICE, "%s server connection timed out\n",
2025 inet_ntoa(c->sin.sin_addr));
2026 b = buffer_create();
2027 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "get %s\r\n", c->event->sound->name); /* old-style */
2028 b->nbytes = strlen(b->buf);
2029 e = event_create(EVENT_WRITE_GET, b, c->event->sound);
2030 event_replace(c, e);
2031 connection_server_reopen(c);
19432032 break;
19442033
19452034 default:
1946 report (REPORT_ERROR, "event_update: unknown get reply '%c'\n",
1947 c->event->start[0]);
1948 done (1);
2035 report(REPORT_ERROR, "event_update: unknown get reply '%c'\n",
2036 c->event->start[0]);
2037 done(1);
19492038 }
19502039 }
19512040 else
19522041 {
1953 report (REPORT_NOTICE, "cannot read get reply from %s\n",
1954 inet_ntoa (c->server->sin.sin_addr));
1955 b = buffer_create ();
1956 SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
1957 b->nbytes = strlen (b->buf);
1958 e = event_create (EVENT_WRITE_FIND, b, c->event->sound);
1959 event_replace (c, e);
1960 connection_server_forward (c);
1961 connection_close (c);
2042 report(REPORT_NOTICE, "cannot read get reply from %s\n",
2043 inet_ntoa(c->server->sin.sin_addr));
2044 b = buffer_create();
2045 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
2046 b->nbytes = strlen(b->buf);
2047 e = event_create(EVENT_WRITE_FIND, b, c->event->sound);
2048 event_replace(c, e);
2049 connection_server_forward(c);
2050 connection_close(c);
19622051 }
19632052 break;
19642053
19652054 case EVENT_READ_SOUND:
19662055 if (c->event->success)
19672056 {
1968 close (c->event->fd);
1969 sound_map (c->event->sound);
1970 spool_ready (c->event->sound);
2057 close(c->event->fd);
2058 sound_map(c->event->sound);
2059 spool_ready(c->event->sound);
19712060 c->event->sound->status = SOUND_READY;
1972 report (REPORT_DEBUG, "sound %s is ready\n", c->event->sound->name);
1973 event_delete (c, 1);
2061 report(REPORT_DEBUG, "sound %s is ready\n", c->event->sound->name);
2062 event_delete(c, 1);
19742063 }
19752064 else
19762065 {
1977 report (REPORT_NOTICE, "cannot read sound %s from %s\n", c->event->sound->name,
1978 inet_ntoa (c->sin.sin_addr));
2066 report(REPORT_NOTICE, "cannot read sound %s from %s\n", c->event->sound->name,
2067 inet_ntoa(c->sin.sin_addr));
19792068 if (c->type == CONNECTION_SERVER)
19802069 {
1981 b = buffer_create ();
1982 SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
1983 b->nbytes = strlen (b->buf);
1984 e = event_create (EVENT_WRITE_FIND, b, c->event->sound);
1985 event_replace (c, e);
1986 connection_server_forward (c);
2070 b = buffer_create();
2071 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */
2072 b->nbytes = strlen(b->buf);
2073 e = event_create(EVENT_WRITE_FIND, b, c->event->sound);
2074 event_replace(c, e);
2075 connection_server_forward(c);
19872076 }
1988 connection_close (c);
2077 connection_close(c);
19892078 }
19902079 break;
19912080
19922081 case EVENT_WRITE_SOUND:
19932082 if (c->event->success)
19942083 {
1995 event_delete (c, 1);
2084 event_delete(c, 1);
19962085 }
19972086 else
19982087 {
1999 connection_close (c);
2088 connection_close(c);
20002089 }
20012090 break;
20022091
20072096 c->event->buffer = c->event->buffer->next;
20082097 if (b->status == BUFFER_FREE)
20092098 {
2010 buffer_destroy (b);
2099 buffer_destroy(b);
20112100 }
20122101 if (c->event->buffer)
20132102 {
20192108 }
20202109 else
20212110 {
2022 event_delete (c, 1);
2111 event_delete(c, 1);
20232112 }
20242113 }
20252114 else
20262115 {
2027 connection_close (c);
2116 connection_close(c);
20282117 }
20292118 break;
20302119
20312120 case EVENT_WRITE_TIMEOUT:
2032 report (REPORT_DEBUG, "%s client connection timeout\n", inet_ntoa (c->sin.sin_addr));
2033 connection_close (c);
2121 report(REPORT_DEBUG, "%s client connection timeout\n", inet_ntoa(c->sin.sin_addr));
2122 connection_close(c);
20342123 break;
20352124
20362125 case EVENT_READ_FLOW:
20382127 case EVENT_PIPE_FLOW:
20392128 if (c->event->success)
20402129 {
2041 event_delete (c, 1);
2130 event_delete(c, 1);
20422131 }
20432132 else
20442133 {
2045 connection_close (c);
2134 connection_close(c);
20462135 }
20472136 break;
20482137
20492138 case EVENT_NOTIFY:
2050 report (REPORT_DEBUG, "event_update: `%d' update?\n", c->event->type);
2051 break;
2052
2139 report(REPORT_DEBUG, "event_update: `%d' update?\n", c->event->type);
2140 break;
2141
2142 case EVENT_WRITE_MONITOR:
2143 if (c->event->success)
2144 {
2145 /* move to the next monitor buffer */
2146 c->event->buffer = c->event->buffer->next;
2147 c->event->start = c->event->buffer->buf;
2148 c->event->ptr = c->event->start;
2149 c->event->nleft = c->event->buffer->nbytes;
2150 c->event->nbytes = c->event->nleft;
2151 c->event->success = 0;
2152
2153 /* need to wait for the buffer to be complete */
2154 if (c->event->buffer == monitor_buffers)
2155 {
2156 connection_monitor_pause(c);
2157 }
2158 }
2159 else
2160 {
2161 connection_close(c);
2162 }
2163 break;
2164
2165 case EVENT_WAIT_MONITOR:
2166 connection_close(c);
2167 break;
2168
20532169 default:
2054 report (REPORT_ERROR, "event_update: unknown event `%d'\n", c->event->type);
2055 done (1);
2056 }
2057 }
2058
2059 #ifdef __STDC__
2060 void
2061 event_first (CONNECTION *c, EVENT *e)
2062 #else
2063 void
2064 event_first (c, e)
2170 report(REPORT_ERROR, "event_update: unknown event `%d'\n", c->event->type);
2171 done(1);
2172 }
2173 }
2174
2175 #ifdef __STDC__
2176 void
2177 event_first(CONNECTION *c, EVENT *e)
2178 #else
2179 void
2180 event_first(c, e)
20652181 CONNECTION *c;
20662182 EVENT *e;
20672183 #endif
20722188
20732189 tail->next = c->event;
20742190 c->event = e;
2075
2191
20762192 if (!c->event->next)
20772193 {
20782194 c->ep = &c->event->next;
20792195 }
20802196
2081 connection_update_fdset (c);
2082
2083 #ifdef EVENT_DEBUG
2084 event_print (c, "first");
2085 #endif
2086 }
2087
2088 #ifdef __STDC__
2089 void
2090 event_insert_before (CONNECTION *c, EVENT *e, int mask)
2091 #else
2092 void
2093 event_insert_before (c, e, mask)
2197 connection_update_fdset(c);
2198
2199 #ifdef EVENT_DEBUG
2200 event_print(c, "first");
2201 #endif
2202 }
2203
2204 #ifdef __STDC__
2205 void
2206 event_insert_before(CONNECTION *c, EVENT *e, int mask)
2207 #else
2208 void
2209 event_insert_before(c, e, mask)
20942210 CONNECTION *c;
20952211 EVENT *e;
20962212 int mask;
20982214 {
20992215 if (!c->event || (c->event->type & mask))
21002216 {
2101 event_first (c, e);
2217 event_first(c, e);
21022218 }
21032219 else
21042220 {
21052221 EVENT *tail, *event;
21062222
21072223 for (tail = e; tail->next; tail = tail->next) ;
2108
2224
21092225 for (event = c->event; event->next; event = event->next)
21102226 {
21112227 if (event->next->type & mask)
21242240
21252241 if (c->event == e)
21262242 {
2127 connection_update_fdset (c);
2128 }
2129
2130 #ifdef EVENT_DEBUG
2131 event_print (c, "before");
2132 #endif
2133 }
2134 }
2135
2136 #ifdef __STDC__
2137 void
2138 event_insert (CONNECTION *c, EVENT *e)
2139 #else
2140 void
2141 event_insert (c, e)
2243 connection_update_fdset(c);
2244 }
2245
2246 #ifdef EVENT_DEBUG
2247 event_print(c, "before");
2248 #endif
2249 }
2250 }
2251
2252 #ifdef __STDC__
2253 void
2254 event_insert(CONNECTION *c, EVENT *e)
2255 #else
2256 void
2257 event_insert(c, e)
21422258 CONNECTION *c;
21432259 EVENT *e;
21442260 #endif
21522268
21532269 if (c->event == e)
21542270 {
2155 connection_update_fdset (c);
2156 }
2157
2158 #ifdef EVENT_DEBUG
2159 event_print (c, "insert");
2160 #endif
2161 }
2162
2163 #ifdef __STDC__
2164 void
2165 event_replace (CONNECTION *c, EVENT *e)
2166 #else
2167 void
2168 event_replace (c, e)
2271 connection_update_fdset(c);
2272 }
2273
2274 #ifdef EVENT_DEBUG
2275 event_print(c, "insert");
2276 #endif
2277 }
2278
2279 #ifdef __STDC__
2280 void
2281 event_replace(CONNECTION *c, EVENT *e)
2282 #else
2283 void
2284 event_replace(c, e)
21692285 CONNECTION *c;
21702286 EVENT *e;
21712287 #endif
21732289 if (c->event)
21742290 {
21752291 e->next = c->event->next;
2176 event_destroy (c->event);
2292 event_destroy(c->event);
21772293 }
21782294 c->event = e;
21792295 if (c->event->next == NULL)
21802296 {
21812297 c->ep = &c->event->next;
21822298 }
2183 connection_update_fdset (c);
2184
2185 #ifdef EVENT_DEBUG
2186 event_print (c, "replace");
2187 #endif
2188 }
2189
2190 #ifdef __STDC__
2191 void
2192 event_delete (CONNECTION *c, int replace)
2193 #else
2194 void
2195 event_delete (c, replace)
2299 connection_update_fdset(c);
2300
2301 #ifdef EVENT_DEBUG
2302 event_print(c, "replace");
2303 #endif
2304 }
2305
2306 #ifdef __STDC__
2307 void
2308 event_delete(CONNECTION *c, int replace)
2309 #else
2310 void
2311 event_delete(c, replace)
21962312 CONNECTION *c;
21972313 int replace;
21982314 #endif
22012317
22022318 if (c->event == NULL)
22032319 {
2204 connection_update_fdset (c);
2320 connection_update_fdset(c);
22052321 return;
22062322 }
22072323
22082324 e = c->event;
22092325 c->event = c->event->next;
22102326
2211 event_destroy (e);
2327 event_destroy(e);
22122328
22132329 if (c->event == NULL)
22142330 {
22192335 {
22202336 if (c->notify_mask)
22212337 {
2222 e = event_create (EVENT_NOTIFY);
2338 e = event_create(EVENT_NOTIFY);
22232339 }
22242340 else
22252341 {
2226 e = event_create (EVENT_READ_COMMAND, buffer_create ());
2342 e = event_create(EVENT_READ_COMMAND, buffer_create());
22272343 }
2228 event_insert (c, e);
2229 }
2230 }
2231
2232 connection_update_fdset (c);
2233
2234 #ifdef EVENT_DEBUG
2235 event_print (c, "delete");
2236 #endif
2344 event_insert(c, e);
2345 }
2346 }
2347
2348 connection_update_fdset(c);
2349
2350 #ifdef EVENT_DEBUG
2351 event_print(c, "delete");
2352 #endif
22372353 }
22382354
22392355 /*
22522368 */
22532369 #ifdef __STDC__
22542370 EVENT *
2255 event_create (int type,...)
2371 event_create(int type,...)
22562372 #else
22572373 EVENT *
2258 event_create (va_alist)
2374 event_create(va_alist)
22592375 va_dcl
22602376 #endif
22612377 {
22632379 va_list args;
22642380
22652381 #ifdef __STDC__
2266 va_start (args, type);
2382 va_start(args, type);
22672383 #else
22682384 int type;
2269 va_start (args);
2270 type = va_arg (args, int);
2271 #endif
2272
2273 e = (EVENT *) malloc (sizeof (EVENT));
2385 va_start(args);
2386 type = va_arg(args, int);
2387 #endif
2388
2389 e = (EVENT *) malloc(sizeof(EVENT));
22742390 if (e == NULL)
22752391 {
2276 report (REPORT_ERROR, "event_create: out of memory\n");
2277 done (1);
2392 report(REPORT_ERROR, "event_create: out of memory\n");
2393 done(1);
22782394 }
22792395
22802396 /*
23012417 {
23022418 case EVENT_READ_COMMAND:
23032419 case EVENT_READ_CONNECT_REPLY:
2304 e->buffer = va_arg (args, BUFFER *);
2420 e->buffer = va_arg(args, BUFFER *);
23052421 e->nleft = RPTP_MAX_LINE;
23062422 e->nbytes = e->nleft;
23072423 e->ptr = e->buffer->buf;
23132429
23142430 case EVENT_WRITE_FIND:
23152431 case EVENT_WRITE_GET:
2316 e->buffer = va_arg (args, BUFFER *);
2432 e->buffer = va_arg(args, BUFFER *);
23172433 e->nleft = e->buffer->nbytes;
23182434 e->nbytes = e->nleft;
23192435 e->ptr = e->buffer->buf;
23202436 e->start = e->ptr;
2321 e->sound = va_arg (args, SOUND *);
2437 e->sound = va_arg(args, SOUND *);
23222438 break;
23232439
23242440 case EVENT_READ_FIND_REPLY:
23252441 case EVENT_READ_GET_REPLY:
2326 e->buffer = va_arg (args, BUFFER *);
2442 e->buffer = va_arg(args, BUFFER *);
23272443 e->nleft = RPTP_MAX_LINE;
23282444 e->nbytes = e->nleft;
23292445 e->ptr = e->buffer->buf;
23302446 e->start = e->ptr;
2331 e->sound = va_arg (args, SOUND *);
2447 e->sound = va_arg(args, SOUND *);
23322448 break;
23332449
23342450 case EVENT_READ_SOUND:
2335 e->fd = va_arg (args, int);
2336 e->buffer = va_arg (args, BUFFER *);
2337 e->nbytes = va_arg (args, int);
2451 e->fd = va_arg(args, int);
2452 e->buffer = va_arg(args, BUFFER *);
2453 e->nbytes = va_arg(args, int);
23382454 e->nleft = e->nbytes;
2339 e->sound = va_arg (args, SOUND *);
2455 e->sound = va_arg(args, SOUND *);
23402456 break;
23412457
23422458 case EVENT_WRITE_SOUND:
2343 e->sound = va_arg (args, SOUND *);
2344 e->buffer = buffer_create ();
2345 e->si = sound_open (e->sound, 0);
2459 e->sound = va_arg(args, SOUND *);
2460 e->buffer = buffer_create();
2461 e->si = sound_open(e->sound, 0);
23462462 if (e->si == NULL)
23472463 {
2348 event_destroy (e);
2464 event_destroy(e);
23492465 return NULL;
23502466 }
2351 if (sound_fill (e->si, e->buffer, 1) <= 0)
2352 {
2353 event_destroy (e);
2467 if (sound_fill(e->si, e->buffer, 1) <= 0)
2468 {
2469 event_destroy(e);
23542470 return NULL;
23552471 }
23562472 e->nbytes = e->sound->size; /* total number of bytes */
23612477
23622478 case EVENT_WRITE:
23632479 case EVENT_WRITE_TIMEOUT:
2364 e->buffer = va_arg (args, BUFFER *);
2480 e->buffer = va_arg(args, BUFFER *);
23652481 e->ptr = e->buffer->buf;
23662482 e->start = e->ptr;
23672483 e->nleft = e->buffer->nbytes;
23722488 break;
23732489
23742490 case EVENT_READ_FLOW:
2375 e->id = va_arg (args, int);
2376 e->nbytes = va_arg (args, int);
2491 e->id = va_arg(args, int);
2492 e->nbytes = va_arg(args, int);
23772493 if (e->nbytes == 0)
23782494 {
23792495 e->nbytes = -1;
23862502 break;
23872503
23882504 case EVENT_PIPE_FLOW:
2389 e->id = va_arg (args, int);
2390 e->sound = va_arg (args, SOUND *);
2391 break;
2392 }
2393
2394 va_end (args);
2505 e->id = va_arg(args, int);
2506 e->sound = va_arg(args, SOUND *);
2507 break;
2508
2509 case EVENT_WAIT_MONITOR:
2510 e->buffer = monitor_buffers;
2511 e->ptr = e->buffer->buf;
2512 e->start = e->ptr;
2513 e->nleft = e->buffer->nbytes;
2514 e->nbytes = e->nleft;
2515 break;
2516 }
2517
2518 va_end(args);
23952519
23962520 return e;
23972521 }
23982522
23992523 #ifdef __STDC__
24002524 void
2401 event_destroy (EVENT *e)
2402 #else
2403 void
2404 event_destroy (e)
2525 event_destroy(EVENT *e)
2526 #else
2527 void
2528 event_destroy(e)
24052529 EVENT *e;
24062530 #endif
24072531 {
24082532 if (e->buffer && e->buffer->status == BUFFER_FREE)
24092533 {
2410 buffer_destroy (e->buffer);
2534 buffer_destroy(e->buffer);
24112535 }
24122536 if (e->si)
24132537 {
2414 sound_close (e->si);
2415 }
2416 free ((char *) e);
2538 sound_close(e->si);
2539 }
2540 free((char *) e);
24172541 }
24182542
24192543 #ifdef EVENT_DEBUG
24202544 static void
2421 event_print (CONNECTION *c, char *message)
2545 event_print(CONNECTION *c, char *message)
24222546 {
24232547 EVENT *e;
24242548
2425 printf ("%8s %s (%s) -> ", message, c->application, inet_ntoa (c->sin.sin_addr));
2549 printf("%8s %s (%s) -> ", message, c->application, inet_ntoa(c->sin.sin_addr));
24262550 e = c->event;
24272551 for (; e; e = e->next)
24282552 {
24292553 switch (e->type)
24302554 {
24312555 case EVENT_READ_COMMAND:
2432 printf ("read_command ");
2556 printf("read_command ");
24332557 break;
24342558
24352559 case EVENT_CONNECT:
2436 printf ("connect ");
2560 printf("connect ");
24372561 break;
24382562
24392563 case EVENT_READ_CONNECT_REPLY:
2440 printf ("read_connect_reply ");
2564 printf("read_connect_reply ");
24412565 break;
24422566
24432567 case EVENT_WRITE_FIND:
2444 printf ("write_find ");
2568 printf("write_find ");
24452569 break;
24462570
24472571 case EVENT_READ_FIND_REPLY:
2448 printf ("read_find_reply ");
2572 printf("read_find_reply ");
24492573 break;
24502574
24512575 case EVENT_WRITE_GET:
2452 printf ("write_get ");
2576 printf("write_get ");
24532577 break;
24542578
24552579 case EVENT_READ_GET_REPLY:
2456 printf ("read_get_reply ");
2580 printf("read_get_reply ");
24572581 break;
24582582
24592583 case EVENT_READ_SOUND:
2460 printf ("read_sound ");
2584 printf("read_sound ");
24612585 break;
24622586
24632587 case EVENT_WRITE:
2464 printf ("write ");
2588 printf("write ");
24652589 break;
24662590
24672591 case EVENT_WRITE_SOUND:
2468 printf ("write_sound ");
2592 printf("write_sound ");
24692593 break;
24702594
24712595 case EVENT_WRITE_TIMEOUT:
2472 printf ("write_timeout ");
2596 printf("write_timeout ");
24732597 break;
24742598
24752599 case EVENT_NOTIFY:
2476 printf ("notify ");
2600 printf("notify ");
24772601 break;
24782602
24792603 case EVENT_READ_FLOW:
2480 printf ("read_flow ");
2604 printf("read_flow ");
24812605 break;
24822606
24832607 case EVENT_WAIT_FLOW:
2484 printf ("wait_flow ");
2608 printf("wait_flow ");
24852609 break;
24862610
24872611 case EVENT_PIPE_FLOW:
2488 printf ("pipe_flow ");
2612 printf("pipe_flow ");
24892613 break;
24902614
24912615 default:
2492 printf ("`%d' ", e->type);
2616 printf("`%d' ", e->type);
24932617 break;
24942618 }
24952619 }
24962620
2497 if (FD_ISSET (c->fd, &write_mask))
2498 {
2499 printf ("[write] ");
2500 }
2501 if (FD_ISSET (c->fd, &read_mask))
2502 {
2503 printf ("[read] ");
2504 }
2505
2506 printf ("\n");
2507 }
2508 #endif
2621 if (FD_ISSET(c->fd, &write_mask))
2622 {
2623 printf("[write] ");
2624 }
2625 if (FD_ISSET(c->fd, &read_mask))
2626 {
2627 printf("[read] ");
2628 }
2629
2630 printf("\n");
2631 }
2632 #endif
0 /* $Id: connection.h,v 1.2 1998/08/13 06:13:49 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: connection.h,v 1.3 1999/03/10 07:58:03 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
5555 #define EVENT_READ_FLOW (1<<12) /* read a flow */
5656 #define EVENT_WAIT_FLOW (1<<13) /* pause the incoming flow data */
5757 #define EVENT_PIPE_FLOW (1<<14) /* piped flow data */
58 #define EVENT_WRITE_MONITOR (1<<15) /* write audio monitor data */
59 #define EVENT_WAIT_MONITOR (1<<16) /* write audio monitor data */
5860
5961 /*
6062 * notify events
7274 #define NOTIFY_MODIFY (1<<9)
7375 #define NOTIFY_LEVEL (1<<10)
7476 #define NOTIFY_POSITION (1<<11)
77 #define NOTIFY_MONITOR (1<<12)
7578 #define NOTIFY_ANY (0xffffffff)
7679 #define NOTIFY_SPOOL (NOTIFY_PLAY|NOTIFY_PAUSE|NOTIFY_CONTINUE|NOTIFY_STOP|NOTIFY_DONE|NOTIFY_SKIP|NOTIFY_MODIFY|NOTIFY_FLOW)
7780
129132 int notify_mask;
130133 int notify_id;
131134 NOTIFY_RATE notify_rate[NOTIFY_RATE_MAX];
135 int monitor;
132136 }
133137 CONNECTION;
134138
0 /* $Id: flange.c,v 1.2 1998/08/13 06:13:50 boyns Exp $ */
0 /* $Id: flange.c,v 1.4 1999/03/10 07:58:03 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
2223
2324
24
2525 #include "rplayd.h"
2626
2727 #ifdef TEST_FLANGE
6262 wl;
6363
6464 void
65 flange (char *native_buf, int nsamples, int nchannels)
65 flange(char *native_buf, int nsamples, int nchannels)
6666 {
6767 short *sample = (short *) native_buf;
6868 short *flanged = (short *) native_buf;
8585 min_sweep = max_sweep - depth;
8686 if (min_sweep < 0)
8787 {
88 exit (1);
88 exit(1);
8989 }
9090
9191 sweep.w[0] = (min_sweep + max_sweep) / 2;
9494 }
9595
9696 #if 0
97 printf ("step = %d, depth = %d, delay = %d\n", step, depth, delay);
98 printf ("max_sweep = %d, min_sweep = %d\n", max_sweep, min_sweep);
97 printf("step = %d, depth = %d, delay = %d\n", step, depth, delay);
98 printf("max_sweep = %d, min_sweep = %d\n", max_sweep, min_sweep);
9999 #endif
100100
101101 for (i = 0; i < size; i++)
0 /* $Id: flange.h,v 1.2 1998/08/13 06:13:51 boyns Exp $ */
0 /* $Id: flange.h,v 1.3 1999/03/10 07:58:03 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: helper.c,v 1.2 1998/08/13 06:13:52 boyns Exp $ */
0 /* $Id: helper.c,v 1.4 1999/03/10 07:58:03 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
4747
4848 #ifdef __STDC__
4949 void
50 helper_read (char *filename)
51 #else
52 void
53 helper_read (filename)
50 helper_read(char *filename)
51 #else
52 void
53 helper_read(filename)
5454 char *filename;
5555 #endif
5656 {
6161 int line = 0;
6262 int error;
6363
64 helper_read_time = time (0);
65
66 fp = fopen (filename, "r");
64 helper_read_time = time(0);
65
66 fp = fopen(filename, "r");
6767 if (fp == NULL)
6868 {
6969 return;
7070 }
7171
72 while (fgets (buf, sizeof (buf), fp) != NULL)
72 while (fgets(buf, sizeof(buf), fp) != NULL)
7373 {
7474 line++;
75
75
7676 switch (buf[0])
7777 {
7878 case '#':
8181 case '\n':
8282 continue;
8383 }
84 p = strchr (buf, '\n');
84 p = strchr(buf, '\n');
8585 if (p)
8686 {
8787 *p = '\0';
8888 }
8989
90 hp = (HELPER *) malloc (sizeof (HELPER));
90 hp = (HELPER *) malloc(sizeof(HELPER));
9191 if (hp == NULL)
9292 {
93 report (REPORT_ERROR, "helper_read: out of memory\n");
94 done (1);
93 report(REPORT_ERROR, "helper_read: out of memory\n");
94 done(1);
9595 }
9696 hp->next = NULL;
9797 hp->program = NULL;
102102 hp->byte_order = 0;
103103
104104 /* pattern */
105 pat = strtok (buf, " \t");
105 pat = strtok(buf, " \t");
106106 if (!pat)
107107 {
108 report (REPORT_ERROR, "helper_read: parse error line %d\n", line);
109 done (1);
108 report(REPORT_ERROR, "helper_read: parse error line %d\n", line);
109 done(1);
110110 }
111111 //memset ((char *) &hp->pattern, 0, sizeof (hp->pattern));
112 error = regncomp (&hp->pattern, pat, strlen (pat), REG_ICASE | REG_NOSUB);
112 error = regncomp(&hp->pattern, pat, strlen(pat), REG_ICASE | REG_NOSUB);
113113 if (error)
114114 {
115 report (REPORT_ERROR, "helper_read: %d line %d\n", error, line);
116 done (1);
115 report(REPORT_ERROR, "helper_read: %d line %d\n", error, line);
116 done(1);
117117 }
118118
119119 /* info */
120 info = strtok (NULL, " \t");
120 info = strtok(NULL, " \t");
121121 if (!info)
122122 {
123 report (REPORT_ERROR, "helper_read: parse error line %d\n", line);
124 done (1);
125 }
126 for (; *info && (*info == ' ' || *info == '\t'); info++);
127
123 report(REPORT_ERROR, "helper_read: parse error line %d\n", line);
124 done(1);
125 }
126 for (; *info && (*info == ' ' || *info == '\t'); info++) ;
127
128128 /* program */
129 prog = strtok (NULL, "");
129 prog = strtok(NULL, "");
130130 if (!prog)
131131 {
132 report (REPORT_ERROR, "helper_read: parse error line %d\n", line);
133 done (1);
134 }
135 for (; *prog && (*prog == ' ' || *prog == '\t'); prog++);
136 hp->program = strdup (prog);
132 report(REPORT_ERROR, "helper_read: parse error line %d\n", line);
133 done(1);
134 }
135 for (; *prog && (*prog == ' ' || *prog == '\t'); prog++) ;
136 hp->program = strdup(prog);
137137
138138 /* parse info */
139 p = strtok (info, ",");
140 if (p) hp->format = string_to_audio_format (p);
141 p = strtok (NULL, ",");
142 if (p) hp->sample_rate = atoi (p);
143 p = strtok (NULL, ",");
144 if (p) hp->precision = atoi (p);
145 p = strtok (NULL, ",");
146 if (p) hp->channels = atoi (p);
147 p = strtok (NULL, ",");
148 if (p) hp->byte_order = string_to_byte_order (p);
139 p = strtok(info, ",");
140 if (p)
141 hp->format = string_to_audio_format(p);
142 p = strtok(NULL, ",");
143 if (p)
144 hp->sample_rate = atoi(p);
145 p = strtok(NULL, ",");
146 if (p)
147 hp->precision = atoi(p);
148 p = strtok(NULL, ",");
149 if (p)
150 hp->channels = atoi(p);
151 p = strtok(NULL, ",");
152 if (p)
153 hp->byte_order = string_to_byte_order(p);
149154 if (!hp->format || !hp->sample_rate || !hp->precision || !hp->channels || !hp->byte_order)
150155 {
151 report (REPORT_ERROR, "helper_read: parse error line %d\n", line);
152 done (1);
153 }
154
155 report (REPORT_DEBUG, "adding helper for \"%s\"\n", pat);
156 report(REPORT_ERROR, "helper_read: parse error line %d\n", line);
157 done(1);
158 }
159
160 report(REPORT_DEBUG, "adding helper for \"%s\"\n", pat);
156161
157162 if (helpers == NULL)
158163 {
166171 }
167172 }
168173
169 fclose (fp);
174 fclose(fp);
170175 }
171176
172177 #ifdef __STDC__
173178 HELPER *
174 helper_lookup (char *sound)
179 helper_lookup(char *sound)
175180 #else
176181 HELPER *
177 helper_lookup (sound)
182 helper_lookup(sound)
178183 char *sound;
179 #endif
184 #endif
180185 {
181186 HELPER *hp;
182
187
183188 for (hp = helpers; hp; hp = hp->next)
184189 {
185 if (regnexec (&hp->pattern, sound, strlen (sound), 0, 0, 0) == 0)
190 if (regnexec(&hp->pattern, sound, strlen(sound), 0, 0, 0) == 0)
186191 {
187192 return hp;
188193 }
192197
193198 #ifdef __STDC__
194199 void
195 helper_reread (char *filename)
196 #else
197 void
198 helper_reread (filename)
200 helper_reread(char *filename)
201 #else
202 void
203 helper_reread(filename)
199204 char *filename;
200205 #endif
201206 {
202207 HELPER *hp, *hp_next;
203
204 report (REPORT_DEBUG, "re-reading helpers\n");
205
208
209 report(REPORT_DEBUG, "re-reading helpers\n");
210
206211 for (hp = helpers; hp; hp = hp_next)
207212 {
208213 hp_next = hp->next;
209 regfree (&hp->pattern);
210 free (hp->program);
214 regfree(&hp->pattern);
215 free(hp->program);
211216 }
212217
213218 helpers = NULL;
214 helper_read (filename);
215 }
216
217 #ifdef __STDC__
218 void
219 helper_stat (char *filename)
220 #else
221 void
222 helper_stat (filename)
219 helper_read(filename);
220 }
221
222 #ifdef __STDC__
223 void
224 helper_stat(char *filename)
225 #else
226 void
227 helper_stat(filename)
223228 char *filename;
224229 #endif
225230 {
226 if (modified (filename, helper_read_time))
227 {
228 helper_reread (filename);
231 if (modified(filename, helper_read_time))
232 {
233 helper_reread(filename);
229234 }
230235 }
231236
0 /* $Id: helper.h,v 1.2 1998/08/13 06:13:53 boyns Exp $ */
0 /* $Id: helper.h,v 1.4 1999/06/09 06:27:44 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifndef _helper_h
2624 #define _helper_h
2725
2826 #ifdef HAVE_HELPERS
2927
28 #ifdef HAVE_RX_RXPOSIX_H
29 #include <rx/rxposix.h>
30 #else
31 #ifdef HAVE_RXPOSIX_H
32 #include <rxposix.h>
33 #else
3034 #include "rxposix.h"
35 #endif
36 #endif
3137
3238 typedef struct _helper
3339 {
0 /* $Id: host.c,v 1.2 1998/08/13 06:13:54 boyns Exp $ */
0 /* $Id: host.c,v 1.6 1999/06/09 06:27:44 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifdef HAVE_CONFIG_H
2624 #include "config.h"
3230 #include <string.h>
3331 #endif
3432 #include "host.h"
35 #include "rxposix.h"
3633 #include "buffer.h"
3734 #include "misc.h"
35 #ifdef HAVE_RX_RXPOSIX_H
36 #include <rx/rxposix.h>
37 #else
38 #ifdef HAVE_RXPOSIX_H
39 #include <rxposix.h>
40 #else
41 #include "rxposix.h"
42 #endif
43 #endif
3844
3945 #ifdef AUTH
4046
41 static regex_t access_read, access_write, access_execute;
47 static regex_t access_read, access_write, access_execute, access_monitor;
4248 BUFFER *host_list = NULL;
4349 BUFFER *b;
4450
5359 */
5460 #ifdef __STDC__
5561 void
56 host_read (char *filename)
57 #else
58 void
59 host_read (filename)
62 host_read(char *filename)
63 #else
64 void
65 host_read(filename)
6066 char *filename;
6167 #endif
6268 {
6571 char expr_read[HOST_EXPR_SIZE];
6672 char expr_write[HOST_EXPR_SIZE];
6773 char expr_execute[HOST_EXPR_SIZE];
74 char expr_monitor[HOST_EXPR_SIZE];
6875 int error = 0;
6976
70 host_read_time = time (0);
71
72 fp = fopen (filename, "r");
77 host_read_time = time(0);
78
79 fp = fopen(filename, "r");
7380 if (fp == NULL)
7481 {
75 report (REPORT_ERROR, "host_read: cannot open %s\n", filename);
82 report(REPORT_ERROR, "host_read: cannot open %s\n", filename);
7683 /* Don't exit anymore. Localhost will be added automatically
7784 later. */
7885 }
7986
80 b = buffer_create ();
87 b = buffer_create();
8188 b->status = BUFFER_KEEP;
82 strcpy (b->buf, "+message=\"hosts\"\r\n");
83 b->nbytes += strlen (b->buf);
89 strcpy(b->buf, "+message=\"hosts\"\r\n");
90 b->nbytes += strlen(b->buf);
8491 host_list = b;
8592
8693 //memset ((char *) &access_read, 0, sizeof (access_read));
8794 //memset ((char *) &access_write, 0, sizeof (access_write));
8895 //memset ((char *) &access_execute, 0, sizeof (access_execute));
8996
90 strcpy (expr_read, "^\\(");
91 strcpy (expr_write, "^\\(");
92 strcpy (expr_execute, "^\\(");
97 strcpy(expr_read, "^\\(");
98 strcpy(expr_write, "^\\(");
99 strcpy(expr_execute, "^\\(");
100 strcpy(expr_monitor, "^\\(");
93101
94102 do
95103 {
96104 if (fp)
97105 {
98 p = fgets (buf, sizeof (buf), fp);
106 p = fgets(buf, sizeof(buf), fp);
99107 if (!p)
100108 {
101 fclose (fp);
109 fclose(fp);
102110 break;
103111 }
104112 }
106114 {
107115 /* rplay.hosts wasn't found and AUTH was defined in config.h.
108116 Assume that only the localhost should have access. */
109 SNPRINTF (SIZE(buf,sizeof(buf)), "%s:rwx", hostaddr);
110 report (REPORT_NOTICE, "host_read: adding %s\n", buf);
111 }
112
117 SNPRINTF(SIZE(buf, sizeof(buf)), "%s:rwx", hostaddr);
118 report(REPORT_NOTICE, "host_read: adding %s\n", buf);
119 }
120
113121 switch (buf[0])
114122 {
115123 case '#':
119127 continue;
120128 }
121129
122 p = strchr (buf, '\n');
130 p = strchr(buf, '\n');
123131 if (p)
124132 {
125133 *p = '\0';
126134 }
127135
128136 name = buf;
129 perms = strchr (buf, ':');
137 perms = strchr(buf, ':');
130138 if (perms)
131139 {
132140 *perms = '\0';
137145 perms = HOST_DEFAULT_ACCESS;
138146 }
139147
140 host_insert (expr_read, expr_write, expr_execute, name, perms);
148 host_insert(expr_read, expr_write, expr_execute, expr_monitor,
149 name, perms);
141150 }
142151 while (fp);
143152
144153 if (b->nbytes + 3 > BUFFER_SIZE) /* room for .\r\n */
145154 {
146 b->next = buffer_create ();
155 b->next = buffer_create();
147156 b = b->next;
148157 b->status = BUFFER_KEEP;
149158 }
150 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n");
159 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE - b->nbytes), ".\r\n");
151160 b->nbytes += 3;
152161
153 if (strlen (expr_read) == 3)
154 {
155 strcat (expr_read, "\\)");
162 if (strlen(expr_read) == 3)
163 {
164 strcat(expr_read, "\\)");
156165 }
157166 else
158167 {
159 expr_read[strlen (expr_read) - 1] = ')';
160 }
161 strcat (expr_read, "$");
162 if (strlen (expr_write) == 3)
163 {
164 strcat (expr_write, "\\)");
168 expr_read[strlen(expr_read) - 1] = ')';
169 }
170 strcat(expr_read, "$");
171 if (strlen(expr_write) == 3)
172 {
173 strcat(expr_write, "\\)");
165174 }
166175 else
167176 {
168 expr_write[strlen (expr_write) - 1] = ')';
169 }
170 strcat (expr_write, "$");
171 if (strlen (expr_execute) == 3)
172 {
173 strcat (expr_execute, "\\)");
177 expr_write[strlen(expr_write) - 1] = ')';
178 }
179 strcat(expr_write, "$");
180 if (strlen(expr_execute) == 3)
181 {
182 strcat(expr_execute, "\\)");
174183 }
175184 else
176185 {
177 expr_execute[strlen (expr_execute) - 1] = ')';
178 }
179 strcat (expr_execute, "$");
180
181 #if 0
182 report (REPORT_DEBUG, "expr_read: %s\n", expr_read);
183 report (REPORT_DEBUG, "expr_write: %s\n", expr_write);
184 report (REPORT_DEBUG, "expr_execute: %s\n", expr_execute);
185 #endif
186
187 error = regncomp (&access_read, expr_read, strlen (expr_read), REG_ICASE | REG_NOSUB);
186 expr_execute[strlen(expr_execute) - 1] = ')';
187 }
188 strcat(expr_execute, "$");
189 if (strlen(expr_monitor) == 3)
190 {
191 strcat(expr_monitor, "\\)");
192 }
193 else
194 {
195 expr_monitor[strlen(expr_monitor) - 1] = ')';
196 }
197 strcat(expr_monitor, "$");
198
199 error = regncomp(&access_read, expr_read, strlen(expr_read),
200 REG_ICASE | REG_NOSUB);
188201 if (error)
189202 {
190 report (REPORT_ERROR, "host_read: regncomp: %d\n", error);
191 done (1);
192 }
193
194 error= regncomp (&access_write, expr_write, strlen (expr_write), REG_ICASE | REG_NOSUB);
203 report(REPORT_ERROR, "host_read: regncomp: %d\n", error);
204 done(1);
205 }
206
207 error = regncomp(&access_write, expr_write, strlen(expr_write),
208 REG_ICASE | REG_NOSUB);
195209 if (error)
196210 {
197 report (REPORT_ERROR, "host_read: regncomp: %d\n", error);
198 done (1);
199 }
200
201 error = regncomp (&access_execute, expr_execute, strlen (expr_execute), REG_ICASE | REG_NOSUB);
211 report(REPORT_ERROR, "host_read: regncomp: %d\n", error);
212 done(1);
213 }
214
215 error = regncomp(&access_execute, expr_execute, strlen(expr_execute),
216 REG_ICASE | REG_NOSUB);
202217 if (error)
203218 {
204 report (REPORT_ERROR, "host_read: regncomp: %d\n", error);
205 done (1);
206 }
207 }
208
209 #ifdef __STDC__
210 void
211 host_reread (char *filename)
212 #else
213 void
214 host_reread (filename)
219 report(REPORT_ERROR, "host_read: regncomp: %d\n", error);
220 done(1);
221 }
222
223 error = regncomp(&access_monitor, expr_monitor, strlen(expr_monitor),
224 REG_ICASE | REG_NOSUB);
225 if (error)
226 {
227 report(REPORT_ERROR, "host_read: regncomp: %d\n", error);
228 done(1);
229 }
230 }
231
232 #ifdef __STDC__
233 void
234 host_reread(char *filename)
235 #else
236 void
237 host_reread(filename)
215238 char *filename;
216239 #endif
217240 {
218241 BUFFER *b, *bb;
219242
220 report (REPORT_DEBUG, "re-reading hosts\n");
243 report(REPORT_DEBUG, "re-reading hosts\n");
221244
222245 /*
223246 * Free the old host buffer list.
224247 */
225 for (b = host_list; b; bb = b, b = b->next, bb->status = BUFFER_FREE, buffer_destroy (bb)) ;
248 for (b = host_list; b;
249 bb = b, b = b->next, bb->status = BUFFER_FREE, buffer_destroy(bb)) ;
226250
227251 host_list = NULL;
228 host_read (filename);
229 }
230
231 #ifdef __STDC__
232 void
233 host_stat (char *filename)
234 #else
235 void
236 host_stat (filename)
252 host_read(filename);
253 }
254
255 #ifdef __STDC__
256 void
257 host_stat(char *filename)
258 #else
259 void
260 host_stat(filename)
237261 char *filename;
238262 #endif
239263 {
240 if (modified (filename, host_read_time))
241 {
242 host_reread (filename);
243 }
244 }
245
246 #ifdef __STDC__
247 void
248 host_insert (char *expr_read, char *expr_write, char *expr_execute, char *name, char *perms)
249 #else
250 void
251 host_insert (expr_read, expr_write, expr_execute, name, perms)
264 if (modified(filename, host_read_time))
265 {
266 host_reread(filename);
267 }
268 }
269
270 #ifdef __STDC__
271 void
272 host_insert(char *expr_read, char *expr_write, char *expr_execute, char *expr_monitor,
273 char *name, char *perms)
274 #else
275 void
276 host_insert(expr_read, expr_write, expr_execute, expr_monitor, name, perms)
252277 char *expr_read;
253278 char *expr_write;
254279 char *expr_execute;
280 char *expr_monitor;
255281 char *name;
256282 char *perms;
257283 #endif
264290 char *re_name = 0;
265291 char line[RPTP_MAX_LINE];
266292
267 SNPRINTF (SIZE(line,sizeof(line)), "host=%s access=%s\r\n", name, perms);
268 n = strlen (line);
293 SNPRINTF(SIZE(line, sizeof(line)), "host=%s access=%s\r\n", name, perms);
294 n = strlen(line);
269295
270296 if (b->nbytes + n > BUFFER_SIZE)
271297 {
272 b->next = buffer_create ();
298 b->next = buffer_create();
273299 b = b->next;
274300 b->status = BUFFER_KEEP;
275301 }
276302
277 strcat (b->buf, line);
303 strcat(b->buf, line);
278304 b->nbytes += n;
279305
280 if (strchr (name, '*'))
281 {
282 re_name = host_ip_to_regex (name);
306 if (strchr(name, '*'))
307 {
308 re_name = host_ip_to_regex(name);
283309 }
284310 else
285311 {
286 addr = inet_addr (name);
312 addr = inet_addr(name);
287313 if (addr == 0xffffffff)
288314 {
289 hp = gethostbyname (name);
315 hp = gethostbyname(name);
290316 if (hp == NULL)
291317 {
292 report (REPORT_NOTICE, "warning: %s unknown host\n", name);
318 report(REPORT_NOTICE, "warning: %s unknown host\n", name);
293319 return;
294320 }
295321 /*
297323 */
298324 for (ap = hp->h_addr_list + 1; *ap; ap++)
299325 {
300 memcpy ((char *) &addr_in, *ap, hp->h_length);
301 host_insert (expr_read, expr_write, expr_execute, inet_ntoa (addr_in), perms);
326 memcpy((char *) &addr_in, *ap, hp->h_length);
327 host_insert(expr_read, expr_write, expr_execute, expr_monitor,
328 inet_ntoa(addr_in), perms);
302329 }
303 memcpy ((char *) &addr_in, (char *) hp->h_addr, sizeof (addr_in));
304 re_name = host_ip_to_regex (inet_ntoa (addr_in));
330 memcpy((char *) &addr_in, (char *) hp->h_addr, sizeof(addr_in));
331 re_name = host_ip_to_regex(inet_ntoa(addr_in));
305332 }
306333 else
307334 {
308 memcpy ((char *) &addr_in, (char *) &addr, sizeof (addr_in));
309 re_name = host_ip_to_regex (inet_ntoa (addr_in));
335 memcpy((char *) &addr_in, (char *) &addr, sizeof(addr_in));
336 re_name = host_ip_to_regex(inet_ntoa(addr_in));
310337 }
311338
312339 /*
313340 * Add localhost automatically.
314341 */
315 if (strcmp (hostaddr, "127.0.0.1") != 0
316 && strcmp (inet_ntoa (addr_in), hostaddr) == 0)
317 {
318 report (REPORT_DEBUG, "host_insert: adding localhost (127.0.0.1)\n");
319 host_insert (expr_read, expr_write, expr_execute, "127.0.0.1", perms);
342 if (strcmp(hostaddr, "127.0.0.1") != 0
343 && strcmp(inet_ntoa(addr_in), hostaddr) == 0)
344 {
345 report(REPORT_DEBUG, "host_insert: adding localhost (127.0.0.1)\n");
346 host_insert(expr_read, expr_write, expr_execute, expr_monitor, "127.0.0.1", perms);
320347 }
321348 }
322349
325352 switch (*p)
326353 {
327354 case HOST_READ:
328 strcat (expr_read, re_name);
329 strcat (expr_read, "\\|");
355 strcat(expr_read, re_name);
356 strcat(expr_read, "\\|");
330357 break;
331358
332359 case HOST_WRITE:
333 strcat (expr_write, re_name);
334 strcat (expr_write, "\\|");
360 strcat(expr_write, re_name);
361 strcat(expr_write, "\\|");
335362 break;
336363
337364 case HOST_EXECUTE:
338 strcat (expr_execute, re_name);
339 strcat (expr_execute, "\\|");
365 strcat(expr_execute, re_name);
366 strcat(expr_execute, "\\|");
367 break;
368
369 case HOST_MONITOR:
370 strcat(expr_monitor, re_name);
371 strcat(expr_monitor, "\\|");
340372 break;
341373
342374 default:
343 report (REPORT_ERROR, "host_insert: '%c' unknown host access permission\n", *p);
344 done (1);
375 report(REPORT_ERROR, "host_insert: '%c' unknown host access permission\n", *p);
376 done(1);
345377 }
346378 }
347379
348380 if (re_name)
349381 {
350 free (re_name);
382 free(re_name);
351383 }
352384 }
353385
354386 /* return 1 if allowed */
355387 #ifdef __STDC__
356388 int
357 host_access (struct sockaddr_in sin, char access_mode)
389 host_access(struct sockaddr_in sin, char access_mode)
358390 #else
359391 int
360 host_access (sin, access_mode)
392 host_access(sin, access_mode)
361393 struct sockaddr_in sin;
362394 char access_mode;
363395 #endif
374406 return 1;
375407 }
376408
377 p = inet_ntoa (sin.sin_addr);
409 p = inet_ntoa(sin.sin_addr);
378410
379411 switch (access_mode)
380412 {
390422 re = &access_execute;
391423 break;
392424
425 case HOST_MONITOR:
426 re = &access_monitor;
427 break;
428
393429 default:
394 report (REPORT_ERROR, "host_access: unknown access mode '%s'\n", access_mode);
395 done (1);
396 }
397
398 n = regnexec (re, p, strlen (p), 0, 0, 0);
430 report(REPORT_ERROR, "host_access: unknown access mode '%s'\n", access_mode);
431 done(1);
432 }
433
434 n = regnexec(re, p, strlen(p), 0, 0, 0);
399435
400436 return !n;
401437 }
402438
403439 #ifdef __STDC__
404440 char *
405 host_ip_to_regex (char *p)
441 host_ip_to_regex(char *p)
406442 #else
407443 char *
408 host_ip_to_regex (p)
444 host_ip_to_regex(p)
409445 char *p;
410446 #endif
411447 {
433469
434470 *q = '\0';
435471
436 return strdup (buf);
472 return strdup(buf);
437473 }
438474
439475 #endif /* AUTH */
0 /* $Id: host.h,v 1.2 1998/08/13 06:13:55 boyns Exp $ */
0 /* $Id: host.h,v 1.3 1999/03/10 07:58:03 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
3636 #define HOST_READ 'r'
3737 #define HOST_WRITE 'w'
3838 #define HOST_EXECUTE 'x'
39 #define HOST_MONITOR 'm'
3940 #define HOST_DEFAULT_ACCESS "rx"
4041
4142 extern BUFFER *host_list;
4647 extern void host_stat (char *filename);
4748 extern char *host_ip_to_regex (char *ip_addr);
4849 extern int host_access (struct sockaddr_in sin, char access_mode);
49 extern void host_insert (char *expr_read, char *expr_write, char *expr_execute, char *name, char *perms);
50 extern void host_insert (char *expr_read, char *expr_write, char *expr_execute,
51 char *expr_monitor, char *name, char *perms);
5052 #else
5153 extern void host_read ( /* char *filename */ );
5254 extern void host_reread ( /* char *filename */ );
5355 extern void host_stat ( /* char *filename */ );
5456 extern char *host_ip_to_regex ( /* char *ip_addr */ );
5557 extern int host_access ( /* struct sockaddr_in sin, char access_mode */ );
56 extern void host_insert ( /* char *expr_read, char *expr_write, char *expr_execute, char *name, char *perms */ );
58 extern void host_insert ();
5759 #endif
5860
5961 #endif /* AUTH */
0 /* $Id: misc.c,v 1.2 1998/08/13 06:13:56 boyns Exp $ */
0 /* $Id: misc.c,v 1.5 1999/03/10 07:58:03 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
4444
4545 #ifdef __STDC__
4646 char *
47 sys_err_str (int error)
48 #else
49 char *
50 sys_err_str (error)
47 sys_err_str(int error)
48 #else
49 char *
50 sys_err_str(error)
5151 int error;
5252 #endif
5353 {
5454 #ifdef HAVE_STRERROR
55 return (char *) strerror (error);
55 return (char *) strerror(error);
5656 #else
5757 extern char *sys_errlist[];
5858 return sys_errlist[error];
6161
6262 #ifdef __STDC__
6363 int
64 udp_socket (int port)
65 #else
66 int
67 udp_socket (port)
64 udp_socket(int port)
65 #else
66 int
67 udp_socket(port)
6868 int port;
6969 #endif
7070 {
7171 int fd;
7272 struct sockaddr_in s;
7373
74 fd = socket (AF_INET, SOCK_DGRAM, 0);
74 fd = socket(AF_INET, SOCK_DGRAM, 0);
7575 if (fd < 0)
7676 {
77 report (REPORT_ERROR, "socket: %s\n", sys_err_str (errno));
78 done (1);
77 report(REPORT_ERROR, "socket: %s\n", sys_err_str(errno));
78 done(1);
7979 }
8080
8181 s.sin_family = AF_INET;
82 s.sin_port = htons (port);
82 s.sin_port = htons(port);
8383 s.sin_addr.s_addr = INADDR_ANY;
8484
85 if (bind (fd, (struct sockaddr *) &s, sizeof (s)) < 0)
86 {
87 report (REPORT_ERROR, "bind: %s\n", sys_err_str (errno));
88 done (1);
85 if (bind(fd, (struct sockaddr *) &s, sizeof(s)) < 0)
86 {
87 report(REPORT_ERROR, "bind: %s\n", sys_err_str(errno));
88 done(1);
8989 }
9090
9191 return fd;
9393
9494 #ifdef __STDC__
9595 int
96 tcp_socket (int port)
97 #else
98 int
99 tcp_socket (port)
96 tcp_socket(int port)
97 #else
98 int
99 tcp_socket(port)
100100 int port;
101101 #endif
102102 {
104104 struct sockaddr_in s;
105105 int on = 1;
106106
107 fd = socket (AF_INET, SOCK_STREAM, 0);
107 fd = socket(AF_INET, SOCK_STREAM, 0);
108108 if (fd < 0)
109109 {
110 report (REPORT_ERROR, "socket: %s\n", sys_err_str (errno));
111 done (1);
112 }
113
114 if (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on)) < 0)
115 {
116 report (REPORT_ERROR, "setsockopt: SO_REUSEADDR: %s\n", sys_err_str (errno));
117 done (1);
110 report(REPORT_ERROR, "socket: %s\n", sys_err_str(errno));
111 done(1);
112 }
113
114 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)) < 0)
115 {
116 report(REPORT_ERROR, "setsockopt: SO_REUSEADDR: %s\n", sys_err_str(errno));
117 done(1);
118118 }
119119
120120 s.sin_family = AF_INET;
121 s.sin_port = htons (port);
121 s.sin_port = htons(port);
122122 s.sin_addr.s_addr = INADDR_ANY;
123123
124 if (bind (fd, (struct sockaddr *) &s, sizeof (s)) < 0)
125 {
126 report (REPORT_ERROR, "bind: %s\n", sys_err_str (errno));
127 done (1);
128 }
129
130 if (listen (fd, 5) < 0)
131 {
132 report (REPORT_ERROR, "listen: %s\n", sys_err_str (errno));
133 done (1);
124 if (bind(fd, (struct sockaddr *) &s, sizeof(s)) < 0)
125 {
126 report(REPORT_ERROR, "bind: %s\n", sys_err_str(errno));
127 done(1);
128 }
129
130 if (listen(fd, 5) < 0)
131 {
132 report(REPORT_ERROR, "listen: %s\n", sys_err_str(errno));
133 done(1);
134134 }
135135
136136 return fd;
141141 */
142142 #ifdef __STDC__
143143 void
144 fd_nonblock (int fd)
144 fd_nonblock(int fd)
145145 #else
146146 void
147 fd_nonblock (fd)
147 fd_nonblock(fd)
148148 int fd;
149149 #endif
150150 {
151151 int flags;
152152
153 flags = fcntl (fd, F_GETFL, 0);
153 flags = fcntl(fd, F_GETFL, 0);
154154 if (flags < 0)
155155 {
156 report (REPORT_ERROR, "fd_nonblock: F_GETFL fcntl: %s\n", sys_err_str (errno));
157 done (1);
156 report(REPORT_ERROR, "fd_nonblock: F_GETFL fcntl: %s\n", sys_err_str(errno));
157 done(1);
158158 }
159159 #ifdef linux
160160 flags |= O_NONBLOCK;
161161 #else
162162 flags |= FNDELAY;
163163 #endif
164 if (fcntl (fd, F_SETFL, flags) < 0)
165 {
166 report (REPORT_ERROR, "fd_nonblock: F_SETFL fcntl: %s\n", sys_err_str (errno));
167 done (1);
164 if (fcntl(fd, F_SETFL, flags) < 0)
165 {
166 report(REPORT_ERROR, "fd_nonblock: F_SETFL fcntl: %s\n", sys_err_str(errno));
167 done(1);
168168 }
169169 }
170170
173173 */
174174 #ifdef __STDC__
175175 void
176 fd_block (int fd)
176 fd_block(int fd)
177177 #else
178178 void
179 fd_block (fd)
179 fd_block(fd)
180180 int fd;
181181 #endif
182182 {
183183 int flags;
184184
185 flags = fcntl (fd, F_GETFL, 0);
185 flags = fcntl(fd, F_GETFL, 0);
186186 if (flags < 0)
187187 {
188 report (REPORT_ERROR, "fd_block: F_GETFL fcntl: %s\n", sys_err_str (errno));
189 done (1);
188 report(REPORT_ERROR, "fd_block: F_GETFL fcntl: %s\n", sys_err_str(errno));
189 done(1);
190190 }
191191 #ifdef linux
192192 flags &= ~O_NONBLOCK;
193193 #else
194194 flags &= ~FNDELAY;
195195 #endif
196 if (fcntl (fd, F_SETFL, flags) < 0)
197 {
198 report (REPORT_ERROR, "fd_block: F_SETFL fcntl: %s\n", sys_err_str (errno));
199 done (1);
200 }
201 }
202
203 #ifdef __STDC__
204 int
205 modified (char *filename, time_t since)
206 #else
207 int
208 modified (filename, since)
196 if (fcntl(fd, F_SETFL, flags) < 0)
197 {
198 report(REPORT_ERROR, "fd_block: F_SETFL fcntl: %s\n", sys_err_str(errno));
199 done(1);
200 }
201 }
202
203 #ifdef __STDC__
204 int
205 modified(char *filename, time_t since)
206 #else
207 int
208 modified(filename, since)
209209 char *filename;
210210 time_t since;
211211 #endif
212212 {
213213 struct stat st;
214214
215 if (stat (filename, &st) < 0)
216 {
217 report (REPORT_ERROR, "%s: %s\n", filename, sys_err_str (errno));
215 if (stat(filename, &st) < 0)
216 {
217 report(REPORT_ERROR, "%s: %s\n", filename, sys_err_str(errno));
218218 return 0;
219219 }
220220
223223
224224 #ifdef __STDC__
225225 char *
226 time2string (time_t t)
227 #else
228 char *
229 time2string (t)
226 time2string(time_t t)
227 #else
228 char *
229 time2string(t)
230230 time_t t;
231231 #endif
232232 {
245245
246246 if (days > 0)
247247 {
248 SNPRINTF (SIZE(buf,sizeof(buf)), "%d+", days);
249 }
250
251 SNPRINTF (SIZE(buf + strlen (buf),sizeof(buf)), "%02d:%02d:%02d", hours, mins, secs);
248 SNPRINTF(SIZE(buf, sizeof(buf)), "%d+", days);
249 }
250
251 SNPRINTF(SIZE(buf + strlen(buf), sizeof(buf) - strlen(buf)), "%02d:%02d:%02d", hours, mins, secs);
252252
253253 return buf;
254254 }
256256
257257 #ifdef __STDC__
258258 char *
259 audio_format_to_string (int format)
260 #else
261 char *
262 audio_format_to_string (format)
259 audio_format_to_string(int format)
260 #else
261 char *
262 audio_format_to_string(format)
263263 int format;
264264 #endif
265265 {
273273
274274 case RPLAY_FORMAT_ULINEAR_8:
275275 return "ulinear-8";
276
276
277277 case RPLAY_FORMAT_LINEAR_16:
278278 return "linear-16";
279279
281281 return "ulinear-16";
282282
283283 case RPLAY_FORMAT_G721:
284 return "g721";
284 return "g721";
285285
286286 case RPLAY_FORMAT_G723_3:
287 return "g723-3";
287 return "g723-3";
288288
289289 case RPLAY_FORMAT_G723_5:
290 return "g723-5";
290 return "g723-5";
291291
292292 case RPLAY_FORMAT_GSM:
293293 return "gsm";
294
294
295295 default:
296296 return "unknown";
297297 }
299299
300300 #ifdef __STDC__
301301 int
302 string_to_audio_format (char *string)
303 #else
304 int
305 string_to_audio_format (string)
302 string_to_audio_format(char *string)
303 #else
304 int
305 string_to_audio_format(string)
306306 char *string;
307307 #endif
308308 {
309 if (strcmp (string, "ulaw") == 0
310 || strcmp (string, "u_law") == 0
311 || strcmp (string, "u-law") == 0)
309 if (strcmp(string, "ulaw") == 0
310 || strcmp(string, "u_law") == 0
311 || strcmp(string, "u-law") == 0)
312312 {
313313 return RPLAY_FORMAT_ULAW;
314314 }
315 else if (strcmp (string, "linear-16") == 0
316 || strcmp (string, "linear_16") == 0
317 || strcmp (string, "linear16") == 0)
315 else if (strcmp(string, "linear-16") == 0
316 || strcmp(string, "linear_16") == 0
317 || strcmp(string, "linear16") == 0)
318318 {
319319 return RPLAY_FORMAT_LINEAR_16;
320320 }
321 else if (strcmp (string, "ulinear-16") == 0
322 || strcmp (string, "ulinear_16") == 0
323 || strcmp (string, "ulinear16") == 0)
321 else if (strcmp(string, "ulinear-16") == 0
322 || strcmp(string, "ulinear_16") == 0
323 || strcmp(string, "ulinear16") == 0)
324324 {
325325 return RPLAY_FORMAT_ULINEAR_16;
326326 }
327 else if (strcmp (string, "linear-8") == 0
328 || strcmp (string, "linear_8") == 0
329 || strcmp (string, "linear8") == 0)
327 else if (strcmp(string, "linear-8") == 0
328 || strcmp(string, "linear_8") == 0
329 || strcmp(string, "linear8") == 0)
330330 {
331331 return RPLAY_FORMAT_LINEAR_8;
332332 }
333 else if (strcmp (string, "ulinear-8") == 0
334 || strcmp (string, "ulinear_8") == 0
335 || strcmp (string, "ulinear8") == 0)
333 else if (strcmp(string, "ulinear-8") == 0
334 || strcmp(string, "ulinear_8") == 0
335 || strcmp(string, "ulinear8") == 0)
336336 {
337337 return RPLAY_FORMAT_ULINEAR_8;
338338 }
339 else if (strcmp (string, "g721") == 0)
339 else if (strcmp(string, "g721") == 0)
340340 {
341341 return RPLAY_FORMAT_G721;
342342 }
343 else if (strcmp (string, "g723-3") == 0
344 || strcmp (string, "g723_3") == 0)
343 else if (strcmp(string, "g723-3") == 0
344 || strcmp(string, "g723_3") == 0)
345345 {
346346 return RPLAY_FORMAT_G723_3;
347347 }
348 else if (strcmp (string, "g723-5") == 0
349 || strcmp (string, "g723_5") == 0)
348 else if (strcmp(string, "g723-5") == 0
349 || strcmp(string, "g723_5") == 0)
350350 {
351351 return RPLAY_FORMAT_G723_5;
352352 }
353 else if (strcmp (string, "gsm") == 0
354 || strcmp (string, "GSM") == 0)
353 else if (strcmp(string, "gsm") == 0
354 || strcmp(string, "GSM") == 0)
355355 {
356356 return RPLAY_FORMAT_GSM;
357357 }
363363
364364 #ifdef __STDC__
365365 char *
366 byte_order_to_string (int byte_order)
367 #else
368 char *
369 byte_order_to_string (byte_order)
366 byte_order_to_string(int byte_order)
367 #else
368 char *
369 byte_order_to_string(byte_order)
370370 int byte_order;
371371 #endif
372372 {
385385
386386 #ifdef __STDC__
387387 int
388 string_to_byte_order (char *string)
389 #else
390 int
391 string_to_byte_order (string)
388 string_to_byte_order(char *string)
389 #else
390 int
391 string_to_byte_order(string)
392392 char *string;
393393 #endif
394394 {
395 if (strcmp (string, "big-endian") == 0
396 || strcmp (string, "big") == 0)
395 if (strcmp(string, "big-endian") == 0
396 || strcmp(string, "big") == 0)
397397 {
398398 return RPLAY_BIG_ENDIAN;
399399 }
400 else if (strcmp (string, "little-endian") == 0
401 || strcmp (string, "little") == 0)
400 else if (strcmp(string, "little-endian") == 0
401 || strcmp(string, "little") == 0)
402402 {
403403 return RPLAY_LITTLE_ENDIAN;
404404 }
410410
411411 #ifdef __STDC__
412412 char *
413 storage_to_string (int storage)
414 #else
415 char *
416 storage_to_string (storage)
413 storage_to_string(int storage)
414 #else
415 char *
416 storage_to_string(storage)
417417 int storage;
418418 #endif
419419 {
435435
436436 #ifdef __STDC__
437437 int
438 string_to_storage (char *string)
439 #else
440 int
441 string_to_storage (string)
438 string_to_storage(char *string)
439 #else
440 int
441 string_to_storage(string)
442442 char *string;
443443 #endif
444444 {
445 if (strcmp (string, "none") == 0)
445 if (strcmp(string, "none") == 0)
446446 {
447447 return SOUND_STORAGE_NONE;
448448 }
449 else if (strcmp (string, "disk") == 0)
449 else if (strcmp(string, "disk") == 0)
450450 {
451451 return SOUND_STORAGE_DISK;
452452 }
453 else if (strcmp (string, "memory") == 0)
453 else if (strcmp(string, "memory") == 0)
454454 {
455455 return SOUND_STORAGE_MEMORY;
456456 }
462462
463463 #ifdef __STDC__
464464 char *
465 input_to_string (int input)
466 #else
467 char *
468 input_to_string (input)
465 input_to_string(int input)
466 #else
467 char *
468 input_to_string(input)
469469 int input;
470470 #endif
471471 {
480480 #ifdef HAVE_CDROM
481481 case SOUND_CDROM:
482482 return "cdrom";
483 #endif /* HAVE_CDROM */
483 #endif /* HAVE_CDROM */
484484
485485 case SOUND_VIRTUAL:
486486 return "virtual";
492492
493493 #ifdef __STDC__
494494 int
495 string_to_input (char *string)
496 #else
497 int
498 string_to_input (string)
495 string_to_input(char *string)
496 #else
497 int
498 string_to_input(string)
499499 char *string;
500500 #endif
501501 {
502 if (strcmp (string, "file") == 0)
502 if (strcmp(string, "file") == 0)
503503 {
504504 return SOUND_FILE;
505505 }
506 else if (strcmp (string, "flow") == 0)
506 else if (strcmp(string, "flow") == 0)
507507 {
508508 return SOUND_FLOW;
509509 }
515515
516516 #ifdef __STDC__
517517 char *
518 audio_port_to_string (int port)
519 #else
520 char *
521 audio_port_to_string (port)
518 audio_port_to_string(int port)
519 #else
520 char *
521 audio_port_to_string(port)
522522 int port;
523523 #endif
524524 {
525525 static char string[128];
526 int n;
526527
527528 string[0] = '\0';
528 if (BIT (port, RPLAY_AUDIO_PORT_NONE))
529 {
530 SNPRINTF (SIZE(string+strlen(string),sizeof(string)), "none,");
531 }
532 if (BIT (port, RPLAY_AUDIO_PORT_SPEAKER))
533 {
534 SNPRINTF (SIZE(string+strlen(string),sizeof(string)), "speaker,");
535 }
536 if (BIT (port, RPLAY_AUDIO_PORT_HEADPHONE))
537 {
538 SNPRINTF (SIZE(string+strlen(string),sizeof(string)), "headphone,");
539 }
540 if (BIT (port, RPLAY_AUDIO_PORT_LINEOUT))
541 {
542 SNPRINTF (SIZE(string+strlen(string),sizeof(string)), "lineout,");
543 }
544 string[strlen (string) - 1] = '\0';
529 if (BIT(port, RPLAY_AUDIO_PORT_NONE))
530 {
531 strncat(string, "none,", sizeof(string) - strlen(string));
532 }
533 if (BIT(port, RPLAY_AUDIO_PORT_SPEAKER))
534 {
535 strncat(string, "speaker,", sizeof(string) - strlen(string));
536 }
537 if (BIT(port, RPLAY_AUDIO_PORT_HEADPHONE))
538 {
539 strncat(string, "headphone,", sizeof(string) - strlen(string));
540 }
541 if (BIT(port, RPLAY_AUDIO_PORT_LINEOUT))
542 {
543 strncat(string, "lineout,", sizeof(string) - strlen(string));
544 }
545 string[strlen(string) - 1] = '\0';
545546
546547 return string;
547548 }
548549
549550 unsigned short
550 little_short (p)
551 little_short(p)
551552 char *p;
552553 {
553554 return (((unsigned long) (((unsigned char *) p)[1])) << 8) |
555556 }
556557
557558 unsigned short
558 big_short (p)
559 big_short(p)
559560 char *p;
560561 {
561562 return (((unsigned long) (((unsigned char *) p)[0])) << 8) |
563564 }
564565
565566 unsigned long
566 little_long (p)
567 little_long(p)
567568 char *p;
568569 {
569570 return (((unsigned long) (((unsigned char *) p)[3])) << 24) |
573574 }
574575
575576 unsigned long
576 big_long (p)
577 big_long(p)
577578 char *p;
578579 {
579580 return (((unsigned long) (((unsigned char *) p)[0])) << 24) |
629630 ****************************************************************/
630631
631632 double
632 ConvertFromIeeeExtended (bytes)
633 ConvertFromIeeeExtended(bytes)
633634 unsigned char *bytes; /* LCN */
634635 {
635636 double f;
659660 else
660661 {
661662 expon -= 16383;
662 f = ldexp (UnsignedToFloat (hiMant), expon -= 31);
663 f += ldexp (UnsignedToFloat (loMant), expon -= 32);
663 f = ldexp(UnsignedToFloat(hiMant), expon -= 31);
664 f += ldexp(UnsignedToFloat(loMant), expon -= 32);
664665 }
665666 }
666667
0 /* $Id: misc.h,v 1.2 1998/08/13 06:13:57 boyns Exp $ */
0 /* $Id: misc.h,v 1.3 1999/03/10 07:58:03 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: native.c,v 1.2 1998/08/13 06:13:58 boyns Exp $ */
0 /* $Id: native.c,v 1.4 1999/03/10 07:58:03 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
3434
3535 /* Native means 16-bit signed. */
3636
37 static int ulaw_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
38 static int s8_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
39 static int u8_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
40 static int big_s16_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
41 static int big_u16_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
42 static int little_s16_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
43 static int little_u16_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
44 static int native_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
45 static int native_to_ulaw ( /* char *native_buf, int nsamples, int nchannels */ );
46 static int native_to_s8 ( /* char *native_buf, int nsamples, int nchannels */ );
47 static int native_to_u8 ( /* char *native_buf, int nsamples, int nchannels */ );
48 static int native_to_s16 ( /* char *native_buf, int nsamples, int nchannels */ );
49 static int native_to_u16 ( /* char *native_buf, int nsamples, int nchannels */ );
50 static int native_to_g721 ( /* char *native_buf, int nsamples, int nchannels */ );
51 static int native_to_g723_3 ( /* char *native_buf, int nsamples, int nchannels */ );
52 static int native_to_g723_5 ( /* char *native_buf, int nsamples, int nchannels */ );
53 static int native_to_gsm ( /* char *native_buf, int nsamples, int nchannels */ );
37 static int ulaw_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
38 static int s8_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
39 static int u8_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
40 static int big_s16_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
41 static int big_u16_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
42 static int little_s16_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
43 static int little_u16_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
44 static int native_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ );
45 static int native_to_ulaw( /* char *native_buf, int nsamples, int nchannels */ );
46 static int native_to_s8( /* char *native_buf, int nsamples, int nchannels */ );
47 static int native_to_u8( /* char *native_buf, int nsamples, int nchannels */ );
48 static int native_to_s16( /* char *native_buf, int nsamples, int nchannels */ );
49 static int native_to_u16( /* char *native_buf, int nsamples, int nchannels */ );
50 static int native_to_g721( /* char *native_buf, int nsamples, int nchannels */ );
51 static int native_to_g723_3( /* char *native_buf, int nsamples, int nchannels */ );
52 static int native_to_g723_5( /* char *native_buf, int nsamples, int nchannels */ );
53 static int native_to_gsm( /* char *native_buf, int nsamples, int nchannels */ );
5454
5555 /* Setup the to and from native table. */
5656 NATIVE_TABLE native_table[] =
5757 {
58 {{0, 0}, {0, 0}},
59 {{s8_to_native, s8_to_native}, {native_to_s8, native_to_s8}},
60 {{u8_to_native, u8_to_native}, {native_to_u8, native_to_u8}},
61 {{big_s16_to_native, little_s16_to_native}, {native_to_s16, native_to_s16}},
62 {{big_u16_to_native, little_u16_to_native}, {native_to_u16, native_to_u16}},
63 {{ulaw_to_native, ulaw_to_native}, {native_to_ulaw, native_to_ulaw}},
64 #ifdef HAVE_ADPCM
65 {{native_to_native, native_to_native}, {native_to_g721, native_to_g721}},
66 {{native_to_native, native_to_native}, {native_to_g723_3, native_to_g723_5}},
67 {{native_to_native, native_to_native}, {native_to_g723_3, native_to_g723_5}},
68 #endif /* HAVE_ADPCM */
58 {
59 {0, 0},
60 {0, 0}},
61 {
62 {s8_to_native, s8_to_native},
63 {native_to_s8, native_to_s8}},
64 {
65 {u8_to_native, u8_to_native},
66 {native_to_u8, native_to_u8}},
67 {
68 {big_s16_to_native, little_s16_to_native},
69 {native_to_s16, native_to_s16}},
70 {
71 {big_u16_to_native, little_u16_to_native},
72 {native_to_u16, native_to_u16}},
73 {
74 {ulaw_to_native, ulaw_to_native},
75 {native_to_ulaw, native_to_ulaw}},
76 #ifdef HAVE_ADPCM
77 {
78 {native_to_native, native_to_native},
79 {native_to_g721, native_to_g721}},
80 {
81 {native_to_native, native_to_native},
82 {native_to_g723_3, native_to_g723_5}},
83 {
84 {native_to_native, native_to_native},
85 {native_to_g723_3, native_to_g723_5}},
86 #endif /* HAVE_ADPCM */
6987 #ifdef HAVE_GSM
70 {{native_to_native, native_to_native}, {native_to_gsm, native_to_gsm}},
71 #endif /* HAVE_GSM */
88 {
89 {native_to_native, native_to_native},
90 {native_to_gsm, native_to_gsm}},
91 #endif /* HAVE_GSM */
7292 };
7393
7494 /* Initialize the native audio buffer. */
7595 void
76 zero_native (native_buf, nsamples, nchannels)
77 char *native_buf;
78 int nsamples;
79 int nchannels;
80 {
81 memset (native_buf, 0, nsamples * nchannels * 2); /* 2 == 16-bit */
96 zero_native(native_buf, nsamples, nchannels)
97 char *native_buf;
98 int nsamples;
99 int nchannels;
100 {
101 memset(native_buf, 0, nsamples * nchannels * 2); /* 2 == 16-bit */
82102 }
83103
84104
85105 void
86 level (native_buf, nsamples, nchannels)
106 level(native_buf, nsamples, nchannels)
87107 char *native_buf;
88108 int nsamples;
89109 int nchannels;
93113 long left_max = 0, right_max = 0;
94114
95115 /* Optimize the cases for stereo and mono output. */
96
116
97117 if (nchannels == 2) /* stereo */
98118 {
99119 while (n--)
102122 sample = (*p++ >> 7);
103123 #else
104124 sample = (*p++ * rplay_audio_volume) >> 14;
105 #endif
125 #endif
106126 if (n & 1)
107127 {
108128 if (sample > right_max)
119139 }
120140 }
121141 }
122 else /* mono */
142 else
143 /* mono */
123144 {
124145 while (n--)
125146 {
127148 sample = (*p++ >> 7);
128149 #else
129150 sample = (*p++ * rplay_audio_volume) >> 14;
130 #endif
151 #endif
131152 if (sample > left_max)
132153 {
133154 left_max = sample;
144165 #ifdef FAKE_VOLUME
145166 /* Simulate hardware volume control. */
146167 void
147 fake_volume (native_buf, nsamples, nchannels)
168 fake_volume(native_buf, nsamples, nchannels)
148169 char *native_buf;
149170 int nsamples;
150171 int nchannels;
317338 /* ulaw */
318339 x_to_native
319340 (
320 ulaw_to_native,
321 linear = ulaw_to_linear (*(sp->ptr + curr_channel))
341 ulaw_to_native,
342 linear = ulaw_to_linear(*(sp->ptr + curr_channel))
322343 )
323344
324345 /* signed 8-bit */
325346 x_to_native
326347 (
327 s8_to_native,
328 linear = (char) *(sp->ptr + curr_channel);
329 linear <<= 8
348 s8_to_native,
349 linear = (char) *(sp->ptr + curr_channel);
350 linear <<= 8
330351 )
331352
332353 /* unsigned 8-bit */
333354 x_to_native
334355 (
335 u8_to_native,
336 linear = (unsigned char) *(sp->ptr + curr_channel) ^ 0x80;
337 linear <<= 8
356 u8_to_native,
357 linear = (unsigned char) *(sp->ptr + curr_channel) ^ 0x80;
358 linear <<= 8
338359 )
339360
340361 /* signed 16-bit big-endian */
341362 x_to_native
342363 (
343 big_s16_to_native,
344 linear = (short) (sp->ptr[curr_channel << 1] << 8 | sp->ptr[(curr_channel << 1) + 1])
364 big_s16_to_native,
365 linear = (short) (sp->ptr[curr_channel << 1] << 8 | sp->ptr[(curr_channel << 1) + 1])
345366 )
346367
347368 /* signed 16-bit little-endian */
348369 x_to_native
349370 (
350 little_s16_to_native,
351 linear = (short) (sp->ptr[(curr_channel << 1) + 1] << 8 | sp->ptr[curr_channel << 1])
371 little_s16_to_native,
372 linear = (short) (sp->ptr[(curr_channel << 1) + 1] << 8 | sp->ptr[curr_channel << 1])
352373 )
353374
354375 /* unsigned 16-bit big-endian */
355376 x_to_native
356377 (
357 big_u16_to_native,
358 linear = (short) (sp->ptr[curr_channel << 1] << 8 | sp->ptr[(curr_channel << 1) + 1]) ^ 0x8000;
378 big_u16_to_native,
379 linear = (short) (sp->ptr[curr_channel << 1] << 8 | sp->ptr[(curr_channel << 1) + 1]) ^ 0x8000;
359380 )
360381
361382 /* unsigned 16-bit little-endian */
362383 x_to_native
363384 (
364 little_u16_to_native,
365 linear = (short) (sp->ptr[(curr_channel << 1) + 1] << 8 | sp->ptr[curr_channel << 1]) ^ 0x8000;
385 little_u16_to_native,
386 linear = (short) (sp->ptr[(curr_channel << 1) + 1] << 8 | sp->ptr[curr_channel << 1]) ^ 0x8000;
366387 )
367388
368389 /* native to native */
369390 x_to_native
370391 (
371 native_to_native,
372 linear = ( *((short *) sp->ptr + curr_channel) )
373 )
374
375 static int
376 native_to_ulaw (native_buf, nsamples, nchannels)
392 native_to_native,
393 linear = (*((short *) sp->ptr + curr_channel))
394 )
395
396 static int
397 native_to_ulaw(native_buf, nsamples, nchannels)
377398 char *native_buf;
378399 int nsamples;
379400 int nchannels;
384405
385406 while (n--)
386407 {
387 *to++ = linear_to_ulaw (*from++);
388 }
389
390 return 0;
391 }
392
393 static int
394 native_to_s8 (native_buf, nsamples, nchannels)
408 *to++ = linear_to_ulaw(*from++);
409 }
410
411 return 0;
412 }
413
414 static int
415 native_to_s8(native_buf, nsamples, nchannels)
395416 char *native_buf;
396417 int nsamples;
397418 int nchannels;
409430 }
410431
411432 static int
412 native_to_u8 (native_buf, nsamples, nchannels)
433 native_to_u8(native_buf, nsamples, nchannels)
413434 char *native_buf;
414435 int nsamples;
415436 int nchannels;
427448 }
428449
429450 static int
430 native_to_s16 (native_buf, nsamples, nchannels)
451 native_to_s16(native_buf, nsamples, nchannels)
431452 char *native_buf;
432453 int nsamples;
433454 int nchannels;
437458 }
438459
439460 static int
440 native_to_u16 (native_buf, nsamples, nchannels)
461 native_to_u16(native_buf, nsamples, nchannels)
441462 char *native_buf;
442463 int nsamples;
443464 int nchannels;
456477
457478 #ifdef HAVE_ADPCM
458479 static int
459 native_to_g721 (native_buf, nsamples, nchannels)
480 native_to_g721(native_buf, nsamples, nchannels)
460481 char *native_buf;
461482 int nsamples;
462483 int nchannels;
466487 }
467488
468489 static int
469 native_to_g723_3 (native_buf, nsamples, nchannels)
490 native_to_g723_3(native_buf, nsamples, nchannels)
470491 char *native_buf;
471492 int nsamples;
472493 int nchannels;
476497 }
477498
478499 static int
479 native_to_g723_5 (native_buf, nsamples, nchannels)
500 native_to_g723_5(native_buf, nsamples, nchannels)
480501 char *native_buf;
481502 int nsamples;
482503 int nchannels;
488509
489510 #ifdef HAVE_GSM
490511 static int
491 native_to_gsm (native_buf, nsamples, nchannels)
512 native_to_gsm(native_buf, nsamples, nchannels)
492513 char *native_buf;
493514 int nsamples;
494515 int nchannels;
0 /* $Id: native.h,v 1.2 1998/08/13 06:14:00 boyns Exp $ */
0 /* $Id: native.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: rplayd.c,v 1.2 1998/08/13 06:14:01 boyns Exp $ */
0 /* $Id: rplayd.c,v 1.8 1999/03/10 07:58:04 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifdef HAVE_CONFIG_H
2624 #include "config.h"
104102 #ifdef AUTH
105103 int auth_enabled = 1; /* Host authentication. (--auth, --no-auth) */
106104 #endif /* AUTH */
107 int rplay_priority_threshold = RPLAY_DEFAULT_PRIORITY; /* Default priority level allowed. */
105 int rplay_priority_threshold = RPLAY_DEFAULT_PRIORITY; /* Default priority level allowed. */
108106
109107 /* Global audio-specific variables */
110108 char *rplay_audio_device = RPLAY_AUDIO_DEVICE; /* Which audio device to use. */
151149 int rplay_audio_left_level = 0;
152150 int rplay_audio_right_level = 0;
153151
154 static int rplay_audio_timeout = RPLAY_AUDIO_TIMEOUT;
152 static int monitor_total_bytes = 176400 * 5; /* 5 seconds */
153 static int monitor_update = 0;
154 int monitor_count = 0;
155 BUFFER *monitor_buffers = NULL;
156
157 int rplay_audio_timeout = RPLAY_AUDIO_TIMEOUT;
155158 static int rplay_audio_flush_timeout = RPLAY_AUDIO_FLUSH_TIMEOUT;
156 static int rplayd_timeout = RPLAYD_TIMEOUT; /* seconds */
157 static int sound_cleanup_timeout = 10; /* seconds */
158 static int buffer_cleanup_timeout = 10; /* seconds */
159 static int spool_cleanup_timeout = 0; /* seconds -- disabled for now */
159 static int rplayd_timeout = RPLAYD_TIMEOUT; /* seconds */
160 static int sound_cleanup_timeout = 10; /* seconds */
161 static int buffer_cleanup_timeout = 10; /* seconds */
162 static int spool_cleanup_timeout = 0; /* seconds -- disabled for now */
160163 static int need_to_reset = 0;
161164 static char *progname;
162165 static char *sounds_file = NULL;
202205 static struct option longopts[] =
203206 {
204207 {"audio-device", required_argument, NULL, 'A'},
205 #ifndef HAVE_OSS
208 #ifndef HAVE_OSS
206209 {"audio-bufsize", required_argument, NULL, 'b'},
207 #endif /* !HAVE_OSS */
210 #endif /* !HAVE_OSS */
208211 {"audio-bits", required_argument, NULL, 'B'},
209212 {"audio-channels", required_argument, NULL, 1},
210213 {"audio-close", required_argument, NULL, 'c'},
211214 {"audio-flush", required_argument, NULL, 'F'},
212215 {"audio-format", required_argument, NULL, 3},
213 #ifdef HAVE_OSS
216 #ifdef HAVE_OSS
214217 {"audio-fragsize", required_argument, NULL, 18},
215 #endif /* HAVE_OSS */
218 #endif /* HAVE_OSS */
216219 {"audio-info", required_argument, NULL, 'i'},
217220 {"audio-info-ulaw", no_argument, NULL, 13},
218221 {"audio-match", no_argument, &rplay_audio_match, 1},
226229 {"cache-directory", required_argument, NULL, 'D'},
227230 {"cache-remove", no_argument, NULL, 12},
228231 {"cache-size", required_argument, NULL, 's'},
229 #ifdef HAVE_CDROM
232 #ifdef HAVE_CDROM
230233 {"cdrom0", required_argument, NULL, 14},
231234 {"cdrom1", required_argument, NULL, 15},
232235 {"cdrom2", required_argument, NULL, 16},
233236 {"cdrom3", required_argument, NULL, 17},
234 #endif /* HAVE_CDROM */
237 #endif /* HAVE_CDROM */
235238 {"conf", required_argument, NULL, 'C'},
236239 {"connection-timeout", required_argument, NULL, 'T'},
237240 {"debug", no_argument, NULL, 'd'},
239242 {"forward", required_argument, NULL, 'f'},
240243 {"group", required_argument, NULL, 21},
241244 {"help", no_argument, NULL, 2},
242 #ifdef HAVE_HELPERS
245 #ifdef HAVE_HELPERS
243246 {"helpers", required_argument, NULL, 20},
244 #endif /* HAVE_HELPERS */
247 #endif /* HAVE_HELPERS */
245248 #ifdef AUTH
246249 {"hosts", required_argument, NULL, 'H'},
247250 #endif
276279
277280 #ifdef sun
278281 #ifdef __STDC__
279 extern int gethostname (char *name, int namelen);
280 #else
281 extern int gethostname ( /* char *name, int namelen */ );
282 #endif
283 #endif
284
285 extern char *ctime ();
282 extern int gethostname(char *name, int namelen);
283 #else
284 extern int gethostname( /* char *name, int namelen */ );
285 #endif
286 #endif
287
288 extern char *ctime();
286289 #ifdef __STDC__
287 static void do_option_file (char *option_file);
288 static void do_option (int option_value);
289 #else
290 static void do_option_file ( /* char *option_file */ );
291 static void do_option ( /* int option_value */ );
292 #endif
293 static void doit ();
294 static void handle_signals ();
295 static void handle_sighup ();
296 static void handle_sigint ();
297 static void handle_sigchld ();
298 static void reset ();
299 static void audio_test ();
290 static void do_option_file(char *option_file);
291 static void do_option(int option_value);
292 #else
293 static void do_option_file( /* char *option_file */ );
294 static void do_option( /* int option_value */ );
295 #endif
296 static void doit();
297 static void handle_signals();
298 static void handle_sighup();
299 static void handle_sigint();
300 static void handle_sigchld();
301 static void reset();
302 static void audio_test();
300303
301304 #if defined(HAVE_CDROM) || defined(HAVE_HELPERS)
302305 #ifdef __STDC__
303 void rplayd_pipe_read (/* fd_set *rfds */);
304 #else
305 void rplayd_pipe_read (/* fd_set *rfds */);
306 void rplayd_pipe_read( /* fd_set *rfds */ );
307 #else
308 void rplayd_pipe_read( /* fd_set *rfds */ );
306309 #endif
307310 #endif
308311
313316 #endif
314317
315318 #ifdef __STDC__
316 main (int argc, char **argv)
317 #else
318 main (argc, argv)
319 main(int argc, char **argv)
320 #else
321 main(argc, argv)
319322 int argc;
320323 char **argv;
321324 #endif
325328 struct in_addr addr;
326329 char *rplaydrc;
327330
328 starttime = time (0);
331 starttime = time(0);
329332
330333 progname = argv[0];
331334
332 servers_file = tilde_expand (RPLAY_SERVERS);
333 #ifdef HAVE_HELPERS
334 helpers_file = tilde_expand (RPLAY_HELPERS);
335 #endif /* HAVE_HELPERS */
336 sounds_file = tilde_expand (RPLAY_CONF);
335 servers_file = tilde_expand(RPLAY_SERVERS);
336 #ifdef HAVE_HELPERS
337 helpers_file = tilde_expand(RPLAY_HELPERS);
338 #endif /* HAVE_HELPERS */
339 sounds_file = tilde_expand(RPLAY_CONF);
337340 #ifdef AUTH
338 hosts_file = tilde_expand (RPLAY_HOSTS);
341 hosts_file = tilde_expand(RPLAY_HOSTS);
339342 #endif /* AUTH */
340 cache_dir = tilde_expand (RPLAY_CACHE);
341 log_file = tilde_expand (RPLAY_LOG);
343 cache_dir = tilde_expand(RPLAY_CACHE);
344 log_file = tilde_expand(RPLAY_LOG);
342345
343346 #ifdef RPLAYD_ALWAYS_LOG
344347 report_level = RPLAYD_LOG_LEVEL;
351354 #endif
352355
353356 /* Parse RPLAYDRC. */
354 rplaydrc = tilde_expand (RPLAYDRC);
357 rplaydrc = tilde_expand(RPLAYDRC);
355358 if (rplaydrc)
356359 {
357360 struct stat st;
358
359 if (stat (rplaydrc, &st) == 0 && S_ISREG (st.st_mode))
360 {
361 do_option_file (rplaydrc);
362 }
363
364 free (rplaydrc);
365 }
366
361
362 if (stat(rplaydrc, &st) == 0 && S_ISREG(st.st_mode))
363 {
364 do_option_file(rplaydrc);
365 }
366
367 free(rplaydrc);
368 }
369
367370 /* Parse command line options. */
368 while ((c = getopt_long (argc, argv, OPTIONS, longopts, 0)) != -1)
369 {
370 do_option (c);
371 while ((c = getopt_long(argc, argv, OPTIONS, longopts, 0)) != -1)
372 {
373 do_option(c);
371374 }
372375
373376 if (audio_test_mode)
374377 {
375378 report_level = 0; /* don't want debug output */
376 audio_test ();
377 done (0);
379 audio_test();
380 done(0);
378381 }
379382
380383 if (run_as_group && *run_as_group)
381384 {
382 struct group *gr = getgrnam (run_as_group);
385 struct group *gr = getgrnam(run_as_group);
383386 if (!gr)
384387 {
385 fprintf (stderr, "Unknown group `%s'.\n", run_as_group);
386 done (1);
387 }
388 if (setgid (gr->gr_gid) < 0)
389 {
390 report (REPORT_ERROR, "setgid: %s\n", sys_err_str (errno));
391 done (1);
392 }
393 report (REPORT_DEBUG, "running as group %s (%d)\n", run_as_group, gr->gr_gid);
388 fprintf(stderr, "Unknown group `%s'.\n", run_as_group);
389 done(1);
390 }
391 if (setgid(gr->gr_gid) < 0)
392 {
393 report(REPORT_ERROR, "setgid: %s\n", sys_err_str(errno));
394 done(1);
395 }
396 report(REPORT_DEBUG, "running as group %s (%d)\n", run_as_group, gr->gr_gid);
394397 }
395398 if (run_as_user && *run_as_user)
396399 {
397 struct passwd *pw = getpwnam (run_as_user);
400 struct passwd *pw = getpwnam(run_as_user);
398401 if (!pw)
399402 {
400 fprintf (stderr, "Unknown user `%s'.\n", run_as_user);
401 done (1);
402 }
403 if (setuid (pw->pw_uid) < 0)
404 {
405 report (REPORT_ERROR, "setuid: %s\n", sys_err_str (errno));
406 done (1);
407 }
408 report (REPORT_DEBUG, "running as user %s (%d)\n", run_as_user, pw->pw_uid);
403 fprintf(stderr, "Unknown user `%s'.\n", run_as_user);
404 done(1);
405 }
406 if (setuid(pw->pw_uid) < 0)
407 {
408 report(REPORT_ERROR, "setuid: %s\n", sys_err_str(errno));
409 done(1);
410 }
411 report(REPORT_DEBUG, "running as user %s (%d)\n", run_as_user, pw->pw_uid);
409412 }
410413
411414 if (debug)
417420 /* Fork */
418421 if (do_fork)
419422 {
420 int pid = fork ();
423 int pid = fork();
421424 if (pid != 0)
422425 {
423 exit (0);
424 }
425 }
426
427 if (gethostname (hostname, sizeof (hostname)) < 0)
428 {
429 report (REPORT_ERROR, "gethostname: %s\n", sys_err_str (errno));
430 done (1);
431 }
432
433 hp = gethostbyname (hostname);
426 exit(0);
427 }
428 }
429
430 if (gethostname(hostname, sizeof(hostname)) < 0)
431 {
432 report(REPORT_ERROR, "gethostname: %s\n", sys_err_str(errno));
433 done(1);
434 }
435
436 hp = gethostbyname(hostname);
434437 if (hp == NULL)
435438 {
436 report (REPORT_ERROR, "gethostbyname: cannot resolve hostname: %s\n", hostname);
437 done (1);
438 }
439 memcpy ((char *) &addr, (char *) hp->h_addr, hp->h_length);
440 hostaddr = strdup (inet_ntoa (addr));
441
442 rplayd_pid = getpid ();
443
444 handle_signals ();
445
439 report(REPORT_ERROR, "gethostbyname: cannot resolve hostname: %s\n", hostname);
440 done(1);
441 }
442 memcpy((char *) &addr, (char *) hp->h_addr, hp->h_length);
443 hostaddr = strdup(inet_ntoa(addr));
444
445 rplayd_pid = getpid();
446
447 handle_signals();
448
446449 /* Call all the initialization routines. */
447 rplayd_init ();
450 rplayd_init();
448451 #ifdef HAVE_HELPERS
449 helper_read (helpers_file);
452 helper_read(helpers_file);
450453 #endif /* HAVE_HELPERS */
451 sound_read (sounds_file);
452 cache_init (cache_dir);
453 cache_read ();
454 sound_read(sounds_file);
455 cache_init(cache_dir);
456 cache_read();
454457 #ifdef AUTH
455 host_read (hosts_file);
458 host_read(hosts_file);
456459 #endif /* AUTH */
457 server_read (servers_file);
458 spool_init ();
459 timer_init ();
460 if (rplayd_audio_init () < 0)
460 server_read(servers_file);
461 spool_init();
462 timer_init();
463 if (rplayd_audio_init() < 0)
461464 {
462465 /* Disable audio. */
463466 audio_enabled = 0;
464 report (REPORT_DEBUG, "audio disabled\n");
467 report(REPORT_DEBUG, "audio disabled\n");
465468 }
466469 else
467470 {
477480 }
478481
479482 #ifdef AUTH
480 report (REPORT_DEBUG, "authentication %s\n", auth_enabled ? "enabled" : "disabled");
481 #else
482 report (REPORT_DEBUG, "no authentication\n");
483 report(REPORT_DEBUG, "authentication %s\n", auth_enabled ? "enabled" : "disabled");
484 #else
485 report(REPORT_DEBUG, "no authentication\n");
483486 #endif
484487
485488 if (forward)
486489 {
487 report (REPORT_DEBUG, "forwarding sounds to %s\n", forward);
488 }
489
490 report (REPORT_DEBUG, "%s rplayd %s ready.\n", hostname, RPLAY_VERSION);
491
492 doit ();
490 report(REPORT_DEBUG, "forwarding sounds to %s\n", forward);
491 }
492
493 report(REPORT_DEBUG, "%s rplayd %s ready.\n", hostname, RPLAY_VERSION);
494
495 doit();
493496 }
494497
495498 #ifdef __STDC__
496499 static void
497 do_option_file (char *option_file)
500 do_option_file(char *option_file)
498501 #else
499502 static void
500 do_option_file (option_file)
503 do_option_file(option_file)
501504 char *option_file;
502505 #endif
503506 {
505508 char buf[BUFSIZ], *p;
506509 FILE *fp;
507510 int saved_optind;
508 char *argv[1024]; /* that should be enough */
511 char *argv[1024]; /* that should be enough */
509512 int argc = 0;
510513
511 fp = fopen (option_file, "r");
514 fp = fopen(option_file, "r");
512515 if (fp == NULL)
513516 {
514 report (REPORT_ERROR, "cannot open `%s'.\n", option_file);
517 report(REPORT_ERROR, "cannot open `%s'.\n", option_file);
515518 return;
516519 }
517
520
518521 argv[argc++] = progname;
519522
520 tilde_additional_prefixes = (char **) xmalloc (2 * sizeof (char *));
523 tilde_additional_prefixes = (char **) xmalloc(2 * sizeof(char *));
521524 tilde_additional_prefixes[0] = "=~";
522525 tilde_additional_prefixes[1] = (char *) NULL;
523
524 while (fgets (buf, sizeof (buf), fp))
526
527 while (fgets(buf, sizeof(buf), fp))
525528 {
526529 switch (buf[0])
527530 {
531534 case '\t':
532535 continue;
533536 }
534
537
535538 first = 1;
536 while (p = (char *) strtok (first ? buf : NULL, " \t\n"))
539 while (p = (char *) strtok(first ? buf : NULL, " \t\n"))
537540 {
538541 first = 0;
539 argv[argc++] = tilde_expand (p);
540 }
541 }
542
543 fclose (fp);
544 free ((char *) tilde_additional_prefixes);
542 argv[argc++] = tilde_expand(p);
543 }
544 }
545
546 fclose(fp);
547 free((char *) tilde_additional_prefixes);
545548 tilde_additional_prefixes = NULL;
546549 argv[argc] = NULL;
547550
548551 saved_optind = optind; /* save optind */
549 optind = 1; /* reset optind */
550 while ((c = getopt_long (argc, argv, OPTIONS, longopts, 0)) != -1)
551 {
552 do_option (c);
552 optind = 1; /* reset optind */
553 while ((c = getopt_long(argc, argv, OPTIONS, longopts, 0)) != -1)
554 {
555 do_option(c);
553556 }
554557 optind = saved_optind; /* restore optind */
555558 }
557560
558561 #ifdef __STDC__
559562 static void
560 do_option (int option_value)
563 do_option(int option_value)
561564 #else
562565 static void
563 do_option (option_value)
566 do_option(option_value)
564567 int option_value;
565568 #endif
566569 {
577580 case 1:
578581 /* --audio-channels */
579582
580 optional_channels = atoi (optarg);
583 optional_channels = atoi(optarg);
581584 if (optional_channels != 1 && optional_channels != 2)
582585 {
583 usage ();
584 done (1);
586 usage();
587 done(1);
585588 }
586589 break;
587590
588591 case 2:
589592 /* --help */
590 usage ();
591 done (1);
593 usage();
594 done(1);
592595
593596 case 3:
594597 /* --audio-format */
595 optional_format = string_to_audio_format (optarg);
598 optional_format = string_to_audio_format(optarg);
596599 if (optional_format < 0)
597600 {
598 usage ();
599 done (1);
601 usage();
602 done(1);
600603 }
601604 break;
602605
603606 case 4:
604607 /* --memory-cache-size */
605 sound_cache_max_size = atoi (optarg);
608 sound_cache_max_size = atoi(optarg);
606609 break;
607610
608611 case 5:
609612 /* --memory-cache-sound-size */
610 sound_cache_max_sound_size = atoi (optarg);
613 sound_cache_max_sound_size = atoi(optarg);
611614 break;
612615
613616 case 6:
614617 /* --port or --rplay-port */
615 rplay_port = atoi (optarg);
618 rplay_port = atoi(optarg);
616619 break;
617620
618621 case 7:
619622 /* --rptp-port */
620 rptp_port = atoi (optarg);
623 rptp_port = atoi(optarg);
621624 break;
622625
623626 #ifdef OTHER_RPLAY_PORTS
624627 case 8:
625628 /* --other-rplay-port */
626 other_rplay_port = atoi (optarg);
629 other_rplay_port = atoi(optarg);
627630 break;
628631
629632 case 9:
630633 /* --other-rptp-port */
631 other_rptp_port = atoi (optarg);
634 other_rptp_port = atoi(optarg);
632635 break;
633636 #endif /* OTHER_RPTP_PORTS */
634637
635638 case 10:
636639 /* --audio-port */
637 if (strstr (optarg, "none"))
638 {
639 SET_BIT (optional_port, RPLAY_AUDIO_PORT_NONE);
640 }
641 if (strstr (optarg, "speaker"))
642 {
643 SET_BIT (optional_port, RPLAY_AUDIO_PORT_SPEAKER);
644 }
645 if (strstr (optarg, "headphone"))
646 {
647 SET_BIT (optional_port, RPLAY_AUDIO_PORT_HEADPHONE);
648 }
649 if (strstr (optarg, "lineout"))
650 {
651 SET_BIT (optional_port, RPLAY_AUDIO_PORT_LINEOUT);
640 if (strstr(optarg, "none"))
641 {
642 SET_BIT(optional_port, RPLAY_AUDIO_PORT_NONE);
643 }
644 if (strstr(optarg, "speaker"))
645 {
646 SET_BIT(optional_port, RPLAY_AUDIO_PORT_SPEAKER);
647 }
648 if (strstr(optarg, "headphone"))
649 {
650 SET_BIT(optional_port, RPLAY_AUDIO_PORT_HEADPHONE);
651 }
652 if (strstr(optarg, "lineout"))
653 {
654 SET_BIT(optional_port, RPLAY_AUDIO_PORT_LINEOUT);
652655 }
653656 break;
654657
655658 case 11:
656 do_option_file (optarg);
659 do_option_file(optarg);
657660 break;
658661
659662 case 12: /* --cache-remove */
667670 optional_channels = 1;
668671 break;
669672
670 #ifdef HAVE_CDROM
673 #ifdef HAVE_CDROM
671674 case 14: /* cdrom0 */
672675 for (i = 0; i < MAX_CDROMS; i++)
673676 {
674 if (strncmp (cdrom_table[i].name, "cdrom0", 6) == 0)
677 if (strncmp(cdrom_table[i].name, "cdrom0", 6) == 0)
675678 {
676679 cdrom_table[i].device = optarg;
677680 break;
678681 }
679 }
682 }
680683 break;
681684
682685 case 15: /* cdrom1 */
683686 for (i = 0; i < MAX_CDROMS; i++)
684687 {
685 if (strncmp (cdrom_table[i].name, "cdrom1", 6) == 0)
688 if (strncmp(cdrom_table[i].name, "cdrom1", 6) == 0)
686689 {
687690 cdrom_table[i].device = optarg;
688691 break;
689692 }
690 }
691 break;
692
693 }
694 break;
695
693696 case 16: /* cdrom2 */
694697 for (i = 0; i < MAX_CDROMS; i++)
695698 {
696 if (strncmp (cdrom_table[i].name, "cdrom2", 6) == 0)
699 if (strncmp(cdrom_table[i].name, "cdrom2", 6) == 0)
697700 {
698701 cdrom_table[i].device = optarg;
699702 break;
700703 }
701 }
704 }
702705 break;
703706
704707 case 17: /* cdrom3 */
705708 for (i = 0; i < MAX_CDROMS; i++)
706709 {
707 if (strncmp (cdrom_table[i].name, "cdrom3", 6) == 0)
710 if (strncmp(cdrom_table[i].name, "cdrom3", 6) == 0)
708711 {
709712 cdrom_table[i].device = optarg;
710713 break;
711714 }
712 }
715 }
713716 break;
714717 #endif /* HAVE_CDROM */
715718
716719 #ifdef HAVE_OSS
717720 case 18: /* audio-fragsize */
718 optional_fragsize = atoi (optarg);
721 optional_fragsize = atoi(optarg);
719722 break;
720723 #endif /* HAVE_OSS */
721724
739742 rplay_audio_device = optarg;
740743 break;
741744
742 #ifndef HAVE_OSS
745 #ifndef HAVE_OSS
743746 case 'b':
744 rplay_audio_bufsize = atoi (optarg);
747 rplay_audio_bufsize = atoi(optarg);
745748 break;
746749 #endif /* !HAVE_OSS */
747750
748751 case 'B':
749 optional_precision = atoi (optarg);
752 optional_precision = atoi(optarg);
750753 if (optional_precision != 8 && optional_precision != 16)
751754 {
752 usage ();
753 done (1);
755 usage();
756 done(1);
754757 }
755758 break;
756759
757760 case 'c':
758 rplay_audio_timeout = atoi (optarg);
761 rplay_audio_timeout = atoi(optarg);
759762 break;
760763
761764 case 'C':
776779 break;
777780
778781 case 'F':
779 rplay_audio_flush_timeout = atoi (optarg);
782 rplay_audio_flush_timeout = atoi(optarg);
780783 break;
781784
782785 #ifdef AUTH
787790
788791 case 'i': /* --audio-info, --info */
789792 /* Example: ulaw,8000,8,1 */
790 p = strtok (optarg, ", ");
791 if (p) optional_format = string_to_audio_format (p);
792 p = strtok (NULL, ",");
793 if (p) optional_sample_rate = atoi (p);
794 p = strtok (NULL, ",");
795 if (p) optional_precision = atoi (p);
796 p = strtok (NULL, ",");
797 if (p) optional_channels = atoi (p);
798 break;
799
793 p = strtok(optarg, ", ");
794 if (p)
795 optional_format = string_to_audio_format(p);
796 p = strtok(NULL, ",");
797 if (p)
798 optional_sample_rate = atoi(p);
799 p = strtok(NULL, ",");
800 if (p)
801 optional_precision = atoi(p);
802 p = strtok(NULL, ",");
803 if (p)
804 optional_channels = atoi(p);
805 break;
806
800807 case 'l':
801808 logging++;
802 report_level = atoi (optarg);
809 report_level = atoi(optarg);
803810 break;
804811
805812 case 'L':
815822 break;
816823
817824 case 'r':
818 rplay_audio_rate = atoi (optarg);
825 rplay_audio_rate = atoi(optarg);
819826 break;
820827
821828 case 'R':
822 optional_sample_rate = atoi (optarg);
829 optional_sample_rate = atoi(optarg);
823830 break;
824831
825832 case 's':
826 cache_max_size = atoi (optarg);
833 cache_max_size = atoi(optarg);
827834 break;
828835
829836 case 'S':
831838 break;
832839
833840 case 't':
834 rplayd_timeout = atoi (optarg);
841 rplayd_timeout = atoi(optarg);
835842 break;
836843
837844 case 'T':
838 rptp_timeout = atoi (optarg);
845 rptp_timeout = atoi(optarg);
839846 break;
840847
841848 case 'v':
842 printf ("rplay %s\n", RPLAY_VERSION);
843 done (0);
849 printf("rplay %s\n", RPLAY_VERSION);
850 done(0);
844851 break;
845852
846853 default:
847 fprintf (stderr, "Try `%s --help' for more information.\n", progname);
848 done (1);
854 fprintf(stderr, "Try `%s --help' for more information.\n", progname);
855 done(1);
849856 }
850857 }
851858
853860 * The main loop of rplayd.
854861 */
855862 static void
856 doit ()
863 doit()
857864 {
858865 int nfds, icount = 0;
859866 int idle = 1;
861868 fd_set rfds, wfds;
862869 SPOOL *sp;
863870 /* Initialize the fd_sets before starting. */
864 FD_ZERO (&rfds);
865 FD_ZERO (&wfds);
866 FD_ZERO (&read_mask);
867 FD_ZERO (&write_mask);
868 FD_SET (rplay_fd, &read_mask);
869 FD_SET (rptp_fd, &read_mask);
871 FD_ZERO(&rfds);
872 FD_ZERO(&wfds);
873 FD_ZERO(&read_mask);
874 FD_ZERO(&write_mask);
875 FD_SET(rplay_fd, &read_mask);
876 FD_SET(rptp_fd, &read_mask);
870877 #ifdef OTHER_RPLAY_PORTS
871 FD_SET (other_rplay_fd, &read_mask);
872 FD_SET (other_rptp_fd, &read_mask);
878 FD_SET(other_rplay_fd, &read_mask);
879 FD_SET(other_rptp_fd, &read_mask);
873880 #endif
874881
875882 for (;;)
876883 {
877884 if (need_to_reset)
878885 {
879 reset ();
886 reset();
880887 need_to_reset = 0;
881888 }
882889
886893 {
887894 if (!spool_nplaying)
888895 {
889 timer_stop ();
896 timer_stop();
890897
891898 rplay_audio_size = 0;
892899 if (rplay_audio_flush_timeout == -1)
893900 {
894 report (REPORT_DEBUG, "flushing %s\n", rplay_audio_device);
895 rplay_audio_flush ();
901 report(REPORT_DEBUG, "flushing %s\n", rplay_audio_device);
902 rplay_audio_flush();
896903 }
897904
898905 /* Notify the final zero levels. */
900907 rplay_audio_right_level = 0;
901908 if (connection_want_level_notify)
902909 {
903 connection_notify (0, NOTIFY_LEVEL, 1); /* force notification */
910 connection_notify(0, NOTIFY_LEVEL, 1); /* force notification */
904911 }
905912 }
906913 else
907914 {
908915 /* keep trying to open */
909 if (!rplay_audio_isopen ())
916 if (!rplay_audio_isopen())
910917 {
911 rplay_audio_open ();
918 rplay_audio_open();
912919 }
913
920
914921 if (connection_level_notify)
915922 {
916 connection_notify (0, NOTIFY_LEVEL, 0);
923 connection_notify(0, NOTIFY_LEVEL, 0);
917924 connection_level_notify = 0;
918925 }
919926
921928 {
922929 if (sp->notify_position)
923930 {
924 connection_notify (0, NOTIFY_POSITION, sp);
931 connection_notify(0, NOTIFY_POSITION, sp);
925932 sp->notify_position = 0;
926933 }
934 }
935
936 if (monitor_count && monitor_update)
937 {
938 connection_monitor_continue();
939 monitor_update = 0;
927940 }
928941 }
929942 }
930943 else if (spool_nplaying)
931944 {
932 if (!rplay_audio_isopen ())
945 if (!rplay_audio_isopen())
933946 {
934 report (REPORT_DEBUG, "opening %s\n", rplay_audio_device);
935 if (rplay_audio_open () < 0)
947 report(REPORT_DEBUG, "opening %s\n", rplay_audio_device);
948 if (rplay_audio_open() < 0)
936949 {
937 report (REPORT_ERROR, "rplay_audio_open: %s: %s (will keep trying)\n",
938 rplay_audio_device, sys_err_str (errno));
950 report(REPORT_ERROR,
951 "rplay_audio_open: %s: %s (will keep trying)\n",
952 rplay_audio_device, sys_err_str(errno));
939953 }
940954 }
941 /* start the time even if the audio device isn't open */
942 timer_start (curr_rate);
955 /* start the timer even if the audio device isn't open */
956 timer_start(curr_rate);
943957 }
944958
945959 if (spool_needs_update)
946960 {
947 spool_update ();
961 spool_update();
948962 }
949963 }
950964
951965 if (connections)
952966 {
953 connection_check_timeout ();
967 connection_check_timeout();
954968 }
955969
956970 rfds = read_mask;
958972
959973 if (idle)
960974 {
961 report (REPORT_DEBUG, "entering idle mode\n");
975 report(REPORT_DEBUG, "entering idle mode\n");
962976 select_timeout.tv_sec = rplayd_timeout;
963977 select_timeout.tv_usec = 0;
964978 #ifdef __hpux
965 nfds = select (FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0,
966 rplayd_timeout ? &select_timeout : 0);
967 #else
968 nfds = select (FD_SETSIZE, &rfds, &wfds, 0,
969 rplayd_timeout ? &select_timeout : 0);
979 nfds = select(FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0,
980 rplayd_timeout ? &select_timeout : 0);
981 #else
982 nfds = select(FD_SETSIZE, &rfds, &wfds, 0,
983 rplayd_timeout ? &select_timeout : 0);
970984 #endif
971985 if (nfds == 0)
972986 {
973 done (0);
987 done(0);
974988 }
975989
976990 #ifdef AUTO_REREAD
977991 #ifdef HAVE_HELPERS
978 helper_stat (helpers_file);
979 #endif /* HAVE_HELPERS */
980 sound_stat (sounds_file);
992 helper_stat(helpers_file);
993 #endif /* HAVE_HELPERS */
994 sound_stat(sounds_file);
981995 #ifdef AUTH
982 host_stat (hosts_file);
996 host_stat(hosts_file);
983997 #endif /* AUTH */
984 server_stat (servers_file);
998 server_stat(servers_file);
985999 #endif /* AUTO_REREAD */
9861000
9871001 idle = 0;
9921006 select_timeout.tv_sec = 1;
9931007 select_timeout.tv_usec = 0;
9941008 #ifdef __hpux
995 nfds = select (FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0,
996 &select_timeout);
997 #else
998 nfds = select (FD_SETSIZE, &rfds, &wfds, 0,
999 &select_timeout);
1009 nfds = select(FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0,
1010 &select_timeout);
1011 #else
1012 nfds = select(FD_SETSIZE, &rfds, &wfds, 0,
1013 &select_timeout);
10001014 #endif
10011015 }
10021016
10051019 case -1:
10061020 if (errno != EINTR && errno != EAGAIN)
10071021 {
1008 report (REPORT_ERROR, "select: %s\n", sys_err_str (errno));
1009 done (1);
1022 report(REPORT_ERROR, "select: %s\n", sys_err_str(errno));
1023 done(1);
10101024 }
10111025 break;
10121026
10191033 if (!spool_nplaying && !rplay_audio_size)
10201034 {
10211035 if (audio_enabled && rplay_audio_timeout && icount == rplay_audio_timeout
1022 && rplay_audio_isopen ())
1036 && rplay_audio_isopen())
10231037 {
1024 report (REPORT_DEBUG, "closing %s\n", rplay_audio_device);
1025 rplay_audio_close ();
1038 report(REPORT_DEBUG, "closing %s\n", rplay_audio_device);
1039 rplay_audio_close();
10261040 }
10271041 if (audio_enabled && rplay_audio_flush_timeout > 0
1028 && icount == rplay_audio_flush_timeout && rplay_audio_isopen ())
1042 && icount == rplay_audio_flush_timeout && rplay_audio_isopen())
10291043 {
1030 report (REPORT_DEBUG, "flushing %s\n", rplay_audio_device);
1031 rplay_audio_flush ();
1044 report(REPORT_DEBUG, "flushing %s\n", rplay_audio_device);
1045 rplay_audio_flush();
10321046 }
10331047 if (sound_cleanup_timeout && icount == sound_cleanup_timeout)
10341048 {
1035 sound_cleanup ();
1049 sound_cleanup();
10361050 }
10371051 if (buffer_cleanup_timeout && icount == buffer_cleanup_timeout)
10381052 {
1039 buffer_cleanup ();
1053 buffer_cleanup();
10401054 }
10411055 if (spool_cleanup_timeout && icount == spool_cleanup_timeout)
10421056 {
1043 spool_cleanup ();
1057 spool_cleanup();
10441058 }
1045
1059
10461060 /*
10471061 * See if rplayd should enter idle mode.
10481062 * Idle mode should only be entered when *nothing*
10491063 * is happening.
10501064 */
10511065 if (icount >= rplay_audio_timeout
1052 && connection_idle ()
1066 && connection_idle()
10531067 && icount >= rplay_audio_flush_timeout
10541068 && icount >= sound_cleanup_timeout
10551069 && icount >= buffer_cleanup_timeout
10561070 && icount >= spool_cleanup_timeout)
10571071 {
10581072 idle = 1;
1073 if (monitor_buffers)
1074 {
1075 if (!monitor_count)
1076 {
1077 report(REPORT_DEBUG, "cleaning monitor buffers - %d bytes\n",
1078 monitor_total_bytes);
1079 monitor_cleanup();
1080 }
1081 else
1082 {
1083 report(REPORT_DEBUG, "keeping monitor buffers - %d bytes\n",
1084 monitor_total_bytes);
1085 }
1086 }
10591087 }
10601088 }
10611089 break;
10621090
10631091 default:
1064 if (FD_ISSET (rplay_fd, &rfds))
1092 if (FD_ISSET(rplay_fd, &rfds))
10651093 {
1066 rplayd_read (rplay_fd);
1094 rplayd_read(rplay_fd);
10671095 }
10681096 #ifdef OTHER_RPLAY_PORTS
1069 if (FD_ISSET (other_rplay_fd, &rfds))
1097 if (FD_ISSET(other_rplay_fd, &rfds))
10701098 {
1071 rplayd_read (other_rplay_fd);
1099 rplayd_read(other_rplay_fd);
10721100 }
10731101 #endif
1074 connection_update (&rfds, &wfds);
1102 connection_update(&rfds, &wfds);
10751103 #if defined(HAVE_CDROM) || defined(HAVE_HELPERS)
1076 rplayd_pipe_read (&rfds);
1104 rplayd_pipe_read(&rfds);
10771105 #endif
10781106 icount = 0;
10791107 break;
10861114 * Set up the sockets to receive RPLAY packets and RPTP connections.
10871115 */
10881116 void
1089 rplayd_init ()
1117 rplayd_init()
10901118 {
10911119 struct sockaddr_in s;
10921120 struct servent *sp;
10961124 rplay_fd = 0;
10971125 #ifdef OTHER_RPLAY_PORTS
10981126 /* Try to figure out which port is being used by inetd. */
1099 sp = getservbyname ("rplay", "udp");
1127 sp = getservbyname("rplay", "udp");
11001128 if (sp == NULL)
11011129 {
1102 report (REPORT_ERROR, "can't find rplay/udp service\n");
1103 done (1);
1104 }
1105
1106 if (ntohs (sp->s_port) == RPLAY_PORT)
1107 {
1108 other_rplay_fd = udp_socket (other_rplay_port ? other_rplay_port : OLD_RPLAY_PORT);
1130 report(REPORT_ERROR, "can't find rplay/udp service\n");
1131 done(1);
1132 }
1133
1134 if (ntohs(sp->s_port) == RPLAY_PORT)
1135 {
1136 other_rplay_fd = udp_socket(other_rplay_port ? other_rplay_port : OLD_RPLAY_PORT);
11091137 }
11101138 else
11111139 {
1112 other_rplay_fd = udp_socket (other_rplay_port ? other_rplay_port : RPLAY_PORT);
1140 other_rplay_fd = udp_socket(other_rplay_port ? other_rplay_port : RPLAY_PORT);
11131141 }
11141142 #endif
11151143 }
11161144 else
11171145 {
1118 rplay_fd = udp_socket (rplay_port ? rplay_port : RPLAY_PORT);
1146 rplay_fd = udp_socket(rplay_port ? rplay_port : RPLAY_PORT);
11191147 #ifdef OTHER_RPLAY_PORTS
1120 other_rplay_fd = udp_socket (other_rplay_port ? other_rplay_port : OLD_RPLAY_PORT);
1148 other_rplay_fd = udp_socket(other_rplay_port ? other_rplay_port : OLD_RPLAY_PORT);
11211149 #endif
11221150 }
11231151
11241152 /*
11251153 * Make the RPLAY sockets non-blocking.
11261154 */
1127 fd_nonblock (rplay_fd);
1155 fd_nonblock(rplay_fd);
11281156 #ifdef OTHER_RPLAY_PORTS
1129 fd_nonblock (other_rplay_fd);
1157 fd_nonblock(other_rplay_fd);
11301158 #endif
11311159
11321160 if (forward)
11331161 {
1134 unsigned long addr = inet_addr (forward);
1135
1136 memset ((char *) &s, 0, sizeof (s));
1162 unsigned long addr = inet_addr(forward);
1163
1164 memset((char *) &s, 0, sizeof(s));
11371165 s.sin_family = AF_INET;
1138 s.sin_port = htons (RPLAY_PORT);
1166 s.sin_port = htons(RPLAY_PORT);
11391167
11401168 if (addr == 0xffffffff)
11411169 {
1142 struct hostent *hp = gethostbyname (forward);
1170 struct hostent *hp = gethostbyname(forward);
11431171 if (hp == NULL)
11441172 {
1145 report (REPORT_ERROR, "gethostbyname: %s unknown host\n", forward);
1146 done (1);
1173 report(REPORT_ERROR, "gethostbyname: %s unknown host\n", forward);
1174 done(1);
11471175 }
1148 memcpy ((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
1176 memcpy((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
11491177 }
11501178 else
11511179 {
1152 memcpy ((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof (addr));
1153 }
1154
1155 forward_fd = socket (AF_INET, SOCK_DGRAM, 0);
1180 memcpy((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof(addr));
1181 }
1182
1183 forward_fd = socket(AF_INET, SOCK_DGRAM, 0);
11561184 if (forward_fd < 0)
11571185 {
1158 report (REPORT_ERROR, "socket: %s\n", sys_err_str (errno));
1159 done (1);
1160 }
1161
1162 if (connect (forward_fd, (struct sockaddr *) &s, sizeof (s)) < 0)
1163 {
1164 report (REPORT_ERROR, "connect: %s\n", sys_err_str (errno));
1165 done (1);
1166 }
1167 }
1168
1169 rptp_fd = tcp_socket (rptp_port ? rptp_port : RPTP_PORT);
1186 report(REPORT_ERROR, "socket: %s\n", sys_err_str(errno));
1187 done(1);
1188 }
1189
1190 if (connect(forward_fd, (struct sockaddr *) &s, sizeof(s)) < 0)
1191 {
1192 report(REPORT_ERROR, "connect: %s\n", sys_err_str(errno));
1193 done(1);
1194 }
1195 }
1196
1197 rptp_fd = tcp_socket(rptp_port ? rptp_port : RPTP_PORT);
11701198 #ifdef OTHER_RPLAY_PORTS
1171 other_rptp_fd = tcp_socket (other_rptp_port ? other_rptp_port : OLD_RPTP_PORT);
1199 other_rptp_fd = tcp_socket(other_rptp_port ? other_rptp_port : OLD_RPTP_PORT);
11721200 #endif
11731201
11741202 /*
11751203 * Make the RPTP sockets non-blocking.
11761204 */
1177 fd_nonblock (rptp_fd);
1205 fd_nonblock(rptp_fd);
11781206 #ifdef OTHER_RPLAY_PORTS
1179 fd_nonblock (other_rptp_fd);
1207 fd_nonblock(other_rptp_fd);
11801208 #endif
11811209 }
11821210
11831211 int
1184 rplayd_audio_init ()
1212 rplayd_audio_init()
11851213 {
11861214 int sample_size;
11871215
11971225
11981226 /* Call rplay_audio_init() which sets all the rplay_audio variables. */
11991227 rplay_audio_table = NULL; /* will be set by rplay_audio_init() */
1200 if (rplay_audio_init () < 0)
1228 if (rplay_audio_init() < 0)
12011229 {
12021230 return -1;
12031231 }
12171245 }
12181246 curr_rate = rplay_audio_rate;
12191247
1220 #ifndef HAVE_OSS
1248 #ifndef HAVE_OSS
12211249 /* Click prevention: Make sure curr_rate won't split up samples.
12221250 If it will, it's easiest right now to modify the rate and not
12231251 the sample_rate. */
12291257 curr_rate--; /* Slow it down. */
12301258 }
12311259
1232 report (REPORT_DEBUG, "changed curr_rate from %d to %d\n",
1233 rplay_audio_rate, curr_rate);
1260 report(REPORT_DEBUG, "changed curr_rate from %d to %d\n",
1261 rplay_audio_rate, curr_rate);
12341262 }
12351263
12361264 if (rplay_audio_match || rplay_audio_bufsize == 0)
12491277 curr_bufsize++; /* Add a little. */
12501278 }
12511279
1252 report (REPORT_DEBUG, "changed curr_bufsize from %d to %d\n",
1253 rplay_audio_bufsize, curr_bufsize);
1254 }
1255 #endif /* !HAVE_OSS */
1280 report(REPORT_DEBUG, "changed curr_bufsize from %d to %d\n",
1281 rplay_audio_bufsize, curr_bufsize);
1282 }
1283 #endif /* !HAVE_OSS */
12561284
12571285 /*
12581286 * Create the audio buffer which holds at most 1 second of 16-bit
12591287 * stereo audio data sampled at MAX_SAMPLE_RATE Hz.
12601288 */
1261 max_rplay_audio_bufsize = MAX_SAMPLE_RATE * 2 /* 16-bit */ * 2 /* stereo */ ;
1289 max_rplay_audio_bufsize = MAX_SAMPLE_RATE * 2 /* 16-bit */ * 2 /* stereo */ ;
12621290 if (rplay_audio_buf)
12631291 {
1264 free ((char *) rplay_audio_buf);
1265 }
1266 rplay_audio_buf = (char *) malloc (max_rplay_audio_bufsize);
1292 free((char *) rplay_audio_buf);
1293 }
1294 rplay_audio_buf = (char *) malloc(max_rplay_audio_bufsize);
12671295 if (rplay_audio_buf == NULL)
12681296 {
1269 report (REPORT_ERROR, "cannot allocate rplay_audio_buf, size=%d\n",
1270 max_rplay_audio_bufsize);
1271 done (1);
1297 report(REPORT_ERROR, "cannot allocate rplay_audio_buf, size=%d\n",
1298 max_rplay_audio_bufsize);
1299 done(1);
12721300 }
12731301
12741302 /*
12751303 * Update the volume of the audio device.
12761304 */
1277 rplay_audio_volume = rplay_audio_get_volume ();
1305 rplay_audio_volume = rplay_audio_get_volume();
12781306 if (rplay_audio_volume < 0)
12791307 {
12801308 rplay_audio_volume = 0;
12811309 }
12821310
1283 report (REPORT_DEBUG, "\
1311 report(REPORT_DEBUG, "\
12841312 audio: bits=%d sample-rate=%d channels=%d format=%s volume=%d port-mask=%0x\n",
1285 rplay_audio_precision, rplay_audio_sample_rate, rplay_audio_channels,
1286 audio_format_to_string (rplay_audio_format), rplay_audio_volume, rplay_audio_port);
1313 rplay_audio_precision, rplay_audio_sample_rate, rplay_audio_channels,
1314 audio_format_to_string(rplay_audio_format), rplay_audio_volume, rplay_audio_port);
12871315
12881316 #ifdef HAVE_OSS
1289 report (REPORT_DEBUG, "timer: rate=%d, min bytes/sec=%d\n", curr_rate,
1290 (rplay_audio_sample_rate / curr_rate * sample_size));
1291 #else
1292 report (REPORT_DEBUG, "timer: rate=%d, bufsize=%d\n", curr_rate, curr_bufsize);
1317 report(REPORT_DEBUG, "timer: rate=%d, min bytes/sec=%d\n", curr_rate,
1318 (rplay_audio_sample_rate / curr_rate * sample_size));
1319 #else
1320 report(REPORT_DEBUG, "timer: rate=%d, bufsize=%d\n", curr_rate, curr_bufsize);
12931321 #endif
12941322
12951323 return 0;
12991327 in `sp'. Currenly only the sample-rate is matched. */
13001328 #ifdef __STDC__
13011329 void
1302 rplayd_audio_match (SPOOL *match_sp)
1330 rplayd_audio_match(SPOOL *match_sp)
13031331 #else
13041332 void
1305 rplayd_audio_match (match_sp)
1333 rplayd_audio_match(match_sp)
13061334 SPOOL *match_sp;
13071335 #endif
13081336 {
13261354 break;
13271355 }
13281356 else if (optional_sample_rate >= prev_sample_rate
1329 && optional_sample_rate <= t->sample_rate)
1357 && optional_sample_rate <= t->sample_rate)
13301358 {
13311359 if ((t->sample_rate - optional_sample_rate)
13321360 > (optional_sample_rate - prev_sample_rate))
13421370 prev_sample_rate = t->sample_rate;
13431371 }
13441372
1345 report (REPORT_DEBUG, "matched %d with %d\n", match_sp->sample_rate,
1346 optional_sample_rate);
1347
1348 if (rplayd_audio_init () < 0)
1373 report(REPORT_DEBUG, "matched %d with %d\n", match_sp->sample_rate,
1374 optional_sample_rate);
1375
1376 if (rplayd_audio_init() < 0)
13491377 {
13501378 /* That sample rate didn't work -- Use the default instead. */
13511379 optional_sample_rate = default_sample_rate;
1352 rplayd_audio_init ();
1380 rplayd_audio_init();
13531381 }
13541382 if (timer_enabled)
13551383 {
1356 timer_restart (curr_rate);
1384 timer_restart(curr_rate);
13571385 }
13581386
13591387 /* Update the spool entries with the new sample-rate. */
13631391 }
13641392 }
13651393 }
1394
1395 monitor_alloc()
1396 {
1397 if (!monitor_buffers)
1398 {
1399 BUFFER *b, *end;
1400 monitor_buffers = buffer_alloc(monitor_total_bytes, BUFFER_KEEP);
1401 for (b = monitor_buffers; b; b = b->next)
1402 {
1403 /* these will always be full buffers */
1404 b->nbytes = BUFFER_SIZE;
1405 if (!b->next)
1406 {
1407 end = b;
1408 }
1409 }
1410 /* make the list of buffer cyclic */
1411 end->next = monitor_buffers;
1412 }
1413
1414 monitor_update = 0;
1415 }
1416
1417 monitor_cleanup()
1418 {
1419 BUFFER *b, *b_next;
1420
1421 for (b = monitor_buffers; b->next != monitor_buffers; b = b->next);
1422 b->next = NULL;
1423 buffer_dealloc(monitor_buffers, 1);
1424 monitor_buffers = NULL;
1425 }
1426
13661427
13671428 /*
13681429 * Write nbytes of audio data from the audio buffer to the audio device.
13691430 */
13701431 #ifdef __STDC__
13711432 void
1372 rplayd_write (int nbytes)
1433 rplayd_write(int nbytes)
13731434 #else
13741435 void
1375 rplayd_write (nbytes)
1436 rplayd_write(nbytes)
13761437 int nbytes;
13771438 #endif
13781439 {
13791440 int nwritten = 0;
13801441
13811442 /* Insert `nbytes' of audio data from the spool into `rplay_audio_buf'. */
1382 spool_process (rplay_audio_buf, nbytes);
1443 spool_process(rplay_audio_buf, nbytes);
13831444
13841445 /*
13851446 * Write the audio data if the audio device is open.
13861447 * Otherwise forget about the data.
13871448 */
1388 if (rplay_audio_size && rplay_audio_isopen ())
1389 {
1390 nwritten = rplay_audio_write (rplay_audio_buf, rplay_audio_size);
1449 if (rplay_audio_size && rplay_audio_isopen())
1450 {
1451 nwritten = rplay_audio_write(rplay_audio_buf, rplay_audio_size);
13911452 #if 0
1392 report (REPORT_DEBUG, "audio_write: %d -> %d\n", rplay_audio_size, nwritten);
1453 report(REPORT_DEBUG, "audio_write: %d -> %d\n", rplay_audio_size, nwritten);
13931454 #endif
13941455 /* Flush after every write? */
13951456 if (rplay_audio_flush_timeout == -2)
13961457 {
1397 report (REPORT_DEBUG, "flushing %s\n", rplay_audio_device);
1398 rplay_audio_flush ();
1399 }
1400 }
1458 report(REPORT_DEBUG, "flushing %s\n", rplay_audio_device);
1459 rplay_audio_flush();
1460 }
1461 }
1462
1463 if (monitor_count)
1464 {
1465 char *buf = rplay_audio_buf;
1466 int size = rplay_audio_size;
1467 int n;
1468
1469 while (size)
1470 {
1471 n = MIN(BUFFER_SIZE - monitor_buffers->offset, size);
1472 memcpy(monitor_buffers->buf + monitor_buffers->offset, buf, n);
1473 monitor_buffers->offset += n;
1474 buf += n;
1475 size -= n;
1476
1477 if (monitor_buffers->offset == BUFFER_SIZE)
1478 {
1479 monitor_buffers = monitor_buffers->next;
1480 monitor_buffers->offset = 0;
1481 monitor_update++;
1482 }
1483 }
1484 }
1485
14011486 rplay_audio_size = 0;
14021487
14031488 /* Flush when the audio stream has ended. */
14051490 {
14061491 if (rplay_audio_flush_timeout == -1)
14071492 {
1408 report (REPORT_DEBUG, "flushing %s\n", rplay_audio_device);
1409 rplay_audio_flush ();
1493 report(REPORT_DEBUG, "flushing %s\n", rplay_audio_device);
1494 rplay_audio_flush();
14101495 }
14111496 }
14121497 }
14161501 */
14171502 #ifdef __STDC__
14181503 void
1419 rplayd_read (int fd)
1504 rplayd_read(int fd)
14201505 #else
14211506 void
1422 rplayd_read (fd)
1507 rplayd_read(fd)
14231508 int fd;
14241509 #endif
14251510 {
14311516
14321517 for (j = 0; j < SPOOL_SIZE; j++)
14331518 {
1434 flen = sizeof (f);
1435
1436 n = recvfrom (fd, recv_buf, sizeof (recv_buf), 0, (struct sockaddr *) &f, &flen);
1519 flen = sizeof(f);
1520
1521 n = recvfrom(fd, recv_buf, sizeof(recv_buf), 0, (struct sockaddr *) &f, &flen);
14371522 if (n <= 0)
14381523 {
14391524 continue;
14411526
14421527 if (forward)
14431528 {
1444 write (forward_fd, recv_buf, n);
1529 write(forward_fd, recv_buf, n);
14451530 continue;
14461531 }
14471532
14481533 #ifdef AUTH
1449 if (!host_access (f, HOST_EXECUTE))
1450 {
1451 if (!host_access (f, HOST_READ) && !host_access (f, HOST_WRITE))
1534 if (!host_access(f, HOST_EXECUTE))
1535 {
1536 if (!host_access(f, HOST_READ) && !host_access(f, HOST_WRITE))
14521537 {
1453 report (REPORT_NOTICE, "%s permission denied\n", inet_ntoa (f.sin_addr));
1538 report(REPORT_NOTICE, "%s permission denied\n", inet_ntoa(f.sin_addr));
14541539 }
14551540 continue;
14561541 }
14651550 case OLD_RPLAY_STOP:
14661551 case OLD_RPLAY_PAUSE:
14671552 case OLD_RPLAY_CONTINUE:
1468 packet = rplay_convert (recv_buf);
1553 packet = rplay_convert(recv_buf);
14691554 #endif /* OLD_RPLAY */
14701555
14711556 case RPLAY_PACKET_ID:
1472 rp = rplay_unpack (packet);
1557 rp = rplay_unpack(packet);
14731558 if (rp == NULL)
14741559 {
1475 report (REPORT_ERROR, "rplay_unpack: %s\n", rplay_errlist[rplay_errno]);
1560 report(REPORT_ERROR, "rplay_unpack: %s\n", rplay_errlist[rplay_errno]);
14761561 break;
14771562 }
14781563
14801565 {
14811566 case RPLAY_PING:
14821567 #ifdef DEBUG
1483 report (REPORT_DEBUG, "received a ping packet\n");
1484 #endif
1485 rplay_destroy (rp);
1568 report(REPORT_DEBUG, "received a ping packet\n");
1569 #endif
1570 rplay_destroy(rp);
14861571 break;
14871572
14881573 case RPLAY_PLAY:
1489 report (REPORT_INFO, "%s play %s\n",
1490 inet_ntoa (f.sin_addr),
1491 (char *) rplay_get (rp, RPLAY_SOUND, 0));
1492 rplayd_play (rp, f);
1574 report(REPORT_INFO, "%s play %s\n",
1575 inet_ntoa(f.sin_addr),
1576 (char *) rplay_get(rp, RPLAY_SOUND, 0));
1577 rplayd_play(rp, f);
14931578 break;
14941579
14951580 case RPLAY_STOP:
1496 report (REPORT_INFO, "%s stop %s\n",
1497 inet_ntoa (f.sin_addr),
1498 (char *) rplay_get (rp, RPLAY_SOUND, 0));
1499 rplayd_stop (rp, f);
1581 report(REPORT_INFO, "%s stop %s\n",
1582 inet_ntoa(f.sin_addr),
1583 (char *) rplay_get(rp, RPLAY_SOUND, 0));
1584 rplayd_stop(rp, f);
15001585 break;
15011586
15021587 case RPLAY_PAUSE:
1503 report (REPORT_INFO, "%s pause %s\n",
1504 inet_ntoa (f.sin_addr),
1505 (char *) rplay_get (rp, RPLAY_SOUND, 0));
1506 rplayd_pause (rp, f);
1588 report(REPORT_INFO, "%s pause %s\n",
1589 inet_ntoa(f.sin_addr),
1590 (char *) rplay_get(rp, RPLAY_SOUND, 0));
1591 rplayd_pause(rp, f);
15071592 break;
15081593
15091594 case RPLAY_CONTINUE:
1510 report (REPORT_INFO, "%s continue %s\n",
1511 inet_ntoa (f.sin_addr),
1512 (char *) rplay_get (rp, RPLAY_SOUND, 0));
1513 rplayd_continue (rp, f);
1595 report(REPORT_INFO, "%s continue %s\n",
1596 inet_ntoa(f.sin_addr),
1597 (char *) rplay_get(rp, RPLAY_SOUND, 0));
1598 rplayd_continue(rp, f);
15141599 break;
15151600
15161601 case RPLAY_RESET:
1517 report (REPORT_INFO, "received a reset packet\n");
1518 need_reset ();
1519 rplay_destroy (rp);
1602 report(REPORT_INFO, "received a reset packet\n");
1603 need_reset();
1604 rplay_destroy(rp);
15201605 break;
15211606
15221607 case RPLAY_DONE:
1523 report (REPORT_INFO, "%s done %s\n",
1524 inet_ntoa (f.sin_addr),
1525 (char *) rplay_get (rp, RPLAY_SOUND, 0));
1526 rplayd_done (rp, f);
1608 report(REPORT_INFO, "%s done %s\n",
1609 inet_ntoa(f.sin_addr),
1610 (char *) rplay_get(rp, RPLAY_SOUND, 0));
1611 rplayd_done(rp, f);
15271612 break;
15281613
15291614 case RPLAY_PUT:
1530 report (REPORT_INFO, "%s put id=%d sequence=%d size=%d\n",
1531 inet_ntoa (f.sin_addr),
1532 rp->id,
1533 rp->sequence,
1534 rp->data_size);
1535 rplayd_put (rp, f);
1615 report(REPORT_INFO, "%s put id=%d sequence=%d size=%d\n",
1616 inet_ntoa(f.sin_addr),
1617 rp->id,
1618 rp->sequence,
1619 rp->data_size);
1620 rplayd_put(rp, f);
15361621 break;
15371622 }
15381623 break;
15391624
15401625 default:
1541 report (REPORT_ERROR, "unknown RPLAY packet received from %s\n",
1542 inet_ntoa (f.sin_addr));
1626 report(REPORT_ERROR, "unknown RPLAY packet received from %s\n",
1627 inet_ntoa(f.sin_addr));
15431628 break;
15441629 }
15451630 }
15501635 This is done using rplayd main select loop for efficiency. */
15511636 #ifdef __STDC__
15521637 void
1553 rplayd_pipe_read (fd_set *rfds)
1638 rplayd_pipe_read(fd_set * rfds)
15541639 #else
15551640 void
1556 rplayd_pipe_read (rfds)
1641 rplayd_pipe_read(rfds)
15571642 fd_set *rfds;
1558 #endif
1643 #endif
15591644 {
15601645 SPOOL *sp, *sp_next;
1561 extern BUFFER *sound_pipe_read (SINDEX *si);
1646 extern BUFFER *sound_pipe_read(SINDEX *si);
15621647
15631648 for (sp = spool; sp; sp = sp_next)
15641649 {
15681653 continue;
15691654 }
15701655
1571 #ifdef HAVE_CDROM
1572 if (sp->si->sound->type == SOUND_CDROM && FD_ISSET (sp->si->fd, rfds))
1573 {
1574 BUFFER *b = sound_pipe_read (sp->si);
1656 #ifdef HAVE_CDROM
1657 if (sp->si->sound->type == SOUND_CDROM && FD_ISSET(sp->si->fd, rfds))
1658 {
1659 BUFFER *b = sound_pipe_read(sp->si);
15751660 if (b)
15761661 {
1577 spool_flow_insert (sp, b);
1662 spool_flow_insert(sp, b);
15781663 }
15791664 }
1580 #endif
1665 #endif
15811666
15821667 #ifdef HAVE_HELPERS
1583 if (sp->si->sound->needs_helper && FD_ISSET (sp->si->fd, rfds))
1584 {
1585 BUFFER *b = sound_pipe_read (sp->si);
1668 if (sp->si->sound->needs_helper && FD_ISSET(sp->si->fd, rfds))
1669 {
1670 BUFFER *b = sound_pipe_read(sp->si);
15861671 if (b)
15871672 {
1588 spool_flow_insert (sp, b);
1673 spool_flow_insert(sp, b);
15891674 }
15901675 }
1591 #endif
1592
1676 #endif
1677
15931678 }
15941679 }
15951680 #endif
15961681
15971682 #ifdef __STDC__
15981683 int
1599 rplayd_play (RPLAY *rp, struct sockaddr_in sin)
1684 rplayd_play(RPLAY *rp, struct sockaddr_in sin)
16001685 #else
16011686 int
1602 rplayd_play (rp, sin)
1687 rplayd_play(rp, sin)
16031688 RPLAY *rp;
16041689 struct sockaddr_in sin;
16051690 #endif
16201705 for (sp = spool; sp; sp = sp->next)
16211706 {
16221707 if (*sp->rp->list_name
1623 && strcmp (rp->list_name, sp->rp->list_name) == 0)
1708 && strcmp(rp->list_name, sp->rp->list_name) == 0)
16241709 {
16251710 break;
16261711 }
16271712 }
16281713 if (sp)
16291714 {
1630 *(sp->rp->attrsp) = rp->attrs; /* Append the new attrs. */
1715 *(sp->rp->attrsp) = rp->attrs; /* Append the new attrs. */
16311716 sp->rp->attrsp = rp->attrsp;
16321717 start_sound = sp->rp->nsounds;
16331718 sp->rp->nsounds += rp->nsounds;
16431728 with priorities less than rplay_priority_threshold. */
16441729 if (rp->priority < rplay_priority_threshold)
16451730 {
1646 report (REPORT_DEBUG, "sound at priority %d ignored\n",
1647 rp->priority);
1648 rplay_destroy (rp);
1731 report(REPORT_DEBUG, "sound at priority %d ignored\n",
1732 rp->priority);
1733 rplay_destroy(rp);
16491734 return -1;
16501735 }
1651
1652 sp = spool_next (rp->priority);
1736
1737 sp = spool_next(rp->priority);
16531738 if (!sp)
16541739 {
1655 report (REPORT_DEBUG, "spool full\n");
1656 rplay_destroy (rp);
1740 report(REPORT_DEBUG, "spool full\n");
1741 rplay_destroy(rp);
16571742 return -1;
16581743 }
16591744 start_sound = 0;
16641749 /* Gotta have attributes! */
16651750 if (!rp->attrs)
16661751 {
1667 report (REPORT_DEBUG, "`rp' missing attributes\n");
1668 rplay_destroy (rp);
1669 spool_destroy (sp);
1752 report(REPORT_DEBUG, "`rp' missing attributes\n");
1753 rplay_destroy(rp);
1754 spool_destroy(sp);
16701755 return -1;
16711756 }
16721757
16801765 {
16811766 SERVER *s;
16821767
1683 s = (SERVER *) malloc (sizeof (SERVER));
1768 s = (SERVER *) malloc(sizeof(SERVER));
16841769 s->next = NULL;
16851770 s->sin.sin_family = AF_INET;
1686 s->sin.sin_port = htons (attrs->rptp_server_port);
1687 s->sin.sin_addr.s_addr = inet_addr (attrs->rptp_server);
1688 sp->sound[i] = sound_lookup (attrs->sound,
1689 attrs->rptp_search ? SOUND_FIND : SOUND_DONT_FIND, s);
1771 s->sin.sin_port = htons(attrs->rptp_server_port);
1772 s->sin.sin_addr.s_addr = inet_addr(attrs->rptp_server);
1773 sp->sound[i] = sound_lookup(attrs->sound,
1774 attrs->rptp_search ? SOUND_FIND : SOUND_DONT_FIND, s);
16901775 }
16911776 else
16921777 {
1693 sp->sound[i] = sound_lookup (attrs->sound,
1694 attrs->rptp_search ? SOUND_FIND : SOUND_DONT_FIND, NULL);
1778 sp->sound[i] = sound_lookup(attrs->sound,
1779 attrs->rptp_search ? SOUND_FIND : SOUND_DONT_FIND, NULL);
16951780 }
16961781
16971782 if (sp->sound[i] == NULL)
16981783 {
1699 rplay_destroy (rp);
1700 spool_destroy (sp);
1784 rplay_destroy(rp);
1785 spool_destroy(sp);
17011786 return -1;
17021787 }
17031788
17231808 }
17241809 else
17251810 {
1726 spool_play (sp);
1727 }
1728 }
1729
1811 spool_play(sp);
1812 }
1813 }
1814
17301815 return sp->id;
17311816 }
17321817
17331818 #ifdef __STDC__
17341819 int
1735 rplayd_stop (RPLAY *rp, struct sockaddr_in sin)
1820 rplayd_stop(RPLAY *rp, struct sockaddr_in sin)
17361821 #else
17371822 int
1738 rplayd_stop (rp, sin)
1823 rplayd_stop(rp, sin)
17391824 RPLAY *rp;
17401825 struct sockaddr_in sin;
17411826 #endif
17441829
17451830 if (!audio_enabled)
17461831 {
1747 rplay_destroy (rp);
1832 rplay_destroy(rp);
17481833 return -1;
17491834 }
17501835
1751 n = spool_match (rp, spool_stop, sin);
1752 rplay_destroy (rp);
1836 n = spool_match(rp, spool_stop, sin);
1837 rplay_destroy(rp);
17531838
17541839 return n > 0 ? 0 : -1;
17551840 }
17561841
17571842 #ifdef __STDC__
17581843 int
1759 rplayd_pause (RPLAY *rp, struct sockaddr_in sin)
1844 rplayd_pause(RPLAY *rp, struct sockaddr_in sin)
17601845 #else
17611846 int
1762 rplayd_pause (rp, sin)
1847 rplayd_pause(rp, sin)
17631848 RPLAY *rp;
17641849 struct sockaddr_in sin;
17651850 #endif
17681853
17691854 if (!audio_enabled)
17701855 {
1771 rplay_destroy (rp);
1856 rplay_destroy(rp);
17721857 return -1;
17731858 }
17741859
1775 n = spool_match (rp, spool_pause, sin);
1776 rplay_destroy (rp);
1860 n = spool_match(rp, spool_pause, sin);
1861 rplay_destroy(rp);
17771862
17781863 return n > 0 ? 0 : -1;
17791864 }
17801865
17811866 #ifdef __STDC__
17821867 int
1783 rplayd_continue (RPLAY *rp, struct sockaddr_in sin)
1868 rplayd_continue(RPLAY *rp, struct sockaddr_in sin)
17841869 #else
17851870 int
1786 rplayd_continue (rp, sin)
1871 rplayd_continue(rp, sin)
17871872 RPLAY *rp;
17881873 struct sockaddr_in sin;
17891874 #endif
17921877
17931878 if (!audio_enabled)
17941879 {
1795 rplay_destroy (rp);
1880 rplay_destroy(rp);
17961881 return -1;
17971882 }
17981883
1799 n = spool_match (rp, spool_continue, sin);
1800 rplay_destroy (rp);
1884 n = spool_match(rp, spool_continue, sin);
1885 rplay_destroy(rp);
18011886
18021887 return n > 0 ? 0 : -1;
18031888 }
18041889
18051890 #ifdef __STDC__
18061891 int
1807 rplayd_done (RPLAY *rp, struct sockaddr_in sin)
1892 rplayd_done(RPLAY *rp, struct sockaddr_in sin)
18081893 #else
18091894 int
1810 rplayd_done (rp, sin)
1895 rplayd_done(rp, sin)
18111896 RPLAY *rp;
18121897 struct sockaddr_in sin;
18131898 #endif
18161901
18171902 if (!audio_enabled)
18181903 {
1819 rplay_destroy (rp);
1904 rplay_destroy(rp);
18201905 return -1;
18211906 }
18221907
1823 n = spool_match (rp, spool_done, sin);
1824 rplay_destroy (rp);
1908 n = spool_match(rp, spool_done, sin);
1909 rplay_destroy(rp);
18251910
18261911 return n > 0 ? 0 : -1;
18271912 }
18281913
18291914 #ifdef __STDC__
18301915 int
1831 rplayd_put (RPLAY *rp, struct sockaddr_in sin)
1916 rplayd_put(RPLAY *rp, struct sockaddr_in sin)
18321917 #else
18331918 int
1834 rplayd_put (rp, sin)
1919 rplayd_put(rp, sin)
18351920 RPLAY *rp;
18361921 struct sockaddr_in sin;
18371922 #endif
18411926
18421927 if (!audio_enabled)
18431928 {
1844 rplay_destroy (rp);
1929 rplay_destroy(rp);
18451930 return -1;
18461931 }
18471932
18481933 /* Find the spool entry. */
1849 sp = spool_find (rp->id);
1934 sp = spool_find(rp->id);
18501935 if (!sp)
18511936 {
1852 report (REPORT_DEBUG, "put: `%d' no such spool id\n", rp->id);
1853 rplay_destroy (rp);
1937 report(REPORT_DEBUG, "put: `%d' no such spool id\n", rp->id);
1938 rplay_destroy(rp);
18541939 return -1;
18551940 }
18561941
18571942 /* Create a buffer and insert the flow data. */
1858 b = buffer_create ();
1943 b = buffer_create();
18591944 b->nbytes = rp->data_size;
1860 memcpy (b->buf, rp->data, b->nbytes);
1861 spool_flow_insert (sp, b);
1862
1863 rplay_destroy (rp);
1945 memcpy(b->buf, rp->data, b->nbytes);
1946 spool_flow_insert(sp, b);
1947
1948 rplay_destroy(rp);
18641949
18651950 return 0;
18661951 }
18671952
18681953 BUFFER *
1869 rplayd_status ()
1954 rplayd_status()
18701955 {
18711956 BUFFER *b;
18721957
1873 b = buffer_create ();
1958 b = buffer_create();
18741959
18751960 b->buf[0] = RPTP_OK;
18761961 b->buf[1] = '\0';
18771962
1878 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "host=%s", hostname);
1879 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " version=%s", RPLAY_VERSION);
1880 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " uptime=%s", time2string (time (0) - starttime));
1963 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), "host=%s", hostname);
1964 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " version=%s", RPLAY_VERSION);
1965 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " uptime=%s", time2string(time(0) - starttime));
18811966
18821967 if (audio_enabled)
18831968 {
1884 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-bits=%d", rplay_audio_precision);
1885 #ifndef HAVE_OSS
1886 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-bufsize=%d", rplay_audio_bufsize);
1887 #endif /* !HAVE_OSS */
1888 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-byte-order=%s",
1889 byte_order_to_string (RPLAY_AUDIO_BYTE_ORDER));
1890 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-channels=%d", rplay_audio_channels);
1891 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-device=%s", rplay_audio_device);
1892 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-format=%s",
1893 audio_format_to_string (rplay_audio_format));
1894 #ifdef HAVE_OSS
1895 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-fragsize=%d", rplay_audio_fragsize);
1896 #endif /* HAVE_OSS */
1897 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-port=%s",
1898 audio_port_to_string (rplay_audio_port));
1899 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-rate=%d", rplay_audio_rate);
1900 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-sample-rate=%d", rplay_audio_sample_rate);
1901 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " volume=%d", rplay_audio_volume);
1902 #ifndef HAVE_OSS
1903 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " curr-bufsize=%d", curr_bufsize);
1904 #endif /* !HAVE_OSS */
1905 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " curr-rate=%d", curr_rate);
1906 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " priority-threshold=%d", rplay_priority_threshold);
1907 }
1908
1909 SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "\r\n");
1910
1911 b->nbytes = strlen (b->buf);
1969 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-bits=%d", rplay_audio_precision);
1970 #ifndef HAVE_OSS
1971 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-bufsize=%d", rplay_audio_bufsize);
1972 #endif /* !HAVE_OSS */
1973 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-byte-order=%s",
1974 byte_order_to_string(RPLAY_AUDIO_BYTE_ORDER));
1975 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-channels=%d", rplay_audio_channels);
1976 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-device=%s", rplay_audio_device);
1977 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-format=%s",
1978 audio_format_to_string(rplay_audio_format));
1979 #ifdef HAVE_OSS
1980 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-fragsize=%d", rplay_audio_fragsize);
1981 #endif /* HAVE_OSS */
1982 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-port=%s",
1983 audio_port_to_string(rplay_audio_port));
1984 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-rate=%d", rplay_audio_rate);
1985 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-sample-rate=%d", rplay_audio_sample_rate);
1986 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " volume=%d", rplay_audio_volume);
1987 #ifndef HAVE_OSS
1988 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " curr-bufsize=%d", curr_bufsize);
1989 #endif /* !HAVE_OSS */
1990 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " curr-rate=%d", curr_rate);
1991 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " priority-threshold=%d",
1992 rplay_priority_threshold);
1993 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-close=%d",
1994 rplay_audio_timeout);
1995 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-device-status=%s",
1996 rplay_audio_isopen() ? "open" : "closed");
1997 }
1998
1999 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), "\r\n");
2000
2001 b->nbytes = strlen(b->buf);
19122002
19132003 return b;
19142004 }
19152005
19162006 void
1917 need_reset ()
2007 need_reset()
19182008 {
19192009 need_to_reset++;
19202010 }
19212011
19222012 /* Reset rplayd's state. */
19232013 static void
1924 reset ()
2014 reset()
19252015 {
19262016 int was_enabled = timer_enabled;
19272017
19282018 if (was_enabled)
19292019 {
1930 timer_stop ();
1931 }
1932 spool_init ();
1933 connection_cleanup ();
2020 timer_stop();
2021 }
2022 spool_init();
2023 connection_cleanup();
19342024 #ifdef HAVE_HELPERS
1935 helper_reread (helpers_file);
1936 #endif /* HAVE_HELPERS */
1937 sound_reread (sounds_file);
1938 cache_init (cache_dir);
1939 cache_read ();
2025 helper_reread(helpers_file);
2026 #endif /* HAVE_HELPERS */
2027 sound_reread(sounds_file);
2028 cache_init(cache_dir);
2029 cache_read();
19402030 #ifdef AUTH
1941 host_reread (hosts_file);
2031 host_reread(hosts_file);
19422032 #endif /* AUTH */
1943 server_reread (servers_file);
2033 server_reread(servers_file);
19442034 if (was_enabled)
19452035 {
1946 timer_start (curr_rate);
2036 timer_start(curr_rate);
19472037 }
19482038 }
19492039
19502040 static void
1951 handle_signals ()
2041 handle_signals()
19522042 {
19532043 /* Ingore SIGPIPE since read will handle closed TCP connections.
19542044 Handle SIGHUP, SIGINT, and SIGCHLD. */
19552045 #ifdef HAVE_SIGSET
1956 sigset (SIGPIPE, SIG_IGN);
1957 sigset (SIGHUP, handle_sighup);
1958 sigset (SIGINT, handle_sigint);
1959 sigset (SIGCHLD, handle_sigchld);
1960 #else
1961 signal (SIGPIPE, SIG_IGN);
1962 signal (SIGHUP, handle_sighup);
1963 signal (SIGINT, handle_sigint);
1964 signal (SIGCHLD, handle_sigchld);
2046 sigset(SIGPIPE, SIG_IGN);
2047 sigset(SIGHUP, handle_sighup);
2048 sigset(SIGINT, handle_sigint);
2049 sigset(SIGCHLD, handle_sigchld);
2050 #else
2051 signal(SIGPIPE, SIG_IGN);
2052 signal(SIGHUP, handle_sighup);
2053 signal(SIGINT, handle_sigint);
2054 signal(SIGCHLD, handle_sigchld);
19652055 #endif
19662056 }
19672057
19682058
19692059 static void
1970 handle_sighup ()
1971 {
1972 report (REPORT_DEBUG, "received SIGHUP signal\n");
1973 need_reset ();
2060 handle_sighup()
2061 {
2062 report(REPORT_DEBUG, "received SIGHUP signal\n");
2063 need_reset();
19742064 }
19752065
19762066 static void
1977 handle_sigint ()
1978 {
1979 report (REPORT_DEBUG, "received SIGINT signal\n");
1980 done (0);
2067 handle_sigint()
2068 {
2069 report(REPORT_DEBUG, "received SIGINT signal\n");
2070 done(0);
19812071 }
19822072
19832073 static void
1984 handle_sigchld ()
2074 handle_sigchld()
19852075 {
19862076 pid_t pid;
19872077 SPOOL *sp;
19882078
19892079 #ifdef linux
1990 handle_signals ();
1991 #endif
1992
1993 report (REPORT_DEBUG, "received SIGCHLD signal\n");
1994
1995 #ifdef HAVE_WAITPID
1996 pid = waitpid ((pid_t)-1, NULL, WNOHANG);
2080 handle_signals();
2081 #endif
2082
2083 report(REPORT_DEBUG, "received SIGCHLD signal\n");
2084
2085 #ifdef HAVE_WAITPID
2086 pid = waitpid((pid_t) - 1, NULL, WNOHANG);
19972087 #else /* not HAVE_WAITPID */
1998 pid = wait (NULL);
2088 pid = wait(NULL);
19992089 #endif /* not HAVE_WAITPID */
20002090 if (pid <= 0)
20012091 {
20042094 }
20052095
20062096 static void
2007 audio_test ()
2097 audio_test()
20082098 {
20092099 static char *spin = "|\\-/";
20102100 static int spin_pos;
2011
2012 printf ("Testing supported audio configurations (this may take a long time)...\n");
2013 for (optional_sample_rate = 4000; optional_sample_rate <= 48000; optional_sample_rate += 5)
2101
2102 printf("Testing supported audio configurations (this may take a long time)...\n");
2103 for (optional_sample_rate = 4000; optional_sample_rate <= 48000; optional_sample_rate += 5)
20142104 for (optional_precision = 8; optional_precision <= 16; optional_precision += 8)
20152105 for (optional_channels = 1; optional_channels <= 2; optional_channels++)
20162106 for (optional_format = 1; optional_format <= 5; optional_format++)
20192109 {
20202110 spin_pos = 0;
20212111 }
2022 fprintf (stderr, "%c\r", spin[spin_pos++]);
2023
2024 if (rplay_audio_init () >= 0)
2112 fprintf(stderr, "%c\r", spin[spin_pos++]);
2113
2114 if (rplay_audio_init() >= 0)
20252115 {
2026 printf (" { %5d, %-24s, %2d, %d },\n",
2027 rplay_audio_sample_rate,
2028 rplay_audio_format == RPLAY_FORMAT_ULAW ? "RPLAY_FORMAT_ULAW" :
2029 rplay_audio_format == RPLAY_FORMAT_LINEAR_8 ? "RPLAY_FORMAT_LINEAR_8" :
2030 rplay_audio_format == RPLAY_FORMAT_ULINEAR_8 ? "RPLAY_FORMAT_ULINEAR_8" :
2031 rplay_audio_format == RPLAY_FORMAT_LINEAR_16 ? "RPLAY_FORMAT_LINEAR_16" :
2032 rplay_audio_format == RPLAY_FORMAT_ULINEAR_16 ? "RPLAY_FORMAT_ULINEAR_16" : "?",
2033 rplay_audio_precision,
2034 rplay_audio_channels);
2116 printf(" { %5d, %-24s, %2d, %d },\n",
2117 rplay_audio_sample_rate,
2118 rplay_audio_format == RPLAY_FORMAT_ULAW ? "RPLAY_FORMAT_ULAW" :
2119 rplay_audio_format == RPLAY_FORMAT_LINEAR_8 ? "RPLAY_FORMAT_LINEAR_8" :
2120 rplay_audio_format == RPLAY_FORMAT_ULINEAR_8 ? "RPLAY_FORMAT_ULINEAR_8" :
2121 rplay_audio_format == RPLAY_FORMAT_LINEAR_16 ? "RPLAY_FORMAT_LINEAR_16" :
2122 rplay_audio_format == RPLAY_FORMAT_ULINEAR_16 ? "RPLAY_FORMAT_ULINEAR_16" : "?",
2123 rplay_audio_precision,
2124 rplay_audio_channels);
20352125 }
20362126 }
20372127 }
20382128
20392129 #ifdef __STDC__
20402130 void
2041 done (int exit_value)
2131 done(int exit_value)
20422132 #else
20432133 void
2044 done (exit_value)
2134 done(exit_value)
20452135 int exit_value;
20462136 #endif
20472137 {
20502140 /* #ifdef HAVE_CDROM */
20512141 /* for (sp = spool; sp; sp = sp->next) */
20522142 /* { */
2053 /* if (sp->si && sp->si->pid > 0) */
2054 /* { */
2055 /* report (REPORT_DEBUG, "killing process %d\n", sp->si->pid); */
2056 /* if (kill (sp->si->pid, SIGKILL) < 0) */
2057 /* { */
2058 /* report (REPORT_DEBUG, "kill %d: %s\n", sp->si->pid, sys_err_str (errno)); */
2059 /* } */
2060 /* } */
2143 /* if (sp->si && sp->si->pid > 0) */
2144 /* { */
2145 /* report (REPORT_DEBUG, "killing process %d\n", sp->si->pid); */
2146 /* if (kill (sp->si->pid, SIGKILL) < 0) */
2147 /* { */
2148 /* report (REPORT_DEBUG, "kill %d: %s\n", sp->si->pid, sys_err_str (errno)); */
2149 /* } */
2150 /* } */
20612151 /* } */
20622152 /* #endif */
20632153 /* connection_cleanup (); */
20642154
2065 cache_cleanup ();
2066 rplay_audio_close ();
2067 close (rplay_fd);
2068 close (rptp_fd);
2155 cache_cleanup();
2156 rplay_audio_close();
2157 close(rplay_fd);
2158 close(rptp_fd);
20692159 #ifdef OTHER_RPLAY_PORTS
2070 close (other_rplay_fd);
2071 close (other_rptp_fd);
2072 #endif
2073 report (REPORT_DEBUG, "exit(%d)\n", exit_value);
2160 close(other_rplay_fd);
2161 close(other_rptp_fd);
2162 #endif
2163 report(REPORT_DEBUG, "exit(%d)\n", exit_value);
20742164 if (logging && log_fd >= 0)
20752165 {
2076 close (log_fd);
2077 }
2078 exit (exit_value);
2166 close(log_fd);
2167 }
2168 exit(exit_value);
20792169 }
20802170
20812171 #ifdef __STDC__
20822172 void
2083 report (int level, char *fmt,...)
2173 report(int level, char *fmt,...)
20842174 #else
20852175 void
2086 report (va_alist)
2176 report(va_alist)
20872177 va_dcl
20882178 #endif
20892179 {
20952185 static char message[2048]; /* XXX: largest message */
20962186
20972187 #ifdef __STDC__
2098 va_start (args, fmt);
2188 va_start(args, fmt);
20992189 #else
21002190 char *fmt;
21012191 int level;
2102 va_start (args);
2103 level = va_arg (args, int);
2104 fmt = va_arg (args, char *);
2192 va_start(args);
2193 level = va_arg(args, int);
2194 fmt = va_arg(args, char *);
21052195 #endif
21062196
21072197 if (report_level >= level)
21082198 {
2109 VSNPRINTF (SIZE(message,sizeof(message)), fmt, args);
2199 VSNPRINTF(SIZE(message, sizeof(message)), fmt, args);
21102200 iov[1].iov_base = message;
2111 iov[1].iov_len = strlen (message);
2201 iov[1].iov_len = strlen(message);
21122202
21132203 if (logging)
21142204 {
2115 now = time (0);
2116 p = ctime (&now);
2205 now = time(0);
2206 p = ctime(&now);
21172207 p += 4;
21182208 p[15] = '\0';
21192209
21222212 #ifndef O_SYNC
21232213 #define O_SYNC 0
21242214 #endif
2125 log_fd = open (log_file, O_WRONLY | O_CREAT | O_APPEND | O_SYNC, 0644);
2215 log_fd = open(log_file, O_WRONLY | O_CREAT | O_APPEND | O_SYNC, 0644);
21262216 if (log_fd < 0)
21272217 {
2128 fprintf (stderr, "%s: cannot open logfile `%s': %s\n",
2129 progname, log_file, sys_err_str (errno));
2218 fprintf(stderr, "%s: cannot open logfile `%s': %s\n",
2219 progname, log_file, sys_err_str(errno));
21302220 /*
21312221 * Turn off logging to avoid further problems.
21322222 */
21362226 }
21372227 }
21382228
2139 SNPRINTF (SIZE(header,sizeof(header)), "%s %s rplayd[%d]: ", p, hostname, rplayd_pid);
2229 SNPRINTF(SIZE(header, sizeof(header)), "%s %s rplayd[%d]: ", p, hostname, rplayd_pid);
21402230 iov[0].iov_base = header;
2141 iov[0].iov_len = strlen (header);
2142
2143 if (writev (log_fd, iov, 2) < 0)
2231 iov[0].iov_len = strlen(header);
2232
2233 if (writev(log_fd, iov, 2) < 0)
21442234 {
2145 fprintf (stderr, "%s: cannot write to log file `%s': %s\n",
2146 progname, log_file, sys_err_str (errno));
2235 fprintf(stderr, "%s: cannot write to log file `%s': %s\n",
2236 progname, log_file, sys_err_str(errno));
21472237 logging = 0;
21482238 log_fd = -1;
2149 fprintf (stderr, "%s: logging disabled\n", progname);
2239 fprintf(stderr, "%s: logging disabled\n", progname);
21502240 }
21512241 }
21522242
21532243 if (debug || level == REPORT_ERROR)
21542244 {
2155 SNPRINTF (SIZE(header,sizeof(header)), "%s: ", progname);
2245 SNPRINTF(SIZE(header, sizeof(header)), "%s: ", progname);
21562246 iov[0].iov_base = header;
2157 iov[0].iov_len = strlen (header);
2247 iov[0].iov_len = strlen(header);
21582248 #ifndef STDERR_FILENO
21592249 #define STDERR_FILENO 2
21602250 #endif
2161 writev (STDERR_FILENO, iov, 2);
2162 }
2163
2164 }
2165
2166 va_end (args);
2251 writev(STDERR_FILENO, iov, 2);
2252 }
2253
2254 }
2255
2256 va_end(args);
21672257 }
21682258
21692259 void
2170 usage ()
2171 {
2172 printf ("\n");
2173 printf ("rplay %s\n", RPLAY_VERSION);
2174 printf ("\n");
2175 printf ("usage: %s [options]\n", progname);
2176 printf ("\n");
2177
2178 printf ("-A DEVICE, --audio-device=DEVICE\n");
2179 printf ("\tUse DEVICE for the audio device (%s).\n", rplay_audio_device);
2180 printf ("\n");
2260 usage()
2261 {
2262 printf("\n");
2263 printf("rplay %s\n", RPLAY_VERSION);
2264 printf("\n");
2265 printf("usage: %s [options]\n", progname);
2266 printf("\n");
2267
2268 printf("-A DEVICE, --audio-device=DEVICE\n");
2269 printf("\tUse DEVICE for the audio device (%s).\n", rplay_audio_device);
2270 printf("\n");
21812271
21822272 #ifndef HAVE_OSS
2183 printf ("-b N, --audio-bufsize=N\n");
2184 printf ("\tAudio buffer size (%d).\n", rplay_audio_bufsize);
2185 printf ("\n");
2186 #endif /* !HAVE_OSS */
2187
2188 printf ("-B N, --audio-bits=N\n");
2189 printf ("\tAudio device bits per sample, 8 or 16.\n");
2190 printf ("\n");
2191
2192 printf ("--audio-channels=N\n");
2193 printf ("\tNumber of audio channels to use, 1 == mono, 2 == stereo.\n");
2194 printf ("\n");
2195
2196 printf ("-c N, --audio-close=N\n");
2197 printf ("\tClose %s after N idle seconds, disabled with 0 (%d).\n",
2198 RPLAY_AUDIO_DEVICE, rplay_audio_timeout);
2199 printf ("\n");
2200
2201 printf ("-F N, --audio_flush=N\n");
2202 printf ("\tFlush %s after N idle seconds, disabled with 0 (%d).\n",
2203 RPLAY_AUDIO_DEVICE, rplay_audio_flush_timeout);
2204 printf ("\tN = -1 : flush when spool is empty.\n");
2205 printf ("\tN = -2 : flush after each audio write. (not recommended)\n");
2206 printf ("\tN should be <= to the audio close timeout.\n");
2207 printf ("\n");
2208
2209 printf ("--audio-format=FORMAT\n");
2210 printf ("\tTell rplayd to write audio data using FORMAT, where FORMAT\n");
2211 printf ("\tcan be ulaw, linear-8, ulinear-8, linear-16, or ulinear-16.\n");
2212 printf ("\t(linear = signed, ulinear = unsigned)\n");
2213 printf ("\n");
2214
2215 #ifdef HAVE_OSS
2216 printf ("--audio-fragsize=N\n");
2217 printf ("\tAudio fragment size (%d). The default size is zero which lets\n",
2218 rplay_audio_fragsize);
2219 printf ("\tthe audio driver pick the \"best\" size. The size specified must\n");
2220 printf ("\tbe a power of 2 greater than 16. Example: 256, 1024, 4096.\n");
2221 printf ("\n");
2273 printf("-b N, --audio-bufsize=N\n");
2274 printf("\tAudio buffer size (%d).\n", rplay_audio_bufsize);
2275 printf("\n");
2276 #endif /* !HAVE_OSS */
2277
2278 printf("-B N, --audio-bits=N\n");
2279 printf("\tAudio device bits per sample, 8 or 16.\n");
2280 printf("\n");
2281
2282 printf("--audio-channels=N\n");
2283 printf("\tNumber of audio channels to use, 1 == mono, 2 == stereo.\n");
2284 printf("\n");
2285
2286 printf("-c N, --audio-close=N\n");
2287 printf("\tClose %s after N idle seconds, disabled with 0 (%d).\n",
2288 RPLAY_AUDIO_DEVICE, rplay_audio_timeout);
2289 printf("\n");
2290
2291 printf("-F N, --audio_flush=N\n");
2292 printf("\tFlush %s after N idle seconds, disabled with 0 (%d).\n",
2293 RPLAY_AUDIO_DEVICE, rplay_audio_flush_timeout);
2294 printf("\tN = -1 : flush when spool is empty.\n");
2295 printf("\tN = -2 : flush after each audio write. (not recommended)\n");
2296 printf("\tN should be <= to the audio close timeout.\n");
2297 printf("\n");
2298
2299 printf("--audio-format=FORMAT\n");
2300 printf("\tTell rplayd to write audio data using FORMAT, where FORMAT\n");
2301 printf("\tcan be ulaw, linear-8, ulinear-8, linear-16, or ulinear-16.\n");
2302 printf("\t(linear = signed, ulinear = unsigned)\n");
2303 printf("\n");
2304
2305 #ifdef HAVE_OSS
2306 printf("--audio-fragsize=N\n");
2307 printf("\tAudio fragment size (%d). The default size is zero which lets\n",
2308 rplay_audio_fragsize);
2309 printf("\tthe audio driver pick the \"best\" size. The size specified must\n");
2310 printf("\tbe a power of 2 greater than 16. Example: 256, 1024, 4096.\n");
2311 printf("\n");
22222312 #endif /* HAVE_OSS */
2223
2224 printf ("--audio-info=INFO, --info=INFO, -i INFO\n");
2225 printf ("\tSpecify complete audio device information with one option.\n");
2226 printf ("\tINFO is of the form: format,sample-rate,bits,channels\n");
2227 printf ("\tExamples: `ulaw,8000,8,1' and `linear-16,44100,16,2'\n");
2228 printf ("\tAlso provided are:\n");
2229 printf ("\t --audio-info-ulaw, --info-ulaw -> ulaw,8000,8,1\n");
2230 printf ("\n");
2231
2232 printf ("--audio-match\n");
2233 printf ("\tAttempt to match the sample rate of the audio device with\n");
2234 printf ("\tthe sample rate of the current sound when no other sounds\n");
2235 printf ("\tare playing. If the match fails, --audio-sample-rate is used.\n");
2236 printf ("\tThis option overrides --audio-bufsize.\n");
2237 printf ("\n");
2238
2239 printf ("--audio-port=PORT[,PORT...]\n");
2240 printf ("\tOutput audio to the specified audio port(s).\n");
2241 printf ("\tValid ports are `speaker', `headphone', and `lineout'.\n");
2242 printf ("\tMultiple ports can be specified using `speaker,headphone,lineout'\n");
2243 printf ("\n");
2244
2245 printf ("-r N, --audio-rate=N\n");
2246 printf ("\tWrite the audio buffer N times per second (%d).\n", rplay_audio_rate);
2247 printf ("\n");
2248
2249 printf ("-R N, --audio-sample-rate=N\n");
2250 printf ("\tSample rate of the audio device.\n");
2251 printf ("\n");
2313
2314 printf("--audio-info=INFO, --info=INFO, -i INFO\n");
2315 printf("\tSpecify complete audio device information with one option.\n");
2316 printf("\tINFO is of the form: format,sample-rate,bits,channels\n");
2317 printf("\tExamples: `ulaw,8000,8,1' and `linear-16,44100,16,2'\n");
2318 printf("\tAlso provided are:\n");
2319 printf("\t --audio-info-ulaw, --info-ulaw -> ulaw,8000,8,1\n");
2320 printf("\n");
2321
2322 printf("--audio-match\n");
2323 printf("\tAttempt to match the sample rate of the audio device with\n");
2324 printf("\tthe sample rate of the current sound when no other sounds\n");
2325 printf("\tare playing. If the match fails, --audio-sample-rate is used.\n");
2326 printf("\tThis option overrides --audio-bufsize.\n");
2327 printf("\n");
2328
2329 printf("--audio-port=PORT[,PORT...]\n");
2330 printf("\tOutput audio to the specified audio port(s).\n");
2331 printf("\tValid ports are `speaker', `headphone', and `lineout'.\n");
2332 printf("\tMultiple ports can be specified using `speaker,headphone,lineout'\n");
2333 printf("\n");
2334
2335 printf("-r N, --audio-rate=N\n");
2336 printf("\tWrite the audio buffer N times per second (%d).\n", rplay_audio_rate);
2337 printf("\n");
2338
2339 printf("-R N, --audio-sample-rate=N\n");
2340 printf("\tSample rate of the audio device.\n");
2341 printf("\n");
22522342
22532343 #ifdef AUTH
2254 printf ("--auth\n");
2255 printf ("\tEnable host access authentication.\n");
2256 printf ("\n");
2257 #endif
2258
2259 printf ("-D DIR, --cache-directory=DIR\n");
2260 printf ("\tUse DIR for rplay.cache (%s).\n", RPLAY_CACHE);
2261 printf ("\n");
2262
2263 printf ("--cache-remove\n");
2264 printf ("\tRemove the cache directory and all its contents when rplayd exists.\n");
2265 printf ("\n");
2266
2267 printf ("-s N, --cache-size=N\n");
2268 printf ("\tMaximum size in bytes of the rplay cache, disabled with 0 (%d).\n",
2269 RPLAY_CACHE_SIZE);
2270 printf ("\n");
2271
2272 #ifdef HAVE_CDROM
2273 printf ("--cdrom0=DEVICE, --cdrom1=DEVICE, --cdrom2=DEVICE, --cdrom3=DEVICE\n");
2274 printf ("\tSpecify the cdrom[0-3] to DEVICE mapping. For Solaris 2.x the default\n");
2275 printf ("\tmapping is cdrom[0-3] -> /vol/dev/aliases/cdrom[0-3].\n");
2276 printf ("\tLinux uses cdrom[0-3] -> /dev/cdrom[0-3].\n");
2277 printf ("\n");
2278 #endif /* HAVE_CDROM */
2279
2280 printf ("-C FILE, --conf=FILE\n");
2281 printf ("\tUse FILE for rplay.conf (%s).\n", RPLAY_CONF);
2282 printf ("\n");
2283
2284 printf ("-T N, --connection-timeout=N\n");
2285 printf ("\tClose idle RPTP connections after N seconds, disabled with 0 (%d).\n",
2286 rptp_timeout);
2287 printf ("\n");
2288
2289 printf ("-d, --debug\n");
2290 printf ("\tEnable debug mode.\n");
2291 printf ("\n");
2292
2293 printf ("-f HOST, --forward=HOST\n");
2294 printf ("\tForward all RPLAY packets to HOST.\n");
2295 printf ("\n");
2296
2297 printf ("--fork\n");
2298 printf ("\tEnable backgrounding rplayd at startup. (%s)\n",
2299 do_fork ? "enabled" : "disabled");
2300 printf ("\n");
2301
2302 printf ("--group=GROUP\n");
2303 printf ("\tRun with GROUP privs. (%s)\n", run_as_group);
2304 printf ("\n");
2305
2306 printf ("--help\n");
2307 printf ("\tDisplay helpful information.\n");
2308 printf ("\n");
2344 printf("--auth\n");
2345 printf("\tEnable host access authentication.\n");
2346 printf("\n");
2347 #endif
2348
2349 printf("-D DIR, --cache-directory=DIR\n");
2350 printf("\tUse DIR for rplay.cache (%s).\n", RPLAY_CACHE);
2351 printf("\n");
2352
2353 printf("--cache-remove\n");
2354 printf("\tRemove the cache directory and all its contents when rplayd exists.\n");
2355 printf("\n");
2356
2357 printf("-s N, --cache-size=N\n");
2358 printf("\tMaximum size in bytes of the rplay cache, disabled with 0 (%d).\n",
2359 RPLAY_CACHE_SIZE);
2360 printf("\n");
2361
2362 #ifdef HAVE_CDROM
2363 printf("--cdrom0=DEVICE, --cdrom1=DEVICE, --cdrom2=DEVICE, --cdrom3=DEVICE\n");
2364 printf("\tSpecify the cdrom[0-3] to DEVICE mapping. For Solaris 2.x the default\n");
2365 printf("\tmapping is cdrom[0-3] -> /vol/dev/aliases/cdrom[0-3].\n");
2366 printf("\tLinux uses cdrom[0-3] -> /dev/cdrom[0-3].\n");
2367 printf("\n");
2368 #endif /* HAVE_CDROM */
2369
2370 printf("-C FILE, --conf=FILE\n");
2371 printf("\tUse FILE for rplay.conf (%s).\n", RPLAY_CONF);
2372 printf("\n");
2373
2374 printf("-T N, --connection-timeout=N\n");
2375 printf("\tClose idle RPTP connections after N seconds, disabled with 0 (%d).\n",
2376 rptp_timeout);
2377 printf("\n");
2378
2379 printf("-d, --debug\n");
2380 printf("\tEnable debug mode.\n");
2381 printf("\n");
2382
2383 printf("-f HOST, --forward=HOST\n");
2384 printf("\tForward all RPLAY packets to HOST.\n");
2385 printf("\n");
2386
2387 printf("--fork\n");
2388 printf("\tEnable backgrounding rplayd at startup. (%s)\n",
2389 do_fork ? "enabled" : "disabled");
2390 printf("\n");
2391
2392 printf("--group=GROUP\n");
2393 printf("\tRun with GROUP privs. (%s)\n", run_as_group);
2394 printf("\n");
2395
2396 printf("--help\n");
2397 printf("\tDisplay helpful information.\n");
2398 printf("\n");
23092399
23102400 #ifdef HAVE_HELPERS
2311 printf ("--helpers=FILE\n");
2312 printf ("\tUse FILE for rplay.helpers (%s).\n", RPLAY_HELPERS);
2313 printf ("\n");
2401 printf("--helpers=FILE\n");
2402 printf("\tUse FILE for rplay.helpers (%s).\n", RPLAY_HELPERS);
2403 printf("\n");
23142404 #endif /* HAVE_HELPERS */
23152405
23162406 #ifdef AUTH
2317 printf ("-H FILE, --hosts=FILE\n");
2318 printf ("\tUse FILE for rplay.hosts (%s).\n", RPLAY_HOSTS);
2319 printf ("\n");
2407 printf("-H FILE, --hosts=FILE\n");
2408 printf("\tUse FILE for rplay.hosts (%s).\n", RPLAY_HOSTS);
2409 printf("\n");
23202410 #endif /* AUTH */
23212411
2322 printf ("--inetd\n");
2323 printf ("\tEnable inetd mode. (%s)\n", inetd ? "enabled" : "disabled");
2324 printf ("\n");
2325
2326 printf ("-L FILE, --log-file=FILE\n");
2327 printf ("\tUse file for rplay.log (%s).\n", RPLAY_LOG);
2328 printf ("\n");
2329
2330 printf ("-l N, --log-level=N\n");
2331 printf ("\tUse logging level N where %d <= n <= %d.\n", REPORT_MIN, REPORT_MAX);
2332 printf ("\n");
2333
2334 printf ("--memory-cache-size=N\n");
2335 printf ("\tMaximum size in bytes of the memory cache, disable caching with 0 (%d).\n",
2336 MEMORY_CACHE_SIZE);
2337 printf ("\n");
2338
2339 printf ("--memory-cache-sound-size=N\n");
2340 printf ("\tMaximum size in bytes of a sound that can be cached in memory.\n");
2341 printf ("\tA value of 0 means to try and cache all sounds. (%d)\n",
2342 MEMORY_CACHE_SOUND_SIZE);
2343 printf ("\n");
2344
2345 printf ("-N, --no-audio\n");
2346 printf ("\tDisable audio, RPTP file server mode.\n");
2347 printf ("\n");
2412 printf("--inetd\n");
2413 printf("\tEnable inetd mode. (%s)\n", inetd ? "enabled" : "disabled");
2414 printf("\n");
2415
2416 printf("-L FILE, --log-file=FILE\n");
2417 printf("\tUse file for rplay.log (%s).\n", RPLAY_LOG);
2418 printf("\n");
2419
2420 printf("-l N, --log-level=N\n");
2421 printf("\tUse logging level N where %d <= n <= %d.\n", REPORT_MIN, REPORT_MAX);
2422 printf("\n");
2423
2424 printf("--memory-cache-size=N\n");
2425 printf("\tMaximum size in bytes of the memory cache, disable caching with 0 (%d).\n",
2426 MEMORY_CACHE_SIZE);
2427 printf("\n");
2428
2429 printf("--memory-cache-sound-size=N\n");
2430 printf("\tMaximum size in bytes of a sound that can be cached in memory.\n");
2431 printf("\tA value of 0 means to try and cache all sounds. (%d)\n",
2432 MEMORY_CACHE_SOUND_SIZE);
2433 printf("\n");
2434
2435 printf("-N, --no-audio\n");
2436 printf("\tDisable audio, RPTP file server mode.\n");
2437 printf("\n");
23482438
23492439 #ifdef AUTH
2350 printf ("--no-auth\n");
2351 printf ("\tDisable host access authentication.\n");
2352 printf ("\n");
2353 #endif
2354
2355 printf ("-n, --no-inetd\n");
2356 printf ("\tDisable inetd mode. (%s)\n", inetd ? "enabled" : "disabled");
2357 printf ("\n");
2358
2359 printf ("--no-fork\n");
2360 printf ("\tDisable backgrounding rplayd at startup. (%s)\n",
2361 do_fork ? "enabled" : "disabled");
2362 printf ("\n");
2363
2364 printf ("--options-file=FILE\n");
2365 printf ("\tRead rplayd options from FILE.\n");
2366 printf ("\n");
2367
2368 printf ("--port=PORT, --rplay-port=PORT\n");
2369 printf ("\tUse PORT as the RPLAY/UDP port. (%d)\n", RPLAY_PORT);
2370 printf ("\t(--other-rplay-port may also be available)\n");
2371 printf ("\n");
2372
2373 printf ("--rptp-port=PORT\n");
2374 printf ("\tUse PORT as the RPTP/TCP port. (%d)\n", RPTP_PORT);
2375 printf ("\t(--other-rptp-port may also be available)\n");
2376 printf ("\n");
2377
2378 printf ("-S FILE, --servers=FILE\n");
2379 printf ("\tUse FILE for rplay.servers (%s).\n", RPLAY_SERVERS);
2380 printf ("\n");
2381
2382 printf ("-t N, --timeout=N\n");
2383 printf ("\tExit after N idle seconds, disabled with 0 (%d).\n", rplayd_timeout);
2384 printf ("\n");
2385
2386 printf ("--user=USER\n");
2387 printf ("\tRun with USER privs. (%s)\n", run_as_user);
2388 printf ("\n");
2389
2390 printf ("-v, --version\n");
2391 printf ("\tPrint the rplay version and exit.\n");
2392 }
2440 printf("--no-auth\n");
2441 printf("\tDisable host access authentication.\n");
2442 printf("\n");
2443 #endif
2444
2445 printf("-n, --no-inetd\n");
2446 printf("\tDisable inetd mode. (%s)\n", inetd ? "enabled" : "disabled");
2447 printf("\n");
2448
2449 printf("--no-fork\n");
2450 printf("\tDisable backgrounding rplayd at startup. (%s)\n",
2451 do_fork ? "enabled" : "disabled");
2452 printf("\n");
2453
2454 printf("--options-file=FILE\n");
2455 printf("\tRead rplayd options from FILE.\n");
2456 printf("\n");
2457
2458 printf("--port=PORT, --rplay-port=PORT\n");
2459 printf("\tUse PORT as the RPLAY/UDP port. (%d)\n", RPLAY_PORT);
2460 printf("\t(--other-rplay-port may also be available)\n");
2461 printf("\n");
2462
2463 printf("--rptp-port=PORT\n");
2464 printf("\tUse PORT as the RPTP/TCP port. (%d)\n", RPTP_PORT);
2465 printf("\t(--other-rptp-port may also be available)\n");
2466 printf("\n");
2467
2468 printf("-S FILE, --servers=FILE\n");
2469 printf("\tUse FILE for rplay.servers (%s).\n", RPLAY_SERVERS);
2470 printf("\n");
2471
2472 printf("-t N, --timeout=N\n");
2473 printf("\tExit after N idle seconds, disabled with 0 (%d).\n", rplayd_timeout);
2474 printf("\n");
2475
2476 printf("--user=USER\n");
2477 printf("\tRun with USER privs. (%s)\n", run_as_user);
2478 printf("\n");
2479
2480 printf("-v, --version\n");
2481 printf("\tPrint the rplay version and exit.\n");
2482 }
0 /* $Id: rplayd.h,v 1.2 1998/08/13 06:14:02 boyns Exp $ */
0 /* $Id: rplayd.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifndef _rplayd_h
2624 #define _rplayd_h
4543 #define REPORT_MIN 0
4644 #define REPORT_MAX 4
4745
48 /* $Id: rplayd.h,v 1.2 1998/08/13 06:14:02 boyns Exp $ */
46 /* $Id: rplayd.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */
4947 #define SET_BIT(w, bit) ( (w) |= (bit) )
5048 #define CLR_BIT(w, bit) ( (w) &= ~(bit) )
5149 #define BIT(w, bit) ( (w) & (bit) )
131129 extern int default_fragsize;
132130 #endif /* HAVE_OSS */
133131
132 extern int monitor_count;
133 extern BUFFER *monitor_buffers;
134134
135135 extern int errno;
136136
0 /* $Id: server.c,v 1.2 1998/08/13 06:14:03 boyns Exp $ */
0 /* $Id: server.c,v 1.5 1999/03/10 07:58:04 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
4545
4646 #ifdef __STDC__
4747 void
48 server_read (char *filename)
48 server_read(char *filename)
4949 #else
5050 void
51 server_read (filename)
51 server_read(filename)
5252 char *filename;
5353 #endif
5454 {
6262 SERVER **s = &servers;
6363 BUFFER *b;
6464
65 server_read_time = time (0);
66
67 fp = fopen (filename, "r");
65 server_read_time = time(0);
66
67 fp = fopen(filename, "r");
6868 if (fp == NULL)
6969 {
7070 /*
7171 * I guess it's ok to not have any servers.
7272 */
73 report (REPORT_NOTICE, "warning: cannot open %s\n", filename);
73 report(REPORT_NOTICE, "warning: cannot open %s\n", filename);
7474 return;
7575 }
7676
77 local_hp = gethostbyname (hostname);
77 local_hp = gethostbyname(hostname);
7878 if (local_hp == NULL)
7979 {
80 report (REPORT_ERROR, "server_read: %s unknown host?!\n", hostname);
81 done (1);
82
83 }
84 memcpy ((char *) &local_addr, (char *) local_hp->h_addr, local_hp->h_length);
85
86 b = buffer_create ();
87 strcpy (b->buf, "+message=\"servers\"\r\n");
88 b->nbytes += strlen (b->buf);
80 report(REPORT_ERROR, "server_read: %s unknown host?!\n", hostname);
81 done(1);
82
83 }
84 memcpy((char *) &local_addr, (char *) local_hp->h_addr, local_hp->h_length);
85
86 b = buffer_create();
87 strcpy(b->buf, "+message=\"servers\"\r\n");
88 b->nbytes += strlen(b->buf);
8989 b->status = BUFFER_KEEP;
9090 server_list = b;
9191
92 while (fgets (buf, sizeof (buf), fp))
92 while (fgets(buf, sizeof(buf), fp))
9393 {
9494 switch (buf[0])
9595 {
100100 continue;
101101 }
102102
103 p = strchr (buf, '\n');
103 p = strchr(buf, '\n');
104104 if (p)
105105 {
106106 *p = '\0';
107107 }
108108
109 p = strchr (buf, ':');
109 p = strchr(buf, ':');
110110 if (p)
111111 {
112112 *p = '\0';
113 port = atoi (p + 1);
113 port = atoi(p + 1);
114114 }
115115 else
116116 {
117117 port = RPTP_PORT;
118118 }
119 addr = inet_addr (buf);
120 memset ((char *) &sin, 0, sizeof (sin));
119 addr = inet_addr(buf);
120 memset((char *) &sin, 0, sizeof(sin));
121121 if (addr == 0xffffffff)
122122 {
123 hp = gethostbyname (buf);
123 hp = gethostbyname(buf);
124124 if (hp == NULL)
125125 {
126 report (REPORT_NOTICE, "warning: %s unknown host in %s\n", buf, filename);
126 report(REPORT_NOTICE, "warning: %s unknown host in %s\n", buf, filename);
127127 continue;
128128 }
129 memcpy ((char *) &sin.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
129 memcpy((char *) &sin.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length);
130130 }
131131 else
132132 {
133 memcpy ((char *) &sin.sin_addr.s_addr, (char *) &addr, sizeof (addr));
134 }
135
136 if (memcmp ((char *) &sin.sin_addr.s_addr, (char *) &local_addr, sizeof (local_addr)) == 0)
133 memcpy((char *) &sin.sin_addr.s_addr, (char *) &addr, sizeof(addr));
134 }
135
136 if (memcmp((char *) &sin.sin_addr.s_addr, (char *) &local_addr, sizeof(local_addr)) == 0)
137137 {
138138 /*
139139 * ignore the server if it's the local host
141141 continue;
142142 }
143143
144 *s = (SERVER *) malloc (sizeof (SERVER));
144 *s = (SERVER *) malloc(sizeof(SERVER));
145145 if (*s == NULL)
146146 {
147 report (REPORT_ERROR, "server_read: out of memory\n");
148 done (1);
147 report(REPORT_ERROR, "server_read: out of memory\n");
148 done(1);
149149 }
150150 sin.sin_family = AF_INET;
151 sin.sin_port = htons (port);
152
153 SNPRINTF (SIZE(line,sizeof(line)), "host=%s port=%d\r\n", buf, port);
154 n = strlen (line);
151 sin.sin_port = htons(port);
152
153 SNPRINTF(SIZE(line, sizeof(line)), "host=%s port=%d\r\n", buf, port);
154 n = strlen(line);
155155
156156 if (b->nbytes + n > BUFFER_SIZE)
157157 {
158 b->next = buffer_create ();
158 b->next = buffer_create();
159159 b = b->next;
160160 b->status = BUFFER_KEEP;
161161 }
162 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), line);
162 SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), line);
163163 b->nbytes += n;
164164
165165 (*s)->sin = sin;
166166 s = &(*s)->next;
167167
168 report (REPORT_DEBUG, "server %s port %d\n", inet_ntoa (sin.sin_addr), port);
168 report(REPORT_DEBUG, "server %s port %d\n", inet_ntoa(sin.sin_addr), port);
169169 }
170170
171171 *s = NULL;
172 fclose (fp);
172 fclose(fp);
173173
174174 if (b->nbytes + 3 > BUFFER_SIZE)
175175 {
176 b->next = buffer_create ();
176 b->next = buffer_create();
177177 b = b->next;
178178 b->status = BUFFER_KEEP;
179179 }
180 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n");
180 SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), ".\r\n");
181181 b->nbytes += 3;
182182 }
183183
184184 #ifdef __STDC__
185185 void
186 server_reread (char *filename)
186 server_reread(char *filename)
187187 #else
188188 void
189 server_reread (filename)
189 server_reread(filename)
190190 char *filename;
191191 #endif
192192 {
193193 BUFFER *b, *bb;
194194 SERVER *s, *ss;
195195
196 report (REPORT_DEBUG, "re-reading servers\n");
196 report(REPORT_DEBUG, "re-reading servers\n");
197197
198198 /*
199199 * Free the server_list buffers.
200200 */
201 for (b = server_list; b; bb = b, b = b->next, bb->status = BUFFER_FREE, buffer_destroy (bb)) ;
201 for (b = server_list; b; bb = b, b = b->next, bb->status = BUFFER_FREE, buffer_destroy(bb)) ;
202202
203203 /*
204204 * Free the servers list.
205205 */
206 for (s = servers; s; ss = s, s = s->next, free ((char *) ss)) ;
206 for (s = servers; s; ss = s, s = s->next, free((char *) ss)) ;
207207
208208 server_list = NULL;
209209 servers = NULL;
210 server_read (filename);
210 server_read(filename);
211211 }
212212
213213 #ifdef __STDC__
214214 void
215 server_stat (char *filename)
215 server_stat(char *filename)
216216 #else
217217 void
218 server_stat (filename)
218 server_stat(filename)
219219 char *filename;
220220 #endif
221221 {
222 if (modified (filename, server_read_time))
223 {
224 server_reread (filename);
222 if (modified(filename, server_read_time))
223 {
224 server_reread(filename);
225225 }
226226 }
0 /* $Id: server.h,v 1.2 1998/08/13 06:14:04 boyns Exp $ */
0 /* $Id: server.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: sound.c,v 1.6 1998/10/15 15:15:25 boyns Exp $ */
0 /* $Id: sound.c,v 1.10 1999/06/09 06:27:44 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
5656 #include "connection.h"
5757 #include "misc.h"
5858 #include "strdup.h"
59 #include "rxposix.h"
6059 #include "spool.h"
6160 #ifdef HAVE_CDROM
6261 #include "cdrom.h"
6463 #ifdef HAVE_HELPERS
6564 #include "helper.h"
6665 #endif /* HAVE_HELPERS */
66 #ifdef HAVE_RX_RXPOSIX_H
67 #include <rx/rxposix.h>
68 #else
69 #ifdef HAVE_RXPOSIX_H
70 #include <rxposix.h>
71 #else
72 #include "rxposix.h"
73 #endif
74 #endif
6775
6876 SOUND *sounds = NULL;
6977 int sound_count = 0;
7886
7987 /* Prepare `bad_dirs'. */
8088 static void
81 bad_dirs_init ()
89 bad_dirs_init()
8290 {
8391 static char *buf;
8492 char *p;
8593 char *dirs;
8694 int first, length;
8795
88 dirs = strdup (BAD_DIRS); /* XXX */
89
90 length = strlen ("^\\(") + strlen ("\\)") + strlen (dirs) + 1;
96 dirs = strdup(BAD_DIRS); /* XXX */
97
98 length = strlen("^\\(") + strlen("\\)") + strlen(dirs) + 1;
9199
92100 //length += strlen ("^");
93101 for (p = dirs; *p; p++)
94102 {
95103 if (*p == ':')
96104 {
97 length += strlen ("\\|") - strlen (":");
105 length += strlen("\\|") - strlen(":");
98106 }
99107 }
100108
101109 if (buf)
102110 {
103 free (buf);
104 }
105 buf = (char *) malloc (length);
111 free(buf);
112 }
113 buf = (char *) malloc(length);
106114 if (buf == NULL)
107115 {
108 report (REPORT_ERROR, "bad_dir_init: out of memory\n");
109 done (1);
116 report(REPORT_ERROR, "bad_dir_init: out of memory\n");
117 done(1);
110118 }
111119
112120 first = 1;
113 strcpy (buf, "^\\(");
114 while (p = (char *) strtok (first ? dirs : 0, ":"))
121 strcpy(buf, "^\\(");
122 while (p = (char *) strtok(first ? dirs : 0, ":"))
115123 {
116124 if (first)
117125 {
121129 else
122130 {
123131 //strcat (buf, "\\|^");
124 strcat (buf, "\\|");
125 }
126 strcat (buf, p);
127 }
128 strcat (buf, "\\)");
132 strcat(buf, "\\|");
133 }
134 strcat(buf, p);
135 }
136 strcat(buf, "\\)");
129137
130138 #if 0
131 report (REPORT_DEBUG, "bad_dirs=%s, strlen=%d, length=%d\n",
132 buf, strlen (buf), length);
139 report(REPORT_DEBUG, "bad_dirs=%s, strlen=%d, length=%d\n",
140 buf, strlen(buf), length);
133141 #endif
134142
135143 //memset ((char *) &bad_dirs, 0, sizeof (bad_dirs));
136144
137 if (regncomp (&bad_dirs, buf, strlen (buf), REG_ICASE | REG_NOSUB))
138 {
139 report (REPORT_ERROR, "bad_dirs: regncomp failed\n");
140 done (1);
141 }
142
143 free (dirs);
145 if (regncomp(&bad_dirs, buf, strlen(buf), REG_ICASE | REG_NOSUB))
146 {
147 report(REPORT_ERROR, "bad_dirs: regncomp failed\n");
148 done(1);
149 }
150
151 free(dirs);
144152 }
145153
146154 #ifdef __STDC__
147155 static int
148 bad_dir (char *dir)
156 bad_dir(char *dir)
149157 #else
150158 static int
151 bad_dir (dir)
159 bad_dir(dir)
152160 char *dir;
153161 #endif
154162 {
155163 /* return 1 if bad */
156 return regnexec (&bad_dirs, dir, strlen (dir), 0, 0, 0) ? 0 : 1;
164 return regnexec(&bad_dirs, dir, strlen(dir), 0, 0, 0) ? 0 : 1;
157165 }
158166
159167 #endif /* BAD_DIRS */
160168
161169 #ifdef __STDC__
162170 void
163 sound_read_directory (char *dirname)
171 sound_read_directory(char *dirname)
164172 #else
165173 void
166 sound_read_directory (dirname)
174 sound_read_directory(dirname)
167175 char *dirname;
168176 #endif
169177 {
170178 char soundname[MAXPATHLEN];
171179 struct dirent *dp;
172 DIR *dir = opendir (dirname);
180 DIR *dir = opendir(dirname);
173181 if (dir == NULL)
174182 {
175 report (REPORT_ERROR, "opendir %s: %s", sys_err_str (errno));
183 report(REPORT_ERROR, "opendir %s: %s", sys_err_str(errno));
176184 return;
177185 }
178186
179 while ((dp = readdir (dir)) != NULL)
180 {
181 if (strcmp (dp->d_name, ".") == 0 || strcmp (dp->d_name, "..") == 0)
187 while ((dp = readdir(dir)) != NULL)
188 {
189 if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)
182190 {
183191 continue;
184192 }
185 sprintf (soundname, "%s/%s", dirname, dp->d_name);
186 sound_insert (soundname, SOUND_READY, SOUND_FILE);
187 }
188
189 closedir (dir);
193 sprintf(soundname, "%s/%s", dirname, dp->d_name);
194 sound_insert(soundname, SOUND_READY, SOUND_FILE);
195 }
196
197 closedir(dir);
190198 }
191199
192200
195203 */
196204 #ifdef __STDC__
197205 void
198 sound_read (char *filename)
206 sound_read(char *filename)
199207 #else
200208 void
201 sound_read (filename)
209 sound_read(filename)
202210 char *filename;
203211 #endif
204212 {
206214 char buf[MAXPATHLEN], *p;
207215 struct stat st;
208216
209 xhash_init (MAX_SOUNDS);
217 xhash_init(MAX_SOUNDS);
210218
211219 #ifdef BAD_DIRS
212 bad_dirs_init ();
220 bad_dirs_init();
213221 #endif
214222
215223 #ifdef HAVE_CDROM
218226 int i;
219227 for (i = 0; i < MAX_CDROMS; i++)
220228 {
221 sound_insert (cdrom_table[i].name, SOUND_READY, SOUND_CDROM);
222 }
223 }
224 #endif /* HAVE_CDROM */
225
226 sound_read_time = time (0);
227
228 fp = fopen (filename, "r");
229 sound_insert(cdrom_table[i].name, SOUND_READY, SOUND_CDROM);
230 }
231 }
232 #endif /* HAVE_CDROM */
233
234 sound_read_time = time(0);
235
236 fp = fopen(filename, "r");
229237 if (fp == NULL)
230238 {
231 report (REPORT_NOTICE, "warning: cannot open %s\n", filename);
239 report(REPORT_NOTICE, "warning: cannot open %s\n", filename);
232240 /*
233241 * no local sounds
234242 */
235243 return;
236244 }
237245
238 while (fgets (buf, sizeof (buf), fp) != NULL)
246 while (fgets(buf, sizeof(buf), fp) != NULL)
239247 {
240248 switch (buf[0])
241249 {
245253 case '\n':
246254 continue;
247255 }
248 p = strchr (buf, '\n');
256 p = strchr(buf, '\n');
249257 if (p)
250258 {
251259 *p = '\0';
252260 }
253261
254 if (stat (buf, &st) < 0)
255 {
256 report (REPORT_ERROR, "sound_read: %s: %s\n", buf, sys_err_str (errno));
262 if (stat(buf, &st) < 0)
263 {
264 report(REPORT_ERROR, "sound_read: %s: %s\n", buf, sys_err_str(errno));
257265 continue;
258266 }
259
260 if (S_ISDIR (st.st_mode))
261 {
262 sound_read_directory (buf);
267
268 if (S_ISDIR(st.st_mode))
269 {
270 sound_read_directory(buf);
263271 }
264272 else
265273 {
266 sound_insert (buf, SOUND_READY, SOUND_FILE);
267 }
268 }
269
270 fclose (fp);
274 sound_insert(buf, SOUND_READY, SOUND_FILE);
275 }
276 }
277
278 fclose(fp);
271279 }
272280
273281 #ifdef __STDC__
274282 static char *
275 destroy (char *hash_string, char *hash_value)
283 destroy(char *hash_string, char *hash_value)
276284 #else
277285 static char *
278 destroy (hash_string, hash_value)
286 destroy(hash_string, hash_value)
279287 char *hash_string;
280288 char *hash_value;
281289 #endif
282290 {
283291 SOUND *s = (SOUND *) hash_value;
284292
285 sound_free (s);
286 free ((char *) s);
293 sound_free(s);
294 free((char *) s);
287295
288296 return NULL;
289297 }
293301 */
294302 #ifdef __STDC__
295303 void
296 sound_reread (char *filename)
304 sound_reread(char *filename)
297305 #else
298306 void
299 sound_reread (filename)
307 sound_reread(filename)
300308 char *filename;
301309 #endif
302310 {
303311 SOUND *s1, *s1_next, *s2, *s2_next;
304312
305 report (REPORT_DEBUG, "re-reading sounds\n");
313 report(REPORT_DEBUG, "re-reading sounds\n");
306314
307315 /*
308316 * Delete all the sounds.
315323 {
316324 s2_next = s2->next;
317325 /* xhash_delete(s2->hash_key); */
318 sound_free (s2);
319 free ((char *) s2);
326 sound_free(s2);
327 free((char *) s2);
320328 }
321329 }
322330 #else
323 xhash_apply (destroy);
324 #endif
325
326 xhash_die ();
327 xhash_init (MAX_SOUNDS);
331 xhash_apply(destroy);
332 #endif
333
334 xhash_die();
335 xhash_init(MAX_SOUNDS);
328336
329337 sounds = NULL;
330338 sound_count = 0;
332340 /*
333341 * and now load the sounds
334342 */
335 sound_read (filename);
343 sound_read(filename);
336344
337345 /*
338346 * don't forget the cache...
339347 */
340 cache_read ();
348 cache_read();
341349 }
342350
343351 #ifdef __STDC__
344352 void
345 sound_stat (char *filename)
353 sound_stat(char *filename)
346354 #else
347355 void
348 sound_stat (filename)
356 sound_stat(filename)
349357 char *filename;
350358 #endif
351359 {
352 if (modified (filename, sound_read_time))
353 {
354 sound_reread (filename);
360 if (modified(filename, sound_read_time))
361 {
362 sound_reread(filename);
355363 }
356364 }
357365
358366 BUFFER *
359 sound_list_create ()
367 sound_list_create()
360368 {
361369 SOUND *s;
362370 int n;
363371 BUFFER *start, *b;
364372 char line[RPTP_MAX_LINE];
365373
366 b = buffer_create ();
374 b = buffer_create();
367375 start = b;
368 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), "+message=\"sounds\"\r\n");
369 b->nbytes += strlen (b->buf);
376 SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), "+message=\"sounds\"\r\n");
377 b->nbytes += strlen(b->buf);
370378
371379 for (s = sounds; s; s = s->list)
372380 {
377385
378386 if (s->mapped)
379387 {
380 SNPRINTF (SIZE(line,sizeof(line)), "\
388 SNPRINTF(SIZE(line, sizeof(line)), "\
381389 sound=\"%s\" size=%d bits=%g sample_rate=%d channels=%d samples=%d\r\n",
382 s->name, s->size, s->input_precision, s->sample_rate, s->channels,
383 s->samples);
390 s->name, s->size, s->input_precision, s->sample_rate, s->channels,
391 s->samples);
384392 }
385393 else
386394 {
387 SNPRINTF (SIZE(line,sizeof(line)), "sound=\"%s\"\r\n", s->name);
388 }
389
390 n = strlen (line);
395 SNPRINTF(SIZE(line, sizeof(line)), "sound=\"%s\"\r\n", s->name);
396 }
397
398 n = strlen(line);
391399 if (b->nbytes + n > BUFFER_SIZE)
392400 {
393 b->next = buffer_create ();
401 b->next = buffer_create();
394402 b = b->next;
395403 }
396 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), line);
404 strncat(b->buf + b->nbytes, line, BUFFER_SIZE - b->nbytes);
397405 b->nbytes += n;
398406 }
399407
400408 if (b->nbytes + 3 > BUFFER_SIZE)
401409 {
402 b->next = buffer_create ();
410 b->next = buffer_create();
403411 b = b->next;
404412 }
405413
406 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n");
414 SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), ".\r\n");
407415 b->nbytes += 3;
408416
409417 return start;
411419
412420 #ifdef __STDC__
413421 SOUND *
414 sound_insert (char *path, int status, int type)
422 sound_insert(char *path, int status, int type)
415423 #else
416424 SOUND *
417 sound_insert (path, status, type)
425 sound_insert(path, status, type)
418426 char *path;
419427 int status;
420428 int type;
424432 char *hash_val;
425433
426434 #ifdef BAD_DIRS
427 if (bad_dir (path))
428 {
429 report (REPORT_NOTICE, "bad_dir: attempt to load %s\n", path);
435 if (bad_dir(path))
436 {
437 report(REPORT_NOTICE, "bad_dir: attempt to load %s\n", path);
430438 return NULL;
431439 }
432440 #endif
433441
434 s = sound_create ();
442 s = sound_create();
435443 if (s == NULL)
436444 {
437 report (REPORT_ERROR, "sound_insert: out of memory\n");
438 done (1);
445 report(REPORT_ERROR, "sound_insert: out of memory\n");
446 done(1);
439447 }
440448
441449 s->type = type;
442450
443 s->path = strdup (path);
451 s->path = strdup(path);
444452 if (s->path == NULL)
445453 {
446 report (REPORT_ERROR, "sound_insert: out of memory\n");
447 done (1);
448 }
449 s->hash_key = strdup (xhash_name (s->path));
454 report(REPORT_ERROR, "sound_insert: out of memory\n");
455 done(1);
456 }
457 s->hash_key = strdup(xhash_name(s->path));
450458 if (s->hash_key == NULL)
451459 {
452 report (REPORT_ERROR, "sound_insert: out of memory\n");
453 done (1);
454 }
455 s->name = s->path[0] == '/' ? strrchr (s->path, '/') + 1 : s->path;
460 report(REPORT_ERROR, "sound_insert: out of memory\n");
461 done(1);
462 }
463 s->name = s->path[0] == '/' ? strrchr(s->path, '/') + 1 : s->path;
456464 s->status = status;
457465
458 hash_val = xhash_get (s->hash_key);
466 hash_val = xhash_get(s->hash_key);
459467 if (hash_val == NULL)
460468 {
461 xhash_put (s->hash_key, (char *) s);
469 xhash_put(s->hash_key, (char *) s);
462470
463471 s->list_prev = NULL;
464472 s->list = sounds;
474482
475483 for (ss = (SOUND *) hash_val; ss; prev = ss, ss = ss->next)
476484 {
477 if (strcmp (ss->path, s->path) == 0)
478 {
479 free ((char *) s);
485 if (strcmp(ss->path, s->path) == 0)
486 {
487 free((char *) s);
480488 return ss;
481489 }
482490 }
492500 */
493501 #ifdef __STDC__
494502 SOUND *
495 sound_create (void)
503 sound_create(void)
496504 #else
497505 SOUND *
498 sound_create ()
506 sound_create()
499507 #endif
500508 {
501509 SOUND *s;
502510
503 s = (SOUND *) malloc (sizeof (SOUND));
511 s = (SOUND *) malloc(sizeof(SOUND));
504512 if (s == NULL)
505513 {
506514 return s;
550558 */
551559 #ifdef __STDC__
552560 SOUND *
553 sound_lookup (char *name, int mode, SERVER *lookup_server)
561 sound_lookup(char *name, int mode, SERVER *lookup_server)
554562 #else
555563 SOUND *
556 sound_lookup (name, mode, lookup_server)
564 sound_lookup(name, mode, lookup_server)
557565 char *name;
558566 int mode;
559567 SERVER *lookup_server;
563571 int has_extension = 0, has_pathname = 0;
564572 struct stat st;
565573 int i;
566
574
567575 #ifdef HAVE_CDROM
568576 /* Map sounds with cdrom prefixes to the cdrom itself. */
569577 for (i = 0; i < MAX_CDROMS; i++)
570578 {
571 if (strncmp (name, cdrom_table[i].name, strlen (cdrom_table[i].name)) == 0)
579 if (strncmp(name, cdrom_table[i].name, strlen(cdrom_table[i].name)) == 0)
572580 {
573581 break;
574582 }
575583 }
576584 if (i < MAX_CDROMS)
577585 {
578 s = (SOUND *) xhash_get (xhash_name (cdrom_table[i].name));
586 s = (SOUND *) xhash_get(xhash_name(cdrom_table[i].name));
579587 }
580588 #endif /* HAVE_CDROM */
581589
582590 if (s == NULL)
583591 {
584 s = (SOUND *) xhash_get (xhash_name (name));
592 s = (SOUND *) xhash_get(xhash_name(name));
585593 }
586594
587595 if (s == NULL)
588596 {
589 report (REPORT_DEBUG, "%s not in hash table\n", name);
597 report(REPORT_DEBUG, "%s not in hash table\n", name);
590598
591599 if (mode == SOUND_DONT_FIND || mode == SOUND_DONT_COUNT)
592600 {
596604 /*
597605 * see if a local file can be loaded (mode == SOUND_LOAD)
598606 */
599 if (stat (name, &st) == 0)
600 {
601 report (REPORT_DEBUG, "loading local file %s\n", name);
602 s = sound_insert (name, SOUND_READY, SOUND_FILE);
607 if (stat(name, &st) == 0)
608 {
609 report(REPORT_DEBUG, "loading local file %s\n", name);
610 s = sound_insert(name, SOUND_READY, SOUND_FILE);
603611 if (s == NULL)
604612 {
605613 return NULL;
607615 }
608616 #if 0
609617 /* virtual sounds cause searching problems */
610 #ifdef HAVE_HELPERS
611 else if (mode == SOUND_CREATE && helper_lookup (name))
612 {
613 s = sound_insert (name, SOUND_READY, SOUND_VIRTUAL);
614 }
615 #endif
616 #endif
618 #ifdef HAVE_HELPERS
619 else if (mode == SOUND_CREATE && helper_lookup(name))
620 {
621 s = sound_insert(name, SOUND_READY, SOUND_VIRTUAL);
622 }
623 #endif
624 #endif
617625 else if (mode == SOUND_FIND)
618626 {
619627 if (name[0] == '/')
620628 {
621 report (REPORT_DEBUG, "not searching for %s\n", name);
629 report(REPORT_DEBUG, "not searching for %s\n", name);
622630 return NULL;
623631 }
624632 if (lookup_server)
625633 {
626 report (REPORT_DEBUG, "searching for %s\n", name);
627 s = sound_insert (cache_name (name), SOUND_SEARCH, SOUND_FILE);
634 report(REPORT_DEBUG, "searching for %s\n", name);
635 s = sound_insert(cache_name(name), SOUND_SEARCH, SOUND_FILE);
628636 if (s == NULL)
629637 {
630638 return NULL;
631639 }
632 connection_server_open (lookup_server, s);
640 connection_server_open(lookup_server, s);
633641 }
634642 else if (servers)
635643 {
636 report (REPORT_DEBUG, "searching for %s\n", name);
637 s = sound_insert (cache_name (name), SOUND_SEARCH, SOUND_FILE);
644 report(REPORT_DEBUG, "searching for %s\n", name);
645 s = sound_insert(cache_name(name), SOUND_SEARCH, SOUND_FILE);
638646 if (s == NULL)
639647 {
640648 return NULL;
641649 }
642 connection_server_open (servers, s);
650 connection_server_open(servers, s);
643651 }
644652 else
645653 {
661669 {
662670 has_pathname++;
663671 }
664 else if (strrchr (name, '.'))
672 else if (strrchr(name, '.'))
665673 {
666674 has_extension++;
667675 }
668676 for (; s; s = s->next)
669677 {
670 if (has_pathname && (!s->path || strcmp (name, s->path) != 0))
678 if (has_pathname && (!s->path || strcmp(name, s->path) != 0))
671679 {
672680 continue;
673681 }
674 if (has_extension && (!s->path || strcmp (name, s->name) != 0))
682 if (has_extension && (!s->path || strcmp(name, s->name) != 0))
675683 {
676684 continue;
677685 }
681689 {
682690 if (has_pathname)
683691 {
684 report (REPORT_DEBUG, "`%s' file name not in hash table\n", name);
685 if (stat (name, &st) == 0)
692 report(REPORT_DEBUG, "`%s' file name not in hash table\n", name);
693 if (stat(name, &st) == 0)
686694 {
687 report (REPORT_DEBUG, "loading local file `%s'\n", name);
688 s = sound_insert (name, SOUND_READY, SOUND_FILE);
695 report(REPORT_DEBUG, "loading local file `%s'\n", name);
696 s = sound_insert(name, SOUND_READY, SOUND_FILE);
689697 if (s == NULL)
690698 {
691699 return NULL;
698706 }
699707 else if (has_extension)
700708 {
701 report (REPORT_DEBUG, "`%s' extension not in hash table\n", name);
709 report(REPORT_DEBUG, "`%s' extension not in hash table\n", name);
702710 return NULL;
703711 }
704712 }
723731
724732 if (!s->mapped)
725733 {
726 return sound_map (s) == 0 ? s : NULL;
734 return sound_map(s) == 0 ? s : NULL;
727735 }
728736 else
729737 {
736744 */
737745 #ifdef __STDC__
738746 int
739 sound_map (SOUND *s)
747 sound_map(SOUND *s)
740748 #else
741749 int
742 sound_map (s)
750 sound_map(s)
743751 SOUND *s;
744752 #endif
745753 {
776784 optional_storage = s->storage;
777785
778786 #ifdef HAVE_HELPERS
779 helper = helper_lookup (s->path);
787 helper = helper_lookup(s->path);
780788 if (helper)
781789 {
782790 s->needs_helper++;
783 strcpy (buf, "HELPER"); /* XXX: not used; see below */
791 strcpy(buf, "HELPER"); /* XXX: not used; see below */
784792 }
785793 else
786794 #endif /* HAVE_HELPERS */
787795 #ifdef HAVE_CDROM
788796 if (s->type == SOUND_CDROM)
789797 {
790 strcpy (buf, "CDROM");
798 strcpy(buf, "CDROM");
791799 }
792800 else
793801 #endif /* HAVE_CDROM */
794802 {
795 si = sound_open (s, 1);
803 si = sound_open(s, 1);
796804 if (si == NULL)
797805 {
798806 return -1;
802810 sort of sound this is. */
803811 storage = s->storage;
804812 s->storage = SOUND_STORAGE_MEMORY;
805 b = buffer_alloc (SOUND_MAX_HEADER_SIZE, BUFFER_FREE);
806 n = sound_fill (si, b, 1);
813 b = buffer_alloc(SOUND_MAX_HEADER_SIZE, BUFFER_FREE);
814 n = sound_fill(si, b, 1);
807815 s->storage = storage;
808816 if (n <= 0)
809817 {
810 report (REPORT_DEBUG, "sound_map: sound_fill %d\n", n);
811 buffer_dealloc (b, 1);
818 report(REPORT_DEBUG, "sound_map: sound_fill %d\n", n);
819 buffer_dealloc(b, 1);
812820 return -1;
813821 }
814822
815 sound_close (si);
823 sound_close(si);
816824
817825 /* Copy the buffer contents to `buf' so `b' can be destroyed. */
818 memcpy (buf, b->buf, MIN (sizeof (buf), b->nbytes));
819 buffer_dealloc (b, 1);
826 memcpy(buf, b->buf, MIN(sizeof(buf), b->nbytes));
827 buffer_dealloc(b, 1);
820828 }
821829
822830 /* u-law */
823 if (strncmp (buf, ".snd", 4) == 0)
831 if (strncmp(buf, ".snd", 4) == 0)
824832 {
825833 long ulaw_hdr_size;
826834 int encoding;
829837
830838 p = buf + 4;
831839
832 ulaw_hdr_size = big_long (p);
840 ulaw_hdr_size = big_long(p);
833841 p += 4;
834842 if (ulaw_hdr_size < ULAW_HDRSIZE)
835843 {
836 report (REPORT_DEBUG, "%s not a ulaw file\n", s->path);
844 report(REPORT_DEBUG, "%s not a ulaw file\n", s->path);
837845 return -1;
838846 }
839847
841849 * The audio data size which may be ~0.
842850 * This value is ignored.
843851 */
844 data_size = big_long (p);
852 data_size = big_long(p);
845853 p += 4;
846854
847 encoding = big_long (p);
855 encoding = big_long(p);
848856 p += 4;
849857 switch (encoding)
850858 {
866874 s->output_precision = 16;
867875 break;
868876
869 #ifdef HAVE_ADPCM
877 #ifdef HAVE_ADPCM
870878 case ULAW_G721:
871879 s->format = RPLAY_FORMAT_G721;
872880 s->input_precision = 4;
873 s->output_precision = 16; /* uncompressed to 16-bit */
881 s->output_precision = 16; /* uncompressed to 16-bit */
874882 break;
875883
876884 case ULAW_G723_3:
877885 s->format = RPLAY_FORMAT_G723_3;
878886 s->input_precision = 3;
879 s->output_precision = 16; /* uncompressed to 16-bit */
887 s->output_precision = 16; /* uncompressed to 16-bit */
880888 break;
881889
882890 case ULAW_G723_5:
883891 s->format = RPLAY_FORMAT_G723_5;
884892 s->input_precision = 5;
885 s->output_precision = 16; /* uncompressed to 16-bit */
893 s->output_precision = 16; /* uncompressed to 16-bit */
886894 break;
887895 #endif /* HAVE_ADPCM */
888
896
889897 default:
890 report (REPORT_DEBUG, "%s: %d - unsupported ulaw encoding\n",
891 s->path, encoding);
898 report(REPORT_DEBUG, "%s: %d - unsupported ulaw encoding\n",
899 s->path, encoding);
892900 return -1;
893901 }
894902
900908 /*
901909 * Sample rate.
902910 */
903 s->sample_rate = big_long (p);
911 s->sample_rate = big_long(p);
904912 p += 4;
905913
906914 /*
907915 * Number of channels.
908916 */
909 s->channels = big_long (p);
917 s->channels = big_long(p);
910918 p += 4;
911919
912920 s->offset = ulaw_hdr_size;
921929 }
922930 }
923931 /* aiff */
924 else if (strncmp (buf, "FORM", 4) == 0)
932 else if (strncmp(buf, "FORM", 4) == 0)
925933 {
926934 unsigned long total_size;
927935 unsigned long chunk_size;
936944
937945 p = buf + 4;
938946
939 total_size = big_long (p);
947 total_size = big_long(p);
940948 p += 4;
941949
942 if (memcmp (p, "AIFF", 4) != 0)
950 if (memcmp(p, "AIFF", 4) != 0)
943951 {
944952 return -1;
945953 }
953961 /*
954962 * Chunk id.
955963 */
956 memcpy (id, p, 4);
964 memcpy(id, p, 4);
957965 id[4] = '\0';
958966 p += 4;
959967
960968 /*
961969 * Chunk size.
962970 */
963 chunk_size = big_long (p);
971 chunk_size = big_long(p);
964972 p += 4;
965973
966974 /*
967975 * COMM Chunk.
968976 */
969 if (memcmp (id, "COMM", 4) == 0)
970 {
971 channels = big_short (p);
977 if (memcmp(id, "COMM", 4) == 0)
978 {
979 channels = big_short(p);
972980 p += 2;
973981
974 frames = big_long (p);
982 frames = big_long(p);
975983 p += 4;
976984
977 bits = big_short (p);
985 bits = big_short(p);
978986 p += 2;
979987
980 rate = ConvertFromIeeeExtended ((unsigned char *) p);
988 rate = ConvertFromIeeeExtended((unsigned char *) p);
981989 p += 10;
982990 }
983991 /*
984992 * SSN Chunk.
985993 */
986 else if (memcmp (id, "SSND", 4) == 0)
987 {
988 offset = big_long (p);
994 else if (memcmp(id, "SSND", 4) == 0)
995 {
996 offset = big_long(p);
989997 p += 4;
990998
991 block_size = big_long (p);
999 block_size = big_long(p);
9921000 sound_chunk_size = block_size;
9931001 p += 4;
9941002 break;
10191027 s->output_precision = bits;
10201028 s->channels = channels;
10211029
1022 switch ((int)s->input_precision)
1030 switch ((int) s->input_precision)
10231031 {
10241032 case 8:
10251033 s->format = RPLAY_FORMAT_LINEAR_8;
10301038 break;
10311039
10321040 default:
1033 report (REPORT_ERROR, "unsupported aiff precision `%g'\n",
1034 s->input_precision);
1041 report(REPORT_ERROR, "unsupported aiff precision `%g'\n",
1042 s->input_precision);
10351043 return -1;
10361044 }
10371045 }
10381046 /* deadsnd files */
1039 else if (*((long *)&buf) == 0x4a02b6d2)
1040 {
1041 DSID *dsid = (DSID *)&buf;
1042
1043 s->offset = sizeof (DSID);
1047 else if (*((long *) &buf) == 0x4a02b6d2)
1048 {
1049 DSID *dsid = (DSID *) & buf;
1050
1051 s->offset = sizeof(DSID);
10441052 s->sample_rate = dsid->freq;
10451053 s->input_precision = s->output_precision = dsid->bps;
10461054 s->channels = (dsid->mode + 1);
10511059 case 8:
10521060 s->format = RPLAY_FORMAT_ULINEAR_8;
10531061 break;
1054
1062
10551063 case 16:
10561064 s->format = RPLAY_FORMAT_LINEAR_16;
10571065 break;
1058
1066
10591067 default:
1060 report (REPORT_ERROR, "unsupported deadsnd precision `%d'\n", dsid->bps);
1068 report(REPORT_ERROR, "unsupported deadsnd precision `%d'\n", dsid->bps);
10611069 return -1;
10621070 }
10631071 }
10641072 /* wave */
1065 else if (strncmp (buf, "RIFF", 4) == 0)
1073 else if (strncmp(buf, "RIFF", 4) == 0)
10661074 {
10671075 unsigned long chunk_size;
10681076 short chunk_type;
10751083 p = buf + 4;
10761084 p += 4;
10771085
1078 if (memcmp (p, "WAVE", 4) != 0)
1079 {
1080 report (REPORT_ERROR, "wave file missing `WAVE' header\n");
1086 if (memcmp(p, "WAVE", 4) != 0)
1087 {
1088 report(REPORT_ERROR, "wave file missing `WAVE' header\n");
10811089 return -1;
10821090 }
10831091 p += 4;
10901098 /*
10911099 * Chunk id.
10921100 */
1093 memcpy (id, p, 4);
1101 memcpy(id, p, 4);
10941102 id[4] = '\0';
10951103 p += 4;
10961104
10971105 /*
10981106 * Chunk size.
10991107 */
1100 chunk_size = little_long (p);
1108 chunk_size = little_long(p);
11011109 p += 4;
11021110
11031111 /*
11041112 * 'fmt ' Chunk.
11051113 */
1106 if (memcmp (id, "fmt ", 4) == 0)
1114 if (memcmp(id, "fmt ", 4) == 0)
11071115 {
11081116 char *start_of_chunk = p;
1109 chunk_type = little_short (p);
1117 chunk_type = little_short(p);
11101118 p += 2;
11111119 /*
11121120 * Only one wave format is supported.
11131121 */
11141122 if (chunk_type == 0x0001)
11151123 {
1116 channels = little_short (p); p += 2;
1117 rate = little_long (p); p += 4;
1118 p += 4; /* bytes/second ? */
1119 p += 2; /* block align ? */
1120 bits = little_short (p); p += 2;
1124 channels = little_short(p);
1125 p += 2;
1126 rate = little_long(p);
1127 p += 4;
1128 p += 4; /* bytes/second ? */
1129 p += 2; /* block align ? */
1130 bits = little_short(p);
1131 p += 2;
11211132 }
11221133 else
11231134 {
1124 report (REPORT_ERROR, "unknown wave chunk `%x'\n", chunk_type);
1135 report(REPORT_ERROR, "unknown wave chunk `%x'\n", chunk_type);
11251136 return -1;
11261137 }
11271138 p = start_of_chunk + chunk_size;
11291140 /*
11301141 * data Chunk.
11311142 */
1132 else if (memcmp (id, "data", 4) == 0)
1143 else if (memcmp(id, "data", 4) == 0)
11331144 {
11341145 /* size */
11351146 sound_chunk_size = chunk_size;
11401151 */
11411152 else
11421153 {
1143 report (REPORT_DEBUG, "ignoring chunk - %s (%d)\n",
1144 id, chunk_size);
1154 report(REPORT_DEBUG, "ignoring chunk - %s (%d)\n",
1155 id, chunk_size);
11451156 p += chunk_size;
11461157 /*
11471158 * skip the pad byte, if necessary
11571168 s->output_precision = bits;
11581169 s->channels = channels;
11591170
1160 switch ((int)s->input_precision)
1171 switch ((int) s->input_precision)
11611172 {
11621173 case 8:
11631174 s->format = RPLAY_FORMAT_ULINEAR_8;
11681179 break;
11691180
11701181 default:
1171 report (REPORT_ERROR, "unsupported wave precision `%g'\n",
1172 s->input_precision);
1182 report(REPORT_ERROR, "unsupported wave precision `%g'\n",
1183 s->input_precision);
11731184 return -1;
11741185 }
11751186
11791190 s->byte_order = RPLAY_LITTLE_ENDIAN;
11801191 }
11811192 /* voc */
1182 else if (strncmp (buf, "Creative Voice File\032", 20) == 0)
1193 else if (strncmp(buf, "Creative Voice File\032", 20) == 0)
11831194 {
11841195 char *p;
11851196 short header_size;
11881199
11891200 p = buf + 20;
11901201
1191 header_size = little_short (p); /* sizeof header */
1202 header_size = little_short(p); /* sizeof header */
11921203 p += 2;
11931204
11941205 /* major/minor version + checksum of version */
1195 p += 2 * sizeof (short);
1206 p += 2 * sizeof(short);
11961207
11971208 for (;;)
11981209 {
12191230 s->channels = 1;
12201231 break;
12211232 }
1222 else if (block_id == 9) /* VOC_DATA_16 */
1233 else if (block_id == 9) /* VOC_DATA_16 */
12231234 {
12241235 //sound_chunk_size = block_length;
12251236
1226 s->sample_rate = little_long (p);
1237 s->sample_rate = little_long(p);
12271238 p += 4;
12281239
12291240 switch (*p)
12321243 s->input_precision = 8;
12331244 s->output_precision = 8;
12341245 break;
1235
1246
12361247 case 16:
12371248 s->input_precision = 16;
12381249 s->output_precision = 16;
12391250 break;
12401251
12411252 default:
1242 report (REPORT_ERROR, "unsupported voc_data_16 precision `%d'\n",
1243 *p);
1253 report(REPORT_ERROR, "unsupported voc_data_16 precision `%d'\n",
1254 *p);
12441255 return -1;
12451256 }
12461257 *p++;
1247
1258
12481259 s->channels = *p++;
1249
1250 p++; /* unknown */
1251 p++; /* not used */
1252 p++; /* not used */
1253 p++; /* not used */
1254 p++; /* not used */
1255 p++; /* not used */
1256
1260
1261 p++; /* unknown */
1262 p++; /* not used */
1263 p++; /* not used */
1264 p++; /* not used */
1265 p++; /* not used */
1266 p++; /* not used */
1267
12571268 break;
12581269 }
12591270
12631274 s->offset = p - buf;
12641275 s->byte_order = RPLAY_LITTLE_ENDIAN;
12651276
1266 switch ((int)s->input_precision)
1277 switch ((int) s->input_precision)
12671278 {
12681279 case 8:
12691280 s->format = RPLAY_FORMAT_ULINEAR_8;
12741285 break;
12751286
12761287 default:
1277 report (REPORT_ERROR, "unsupported voc precision `%d'\n",
1278 s->input_precision);
1288 report(REPORT_ERROR, "unsupported voc precision `%d'\n",
1289 s->input_precision);
12791290 return -1;
12801291 }
12811292 }
12851296 {
12861297 s->offset = 0;
12871298 s->format = RPLAY_FORMAT_GSM;
1288 s->byte_order = RPLAY_BIG_ENDIAN; /* ??? */
1299 s->byte_order = RPLAY_BIG_ENDIAN; /* ??? */
12891300 s->sample_rate = 8000;
12901301 s->input_precision = 1.65;
12911302 s->output_precision = 16;
12931304 }
12941305 #endif /* HAVE_GSM */
12951306 #ifdef HAVE_CDROM
1296 else if (strcmp (buf, "CDROM") == 0)
1307 else if (strcmp(buf, "CDROM") == 0)
12971308 {
12981309 s->offset = 0;
12991310 s->format = RPLAY_FORMAT_LINEAR_16;
13041315 s->channels = 2;
13051316 s->storage = SOUND_STORAGE_NONE;
13061317 }
1307 #endif /* HAVE_CDROM */
1318 #endif /* HAVE_CDROM */
13081319 /* Unknown audio header -- try to use the extension. */
13091320 else
13101321 {
13111322 char *p;
13121323
1313 report (REPORT_DEBUG, "%s missing sound header; trying helper or extension\n", s->path);
1314 p = strrchr (s->path, '.');
1315 #ifdef HAVE_HELPERS
1324 report(REPORT_DEBUG, "%s missing sound header; trying helper or extension\n", s->path);
1325 p = strrchr(s->path, '.');
1326 #ifdef HAVE_HELPERS
13161327 if (s->needs_helper)
13171328 {
13181329 s->offset = 0;
13251336 s->storage = SOUND_STORAGE_NONE;
13261337 }
13271338 else
1328 #endif
1329 if (p && strcmp (p, ".ub") == 0)
1330 {
1331 report (REPORT_DEBUG, "%s assuming ub\n", s->path);
1339 #endif
1340 if (p && strcmp(p, ".ub") == 0)
1341 {
1342 report(REPORT_DEBUG, "%s assuming ub\n", s->path);
13321343 s->offset = 0;
13331344 s->format = RPLAY_FORMAT_ULINEAR_8;
13341345 s->byte_order = RPLAY_BIG_ENDIAN;
13371348 s->output_precision = 8;
13381349 s->channels = 1;
13391350 }
1340 else if (p && (strcmp (p, ".au") == 0 || strcmp (p, ".ul") == 0))
1341 {
1342 report (REPORT_DEBUG, "%s assuming ulaw\n", s->path);
1351 else if (p && (strcmp(p, ".au") == 0 || strcmp(p, ".ul") == 0))
1352 {
1353 report(REPORT_DEBUG, "%s assuming ulaw\n", s->path);
13431354 s->offset = 0;
13441355 s->format = RPLAY_FORMAT_ULAW;
13451356 s->byte_order = RPLAY_BIG_ENDIAN;
13481359 s->output_precision = 8;
13491360 s->channels = 1;
13501361 }
1351 #ifdef HAVE_GSM
1352 else if (p && (strcmp (p, ".gsm") == 0 || strcmp (p, ".GSM") == 0))
1353 {
1354 report (REPORT_DEBUG, "%s assuming gsm\n", s->path);
1362 #ifdef HAVE_GSM
1363 else if (p && (strcmp(p, ".gsm") == 0 || strcmp(p, ".GSM") == 0))
1364 {
1365 report(REPORT_DEBUG, "%s assuming gsm\n", s->path);
13551366 s->offset = 0;
13561367 s->format = RPLAY_FORMAT_GSM;
1357 s->byte_order = RPLAY_BIG_ENDIAN; /* ??? */
1368 s->byte_order = RPLAY_BIG_ENDIAN; /* ??? */
13581369 s->sample_rate = 8000;
13591370 s->input_precision = 1.65;
13601371 s->output_precision = 16;
13671378 && !optional_input_precision
13681379 && !optional_channels)
13691380 {
1370 report (REPORT_ERROR, "`%s' unknown audio file\n", s->path);
1381 report(REPORT_ERROR, "`%s' unknown audio file\n", s->path);
13711382 return -1;
13721383 }
13731384 }
13921403 switch (s->format)
13931404 {
13941405 #ifdef HAVE_ADPCM
1395 /* G.72X files *must* have 16-bit output. */
1406 /* G.72X files *must* have 16-bit output. */
13961407 case RPLAY_FORMAT_G721:
13971408 case RPLAY_FORMAT_G723_3:
13981409 case RPLAY_FORMAT_G723_5:
14011412 #endif /* HAVE_ADPCM */
14021413
14031414 #ifdef HAVE_GSM
1404 /* Fix-up GSM info. */
1415 /* Fix-up GSM info. */
14051416 case RPLAY_FORMAT_GSM:
14061417 s->output_precision = 16;
14071418 s->input_precision = 1.65;
14101421 s->offset = 0;
14111422 break;
14121423 #endif /* HAVE_GSM */
1413
1424
14141425 default:
14151426 break;
14161427 }
14181429 if (!s->format || !s->byte_order || !s->sample_rate
14191430 || !s->input_precision || !s->output_precision || !s->channels)
14201431 {
1421 report (REPORT_ERROR, "`%s' invalid audio parameters\n", s->path);
1432 report(REPORT_ERROR, "`%s' invalid audio parameters\n", s->path);
14221433 return -1;
14231434 }
14241435
14311442 if (sound_chunk_size > 0)
14321443 {
14331444 /* Make sure sound_chunk_size is valid */
1434 if (s->size == 0 || sound_chunk_size < s->size) /* size==0 for flows */
1445 if (s->size == 0 || sound_chunk_size < s->size) /* size==0 for flows */
14351446 {
14361447 s->chunk_size = sound_chunk_size;
14371448 }
14491460 s->chunk_size = s->size - s->offset;
14501461 }
14511462
1452 #if 0
1453 printf ("SOUND: %s size=%d chunk=%d tail=%d offset=%d\n",
1454 s->name, s->size, s->chunk_size, s->tail, s->offset);
1455 #endif
1463 #if 0
1464 printf("SOUND: %s size=%d chunk=%d tail=%d offset=%d\n",
1465 s->name, s->size, s->chunk_size, s->tail, s->offset);
1466 #endif
14561467
14571468 if (s->type != SOUND_FILE)
14581469 {
14661477 s->size = 0;
14671478 s->samples = 0;
14681479 }
1469 #endif
1480 #endif
14701481 else
14711482 {
1472 s->samples = number_of_samples (s, 0); // NUMBER_OF_SAMPLES (s);
1483 s->samples = number_of_samples(s, 0); // NUMBER_OF_SAMPLES (s);
1484
14731485 }
14741486
14751487 s->mapped = 1;
14761488
1477 report (REPORT_DEBUG, "\
1489 report(REPORT_DEBUG, "\
14781490 %s input=%s bits=%g sample-rate=%d channels=%d samples=%d format=%s byte-order=%s\n",
1479 s->name,
1480 input_to_string (s->type),
1481 s->input_precision,
1482 s->sample_rate,
1483 s->channels,
1484 s->samples,
1485 audio_format_to_string (s->format),
1486 byte_order_to_string (s->byte_order));
1491 s->name,
1492 input_to_string(s->type),
1493 s->input_precision,
1494 s->sample_rate,
1495 s->channels,
1496 s->samples,
1497 audio_format_to_string(s->format),
1498 byte_order_to_string(s->byte_order));
14871499
14881500 return 0;
14891501 }
14931505 */
14941506 #ifdef __STDC__
14951507 int
1496 sound_unmap (SOUND *s)
1508 sound_unmap(SOUND *s)
14971509 #else
14981510 int
1499 sound_unmap (s)
1511 sound_unmap(s)
15001512 SOUND *s;
15011513 #endif
15021514 {
15051517 if (s->cache)
15061518 {
15071519 #ifdef HAVE_MMAP
1508 munmap (s->cache, s->size);
1520 munmap(s->cache, s->size);
15091521 #else /* not HAVE_MMAP */
1510 free ((char *) s->cache);
1522 free((char *) s->cache);
15111523 #endif /* not HAVE_MMAP */
15121524 s->cache = NULL;
15131525 sound_cache_size -= s->size;
15141526 }
15151527 }
1516
1528
15171529 if (s->type == SOUND_FLOW || s->needs_helper)
15181530 {
1519 buffer_dealloc (s->flow, 1);
1531 buffer_dealloc(s->flow, 1);
15201532 s->flow = NULL;
15211533 s->flowp = &s->flow;
15221534 }
15291541 /* Free *all* memory used by a sound. */
15301542 #ifdef __STDC__
15311543 int
1532 sound_free (SOUND *s)
1544 sound_free(SOUND *s)
15331545 #else
15341546 int
1535 sound_free (s)
1547 sound_free(s)
15361548 SOUND *s;
15371549 #endif
15381550 {
1539 sound_unmap (s);
1540
1541 free ((char *) s->path);
1551 sound_unmap(s);
1552
1553 free((char *) s->path);
15421554 s->path = NULL;
1543 free ((char *) s->hash_key);
1555 free((char *) s->hash_key);
15441556 s->hash_key = NULL;
15451557
15461558 return 0;
15491561 /* Delete a sound from the list of sounds. */
15501562 #ifdef __STDC__
15511563 void
1552 sound_delete (SOUND *s, int remove)
1564 sound_delete(SOUND *s, int remove)
15531565 #else
15541566 void
1555 sound_delete (s, remove)
1567 sound_delete(s, remove)
15561568 SOUND *s;
15571569 int remove;
15581570 #endif
15631575 {
15641576 if (s->hash_key)
15651577 {
1566 xhash_delete (s->hash_key);
1578 xhash_delete(s->hash_key);
15671579 }
15681580 if (s->list_prev)
15691581 {
16091621 /* Copy the list links. */
16101622 s->next->list = s->list;
16111623 s->next->list_prev = s->list_prev;
1612
1613 xhash_replace (s->next->hash_key, (char *) s->next);
1624
1625 xhash_replace(s->next->hash_key, (char *) s->next);
16141626 }
16151627 }
16161628
16181630 {
16191631 struct stat st;
16201632
1621 if (stat (s->path, &st) == 0)
1622 {
1623 if (unlink (s->path) < 0)
1624 {
1625 report (REPORT_ERROR, "sound_delete: unlink %s: %s\n", s->path,
1626 sys_err_str (errno));
1627 }
1628 }
1629 }
1630
1631 sound_free (s);
1632 free ((char *) s);
1633 if (stat(s->path, &st) == 0)
1634 {
1635 if (unlink(s->path) < 0)
1636 {
1637 report(REPORT_ERROR, "sound_delete: unlink %s: %s\n", s->path,
1638 sys_err_str(errno));
1639 }
1640 }
1641 }
1642
1643 sound_free(s);
1644 free((char *) s);
16331645 }
16341646
16351647 /*
16361648 * Free cached sounds and delete sound flows.
16371649 */
16381650 void
1639 sound_cleanup ()
1651 sound_cleanup()
16401652 {
16411653 SOUND *s1, *s1_next, *s, *s_next;
16421654 EVENT *e;
16431655 CONNECTION *c;
16441656 SPOOL *sp;
16451657 int n;
1646
1647 report (REPORT_DEBUG, "cleaning up sounds\n");
1648
1658
1659 report(REPORT_DEBUG, "cleaning up sounds\n");
1660
16491661 for (s1 = sounds; s1; s1 = s1_next)
16501662 {
16511663 s1_next = s1->list;
16891701 }
16901702 if (n == 0)
16911703 {
1692 sound_unmap (s);
1704 sound_unmap(s);
16931705 }
16941706 }
16951707 /* Flows */
17061718 }
17071719 if (n != 0)
17081720 {
1709 report (REPORT_DEBUG, "sound_clean: not cleaning flow `%s'\n", s->name);
1721 report(REPORT_DEBUG, "sound_clean: not cleaning flow `%s'\n", s->name);
17101722 }
17111723 else
17121724 {
1713 sound_clean (s);
1725 sound_clean(s);
17141726 }
17151727 }
17161728 #ifdef HAVE_CDROM
17261738 }
17271739 if (n != 0)
17281740 {
1729 report (REPORT_DEBUG, "sound_clean: not cleaning cdrom `%s'\n", s->name);
1741 report(REPORT_DEBUG, "sound_clean: not cleaning cdrom `%s'\n", s->name);
17301742 }
17311743 else
17321744 {
1733 sound_clean (s);
1745 sound_clean(s);
17341746 }
17351747 }
17361748 #endif /* HAVE_CDROM */
17421754
17431755 #ifdef __STDC__
17441756 void
1745 sound_clean (SOUND *s)
1757 sound_clean(SOUND *s)
17461758 #else
17471759 void
1748 sound_clean (s)
1760 sound_clean(s)
17491761 SOUND *s;
1750 #endif
1762 #endif
17511763 {
17521764 BUFFER *b;
17531765 int n, fd;
17601772 s->size = 0;
17611773 if (s->flow)
17621774 {
1763 buffer_dealloc (s->flow, 1);
1775 buffer_dealloc(s->flow, 1);
17641776 }
17651777 s->flow = NULL;
17661778 s->flowp = &s->flow;
17801792 s->size = 0;
17811793 if (s->flow)
17821794 {
1783 buffer_dealloc (s->flow, 1);
1795 buffer_dealloc(s->flow, 1);
17841796 }
17851797 s->flow = NULL;
17861798 s->flowp = &s->flow;
17921804 {
17931805 case SOUND_STORAGE_NONE:
17941806 /* nothing to free -- delete it */
1795 report (REPORT_DEBUG, "sound_clean: deleting flow `%s'\n", s->name);
1796 sound_delete (s, 0);
1807 report(REPORT_DEBUG, "sound_clean: deleting flow `%s'\n", s->name);
1808 sound_delete(s, 0);
17971809 break;
17981810
17991811 case SOUND_STORAGE_MEMORY:
18001812 /* keep it in memory? */
1801 report (REPORT_DEBUG, "sound_clean: keeping flow `%s' in memory\n", s->name);
1813 report(REPORT_DEBUG, "sound_clean: keeping flow `%s' in memory\n", s->name);
18021814 break;
1803
1815
18041816 case SOUND_STORAGE_DISK:
18051817 /* Save the flow in the disk cache. */
1806 if (cache_free (s->size) < 0)
1807 {
1808 report (REPORT_ERROR, "sound_clean: can't cache_free %d bytes\n", s->size);
1809 sound_delete (s, 0); /* delete it */
1818 if (cache_free(s->size) < 0)
1819 {
1820 report(REPORT_ERROR, "sound_clean: can't cache_free %d bytes\n", s->size);
1821 sound_delete(s, 0); /* delete it */
18101822 break;
18111823 }
18121824
1813 fd = cache_create (s->path, s->size);
1825 fd = cache_create(s->path, s->size);
18141826 if (fd < 0)
18151827 {
1816 report (REPORT_ERROR, "sound_clean: can't cache_create %d bytes\n", s->size);
1817 sound_delete (s, 0);
1828 report(REPORT_ERROR, "sound_clean: can't cache_create %d bytes\n", s->size);
1829 sound_delete(s, 0);
18181830 break;
18191831 }
18201832
18211833 /* Dump the flow buffers to disk. */
1822 report (REPORT_DEBUG, "sound_clean: storing %s\n", s->path);
1834 report(REPORT_DEBUG, "sound_clean: storing %s\n", s->path);
18231835 for (b = s->flow; b; b = b->next)
18241836 {
1825 retry:
1826 n = write (fd, b->buf, b->nbytes);
1837 retry:
1838 n = write(fd, b->buf, b->nbytes);
18271839 if (n < 0)
18281840 {
18291841 if (errno == EINTR || errno == EINTR)
18321844 }
18331845 else
18341846 {
1835 report (REPORT_ERROR, "sound_clean: write: %s\n", sys_err_str (errno));
1836 sound_delete (s, 1);
1847 report(REPORT_ERROR, "sound_clean: write: %s\n", sys_err_str(errno));
1848 sound_delete(s, 1);
18371849 s = NULL;
18381850 break;
18391851 }
18401852 }
18411853 }
1842 close (fd);
1854 close(fd);
18431855
18441856 if (s)
18451857 {
18461858 /* The flow is now a file. */
1847 sound_unmap (s);
1859 sound_unmap(s);
18481860 s->type = SOUND_FILE;
18491861 }
18501862 break;
18531865
18541866 #ifdef __STDC__
18551867 SINDEX *
1856 sound_open (SOUND *s, int use_helper)
1868 sound_open(SOUND *s, int use_helper)
18571869 #else
18581870 SINDEX *
1859 sound_open (s, use_helper)
1871 sound_open(s, use_helper)
18601872 SOUND *s;
18611873 int use_helper;
18621874 #endif
18641876 SINDEX *si;
18651877 int n;
18661878
1867 si = (SINDEX *) malloc (sizeof (SINDEX));
1879 si = (SINDEX *) malloc(sizeof(SINDEX));
18681880 if (si == NULL)
18691881 {
18701882 return NULL;
18851897 #if defined (HAVE_CDROM) || defined (HAVE_HELPERS)
18861898 si->pid = -1;
18871899 #endif
1888
1900
18891901 switch (s->format)
18901902 {
18911903 #ifdef HAVE_ADPCM
18921904 case RPLAY_FORMAT_G721:
18931905 case RPLAY_FORMAT_G723_3:
18941906 case RPLAY_FORMAT_G723_5:
1895 g72x_init_state (&si->adpcm_state[0]);
1896 g72x_init_state (&si->adpcm_state[1]);
1907 g72x_init_state(&si->adpcm_state[0]);
1908 g72x_init_state(&si->adpcm_state[1]);
18971909 si->adpcm_in_buffer = 0;
18981910 si->adpcm_in_bits = 0;
18991911 break;
19011913
19021914 #ifdef HAVE_GSM
19031915 case RPLAY_FORMAT_GSM:
1904 si->gsm_object = gsm_create ();
1916 si->gsm_object = gsm_create();
19051917 si->gsm_bit_frame_bytes = 0;
19061918 si->gsm_fixed_buffer_size = 0;
19071919 break;
19081920 #endif /* HAVE_GSM */
1909
1921
19101922 default:
19111923 break;
19121924 }
19171929 int fds[2];
19181930 HELPER *helper;
19191931
1920 helper = helper_lookup (s->path);
1932 helper = helper_lookup(s->path);
19211933 if (!helper)
19221934 {
1923 report (REPORT_ERROR, "%s helper not found\n", s->path);
1924 done (1);
1935 report(REPORT_ERROR, "%s helper not found\n", s->path);
1936 done(1);
19251937 }
19261938
19271939 si->is_flow = 1;
19281940 si->flowp = &s->flow;
1929
1930 if (pipe (fds) < 0)
1931 {
1932 report (REPORT_ERROR, "helper pipe: %s\n", sys_err_str (errno));
1933 sound_close (si);
1941
1942 if (pipe(fds) < 0)
1943 {
1944 report(REPORT_ERROR, "helper pipe: %s\n", sys_err_str(errno));
1945 sound_close(si);
19341946 return NULL;
19351947 }
19361948
1937 si->pid = fork ();
1949 si->pid = fork();
19381950 if (si->pid < 0)
19391951 {
1940 report (REPORT_ERROR, "helper fork: %s\n", sys_err_str (errno));
1941 sound_close (si);
1952 report(REPORT_ERROR, "helper fork: %s\n", sys_err_str(errno));
1953 sound_close(si);
19421954 return NULL;
19431955 }
19441956
19451957 if (si->pid == 0) /* child */
19461958 {
19471959 int first;
1948 char *argv[64]; /* XXX */
1960 char *argv[64]; /* XXX */
19491961 int argc = 0;
19501962 char buf[MAXPATHLEN], *p;
19511963 int input_fd = -1;
19521964
19531965 if (s->type == SOUND_FILE)
19541966 {
1955 input_fd = open (s->path, O_RDONLY /* | O_NDELAY */, 0);
1967 input_fd = open(s->path, O_RDONLY /* | O_NDELAY */ , 0);
19561968 if (input_fd < 0)
19571969 {
1958 report (REPORT_ERROR, "can't open %s: %s\n", s->path, sys_err_str (errno));
1959 exit (1);
1970 report(REPORT_ERROR, "can't open %s: %s\n", s->path, sys_err_str(errno));
1971 exit(1);
19601972 }
19611973 }
19621974 else if (s->type == SOUND_FLOW)
19701982 if (e->type == EVENT_PIPE_FLOW && e->sound == s)
19711983 {
19721984 input_fd = c->fd;
1973 fd_block (input_fd);
1985 fd_block(input_fd);
19741986 break;
19751987 }
19761988 }
19791991
19801992 if (input_fd == -1)
19811993 {
1982 report (REPORT_ERROR, "No input for helper, type=%d.\n", s->type);
1983 exit (1);
1994 report(REPORT_ERROR, "No input for helper, type=%d.\n", s->type);
1995 exit(1);
19841996 }
19851997
19861998 first = 1;
1987 while (p = (char *) strtok (first ? helper->program : NULL, " \t\n"))
1999 while (p = (char *) strtok(first ? helper->program : NULL, " \t\n"))
19882000 {
19892001 first = 0;
19902002 argv[argc++] = p;
19912003 }
19922004 argv[argc] = NULL;
19932005
1994 close (fds[0]);
2006 close(fds[0]);
19952007
19962008 if (input_fd != -1)
19972009 {
1998 if (dup2 (input_fd, 0) != 0) /* input for the helper */
2010 if (dup2(input_fd, 0) != 0) /* input for the helper */
19992011 {
2000 report (REPORT_ERROR, "can't dup2 stdin: %s\n", sys_err_str (errno));
2001 exit (1);
2012 report(REPORT_ERROR, "can't dup2 stdin: %s\n", sys_err_str(errno));
2013 exit(1);
20022014 }
20032015 }
2004 if (dup2 (fds[1], 1) != 1) /* output for rplayd */
2005 {
2006 report (REPORT_ERROR, "can't dup2 stdout: %s\n", sys_err_str (errno));
2007 exit (1);
2008 }
2009
2010 execv (argv[0], argv);
2011
2012 report (REPORT_ERROR, "can't execute %s: %s\n", argv[0], sys_err_str (errno));
2013 exit (1);
2014 }
2015
2016 report (REPORT_DEBUG, "forked helper process %d\n", si->pid);
2017 close (fds[1]);
2016 if (dup2(fds[1], 1) != 1) /* output for rplayd */
2017 {
2018 report(REPORT_ERROR, "can't dup2 stdout: %s\n", sys_err_str(errno));
2019 exit(1);
2020 }
2021
2022 execv(argv[0], argv);
2023
2024 report(REPORT_ERROR, "can't execute %s: %s\n", argv[0], sys_err_str(errno));
2025 exit(1);
2026 }
2027
2028 report(REPORT_DEBUG, "forked helper process %d\n", si->pid);
2029 close(fds[1]);
20182030 si->fd = fds[0];
2019 FD_SET (si->fd, &read_mask);
2031 FD_SET(si->fd, &read_mask);
20202032 }
20212033 #else
2022 if (0)
2034 if (0)
20232035 {
20242036 /* hack */
20252037 }
2026 #endif /* HAVE_HELPERS */
2038 #endif /* HAVE_HELPERS */
20272039 else if (s->type == SOUND_FILE)
20282040 {
20292041 if (!s->cache)
20302042 {
20312043 struct stat st;
20322044
2033 si->fd = open (s->path, O_RDONLY | O_NDELAY, 0);
2045 si->fd = open(s->path, O_RDONLY | O_NDELAY, 0);
20342046 if (si->fd < 0)
20352047 {
2036 report (REPORT_DEBUG, "sound_open: open %s: %s\n", s->path,
2037 sys_err_str (errno));
2038 sound_close (si);
2048 report(REPORT_DEBUG, "sound_open: open %s: %s\n", s->path,
2049 sys_err_str(errno));
2050 sound_close(si);
20392051 return NULL;
20402052 }
20412053
2042 fd_nonblock (si->fd);
2054 fd_nonblock(si->fd);
20432055
20442056 if (!s->mapped || (s->mapped && !s->size))
20452057 {
2046 if (fstat (si->fd, &st) < 0)
2058 if (fstat(si->fd, &st) < 0)
20472059 {
2048 report (REPORT_ERROR, "sound_open: fstat %s: %s\n",
2049 s->path, sys_err_str (errno));
2050 sound_close (si);
2060 report(REPORT_ERROR, "sound_open: fstat %s: %s\n",
2061 s->path, sys_err_str(errno));
2062 sound_close(si);
20512063 return NULL;
20522064 }
20532065
2054 if (S_ISDIR (st.st_mode))
2066 if (S_ISDIR(st.st_mode))
20552067 {
2056 report (REPORT_ERROR, "sound_open: %s is a directory\n",
2057 s->path);
2058 sound_close (si);
2068 report(REPORT_ERROR, "sound_open: %s is a directory\n",
2069 s->path);
2070 sound_close(si);
20592071 return NULL;
20602072 }
20612073
20632075
20642076 /* See if the entire sound can be cached. */
20652077 if (sound_cache_max_size
2066 && !helper_lookup (s->path)
2078 && !helper_lookup(s->path)
20672079 && (sound_cache_max_sound_size == 0 || (s->size <= sound_cache_max_sound_size))
20682080 && (sound_cache_size + s->size <= sound_cache_max_size))
20692081 {
20732085 #ifndef MAP_FILE
20742086 #define MAP_FILE 0
20752087 #endif
2076 s->cache = mmap (0, s->size, PROT_READ, MAP_SHARED | MAP_FILE, si->fd, 0);
2077 if (s->cache == (caddr_t) -1)
2088 s->cache = mmap(0, s->size, PROT_READ, MAP_SHARED | MAP_FILE, si->fd, 0);
2089 if (s->cache == (caddr_t) - 1)
20782090 {
2079 report (REPORT_ERROR, "sound_open: %s size=%d mmap: %s\n",
2080 s->path, s->size, sys_err_str (errno));
2081 sound_close (si);
2091 report(REPORT_ERROR, "sound_open: %s size=%d mmap: %s\n",
2092 s->path, s->size, sys_err_str(errno));
2093 sound_close(si);
20822094 return NULL;
20832095 }
20842096 #else /* not HAVE_MMAP */
20852097 /* Use malloc+read to load the entire sound. */
2086 s->cache = (char *) malloc (s->size);
2098 s->cache = (char *) malloc(s->size);
20872099 if (s->cache == NULL)
20882100 {
2089 report (REPORT_ERROR, "sound_open: %s size=%d malloc: %s\n",
2090 s->path, s->size, sys_err_str (errno));
2091 sound_close (si);
2101 report(REPORT_ERROR, "sound_open: %s size=%d malloc: %s\n",
2102 s->path, s->size, sys_err_str(errno));
2103 sound_close(si);
20922104 return NULL;
20932105 }
20942106 again:
2095 n = read (si->fd, s->cache, s->size);
2107 n = read(si->fd, s->cache, s->size);
20962108 if (n < 0 && (errno == EINTR || errno == EAGAIN))
20972109 {
20982110 goto again;
20992111 }
21002112 if (n != s->size)
21012113 {
2102 report (REPORT_ERROR, "sound_open: read %s %d: %s\n",
2103 s->path, s->size, sys_err_str (errno));
2104 free ((char *) s->cache);
2114 report(REPORT_ERROR, "sound_open: read %s %d: %s\n",
2115 s->path, s->size, sys_err_str(errno));
2116 free((char *) s->cache);
21052117 s->cache = NULL;
2106 sound_close (si);
2118 sound_close(si);
21072119 return NULL;
21082120 }
21092121 #endif /* not HAVE_MMAP */
21102122
21112123 sound_cache_size += s->size;
21122124 #if 0
2113 report (REPORT_DEBUG, "- cached %s %d, cache_size=%d\n",
2114 s->path, s->size, sound_cache_size);
2125 report(REPORT_DEBUG, "- cached %s %d, cache_size=%d\n",
2126 s->path, s->size, sound_cache_size);
21152127 #endif
21162128
21172129 /* Cached sounds won't need the file descriptor. */
2118 close (si->fd);
2130 close(si->fd);
21192131 si->fd = 0;
21202132 }
21212133 }
21442156
21452157 si->is_flow = 1;
21462158 si->flowp = &s->flow;
2147
2148 if (pipe (fds) < 0)
2149 {
2150 report (REPORT_ERROR, "cdrom pipe: %s\n", sys_err_str (errno));
2151 sound_close (si);
2159
2160 if (pipe(fds) < 0)
2161 {
2162 report(REPORT_ERROR, "cdrom pipe: %s\n", sys_err_str(errno));
2163 sound_close(si);
21522164 return NULL;
21532165 }
21542166
2155 si->pid = fork ();
2167 si->pid = fork();
21562168 if (si->pid < 0)
21572169 {
2158 report (REPORT_ERROR, "cdrom fork: %s\n", sys_err_str (errno));
2159 sound_close (si);
2170 report(REPORT_ERROR, "cdrom fork: %s\n", sys_err_str(errno));
2171 sound_close(si);
21602172 return NULL;
21612173 }
21622174
21642176 {
21652177 int i;
21662178
2167 close (fds[0]);
2179 close(fds[0]);
21682180
21692181 #ifdef HAVE_SIGSET
2170 sigset (SIGHUP, SIG_DFL);
2171 sigset (SIGINT, SIG_DFL);
2172 sigset (SIGCHLD, SIG_DFL);
2182 sigset(SIGHUP, SIG_DFL);
2183 sigset(SIGINT, SIG_DFL);
2184 sigset(SIGCHLD, SIG_DFL);
21732185 #else
2174 signal (SIGHUP, SIG_DFL);
2175 signal (SIGINT, SIG_DFL);
2176 signal (SIGCHLD, SIG_DFL);
2186 signal(SIGHUP, SIG_DFL);
2187 signal(SIGINT, SIG_DFL);
2188 signal(SIGCHLD, SIG_DFL);
21772189 #endif
21782190
21792191 for (i = 0; i < MAX_CDROMS; i++)
21802192 {
2181 if (strcmp (cdrom_table[i].name, si->sound->name) == 0)
2193 if (strcmp(cdrom_table[i].name, si->sound->name) == 0)
21822194 {
2183 cdrom_reader (i, si->sound->starting_track, si->sound->ending_track, fds[1]);
2184 exit (0);
2195 cdrom_reader(i, si->sound->starting_track, si->sound->ending_track, fds[1]);
2196 exit(0);
21852197 }
21862198 }
2187
2188 report (REPORT_DEBUG, "cdrom `%s' not found\n", si->sound->name);
2189 exit (1);
2190 }
2191
2192 report (REPORT_DEBUG, "forked cdrom process %d\n", si->pid);
2193 close (fds[1]);
2199
2200 report(REPORT_DEBUG, "cdrom `%s' not found\n", si->sound->name);
2201 exit(1);
2202 }
2203
2204 report(REPORT_DEBUG, "forked cdrom process %d\n", si->pid);
2205 close(fds[1]);
21942206 si->fd = fds[0];
2195
2196 FD_SET (si->fd, &read_mask);
2197 }
2198 #endif /* HAVE_CDROM */
2207
2208 FD_SET(si->fd, &read_mask);
2209 }
2210 #endif /* HAVE_CDROM */
21992211
22002212 return si;
22012213 }
22022214
22032215 #ifdef __STDC__
22042216 int
2205 sound_close (SINDEX *si)
2217 sound_close(SINDEX *si)
22062218 #else
22072219 int
2208 sound_close (si)
2220 sound_close(si)
22092221 SINDEX *si;
22102222 #endif
22112223 {
22142226 {
22152227 if (si->pid != -1)
22162228 {
2217 report (REPORT_DEBUG, "killing helper process %d\n", si->pid);
2218 if (kill (si->pid, SIGKILL) < 0)
2219 {
2220 report (REPORT_DEBUG, "kill %d: %s\n", si->pid, sys_err_str (errno));
2229 report(REPORT_DEBUG, "killing helper process %d\n", si->pid);
2230 if (kill(si->pid, SIGKILL) < 0)
2231 {
2232 report(REPORT_DEBUG, "kill %d: %s\n", si->pid, sys_err_str(errno));
22212233 }
22222234 }
22232235 if (si->fd != 0)
22242236 {
2225 FD_CLR (si->fd, &read_mask);
2226 close (si->fd);
2237 FD_CLR(si->fd, &read_mask);
2238 close(si->fd);
22272239 }
22282240 if (si->sound->type == SOUND_FLOW)
22292241 {
22362248 {
22372249 if (e->type == EVENT_PIPE_FLOW && e->sound == si->sound)
22382250 {
2239 connection_close (c);
2251 connection_close(c);
22402252 break;
22412253 }
22422254 }
22502262 {
22512263 if (!si->is_cached)
22522264 {
2253 close (si->fd);
2265 close(si->fd);
22542266 }
22552267 }
22562268 #ifdef HAVE_CDROM
22582270 {
22592271 if (si->pid != -1)
22602272 {
2261 report (REPORT_DEBUG, "killing cdrom process %d\n", si->pid);
2262 if (kill (si->pid, SIGKILL) < 0)
2263 {
2264 report (REPORT_DEBUG, "kill %d: %s\n", si->pid, sys_err_str (errno));
2273 report(REPORT_DEBUG, "killing cdrom process %d\n", si->pid);
2274 if (kill(si->pid, SIGKILL) < 0)
2275 {
2276 report(REPORT_DEBUG, "kill %d: %s\n", si->pid, sys_err_str(errno));
22652277 }
22662278 }
22672279 if (si->fd != 0)
22682280 {
2269 FD_CLR (si->fd, &read_mask);
2270 close (si->fd);
2281 FD_CLR(si->fd, &read_mask);
2282 close(si->fd);
22712283 }
22722284 }
22732285 #endif /* HAVE_CDROM */
22762288 {
22772289 #ifdef HAVE_GSM
22782290 case RPLAY_FORMAT_GSM:
2279 gsm_destroy (si->gsm_object);
2291 gsm_destroy(si->gsm_object);
22802292 break;
22812293 #endif /* HAVE_GSM */
22822294
22832295 default:
22842296 break;
22852297 }
2286
2287 free ((char *) si);
2298
2299 free((char *) si);
22882300
22892301 return 0;
22902302 }
22932305 /* This routine is based on the unpack_input routine from
22942306 Sun's CCITT ADPCM decoder. */
22952307 static int
2296 adpcm_unpack (si, b, code, bits)
2308 adpcm_unpack(si, b, code, bits)
22972309 SINDEX *si;
22982310 BUFFER *b;
22992311 unsigned char *code;
23002312 int bits;
23012313 {
23022314 unsigned char in_byte;
2303
2315
23042316 if (si->adpcm_in_bits < bits)
23052317 {
2306 if (b->offset >= b->nbytes)
2307 {
2308 *code = 0;
2309 return -1;
2310 }
2318 if (b->offset >= b->nbytes)
2319 {
2320 *code = 0;
2321 return -1;
2322 }
23112323 in_byte = b->buf[b->offset++];
2312 si->adpcm_in_buffer |= (in_byte << si->adpcm_in_bits);
2313 si->adpcm_in_bits += 8;
2324 si->adpcm_in_buffer |= (in_byte << si->adpcm_in_bits);
2325 si->adpcm_in_bits += 8;
23142326 }
23152327
23162328 *code = si->adpcm_in_buffer & ((1 << bits) - 1);
23222334
23232335 /* Uncompress the `data' buffers into 16-bit linear data. */
23242336 static void
2325 adpcm_decode (si, data, decode_routine, decode_bits)
2337 adpcm_decode(si, data, decode_routine, decode_bits)
23262338 SINDEX *si;
23272339 BUFFER *data;
2328 int (*decode_routine)();
2340 int (*decode_routine) ();
23292341 int decode_bits;
23302342 {
2331 BUFFER *b = buffer_create ();
2343 BUFFER *b = buffer_create();
23322344 short *ptr;
23332345 unsigned char code;
23342346 int channel = 0;
2335
2347
23362348 for (; data && data->nbytes; data = data->next)
23372349 {
2338 memcpy (b->buf, data->buf, data->nbytes);
2339 b->nbytes = data->nbytes;
2340 b->offset = 0;
2341
2342 ptr = (short *) data->buf;
2350 memcpy(b->buf, data->buf, data->nbytes);
2351 b->nbytes = data->nbytes;
2352 b->offset = 0;
2353
2354 ptr = (short *) data->buf;
23432355 data->nbytes = 0;
23442356
2345 while (adpcm_unpack (si, b, &code, decode_bits) >= 0)
2346 {
2347 *ptr++ = (*decode_routine) (code, AUDIO_ENCODING_LINEAR, &si->adpcm_state[channel]);
2357 while (adpcm_unpack(si, b, &code, decode_bits) >= 0)
2358 {
2359 *ptr++ = (*decode_routine) (code, AUDIO_ENCODING_LINEAR, &si->adpcm_state[channel]);
23482360 if (si->sound->channels == 2)
23492361 {
2350 channel ^= 1;
2351 }
2352 data->nbytes += 2; /* 16-bit */
2353 }
2362 channel ^= 1;
2363 }
2364 data->nbytes += 2; /* 16-bit */
2365 }
23542366 #if 1
2355 report (REPORT_DEBUG, "adpcm_decode: uncompressed from %d to %d bytes\n",
2356 b->nbytes, data->nbytes);
2357 #endif
2358 }
2359
2360 buffer_destroy (b);
2367 report(REPORT_DEBUG, "adpcm_decode: uncompressed from %d to %d bytes\n",
2368 b->nbytes, data->nbytes);
2369 #endif
2370 }
2371
2372 buffer_destroy(b);
23612373 }
23622374 #endif /* HAVE_ADPCM */
23632375
23642376 #ifdef HAVE_GSM
23652377 /* Uncompress the `data' buffers into 16-bit linear data. */
23662378 static void
2367 gsm_uncompress (si, data)
2379 gsm_uncompress(si, data)
23682380 SINDEX *si;
23692381 BUFFER *data;
23702382 {
2371 BUFFER *b = buffer_create ();
2383 BUFFER *b = buffer_create();
23722384 gsm_signal sample[160];
23732385 int nbytes;
23742386
23752387 for (; data; data = data->next)
23762388 {
2377 memcpy (b->buf, data->buf, data->nbytes);
2378 b->nbytes = data->nbytes;
2379 b->offset = 0;
2389 memcpy(b->buf, data->buf, data->nbytes);
2390 b->nbytes = data->nbytes;
2391 b->offset = 0;
23802392 data->nbytes = 0;
2381
2393
23822394 do
23832395 {
2384 nbytes = MIN (b->nbytes - b->offset, sizeof (si->gsm_bit_frame) - si->gsm_bit_frame_bytes);
2385 memcpy (si->gsm_bit_frame, b->buf + b->offset, nbytes);
2396 nbytes = MIN(b->nbytes - b->offset, sizeof(si->gsm_bit_frame) - si->gsm_bit_frame_bytes);
2397 memcpy(si->gsm_bit_frame, b->buf + b->offset, nbytes);
23862398 b->offset += nbytes;
23872399 si->gsm_bit_frame_bytes += nbytes;
23882400
2389 if (si->gsm_bit_frame_bytes == sizeof (si->gsm_bit_frame)) /* Only decode complete frames */
2390 {
2391 gsm_decode (si->gsm_object, si->gsm_bit_frame, sample);
2392 memcpy (data->buf + data->nbytes, (char *) sample, sizeof (sample));
2393 data->nbytes += sizeof (sample);
2401 if (si->gsm_bit_frame_bytes == sizeof(si->gsm_bit_frame)) /* Only decode complete frames */
2402 {
2403 gsm_decode(si->gsm_object, si->gsm_bit_frame, sample);
2404 memcpy(data->buf + data->nbytes, (char *) sample, sizeof(sample));
2405 data->nbytes += sizeof(sample);
23942406 si->gsm_bit_frame_bytes = 0;
23952407 }
23962408
23972409 #if 0
2398 printf ("b->offset=%d data->nbytes=%d gsm_bit_frame_bytes=%d\n",
2399 b->offset, data->nbytes, si->gsm_bit_frame_bytes);
2400 #endif
2401
2410 printf("b->offset=%d data->nbytes=%d gsm_bit_frame_bytes=%d\n",
2411 b->offset, data->nbytes, si->gsm_bit_frame_bytes);
2412 #endif
2413
24022414 }
24032415 while (b->offset < b->nbytes);
2404
2416
24052417 #if 1
2406 report (REPORT_DEBUG, "gsm_uncompress: uncompressed from %d to %d bytes\n",
2407 b->nbytes, data->nbytes);
2408 #endif
2409 }
2410
2411 buffer_destroy (b);
2418 report(REPORT_DEBUG, "gsm_uncompress: uncompressed from %d to %d bytes\n",
2419 b->nbytes, data->nbytes);
2420 #endif
2421 }
2422
2423 buffer_destroy(b);
24122424 }
24132425 #endif /* HAVE_GSM */
24142426
24152427 #ifdef __STDC__
24162428 int
2417 sound_fill (SINDEX *si, BUFFER *data, int as_is)
2429 sound_fill(SINDEX *si, BUFFER *data, int as_is)
24182430 #else
24192431 int
2420 sound_fill (si, data, as_is)
2432 sound_fill(si, data, as_is)
24212433 SINDEX *si;
24222434 BUFFER *data;
24232435 int as_is;
24292441 BUFFER *b;
24302442 float bit_factor;
24312443 int max_per_buffer;
2432
2444
24332445 if (si->eof && !si->is_flow)
24342446 {
24352447 return 0;
24522464 if (si->gsm_fixed_buffer_size == 0)
24532465 {
24542466 si->gsm_fixed_buffer_size = max_per_buffer;
2455 while (si->gsm_fixed_buffer_size % sizeof (si->gsm_bit_frame))
2467 while (si->gsm_fixed_buffer_size % sizeof(si->gsm_bit_frame))
24562468 {
24572469 si->gsm_fixed_buffer_size--;
24582470 }
24592471 }
24602472 max_per_buffer = si->gsm_fixed_buffer_size;
24612473 }
2462
2474
24632475 /* Read from a flow. */
24642476 if (si->is_flow)
24652477 {
24662478 BUFFER *f, *f_next;
2467
2479
24682480 if (!si->flowp)
24692481 {
24702482 return 0;
24902502 #endif
24912503 if (!si->high_water_mark)
24922504 {
2493 si->low_water_mark = LOW_WATER_MARK (si->sound);
2494 si->high_water_mark = HIGH_WATER_MARK (si->sound);
2505 #if 1
2506 /* XXX test */
2507 SOUND *s = si->sound;
2508 si->low_water_mark = (s->sample_rate * s->input_sample_size) / 4;
2509 si->high_water_mark = (s->sample_rate * s->input_sample_size) / 2;
2510 #else
2511 si->low_water_mark = LOW_WATER_MARK(si->sound);
2512 si->high_water_mark = HIGH_WATER_MARK(si->sound);
2513 #endif
24952514 }
24962515 }
24972516
25102529 else
25112530 {
25122531 /* Calculate the number of bytes needed. */
2513 i = MIN (n, max_per_buffer - b->nbytes);
2514 memcpy (b->buf + b->nbytes, f->buf + si->buffer_offset + si->skip, i);
2532 i = MIN(n, max_per_buffer - b->nbytes);
2533 memcpy(b->buf + b->nbytes, f->buf + si->buffer_offset + si->skip, i);
25152534 si->skip = 0;
25162535 b->nbytes += i;
25172536 total += i;
25312550 if (si->sound->storage == SOUND_STORAGE_NONE
25322551 || si->sound->storage == SOUND_STORAGE_NULL)
25332552 {
2534 buffer_destroy (f);
2553 buffer_destroy(f);
25352554 }
25362555
25372556 f = f_next;
25622581 n = si->sound->size - si->offset;
25632582 for (b = data; b; b = b->next)
25642583 {
2565 i = MIN (n, max_per_buffer);
2584 i = MIN(n, max_per_buffer);
25662585 if (i > 0)
25672586 {
25682587 #ifdef DEBUG
2569 report (REPORT_DEBUG, "- cache-read %s %d\n", si->sound->name, i);
2570 #endif
2571 memcpy (b->buf, si->sound->cache + si->offset, i);
2588 report(REPORT_DEBUG, "- cache-read %s %d\n", si->sound->name, i);
2589 #endif
2590 memcpy(b->buf, si->sound->cache + si->offset, i);
25722591 b->nbytes = i;
25732592 si->offset += i;
25742593 n -= i;
25942613 iov[i].iov_len = max_per_buffer;
25952614 }
25962615
2597 n = readv (si->fd, iov, i);
2616 n = readv(si->fd, iov, i);
25982617 if (n < 0)
25992618 {
2600 report (REPORT_ERROR, "sound_fill: readv: %s, fd=%d, %s\n",
2601 si->sound->name, si->fd, sys_err_str (errno));
2619 report(REPORT_ERROR, "sound_fill: readv: %s, fd=%d, %s\n",
2620 si->sound->name, si->fd, sys_err_str(errno));
26022621 return -1;
26032622 }
26042623 else if (n == 0)
26152634 {
26162635 i = 0;
26172636 }
2618 b->nbytes = MIN (i, max_per_buffer);
2637 b->nbytes = MIN(i, max_per_buffer);
26192638 }
26202639 total = n;
26212640 }
26282647 {
26292648 #ifdef HAVE_ADPCM
26302649 case RPLAY_FORMAT_G721:
2631 adpcm_decode (si, data, g721_decoder, 4);
2650 adpcm_decode(si, data, g721_decoder, 4);
26322651 break;
26332652
26342653 case RPLAY_FORMAT_G723_3:
2635 adpcm_decode (si, data, g723_24_decoder, 3);
2654 adpcm_decode(si, data, g723_24_decoder, 3);
26362655 break;
26372656
26382657 case RPLAY_FORMAT_G723_5:
2639 adpcm_decode (si, data, g723_40_decoder, 5);
2658 adpcm_decode(si, data, g723_40_decoder, 5);
26402659 break;
26412660 #endif /* HAVE_ADPCM */
26422661
26432662 #ifdef HAVE_GSM
26442663 case RPLAY_FORMAT_GSM:
2645 gsm_uncompress (si, data);
2664 gsm_uncompress(si, data);
26462665 break;
26472666 #endif /* HAVE_GSM */
26482667 }
26492668 }
2650
2669
26512670 return total;
26522671 }
26532672
26542673 #ifdef __STDC__
26552674 int
2656 sound_seek (SINDEX *si, int offset, int whence)
2675 sound_seek(SINDEX *si, int offset, int whence)
26572676 #else
26582677 int
2659 sound_seek (si, offset, whence)
2678 sound_seek(si, offset, whence)
26602679 SINDEX *si;
26612680 int offset;
26622681 int whence;
26642683 {
26652684 if (si->is_flow)
26662685 {
2667 si->skip += offset; /* XXX: whence is ignored */
2686 si->skip += offset; /* XXX: whence is ignored */
26682687 return 0;
26692688 }
26702689 else if (si->is_cached)
26712690 {
2672 si->offset += offset; /* XXX: whence is ignored */
2691 si->offset += offset; /* XXX: whence is ignored */
26732692 return 0;
26742693 }
26752694 #ifdef HAVE_CDROM
26772696 {
26782697 return 0;
26792698 }
2680 #endif /* HAVE_CDROM */
2699 #endif /* HAVE_CDROM */
26812700 #ifdef HAVE_HELPERS
26822701 else if (si->sound->needs_helper)
26832702 {
26842703 return 0;
26852704 }
2686 #endif /* HAVE_HELPERS */
2705 #endif /* HAVE_HELPERS */
26872706 else
26882707 {
2689 return lseek (si->fd, offset, whence);
2708 return lseek(si->fd, offset, whence);
26902709 }
26912710 }
26922711
26942713 /* Read data from the pipe and return the data in a buffer list. */
26952714 #ifdef __STDC__
26962715 BUFFER *
2697 sound_pipe_read (SINDEX *si)
2716 sound_pipe_read(SINDEX *si)
26982717 #else
26992718 BUFFER *
2700 sound_pipe_read (si)
2719 sound_pipe_read(si)
27012720 SINDEX *si;
2702 #endif
2721 #endif
27032722 {
27042723 static struct iovec iov[UIO_MAXIOV];
27052724 int i, n, nbytes;
27092728 /* Pause */
27102729 if (si->water_mark - si->offset > si->high_water_mark)
27112730 {
2712 FD_CLR (si->fd, &read_mask);
2731 FD_CLR(si->fd, &read_mask);
27132732 return NULL;
27142733 }
27152734
27162735 /* Determine the number of bytes available in the pipe. */
2717 #if defined (sun) && defined (SVR4) /* Solaris 2.x */
2736 #if defined (sun) && defined (SVR4) /* Solaris 2.x */
27182737 {
27192738 struct stat st;
2720 if (fstat (si->fd, &st) < 0)
2721 {
2722 report (REPORT_DEBUG, "sound_pipe_read: fstat: %s\n",
2723 sys_err_str (errno));
2739 if (fstat(si->fd, &st) < 0)
2740 {
2741 report(REPORT_DEBUG, "sound_pipe_read: fstat: %s\n",
2742 sys_err_str(errno));
27242743 return NULL;
27252744 }
27262745 nbytes = st.st_size;
27272746 }
27282747 #else /* not Solaris */
2729 #ifdef FIONREAD
2730 if (ioctl (si->fd, FIONREAD, &nbytes) < 0)
2731 {
2732 report (REPORT_DEBUG, "sound_pipe_read: ioctl FIONREAD: %s\n",
2733 sys_err_str (errno));
2748 #if 0 /* disable FIONREAD for now */
2749 #ifdef FIONREAD
2750 if (ioctl(si->fd, FIONREAD, &nbytes) < 0)
2751 {
2752 report(REPORT_DEBUG, "sound_pipe_read: ioctl FIONREAD: %s\n",
2753 sys_err_str(errno));
27342754 return NULL;
27352755 }
27362756 #endif /* not FIONREAD */
2757 #endif
27372758 /* guess */
27382759 nbytes = (si->sound->sample_rate * si->sound->input_sample_size) / 2;
27392760 #endif /* not Solaris */
2740
2741 data = buffer_alloc (nbytes, BUFFER_FREE);
2761
2762 data = buffer_alloc(nbytes, BUFFER_FREE);
27422763
27432764 for (b = data, i = 0; b && i < UIO_MAXIOV; b = b->next, i++)
27442765 {
27462767 iov[i].iov_len = BUFFER_SIZE;
27472768 }
27482769
2749 n = readv (si->fd, iov, i);
2770 n = readv(si->fd, iov, i);
27502771 if (n <= 0)
27512772 {
2752 buffer_dealloc (data, 1);
2753 spool_remove (si->sound); /* XXX */
2773 buffer_dealloc(data, 1);
2774 spool_remove(si->sound); /* XXX */
27542775 return NULL;
27552776 }
27562777
27602781 {
27612782 i = 0;
27622783 }
2763 b->nbytes = MIN (i, BUFFER_SIZE);
2764 }
2765
2784 b->nbytes = MIN(i, BUFFER_SIZE);
2785 }
2786
27662787 return data;
27672788 }
27682789 #endif
27692790
27702791 #ifdef __STDC__
27712792 static int
2772 bytes_in_sound (SOUND *s)
2793 bytes_in_sound(SOUND *s)
27732794 #else
27742795 static int
2775 bytes_in_sound (s)
2796 bytes_in_sound(s)
27762797 SOUND *s;
27772798 #endif
27782799 {
27792800 int bytes = 0;
2780
2801
27812802 if (s->chunk_size)
27822803 {
27832804 bytes = s->chunk_size;
27962817
27972818 #ifdef __STDC__
27982819 int
2799 number_of_samples (SOUND *s, int bytes)
2820 number_of_samples(SOUND *s, int bytes)
28002821 #else
28012822 int
2802 number_of_samples (s, bytes)
2823 number_of_samples(s, bytes)
28032824 SOUND *s;
28042825 int bytes;
28052826 #endif
28062827 {
28072828 if (!bytes)
28082829 {
2809 bytes = bytes_in_sound (s);
2830 bytes = bytes_in_sound(s);
28102831 }
28112832 return (bytes << 3) / (s->input_precision * s->channels);
28122833 }
0 /* $Id: sound.h,v 1.2 1998/08/13 06:14:06 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
0 /* $Id: sound.h,v 1.4 1999/06/09 06:27:44 boyns Exp $ */
1
2 /*
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
3737 #include "g72x.h"
3838 #endif /* HAVE_ADPCM */
3939 #ifdef HAVE_GSM
40 #include "gsm.h"
40 #ifdef HAVE_GSM_GSM_H
41 #include <gsm/gsm.h>
42 #else
43 #ifdef HAVE_GSM_H
44 #include <gsm.h>
45 #else
46 #include "gsm.h"
47 #endif
48 #endif
4149 #endif /* HAVE_GSM */
4250
4351 #undef NUMBER_OF_SAMPLES
0 /* $Id: spool.c,v 1.2 1998/08/13 06:14:07 boyns Exp $ */
0 /* $Id: spool.c,v 1.6 1999/03/10 21:14:38 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
23
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
5353 * initialize the sound spool
5454 */
5555 void
56 spool_init ()
56 spool_init()
5757 {
5858 SPOOL *sp, *sp_next;
5959
6161 for (sp = spool; sp; sp = sp_next)
6262 {
6363 sp_next = sp->next;
64 spool_destroy (sp);
64 spool_destroy(sp);
6565 }
6666
6767 spool = NULL;
7272
7373 /* Create a new spool entry. */
7474 SPOOL *
75 spool_create ()
76 {
77 SPOOL *sp = (SPOOL *) malloc (sizeof (SPOOL));
75 spool_create()
76 {
77 SPOOL *sp = (SPOOL *) malloc(sizeof(SPOOL));
7878 if (sp == NULL)
7979 {
80 report (REPORT_ERROR, "spool_create: out of memory\n");
81 done (1);
80 report(REPORT_ERROR, "spool_create: out of memory\n");
81 done(1);
8282 }
8383
8484 /* `sp' must be initialized before being reset. */
85 memset ((char *) sp, 0, sizeof (SPOOL));
85 memset((char *) sp, 0, sizeof(SPOOL));
8686 sp->id = -1; /* XXX */
8787
88 spool_reset (sp);
88 spool_reset(sp);
8989
9090 /* Insert the new entry into the spool list. */
9191 sp->next = spool;
104104 /* Destroy the given spool entry. */
105105 #ifdef __STDC__
106106 void
107 spool_destroy (SPOOL *sp)
108 #else
109 void
110 spool_destroy (sp)
107 spool_destroy(SPOOL *sp)
108 #else
109 void
110 spool_destroy(sp)
111111 SPOOL *sp;
112112 #endif
113113 {
114114 /* Reset `sp' in case any resources are allocated. */
115 spool_reset (sp);
115 spool_reset(sp);
116116
117117 /* Remove `sp' from the spool list. */
118118 if (sp->prev)
130130
131131 spool_size--;
132132
133 free ((char *) sp);
133 free((char *) sp);
134134 }
135135
136136 /*
141141 */
142142 #ifdef __STDC__
143143 SPOOL *
144 spool_next (int priority)
144 spool_next(int priority)
145145 #else
146146 SPOOL *
147 spool_next (priority)
147 spool_next(priority)
148148 int priority;
149149 #endif
150150 {
155155 /* There's room for a new entry. */
156156 if (spool_size < SPOOL_SIZE)
157157 {
158 sp = spool_create ();
159 sp->id = spool_id ();
158 sp = spool_create();
159 sp->id = spool_id();
160160 return sp;
161161 }
162162
181181 sp = lowest;
182182 if (sp->notify_position)
183183 {
184 connection_notify (0, NOTIFY_POSITION, sp);
184 connection_notify(0, NOTIFY_POSITION, sp);
185185 sp->notify_position = 0;
186186 }
187 connection_notify (0, NOTIFY_DONE, sp);
188 spool_reset (sp);
187 connection_notify(0, NOTIFY_DONE, sp);
188 spool_reset(sp);
189189 spool_nplaying--;
190 sp->id = spool_id ();
190 sp->id = spool_id();
191191 return sp;
192192 }
193193 else
200200 `next' and `prev' are NOT changed. */
201201 #ifdef __STDC__
202202 void
203 spool_reset (SPOOL *sp)
204 #else
205 void
206 spool_reset (sp)
203 spool_reset(SPOOL *sp)
204 #else
205 void
206 spool_reset(sp)
207207 SPOOL *sp;
208208 #endif
209209 {
212212 {
213213 /* Wakeup any connections that may be waiting for this
214214 spool entry. Their flow data will be ignored. */
215 connection_flow_continue (sp);
215 connection_flow_continue(sp);
216216 }
217217 sp->id = -1;
218218 sp->time = 0;
222222
223223 for (i = 0; i < sp->rp->nsounds; i++)
224224 {
225 sound_clean (sp->sound[i]);
226 }
227
228 rplay_destroy (sp->rp);
225 sound_clean(sp->sound[i]);
226 }
227
228 rplay_destroy(sp->rp);
229229 }
230230 sp->rp = NULL;
231231 sp->ptr = NULL;
239239 sp->oversample_inc[1] = 0;
240240 if (sp->curr_buffer)
241241 {
242 buffer_dealloc (sp->curr_buffer, 1);
242 buffer_dealloc(sp->curr_buffer, 1);
243243 }
244244 sp->curr_buffer = NULL;
245245 if (sp->next_buffer)
246246 {
247 buffer_dealloc (sp->next_buffer, 1);
247 buffer_dealloc(sp->next_buffer, 1);
248248 }
249249 sp->next_buffer = NULL;
250250 sp->offset = 0;
251251 if (sp->si)
252252 {
253 sound_close (sp->si);
253 sound_close(sp->si);
254254 }
255255 sp->si = NULL;
256256 sp->to_native = NULL;
258258 sp->auto_pause = 0;
259259 sp->notify_position = 0;
260260
261 spool_setprio ();
261 spool_setprio();
262262 }
263263
264264 /* Find the maximum spool priority. */
265265 #ifdef __STDC__
266266 void
267 spool_setprio (void)
268 #else
269 void
270 spool_setprio ()
267 spool_setprio(void)
268 #else
269 void
270 spool_setprio()
271271 #endif
272272 {
273273 SPOOL *sp;
277277 {
278278 if (sp->state == SPOOL_PLAY)
279279 {
280 spool_prio = MAX (spool_prio, sp->rp->priority);
280 spool_prio = MAX(spool_prio, sp->rp->priority);
281281 }
282282 }
283283 }
285285 /* Find the given RPLAY object in the spool. */
286286 #ifdef __STDC__
287287 int
288 spool_match (RPLAY *match, void (*action) (SPOOL *), struct sockaddr_in sin)
288 spool_match(RPLAY *match, void (*action) (SPOOL *), struct sockaddr_in sin)
289289 #else
290290 int
291 spool_match (match, action, sin)
291 spool_match(match, action, sin)
292292 RPLAY *match;
293293 void (*action) ();
294294 struct sockaddr_in sin;
313313 {
314314 for (; a2; a2 = a2->next)
315315 {
316 id = atoi (a2->sound + 1);
316 id = atoi(a2->sound + 1);
317317 if (id == 0 || id == sp->id)
318318 {
319319 sp->sin = sin;
328328 rp = sp->rp;
329329 for (a1 = rp->attrs, a2 = match->attrs; a1 && a2; a1 = a1->next, a2 = a2->next)
330330 {
331 if (strcmp (a1->sound, a2->sound))
331 if (strcmp(a1->sound, a2->sound))
332332 {
333333 break;
334334 }
347347 /* Remove any spool entries with `sound' from the spool. */
348348 #ifdef __STDC__
349349 void
350 spool_remove (SOUND *sound)
351 #else
352 void
353 spool_remove (sound)
350 spool_remove(SOUND *sound)
351 #else
352 void
353 spool_remove(sound)
354354 SOUND *sound;
355355 #endif
356356 {
376376 }
377377 if (n)
378378 {
379 spool_done (sp);
379 spool_done(sp);
380380 }
381381 }
382382 }
386386 */
387387 #ifdef __STDC__
388388 void
389 spool_ready (SOUND *sound)
390 #else
391 void
392 spool_ready (sound)
389 spool_ready(SOUND *sound)
390 #else
391 void
392 spool_ready(sound)
393393 SOUND *sound;
394394 #endif
395395 {
421421 {
422422 for (j = 0; j < sp->rp->nsounds; j++)
423423 {
424 sound_map (sp->sound[j]);
424 sound_map(sp->sound[j]);
425425 }
426426
427 spool_play (sp);
427 spool_play(sp);
428428 }
429429 }
430430 }
432432
433433 /* Return a buffer list for the `list spool' command. */
434434 BUFFER *
435 spool_list_create ()
435 spool_list_create()
436436 {
437437 BUFFER *spool_list, *b;
438438 int i, n;
439439 char buf[RPTP_MAX_LINE];
440 char line[RPTP_MAX_LINE];
440441 SOUND *s;
441442 SPOOL *sp;
442
443 b = buffer_create ();
443 int length;
444
445 b = buffer_create();
444446 spool_list = b;
445 SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "+message=\"spool\"\r\n");
446 b->nbytes += strlen (b->buf);
447 SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "+message=\"spool\"\r\n");
448 b->nbytes += strlen(b->buf);
447449
448450 for (sp = spool; sp; sp = sp->next)
449451 {
450 SNPRINTF (SIZE(buf,sizeof(buf)), "id=#%d", sp->id);
451 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), " state=");
452 length = 0;
453 line[0] = '\0';
454
455 SNPRINTF(SIZE(buf, sizeof(buf)), "id=#%d state=", sp->id);
456 strncat(line + length, buf, sizeof(line) - length);
457 length += strlen(buf);
458
452459 switch (sp->state)
453460 {
454461 case SPOOL_PLAY:
455 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "play");
462 SNPRINTF(SIZE(buf, sizeof(buf)), "play");
456463 break;
457464
458465 case SPOOL_PAUSE:
459 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "pause");
466 SNPRINTF(SIZE(buf, sizeof(buf)), "pause");
460467 break;
461468
462469 case SPOOL_WAIT:
463 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "wait");
470 SNPRINTF(SIZE(buf, sizeof(buf)), "wait");
464471 break;
465472
466473 case SPOOL_NEXT:
467 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "next");
474 SNPRINTF(SIZE(buf, sizeof(buf)), "next");
468475 break;
469476
470477 case SPOOL_SKIP:
471 SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "skip");
478 SNPRINTF(SIZE(buf, sizeof(buf)), "skip");
472479 break;
473480
474481 default:
475482 continue;
476483 }
484 strncat(line + length, buf, sizeof(line) - length);
485 length += strlen(buf);
477486
478487 s = sp->sound[sp->curr_sound];
479488
480 SNPRINTF (SIZE(buf + strlen (buf),sizeof(buf)), "\
489 SNPRINTF(SIZE(buf, sizeof(buf)), "\
481490 sound=\"%s\" host=%s volume=%d priority=%d count=%d position=%.2f remain=%.2f seconds=%.2f size=%d\
482491 sample-rate=%d channels=%d bits=%g input=%s client-data=\"%s\" list-name=\"%s\"\r\n",
483492 sp->curr_attrs->sound,
484 inet_ntoa (sp->sin.sin_addr),
493 inet_ntoa(sp->sin.sin_addr),
485494 sp->curr_attrs->volume,
486495 sp->rp->priority,
487496 sp->curr_count,
492501 sp->sample_rate,
493502 s->channels,
494503 s->input_precision,
495 input_to_string (s->type),
504 input_to_string(s->type),
496505 sp->curr_attrs->client_data,
497506 sp->rp->list_name);
498507
499 n = strlen (buf);
500 if (b->nbytes + n > BUFFER_SIZE)
501 {
502 b->next = buffer_create ();
508 strncat(line + length, buf, sizeof(line) - length);
509 length += strlen(buf);
510
511 if (b->nbytes + length > BUFFER_SIZE)
512 {
513 b->next = buffer_create();
503514 b = b->next;
504515 }
505516
506 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), buf);
507 b->nbytes += n;
517 strncat(b->buf + b->nbytes, line, BUFFER_SIZE - b->nbytes);
518 b->nbytes += length;
508519 }
509520
510521 if (b->nbytes + 3 > BUFFER_SIZE)
511522 {
512 b->next = buffer_create ();
523 b->next = buffer_create();
513524 b = b->next;
514525 }
515 SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n");
526
527 strncat(b->buf + b->nbytes, ".\r\n", BUFFER_SIZE - b->nbytes);
516528 b->nbytes += 3;
517529
518530 return spool_list;
522534 * Return a unique spool id.
523535 */
524536 int
525 spool_id ()
537 spool_id()
526538 {
527539 static int id = 0;
528540 SPOOL *sp;
550562
551563 #ifdef __STDC__
552564 void
553 spool_stop (SPOOL *sp)
554 #else
555 void
556 spool_stop (sp)
557 SPOOL *sp;
558 #endif
559 {
560 timer_block ();
565 spool_stop(SPOOL *sp)
566 #else
567 void
568 spool_stop(sp)
569 SPOOL *sp;
570 #endif
571 {
572 timer_block();
561573 switch (sp->state)
562574 {
563575 case SPOOL_PLAY:
573585 }
574586 if (sp->notify_position)
575587 {
576 connection_notify (0, NOTIFY_POSITION, sp);
588 connection_notify(0, NOTIFY_POSITION, sp);
577589 sp->notify_position = 0;
578590 }
579 connection_notify (0, NOTIFY_STOP, sp);
580 connection_notify (0, NOTIFY_DONE, sp);
581 spool_destroy (sp);
591 connection_notify(0, NOTIFY_STOP, sp);
592 connection_notify(0, NOTIFY_DONE, sp);
593 spool_destroy(sp);
582594 break;
583595 }
584 timer_unblock ();
585 }
586
587 #ifdef __STDC__
588 void
589 spool_pause (SPOOL *sp)
590 #else
591 void
592 spool_pause (sp)
593 SPOOL *sp;
594 #endif
595 {
596 timer_block ();
596 timer_unblock();
597 }
598
599 #ifdef __STDC__
600 void
601 spool_pause(SPOOL *sp)
602 #else
603 void
604 spool_pause(sp)
605 SPOOL *sp;
606 #endif
607 {
608 timer_block();
597609 if (sp->state == SPOOL_PLAY)
598610 {
599611 sp->state = SPOOL_PAUSE;
601613 spool_npaused++;
602614 if (sp->notify_position)
603615 {
604 connection_notify (0, NOTIFY_POSITION, sp);
616 connection_notify(0, NOTIFY_POSITION, sp);
605617 sp->notify_position = 0;
606618 }
607 connection_notify (0, NOTIFY_PAUSE, sp);
608 }
609 timer_unblock ();
610 }
611
612 #ifdef __STDC__
613 void
614 spool_continue (SPOOL *sp)
615 #else
616 void
617 spool_continue (sp)
618 SPOOL *sp;
619 #endif
620 {
621 timer_block ();
619 connection_notify(0, NOTIFY_PAUSE, sp);
620 }
621 timer_unblock();
622 }
623
624 #ifdef __STDC__
625 void
626 spool_continue(SPOOL *sp)
627 #else
628 void
629 spool_continue(sp)
630 SPOOL *sp;
631 #endif
632 {
633 timer_block();
622634 if (sp->state == SPOOL_PAUSE)
623635 {
624636 sp->state = SPOOL_PLAY;
625637 if (rplay_audio_match)
626638 {
627 rplayd_audio_match (sp);
639 rplayd_audio_match(sp);
628640 }
629641 spool_nplaying++;
630642 spool_npaused--;
631643 spool_needs_update++;
632 connection_notify (0, NOTIFY_CONTINUE, sp);
633 }
634 timer_unblock ();
635 }
636
637 #ifdef __STDC__
638 void
639 spool_done (SPOOL *sp)
640 #else
641 void
642 spool_done (sp)
643 SPOOL *sp;
644 #endif
645 {
646 timer_block ();
644 connection_notify(0, NOTIFY_CONTINUE, sp);
645 }
646 timer_unblock();
647 }
648
649 #ifdef __STDC__
650 void
651 spool_done(SPOOL *sp)
652 #else
653 void
654 spool_done(sp)
655 SPOOL *sp;
656 #endif
657 {
658 timer_block();
647659 switch (sp->state)
648660 {
649661 case SPOOL_PLAY:
651663 case SPOOL_WAIT:
652664 if (sp->si && sp->si->is_flow && sp->state == SPOOL_PLAY)
653665 {
654 sp->si->eof = 1; /* spool_update will deal with this */
666 sp->si->eof = 1; /* spool_update will deal with this */
655667 }
656668 else
657669 {
665677 }
666678 if (sp->notify_position)
667679 {
668 connection_notify (0, NOTIFY_POSITION, sp);
680 connection_notify(0, NOTIFY_POSITION, sp);
669681 sp->notify_position = 0;
670682 }
671 connection_notify (0, NOTIFY_DONE, sp);
672 spool_destroy (sp);
683 connection_notify(0, NOTIFY_DONE, sp);
684 spool_destroy(sp);
673685 }
674686 break;
675687 }
676 timer_unblock ();
677 }
678
679 #ifdef __STDC__
680 void
681 spool_flow_pause (SPOOL *sp)
682 #else
683 void
684 spool_flow_pause (sp)
685 SPOOL *sp;
686 #endif
687 {
688 timer_block ();
688 timer_unblock();
689 }
690
691 #ifdef __STDC__
692 void
693 spool_flow_pause(SPOOL *sp)
694 #else
695 void
696 spool_flow_pause(sp)
697 SPOOL *sp;
698 #endif
699 {
700 timer_block();
689701
690702 if (sp->state == SPOOL_PLAY)
691703 {
693705 spool_nplaying--;
694706 }
695707
696 timer_unblock ();
697 }
698
699 #ifdef __STDC__
700 void
701 spool_flow_continue (SPOOL *sp)
702 #else
703 void
704 spool_flow_continue (sp)
705 SPOOL *sp;
706 #endif
707 {
708 timer_block ();
708 timer_unblock();
709 }
710
711 #ifdef __STDC__
712 void
713 spool_flow_continue(SPOOL *sp)
714 #else
715 void
716 spool_flow_continue(sp)
717 SPOOL *sp;
718 #endif
719 {
720 timer_block();
709721
710722 if (sp->state == SPOOL_WAIT)
711723 {
714726 spool_needs_update++;
715727 }
716728
717 timer_unblock ();
729 timer_unblock();
718730 }
719731
720732 #ifdef __STDC__
721733 int
722 spool_flow_insert (SPOOL *sp, BUFFER *b)
734 spool_flow_insert(SPOOL *sp, BUFFER *b)
723735 #else
724736 int
725 spool_flow_insert (sp, b)
737 spool_flow_insert(sp, b)
726738 SPOOL *sp;
727739 BUFFER *b;
728740 #endif
732744
733745 s = sp->sound[sp->curr_sound];
734746 *s->flowp = b;
735 for (tmp_buf = b; tmp_buf->next; tmp_buf = tmp_buf->next);
747 for (tmp_buf = b; tmp_buf->next; tmp_buf = tmp_buf->next) ;
736748 s->flowp = &tmp_buf->next;
737749
738750 /* Enable the sound. */
739751 if (s->status == SOUND_NOT_READY)
740752 {
741753 s->status = SOUND_READY;
742 if (sound_map (s) < 0)
754 if (sound_map(s) < 0)
743755 {
744756 /* Punt - can't determine what type of sound it is. */
745 spool_remove (s);
757 spool_remove(s);
746758 /* spool_remove now deletes the sound - sound_delete (s, 0); */
747759 return -1;
748760 }
749 spool_ready (s);
761 spool_ready(s);
750762 }
751763
752764 for (tmp_buf = b; tmp_buf; tmp_buf = tmp_buf->next)
755767 sp->si->water_mark += tmp_buf->nbytes;
756768 }
757769
758 s->samples = number_of_samples (s, sp->si->water_mark);
770 s->samples = number_of_samples(s, sp->si->water_mark);
759771
760772 /* Wakeup the spool entry. */
761773 if (sp->state == SPOOL_WAIT)
762774 {
763 spool_flow_continue (sp);
775 spool_flow_continue(sp);
764776 }
765777
766778 return 0;
768780
769781 #ifdef __STDC__
770782 void
771 spool_skip (SPOOL *sp, int count)
772 #else
773 void
774 spool_skip (sp, count)
783 spool_skip(SPOOL *sp, int count)
784 #else
785 void
786 spool_skip(sp, count)
775787 SPOOL *sp;
776788 int count;
777789 #endif
778790 {
779791 SOUND *s;
780792
781 timer_block ();
793 timer_block();
782794 s = sp->sound[sp->curr_sound];
783795 /* Only sounds that are playing or paused can be skipped.
784796 Flows can't be skipped right now. */
793805 sp->state = SPOOL_SKIP;
794806 sp->skip_count = count;
795807 spool_needs_update++;
796 connection_notify (0, NOTIFY_SKIP, sp);
797 }
798 timer_unblock ();
799 }
800
801 #ifdef __STDC__
802 void
803 spool_play (SPOOL *sp)
804 #else
805 void
806 spool_play (sp)
808 connection_notify(0, NOTIFY_SKIP, sp);
809 }
810 timer_unblock();
811 }
812
813 #ifdef __STDC__
814 void
815 spool_play(SPOOL *sp)
816 #else
817 void
818 spool_play(sp)
807819 SPOOL *sp;
808820 #endif
809821 {
817829 {
818830 char name_buf[MAXPATHLEN];
819831 char *p;
820
821 strncpy (name_buf, sp->curr_attrs->sound, sizeof(name_buf));
822 p = strchr (name_buf, ':');
832
833 strncpy(name_buf, sp->curr_attrs->sound, sizeof(name_buf));
834 p = strchr(name_buf, ':');
823835 if (p == NULL)
824836 {
825 report (REPORT_DEBUG, "spool_play: can't parse cdrom name `%s'\n", s->name);
837 report(REPORT_DEBUG, "spool_play: can't parse cdrom name `%s'\n", s->name);
826838 return;
827839 }
828840 *p++ = '\0';
829841
830 if (strchr (p, '-'))
831 {
832 p = strtok (p, "-");
842 if (strchr(p, '-'))
843 {
844 p = strtok(p, "-");
833845 if (p)
834846 {
835 s->starting_track = atoi (p);
836 p = strtok (NULL, "");
847 s->starting_track = atoi(p);
848 p = strtok(NULL, "");
837849 if (p)
838850 {
839 s->ending_track = atoi (p);
851 s->ending_track = atoi(p);
840852 }
841853 }
842854 }
843855 else
844856 {
845 s->starting_track = atoi (p);
846 s->ending_track = atoi (p);
847 }
848 }
849 #endif /* HAVE_CDROM */
850
851 sp->si = sound_open (s, 1);
857 s->starting_track = atoi(p);
858 s->ending_track = atoi(p);
859 }
860 }
861 #endif /* HAVE_CDROM */
862
863 sp->si = sound_open(s, 1);
852864 if (sp->si == NULL)
853865 {
854 spool_destroy (sp);
866 spool_destroy(sp);
855867 return;
856868 }
857869
858 sound_seek (sp->si, s->offset, SEEK_SET); /* skip the audio header */
870 sound_seek(sp->si, s->offset, SEEK_SET); /* skip the audio header */
859871
860872 sp->curr_buffer = NULL;
861873 sp->next_buffer = NULL;
863875 sp->to_native = native_table[s->format].to_native[s->byte_order - 1];
864876
865877
866 spool_set_sample_rate (sp,
867 (sp->curr_attrs->sample_rate == RPLAY_DEFAULT_SAMPLE_RATE)
868 ? s->sample_rate : sp->curr_attrs->sample_rate);
878 spool_set_sample_rate(sp,
879 (sp->curr_attrs->sample_rate == RPLAY_DEFAULT_SAMPLE_RATE)
880 ? s->sample_rate : sp->curr_attrs->sample_rate);
869881
870882 /* Change the state to SPOOL_PLAY when ALL fields have been assigned. */
871883 sp->state = SPOOL_PLAY;
872
884
873885 spool_nplaying++;
874 spool_setprio ();
886 spool_setprio();
875887 spool_needs_update++;
876 connection_notify (0, NOTIFY_PLAY, sp);
877 connection_notify (0, NOTIFY_POSITION, sp);
888 connection_notify(0, NOTIFY_PLAY, sp);
889 connection_notify(0, NOTIFY_POSITION, sp);
878890
879891 if (sp->auto_pause)
880892 {
881 spool_pause (sp);
893 spool_pause(sp);
882894 sp->auto_pause = 0;
883895 }
884896 }
885897
886898 #ifdef __STDC__
887899 void
888 spool_update (void)
889 #else
890 void
891 spool_update ()
900 spool_update(void)
901 #else
902 void
903 spool_update()
892904 #endif
893905 {
894906 int i, n;
896908 SOUND *s;
897909 BUFFER *b;
898910 time_t now;
899
911
900912 spool_needs_update = 0;
901 now = time (0);
902
913 now = time(0);
914
903915 for (sp = spool; sp; sp = sp_next)
904916 {
905917 sp_next = sp->next; /* sp may be destroyed */
916928 case SPOOL_NEXT:
917929 if (sp->notify_position)
918930 {
919 connection_notify (0, NOTIFY_POSITION, sp);
931 connection_notify(0, NOTIFY_POSITION, sp);
920932 sp->notify_position = 0;
921933 }
922
934
923935 if (!sp->auto_pause) /* something was playing */
924936 {
925937 spool_nplaying--;
926938 }
927
939
928940 if (sp->si)
929941 {
930 sound_close (sp->si);
942 sound_close(sp->si);
931943 sp->si = NULL;
932944 }
933 buffer_dealloc (sp->curr_buffer, 0);
934 buffer_dealloc (sp->next_buffer, 0);
945 buffer_dealloc(sp->curr_buffer, 0);
946 buffer_dealloc(sp->next_buffer, 0);
935947 sp->curr_buffer = NULL;
936948 sp->next_buffer = NULL;
937949 sp->offset = 0;
939951 if (sp->state == SPOOL_SKIP)
940952 {
941953 /* The current sound is now `done'. */
942 connection_notify (0, NOTIFY_DONE, sp);
943
954 connection_notify(0, NOTIFY_DONE, sp);
955
944956 if (sp->skip_count == 0)
945957 {
946958 sp->curr_count++; /* "play it again Sam" */
10011013 sp->curr_attrs = sp->rp->attrs;
10021014 sp->curr_sound = 0;
10031015 }
1004 else /* The spool entry is finished. */
1005 {
1006 if (sp->state != SPOOL_SKIP) /* already sent `done' */
1016 else
1017 /* The spool entry is finished. */
1018 {
1019 if (sp->state != SPOOL_SKIP) /* already sent `done' */
10071020 {
1008 connection_notify (0, NOTIFY_DONE, sp);
1021 connection_notify(0, NOTIFY_DONE, sp);
10091022 }
10101023
1011 spool_destroy (sp);
1024 spool_destroy(sp);
10121025 continue;
10131026 }
10141027 }
10351048
10361049 sp->curr_count = sp->curr_attrs->count;
10371050 }
1038 spool_play (sp);
1051 spool_play(sp);
10391052 /* break; */
10401053
10411054 case SPOOL_PLAY:
10441057 {
10451058 s = sp->sound[sp->curr_sound];
10461059
1047 #ifdef HAVE_OSS
1048 b = buffer_alloc (MIN (s->sample_rate * s->output_sample_size, SOUND_FILL_SIZE),
1049 BUFFER_REUSE);
1050 #else
1051 b = buffer_alloc (MIN (MAX (curr_bufsize * curr_rate,
1052 s->sample_rate * s->output_sample_size),
1053 SOUND_FILL_SIZE),
1054 BUFFER_REUSE);
1055 #endif
1056
1057 n = sound_fill (sp->si, b, 0);
1058
1060 #ifdef HAVE_OSS
1061 b = buffer_alloc(MIN(s->sample_rate * s->output_sample_size, SOUND_FILL_SIZE),
1062 BUFFER_REUSE);
1063 #else
1064 b = buffer_alloc(MIN(MAX(curr_bufsize * curr_rate,
1065 s->sample_rate * s->output_sample_size),
1066 SOUND_FILL_SIZE),
1067 BUFFER_REUSE);
1068 #endif
1069
1070 n = sound_fill(sp->si, b, 0);
1071
10591072 if (n <= 0)
10601073 {
1061 buffer_dealloc (b, 1);
1074 buffer_dealloc(b, 1);
10621075
10631076 if (s->needs_helper)
10641077 {
10661079 {
10671080 if (sp->si->eof)
10681081 {
1069 sound_close (sp->si);
1070 sp->si = NULL; /* rplayd_write will see this as a dead sound */
1082 sound_close(sp->si);
1083 sp->si = NULL; /* rplayd_write will see this as a dead sound */
10711084 spool_needs_update++;
10721085 }
10731086 else
10741087 {
1075 spool_flow_pause (sp);
1088 spool_flow_pause(sp);
10761089 }
10771090 }
10781091 }
10791092 else if (s->type == SOUND_FILE)
10801093 {
1081 sound_close (sp->si);
1082 sp->si = NULL; /* rplayd_write will see this as a dead sound */
1094 sound_close(sp->si);
1095 sp->si = NULL; /* rplayd_write will see this as a dead sound */
10831096 }
10841097 else if (s->type == SOUND_FLOW)
10851098 {
10871100 {
10881101 if (sp->si->eof)
10891102 {
1090 sound_close (sp->si);
1091 sp->si = NULL; /* rplayd_write will see this as a dead sound */
1103 sound_close(sp->si);
1104 sp->si = NULL; /* rplayd_write will see this as a dead sound */
10921105 spool_needs_update++;
10931106 }
10941107 else
10951108 {
1096 spool_flow_pause (sp);
1109 spool_flow_pause(sp);
10971110 }
10981111 }
10991112 }
11041117 {
11051118 if (sp->si->eof)
11061119 {
1107 sound_close (sp->si);
1108 sp->si = NULL; /* rplayd_write will see this as a dead sound */
1120 sound_close(sp->si);
1121 sp->si = NULL; /* rplayd_write will see this as a dead sound */
11091122 spool_needs_update++;
11101123 }
11111124 else
11121125 {
1113 spool_flow_pause (sp);
1126 spool_flow_pause(sp);
11141127 }
11151128 }
11161129 #endif /* HAVE_CDROM */
11191132 else
11201133 {
11211134 sp->time = now;
1122
1135
11231136 if (!sp->curr_buffer)
11241137 {
1125 timer_block ();
1138 timer_block();
11261139 sp->ptr = (unsigned char *) b->buf + sp->offset;
11271140 sp->ptr_end = (unsigned char *) b->buf + b->nbytes;
11281141 sp->curr_buffer = b;
1129 timer_unblock ();
1142 timer_unblock();
11301143 }
11311144 else
11321145 {
11331146 sp->next_buffer = b;
11341147 }
1135
1148
11361149 #ifdef HAVE_HELPERS
11371150 if (s->needs_helper
11381151 && ((sp->si->water_mark - sp->si->offset) < sp->si->low_water_mark))
11391152 {
1140 FD_SET (sp->si->fd, &read_mask);
1153 FD_SET(sp->si->fd, &read_mask);
11411154 }
11421155 #else
11431156 if (0)
11461159 }
11471160 #endif /* HAVE_HELPERS */
11481161 else if (s->type == SOUND_FLOW
1149 && ((sp->si->water_mark - sp->si->offset) < sp->si->low_water_mark))
1150 {
1151 connection_notify (0, NOTIFY_FLOW, sp);
1152 connection_flow_continue (sp);
1162 && ((sp->si->water_mark - sp->si->offset) < sp->si->low_water_mark))
1163 {
1164 connection_notify(0, NOTIFY_FLOW, sp);
1165 connection_flow_continue(sp);
11531166 }
11541167 #ifdef HAVE_CDROM
11551168 else if (s->type == SOUND_CDROM
11561169 && ((sp->si->water_mark - sp->si->offset) < sp->si->low_water_mark))
11571170 {
1158 FD_SET (sp->si->fd, &read_mask);
1171 FD_SET(sp->si->fd, &read_mask);
11591172 }
11601173 #endif /* HAVE_CDROM */
11611174 }
11671180
11681181 #ifdef __STDC__
11691182 int
1170 spool_process (char *buf, int nbytes)
1183 spool_process(char *buf, int nbytes)
11711184 #else
11721185 int
1173 spool_process (buf, nbytes)
1186 spool_process(buf, nbytes)
11741187 char *buf;
11751188 int nbytes;
11761189 #endif
11821195 /* Determine the number of samples that need to be processed. */
11831196 nsamples = nbytes / ((rplay_audio_precision >> 3) * rplay_audio_channels);
11841197
1185 zero_native (rplay_audio_buf, nsamples, rplay_audio_channels);
1186
1198 zero_native(rplay_audio_buf, nsamples, rplay_audio_channels);
1199
11871200 for (sp = spool; sp; sp = sp_next)
11881201 {
11891202 sp_next = sp->next;
12001213 }
12011214 /* See if more buffers need to be filled by `spool_update'. */
12021215 else if (sp->curr_buffer == NULL ||
1203 (sp->si && !sp->si->eof && !sp->next_buffer))
1216 (sp->si && !sp->si->eof && !sp->next_buffer))
12041217 {
12051218 spool_needs_update++;
12061219 }
12121225 if (number_playing)
12131226 {
12141227 #ifdef TEST_FLANGE
1215 flange (rplay_audio_buf, nsamples, rplay_audio_channels);
1228 flange(rplay_audio_buf, nsamples, rplay_audio_channels);
12161229 #endif
12171230
12181231 #ifdef FAKE_VOLUME
1219 fake_volume (rplay_audio_buf, nsamples, rplay_audio_channels);
1220 #endif
1221
1232 fake_volume(rplay_audio_buf, nsamples, rplay_audio_channels);
1233 #endif
1234
12221235 /* Only calculate left and right levels if there's a connection
12231236 that needs the information. */
12241237 if (connection_want_level_notify)
12251238 {
1226 level (rplay_audio_buf, nsamples, rplay_audio_channels);
1227 connection_level_notify++;
1239 level(rplay_audio_buf, nsamples, rplay_audio_channels);
1240 connection_level_notify++;
12281241 }
12291242
12301243 /* Convert rplay_audio_buf to the audio device format. */
12371250
12381251 #ifdef __STDC__
12391252 SPOOL *
1240 spool_find (int id)
1253 spool_find(int id)
12411254 #else
12421255 SPOOL *
1243 spool_find (id)
1256 spool_find(id)
12441257 int id;
12451258 #endif
12461259 {
12471260 SPOOL *sp;
1248
1261
12491262 for (sp = spool; sp; sp = sp->next)
12501263 {
12511264 if (sp->id == id)
12601273 /* This routine can be used to remove idle flows from the spool. */
12611274 #ifdef __STDC__
12621275 void
1263 spool_cleanup (void)
1264 #else
1265 void
1266 spool_cleanup ()
1276 spool_cleanup(void)
1277 #else
1278 void
1279 spool_cleanup()
12671280 #endif
12681281 {
12691282 SPOOL *sp;
12701283 int flows_cleaned = 0;
1271
1284
12721285 for (sp = spool; sp; sp = sp->next)
12731286 {
12741287 if (sp->state == SPOOL_WAIT
12751288 && sp->sound[sp->curr_sound]->type == SOUND_FLOW)
12761289 {
1277 spool_done (sp);
1290 spool_done(sp);
12781291 flows_cleaned++;
12791292 }
12801293 }
12811294
1282 report (REPORT_DEBUG, "cleaning up the spool - %d flows\n",
1283 flows_cleaned);
1284 }
1285
1286 #ifdef __STDC__
1287 void
1288 spool_set_count (SPOOL *sp, int count)
1289 #else
1290 void
1291 spool_set_count (sp, count)
1295 report(REPORT_DEBUG, "cleaning up the spool - %d flows\n",
1296 flows_cleaned);
1297 }
1298
1299 #ifdef __STDC__
1300 void
1301 spool_set_count(SPOOL *sp, int count)
1302 #else
1303 void
1304 spool_set_count(sp, count)
12921305 SPOOL *sp;
12931306 int count;
12941307 #endif
13021315
13031316 #ifdef __STDC__
13041317 void
1305 spool_set_list_count (SPOOL *sp, int count)
1306 #else
1307 void
1308 spool_set_list_count (sp, count)
1318 spool_set_list_count(SPOOL *sp, int count)
1319 #else
1320 void
1321 spool_set_list_count(sp, count)
13091322 SPOOL *sp;
13101323 int count;
13111324 #endif
13191332
13201333 #ifdef __STDC__
13211334 void
1322 spool_set_priority (SPOOL *sp, int priority)
1323 #else
1324 void
1325 spool_set_priority (sp, priority)
1335 spool_set_priority(SPOOL *sp, int priority)
1336 #else
1337 void
1338 spool_set_priority(sp, priority)
13261339 SPOOL *sp;
13271340 int priority;
13281341 #endif
13301343 if (sp)
13311344 {
13321345 sp->rp->priority = priority;
1333 spool_setprio ();
1334 }
1335 }
1336
1337 #ifdef __STDC__
1338 void
1339 spool_set_sample_rate (SPOOL *sp, int sample_rate)
1340 #else
1341 void
1342 spool_set_sample_rate (sp, sample_rate)
1346 spool_setprio();
1347 }
1348 }
1349
1350 #ifdef __STDC__
1351 void
1352 spool_set_sample_rate(SPOOL *sp, int sample_rate)
1353 #else
1354 void
1355 spool_set_sample_rate(sp, sample_rate)
13431356 SPOOL *sp;
13441357 int sample_rate;
13451358 #endif
13521365
13531366 if (rplay_audio_match)
13541367 {
1355 rplayd_audio_match (sp);
1356 }
1357 }
1358 }
1359
1360 #ifdef __STDC__
1361 void
1362 spool_set_volume (SPOOL *sp, int volume)
1363 #else
1364 void
1365 spool_set_volume (sp, volume)
1368 rplayd_audio_match(sp);
1369 }
1370 }
1371 }
1372
1373 #ifdef __STDC__
1374 void
1375 spool_set_volume(SPOOL *sp, int volume)
1376 #else
1377 void
1378 spool_set_volume(sp, volume)
13661379 SPOOL *sp;
13671380 int volume;
13681381 #endif
13751388
13761389 #ifdef __STDC__
13771390 void
1378 spool_set_client_data (SPOOL *sp, char *client_data)
1379 #else
1380 void
1381 spool_set_client_data (sp, client_data)
1391 spool_set_client_data(SPOOL *sp, char *client_data)
1392 #else
1393 void
1394 spool_set_client_data(sp, client_data)
13821395 SPOOL *sp;
13831396 char *client_data;
13841397 #endif
13871400 {
13881401 if (*sp->curr_attrs->client_data)
13891402 {
1390 free ((char *) sp->curr_attrs->client_data);
1391 }
1392
1393 sp->curr_attrs->client_data = strdup (client_data);
1403 free((char *) sp->curr_attrs->client_data);
1404 }
1405
1406 sp->curr_attrs->client_data = strdup(client_data);
13941407 }
13951408 }
13961409
13971410 #ifdef __STDC__
13981411 SPOOL *
1399 spool_find_pid (int pid)
1412 spool_find_pid(int pid)
14001413 #else
14011414 SPOOL *
1402 spool_find_pid (pid)
1415 spool_find_pid(pid)
14031416 int pid;
14041417 #endif
14051418 {
14061419 SPOOL *sp;
1407
1420
14081421 #if defined(HAVE_CDROM) || defined(HAVE_HELPERS)
14091422 for (sp = spool; sp; sp = sp->next)
14101423 {
0 /* $Id: spool.h,v 1.2 1998/08/13 06:14:08 boyns Exp $ */
0 /* $Id: spool.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: timer.c,v 1.2 1998/08/13 06:14:09 boyns Exp $ */
0 /* $Id: timer.c,v 1.4 1999/03/10 07:58:04 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifdef HAVE_CONFIG_H
2624 #include "config.h"
3836 int timer_enabled = 0;
3937
4038 void
41 timer_update ()
39 timer_update()
4240 {
4341 #ifdef HAVE_OSS
44 int bytes = rplay_audio_getospace_bytes ();
42 int bytes = rplay_audio_getospace_bytes();
4543 /* check bytes and sample size? */
4644 if (bytes > 0)
4745 {
48 rplayd_write (bytes);
46 rplayd_write(bytes);
4947 }
5048 /* if audio device isn't open, just pretend to keep spool going */
51 else if (!rplay_audio_isopen ())
49 else if (!rplay_audio_isopen())
5250 {
5351 /* approximate the amount to be written */
5452 int sample_size = (rplay_audio_precision >> 3) * rplay_audio_channels;
55 rplayd_write (rplay_audio_sample_rate / curr_rate * sample_size);
53 rplayd_write(rplay_audio_sample_rate / curr_rate * sample_size);
5654 }
57 #else
58 rplayd_write (curr_bufsize);
55 #else
56 rplayd_write(curr_bufsize);
5957 #endif
60
58
6159 timer_count += timer_rate;
6260 }
6361
6462 void
65 timer_init ()
63 timer_init()
6664 {
6765 struct sigaction sa;
6866
7169 #if defined(SA_RESTART) && ! defined(sgi)
7270 sa.sa_flags |= SA_RESTART;
7371 #endif
74 sigemptyset (&sa.sa_mask);
75 sigaddset (&sa.sa_mask, SIGALRM);
76 if (sigaction (SIGALRM, &sa, (struct sigaction *) NULL) < 0)
72 sigemptyset(&sa.sa_mask);
73 sigaddset(&sa.sa_mask, SIGALRM);
74 if (sigaction(SIGALRM, &sa, (struct sigaction *) NULL) < 0)
7775 {
78 report (REPORT_ERROR, "timer_init: sigaction: %s\n", sys_err_str (errno));
79 done (1);
76 report(REPORT_ERROR, "timer_init: sigaction: %s\n", sys_err_str(errno));
77 done(1);
8078 }
8179
8280 timer_enabled = 0;
8381 }
8482
8583 void
86 timer_block ()
84 timer_block()
8785 {
8886 sigset_t sigset;
8987
90 sigemptyset (&sigset);
91 sigaddset (&sigset, SIGALRM);
88 sigemptyset(&sigset);
89 sigaddset(&sigset, SIGALRM);
9290
93 if (sigprocmask (SIG_BLOCK, &sigset, NULL) < 0)
91 if (sigprocmask(SIG_BLOCK, &sigset, NULL) < 0)
9492 {
95 report (REPORT_ERROR, "timer_block: sigsetprocmask: %s\n", sys_err_str (errno));
96 done (1);
93 report(REPORT_ERROR, "timer_block: sigsetprocmask: %s\n", sys_err_str(errno));
94 done(1);
9795 }
9896 }
9997
10098 void
101 timer_unblock ()
99 timer_unblock()
102100 {
103101 sigset_t sigset;
104102
105 sigemptyset (&sigset);
106 sigaddset (&sigset, SIGALRM);
103 sigemptyset(&sigset);
104 sigaddset(&sigset, SIGALRM);
107105
108 if (sigprocmask (SIG_UNBLOCK, &sigset, NULL) < 0)
106 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL) < 0)
109107 {
110 report (REPORT_ERROR, "timer_block: sigsetprocmask: %s\n", sys_err_str (errno));
111 done (1);
108 report(REPORT_ERROR, "timer_block: sigsetprocmask: %s\n", sys_err_str(errno));
109 done(1);
112110 }
113111 }
114112
115113 #ifdef __STDC__
116114 void
117 timer_restart (int new_rate)
115 timer_restart(int new_rate)
118116 #else
119117 void
120 timer_restart (new_rate)
118 timer_restart(new_rate)
121119 int new_rate;
122120 #endif
123121 {
127125
128126 if (new_rate <= 0)
129127 {
130 report (REPORT_ERROR, "timer_restart: new_rate=%d, must be >= 1\n", new_rate);
131 done (1);
128 report(REPORT_ERROR, "timer_restart: new_rate=%d, must be >= 1\n", new_rate);
129 done(1);
132130 }
133131 else if (new_rate == 1)
134132 {
141139 it.it_interval.tv_usec = 1000000 / new_rate;
142140 }
143141 it.it_value = it.it_interval;
144 if (setitimer (ITIMER_REAL, &it, NULL) < 0)
142 if (setitimer(ITIMER_REAL, &it, NULL) < 0)
145143 {
146 report (REPORT_ERROR, "timer_restart: setitimer: %s\n", sys_err_str (errno));
147 done (1);
144 report(REPORT_ERROR, "timer_restart: setitimer: %s\n", sys_err_str(errno));
145 done(1);
148146 }
149147
150148 if (it.it_interval.tv_sec)
159157
160158 #ifdef __STDC__
161159 void
162 timer_start (int new_rate)
160 timer_start(int new_rate)
163161 #else
164162 void
165 timer_start (new_rate)
163 timer_start(new_rate)
166164 int new_rate;
167165 #endif
168166 {
169 timer_restart (new_rate);
167 timer_restart(new_rate);
170168 }
171169
172170 void
173 timer_stop ()
171 timer_stop()
174172 {
175173 struct itimerval it;
176174
179177 it.it_interval.tv_sec = 0;
180178 it.it_interval.tv_usec = 0;
181179 it.it_value = it.it_interval;
182 if (setitimer (ITIMER_REAL, &it, NULL) < 0)
180 if (setitimer(ITIMER_REAL, &it, NULL) < 0)
183181 {
184 report (REPORT_ERROR, "timer_stop: setitimer: %s\n", sys_err_str (errno));
185 done (1);
182 report(REPORT_ERROR, "timer_stop: setitimer: %s\n", sys_err_str(errno));
183 done(1);
186184 }
187185 }
0 /* $Id: timer.h,v 1.2 1998/08/13 06:14:10 boyns Exp $ */
0 /* $Id: timer.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: ulaw.c,v 1.2 1998/08/13 06:14:11 boyns Exp $ */
0 /* $Id: ulaw.c,v 1.4 1999/03/10 07:58:04 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
2223
2324
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
0 /* $Id: ulaw.h,v 1.2 1998/08/13 06:14:12 boyns Exp $ */
0 /* $Id: ulaw.h,v 1.3 1999/03/10 07:58:05 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
0 /* $Id: xhash.c,v 1.2 1998/08/13 06:14:13 boyns Exp $ */
0 /* $Id: xhash.c,v 1.4 1999/03/10 07:58:05 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
2223
2324
24
2525 #ifdef HAVE_CONFIG_H
2626 #include "config.h"
2727 #endif
3939
4040 #ifdef DEBUG
4141 static void
42 xhash_stats ()
42 xhash_stats()
4343 {
4444 int statbuf[HASH_STATLENGTH];
45 hash_say (htable, statbuf, HASH_STATLENGTH);
46 printf (" %d size, %d read, %d write, %d collisions, %d used\n",
47 statbuf[1], statbuf[2], statbuf[3], statbuf[4], statbuf[5]);
45 hash_say(htable, statbuf, HASH_STATLENGTH);
46 printf(" %d size, %d read, %d write, %d collisions, %d used\n",
47 statbuf[1], statbuf[2], statbuf[3], statbuf[4], statbuf[5]);
4848 }
4949 #endif
5050
5151 #ifdef __STDC__
5252 void
53 xhash_init (int hash_table_size)
53 xhash_init(int hash_table_size)
5454 #else
5555 void
56 xhash_init (hash_table_size)
56 xhash_init(hash_table_size)
5757 int hash_table_size;
5858 #endif
5959 {
60 htable = hash_new ();
60 htable = hash_new();
6161 }
6262
6363 #ifdef __STDC__
6464 char *
65 xhash_get (char *hash_key)
65 xhash_get(char *hash_key)
6666 #else
6767 char *
68 xhash_get (hash_key)
68 xhash_get(hash_key)
6969 char *hash_key;
7070 #endif
7171 {
72 return (char *) hash_find (htable, hash_key);
72 return (char *) hash_find(htable, hash_key);
7373 }
7474
7575 #ifdef __STDC__
7676 void
77 xhash_put (char *hash_key, char *data)
77 xhash_put(char *hash_key, char *data)
7878 #else
7979 void
80 xhash_put (hash_key, data)
80 xhash_put(hash_key, data)
8181 char *hash_key;
8282 char *data;
8383 #endif
8484 {
85 hash_insert (htable, hash_key, data);
85 hash_insert(htable, hash_key, data);
8686 }
8787
8888 #ifdef __STDC__
8989 void
90 xhash_replace (char *hash_key, char *data)
90 xhash_replace(char *hash_key, char *data)
9191 #else
9292 void
93 xhash_replace (hash_key, data)
93 xhash_replace(hash_key, data)
9494 char *hash_key;
9595 char *data;
9696 #endif
9797 {
98 hash_replace (htable, hash_key, data);
98 hash_replace(htable, hash_key, data);
9999 }
100100
101101 #ifdef __STDC__
102102 void
103 xhash_delete (char *hash_key)
103 xhash_delete(char *hash_key)
104104 #else
105105 void
106 xhash_delete (hash_key)
106 xhash_delete(hash_key)
107107 char *hash_key;
108108 #endif
109109 {
110 hash_delete (htable, hash_key);
110 hash_delete(htable, hash_key);
111111 }
112112
113113 /*
115115 */
116116 #ifdef __STDC__
117117 char *
118 xhash_name (char *pathname)
118 xhash_name(char *pathname)
119119 #else
120120 char *
121 xhash_name (pathname)
121 xhash_name(pathname)
122122 char *pathname;
123123 #endif
124124 {
127127
128128 if (pathname[0] == '/')
129129 {
130 pathname = strrchr (pathname, '/') + 1;
130 pathname = strrchr(pathname, '/') + 1;
131131 }
132132
133 strncpy (name, pathname, sizeof(name));
134 extension = strrchr (name, '.');
133 strncpy(name, pathname, sizeof(name));
134 extension = strrchr(name, '.');
135135 if (extension)
136136 {
137137 *extension = '\0';
142142
143143 #ifdef __STDC__
144144 void
145 xhash_apply (char *(*func) ())
145 xhash_apply(char *(*func) ())
146146 #else
147147 void
148 xhash_apply (func)
148 xhash_apply(func)
149149 char *(*func) ();
150150 #endif
151151 {
152 hash_apply (htable, func);
152 hash_apply(htable, func);
153153 }
154154
155155 void
156 xhash_die ()
156 xhash_die()
157157 {
158 hash_die (htable);
158 hash_die(htable);
159159 }
0 /* $Id: xhash.h,v 1.2 1998/08/13 06:14:14 boyns Exp $ */
0 /* $Id: xhash.h,v 1.3 1999/03/10 07:58:05 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
+0
-3
rptp/CVS/Entries less more
0 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998//
1 /rptp.c/1.2/Thu Aug 13 06:14:28 1998//
2 D
+0
-1
rptp/CVS/Repository less more
0 /usr/local/cvsroot/rplay/rptp
+0
-1
rptp/CVS/Root less more
0 /usr/local/cvsroot
1212 .c.o:
1313 $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
1414
15 LDFLAGS= $(LD_OPTIONS) -L../librplay -lrplay -L../lib -lrp @LDFLAGS@ @LIBS@
15 LDFLAGS= $(LD_OPTIONS) -L../librplay -lrplay -L../lib -lrp @LDFLAGS@ @RL_LIBS@ @LIBS@
1616
1717 TARGET= rptp
1818
2424
2525 $(TARGET): $(OBJS) ../librplay/$(LIBRPLAY_NAME) ../lib/librp.a
2626 $(CC) -o $@ $(OBJS) $(LDFLAGS)
27
28 ../librplay/$(LIBRPLAY_NAME):
29 (cd ../librplay; $(MAKE) $(MFLAGS))
30
31 ../lib/librp.a:
32 (cd ../lib; $(MAKE) $(MFLAGS))
2733
2834 install: all
2935 $(MKINSTALLDIRS) $(bindir)
0 /* $Id: rptp.c,v 1.2 1998/08/13 06:14:28 boyns Exp $ */
0 /* $Id: rptp.c,v 1.6 1999/03/21 00:45:08 boyns Exp $ */
11
22 /*
3 * Copyright (C) 1993-98 Mark R. Boyns <boyns@doit.org>
3 * Copyright (C) 1993-99 Mark R. Boyns <boyns@doit.org>
44 *
55 * This file is part of rplay.
66 *
1919 * Free Software Foundation, Inc.,
2020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
2121 */
22
23
2422
2523 #ifdef HAVE_CONFIG_H
2624 #include "config.h"
3230 #ifdef HAVE_STRING_H
3331 #include <string.h>
3432 #endif
33 #ifdef HAVE_LIBREADLINE
34 #include <readline/readline.h>
35 #include <readline/history.h>
36 #endif /* HAVE_LIBREADLINE */
3537 #include "rplay.h"
3638 #include "getopt.h"
3739
5052 COMMAND;
5153
5254 #ifdef __STDC__
53 void command_open (int argc, char **argv);
54 void command_close (int argc, char **argv);
55 void command_play (int argc, char **argv);
56 void command_help (int argc, char **argv);
57 void command_list (int argc, char **argv);
58 void command_quit (int argc, char **argv);
59 void command_put (int argc, char **argv);
60 void command_get (int argc, char **argv);
61 void command_unknown (int argc, char **argv);
62 void command_status (int argc, char **argv);
63 void command_generic (int argc, char **argv);
64 void command_volume (int argc, char **argv);
65 void command_skip (int argc, char **argv);
66 void argv_to_command (char **argv);
67 int connected ();
68 void done (int exit_value);
69 void usage ();
70 void do_application ();
71 void do_error (char *repsonse);
72 #else
73 void command_open ( /* int argc, char **argv */ );
74 void command_close ( /* int argc, char **argv */ );
75 void command_play ( /* int argc, char **argv */ );
76 void command_help ( /* int argc, char **argv */ );
77 void command_list ( /* int argc, char **argv */ );
78 void command_quit ( /* int argc, char **argv */ );
79 void command_put ( /* int argc, char **argv */ );
80 void command_get ( /* int argc, char **argv */ );
81 void command_unknown ( /* int argc, char **argv */ );
82 void command_status ( /* int argc, char **argv */ );
83 void command_generic ( /* int argc, char **argv */ );
84 void command_volume ( /* int argc, char **argv */ );
85 void command_skip ( /* int argc, char **argv */ );
86 void argv_to_command ( /* char **argv */ );
87 int connected ();
88 void done ( /* int exit_value */ );
89 void usage ();
90 void do_application ();
91 void do_error ( /* char *repsonse */ );
55 void command_open(int argc, char **argv);
56 void command_close(int argc, char **argv);
57 void command_play(int argc, char **argv);
58 void command_help(int argc, char **argv);
59 void command_list(int argc, char **argv);
60 void command_quit(int argc, char **argv);
61 void command_put(int argc, char **argv);
62 void command_get(int argc, char **argv);
63 void command_unknown(int argc, char **argv);
64 void command_set(int argc, char **argv);
65 void command_status(int argc, char **argv);
66 void command_generic(int argc, char **argv);
67 void command_volume(int argc, char **argv);
68 void command_skip(int argc, char **argv);
69 void command_set(int argc, char **argv);
70 void command_monitor(int argc, char **argv);
71 void argv_to_command(char **argv);
72 int connected();
73 void done(int exit_value);
74 void usage();
75 void do_application();
76 void do_error(char *repsonse);
77 #else
78 void command_open( /* int argc, char **argv */ );
79 void command_close( /* int argc, char **argv */ );
80 void command_play( /* int argc, char **argv */ );
81 void command_help( /* int argc, char **argv */ );
82 void command_list( /* int argc, char **argv */ );
83 void command_quit( /* int argc, char **argv */ );
84 void command_put( /* int argc, char **argv */ );
85 void command_get( /* int argc, char **argv */ );
86 void command_unknown( /* int argc, char **argv */ );
87 void command_status( /* int argc, char **argv */ );
88 void command_generic( /* int argc, char **argv */ );
89 void command_volume( /* int argc, char **argv */ );
90 void command_skip( /* int argc, char **argv */ );
91 void command_set( /* int argc, char **argv */ );
92 void command_monitor( /* int argc, char **argv */ );
93 void argv_to_command( /* char **argv */ );
94 int connected();
95 void done( /* int exit_value */ );
96 void usage();
97 void do_application();
98 void do_error( /* char *repsonse */ );
9299 #endif
93100
94101 COMMAND commands[] =
101108 "help", 0, 1, "[command]", command_help,
102109 "info", 1, 1, "sound", command_generic,
103110 "list", 0, 1, "[connections|hosts|servers|spool|sounds]", command_list,
111 "monitor", 0, 0, "", command_monitor,
104112 "open", 1, 2, "hostname [port]", command_open,
105113 "pause", 1, -1, "#id|sound ...", command_play,
106114 "play", 1, -1, "[options] sound ...", command_play,
107115 "put", 1, 1, "sound", command_put,
108116 "quit", 0, 0, "", command_quit,
109117 "reset", 0, 0, "", command_generic,
118 "set", 1, -1, "name=value", command_set,
110119 "skip", 0, 2, "[#id] [[+|-]count]", command_skip,
111120 "status", 0, 0, "", command_status,
112121 "stop", 1, -1, "#id|sound ...", command_play,
140149 extern char *optarg;
141150
142151 #ifdef __STDC__
143 main (int argc, char **argv)
144 #else
145 main (argc, argv)
152 main(int argc, char **argv)
153 #else
154 main(argc, argv)
146155 int argc;
147156 char **argv;
148157 #endif
155164 int ac, first;
156165 char numeric_string[128];
157166
158 while ((c = getopt_long (argc, argv, "+h:p:rv", longopts, 0)) != -1)
167 while ((c = getopt_long(argc, argv, "+h:p:rv", longopts, 0)) != -1)
159168 {
160169 switch (c)
161170 {
164173 break;
165174
166175 case 1: /* --help */
167 usage ();
168 done (0);
176 usage();
177 done(0);
169178
170179 case 2: /* --prompt */
171180 prompt = optarg;
176185 break;
177186
178187 case 'p':
179 port = atoi (optarg);
188 port = atoi(optarg);
180189 break;
181190
182191 case 'r':
184193 break;
185194
186195 case 'v':
187 printf ("rplay %s\n", RPLAY_VERSION);
188 done (0);
196 printf("rplay %s\n", RPLAY_VERSION);
197 done(0);
189198
190199 default:
191 fprintf (stderr, "Try `rptp --help' for more information.\n");
192 exit (1);
200 fprintf(stderr, "Try `rptp --help' for more information.\n");
201 exit(1);
193202 }
194203 }
195204
200209
201210 if (host == NULL)
202211 {
203 host = rplay_default_host ();
204 }
205
206 rptp_fd = rptp_open (host, port, response, sizeof (response));
212 host = rplay_default_host();
213 }
214
215 rptp_fd = rptp_open(host, port, response, sizeof(response));
207216 if (rptp_fd < 0)
208217 {
209 rptp_perror ("open");
218 rptp_perror("open");
210219 }
211220 else if (interactive)
212221 {
213222 if (raw)
214223 {
215 printf ("%s\n", response);
224 printf("%s\n", response);
216225 }
217226 else
218227 {
219 if (strchr (response, '='))
228 if (strchr(response, '='))
220229 {
221 rptp_parse (response, 0);
222 printf ("%s rplayd %s connected\n",
223 rptp_parse (0, "host"),
224 rptp_parse (0, "version"));
230 rptp_parse(response, 0);
231 printf("%s rplayd %s connected\n",
232 rptp_parse(0, "host"),
233 rptp_parse(0, "version"));
225234 }
226235 else
227236 {
228 printf ("Connected to %s port %d.\n", host, port);
229 printf ("%s\n", response + 1);
237 printf("Connected to %s port %d.\n", host, port);
238 printf("%s\n", response + 1);
230239 }
231240 }
232241 }
233242
234 do_application ();
243 do_application();
235244
236245 do
237246 {
239248 {
240249 if (!raw)
241250 {
242 printf (prompt);
243 fflush (stdout);
251 #ifdef HAVE_LIBREADLINE
252 p = readline(prompt);
253 if (!p)
254 {
255 done(0);
256 }
257 add_history(p);
258 strcpy(buf, p);
259 #else
260 printf(prompt);
261 fflush(stdout);
262 #endif
244263 }
245 if (fgets (buf, sizeof (buf), stdin) == NULL)
264
265 #ifndef HAVE_LIBREADLINE
266 if (fgets(buf, sizeof(buf), stdin) == NULL)
246267 {
247 done (0);
268 done(0);
248269 }
270 #endif
249271 first = 1;
250272 ac = 0;
251 while ((p = strtok (first ? buf : NULL, " \t\r\n")))
273 while ((p = strtok(first ? buf : NULL, " \t\r\n")))
252274 {
253275 av[ac++] = p;
254276 first = 0;
274296
275297 for (i = 0; i < NCOMMANDS; i++)
276298 {
277 if (strcasecmp (commands[i].name, av[0]) == 0)
299 if (strcasecmp(commands[i].name, av[0]) == 0)
278300 {
279301 if ((commands[i].min_args >= 0 && ac - 1 < commands[i].min_args)
280302 || (commands[i].max_args >= 0 && ac - 1 > commands[i].max_args))
281303 {
282 printf ("Usage: %s %s\n", commands[i].name, commands[i].usage);
304 printf("Usage: %s %s\n", commands[i].name, commands[i].usage);
283305 }
284306 else
285307 {
290312 }
291313 if (i == NCOMMANDS)
292314 {
293 command_unknown (ac, av);
315 command_unknown(ac, av);
294316 }
295317 }
296318 while (interactive);
297319
298 done (0);
299 }
300
301 #ifdef __STDC__
302 void
303 argv_to_command (char **argv)
304 #else
305 void
306 argv_to_command (argv)
320 done(0);
321 }
322
323 #ifdef __STDC__
324 void
325 argv_to_command(char **argv)
326 #else
327 void
328 argv_to_command(argv)
307329 char **argv;
308330 #endif
309331 {
310332 command[0] = '\0';
311333 for (; *argv; argv++)
312334 {
313 strcat (command, *argv);
335 strcat(command, *argv);
314336 if (*(argv + 1))
315337 {
316 strcat (command, " ");
338 strcat(command, " ");
317339 }
318340 }
319341 }
320342
321343 int
322 connected ()
344 connected()
323345 {
324346 if (rptp_fd != -1)
325347 {
327349 }
328350 else
329351 {
330 printf ("You're not connected, use `open' first.\n");
352 printf("You're not connected, use `open' first.\n");
331353 return 0;
332354 }
333355 }
334356
335357 #ifdef __STDC__
336358 void
337 command_open (int argc, char **argv)
338 #else
339 void
340 command_open (argc, argv)
359 command_open(int argc, char **argv)
360 #else
361 void
362 command_open(argc, argv)
341363 int argc;
342364 char **argv;
343365 #endif
346368
347369 if (rptp_fd != -1)
348370 {
349 printf ("You're already connected, use `close' first.\n");
371 printf("You're already connected, use `close' first.\n");
350372 }
351373 else
352374 {
353 port = argc == 3 ? atoi (argv[2]) : RPTP_PORT;
354 rptp_fd = rptp_open (argv[1], port, response, sizeof (response));
375 port = argc == 3 ? atoi(argv[2]) : RPTP_PORT;
376 rptp_fd = rptp_open(argv[1], port, response, sizeof(response));
355377 if (rptp_fd < 0)
356378 {
357 rptp_perror ("open");
379 rptp_perror("open");
358380 }
359381 else
360382 {
361383 if (raw)
362384 {
363 printf ("%s\n", response);
385 printf("%s\n", response);
364386 }
365387 else
366388 {
367 if (strchr (response, '='))
389 if (strchr(response, '='))
368390 {
369 printf ("%s rplayd %s connected\n",
370 rptp_parse (response, "host"),
371 rptp_parse (0, "version"));
391 printf("%s rplayd %s connected\n",
392 rptp_parse(response, "host"),
393 rptp_parse(0, "version"));
372394 }
373395 else
374396 {
375 printf ("Connected to %s port %d.\n", argv[1], port);
376 printf ("%s\n", response + 1);
397 printf("Connected to %s port %d.\n", argv[1], port);
398 printf("%s\n", response + 1);
377399 }
378400 }
379 do_application ();
380 }
381 }
382 }
383
384 #ifdef __STDC__
385 void
386 command_close (int argc, char **argv)
387 #else
388 void
389 command_close (argc, argv)
390 int argc;
391 char **argv;
392 #endif
393 {
394 if (connected ())
395 {
396 rptp_close (rptp_fd);
401 do_application();
402 }
403 }
404 }
405
406 #ifdef __STDC__
407 void
408 command_close(int argc, char **argv)
409 #else
410 void
411 command_close(argc, argv)
412 int argc;
413 char **argv;
414 #endif
415 {
416 if (connected())
417 {
418 rptp_close(rptp_fd);
397419 rptp_fd = -1;
398420 if (interactive)
399421 {
400 printf ("Connection closed.\n");
401 }
402 }
403 }
404
405 #ifdef __STDC__
406 void
407 command_play (int argc, char **argv)
408 #else
409 void
410 command_play (argc, argv)
411 int argc;
412 char **argv;
413 #endif
414 {
415 argv_to_command (argv);
416
417 if (!connected ())
418 {
419 return;
420 }
421
422 switch (rptp_command (rptp_fd, command, response, sizeof (response)))
422 printf("Connection closed.\n");
423 }
424 }
425 }
426
427 #ifdef __STDC__
428 void
429 command_play(int argc, char **argv)
430 #else
431 void
432 command_play(argc, argv)
433 int argc;
434 char **argv;
435 #endif
436 {
437 argv_to_command(argv);
438
439 if (!connected())
440 {
441 return;
442 }
443
444 switch (rptp_command(rptp_fd, command, response, sizeof(response)))
423445 {
424446 case -1:
425 rptp_perror (argv[0]);
426 command_close (argc, argv);
447 rptp_perror(argv[0]);
448 command_close(argc, argv);
427449 return;
428450
429451 case 1:
430 do_error (response);
452 do_error(response);
431453 return;
432454
433455 case 0:
436458
437459 if (raw)
438460 {
439 printf ("%s\n", response);
440 }
441 }
442
443 #ifdef __STDC__
444 void
445 command_generic (int argc, char **argv)
446 #else
447 void
448 command_generic (argc, argv)
449 int argc;
450 char **argv;
451 #endif
452 {
453 argv_to_command (argv);
454
455 if (!connected ())
456 {
457 return;
458 }
459
460 switch (rptp_command (rptp_fd, command, response, sizeof (response)))
461 printf("%s\n", response);
462 }
463 }
464
465 #ifdef __STDC__
466 void
467 command_generic(int argc, char **argv)
468 #else
469 void
470 command_generic(argc, argv)
471 int argc;
472 char **argv;
473 #endif
474 {
475 argv_to_command(argv);
476
477 if (!connected())
478 {
479 return;
480 }
481
482 switch (rptp_command(rptp_fd, command, response, sizeof(response)))
461483 {
462484 case -1:
463 rptp_perror (argv[0]);
464 command_close (argc, argv);
485 rptp_perror(argv[0]);
486 command_close(argc, argv);
465487 return;
466488
467489 case 1:
468 do_error (response);
490 do_error(response);
469491 return;
470492
471493 case 0:
472494 break;
473495 }
474496
475 printf ("%s\n", raw ? response : response + 1);
476 }
477
478 #ifdef __STDC__
479 void
480 command_help (int argc, char **argv)
481 #else
482 void
483 command_help (argc, argv)
497 printf("%s\n", raw ? response : response + 1);
498 }
499
500 #ifdef __STDC__
501 void
502 command_help(int argc, char **argv)
503 #else
504 void
505 command_help(argc, argv)
484506 int argc;
485507 char **argv;
486508 #endif
491513 {
492514 for (i = 0; i < NCOMMANDS; i++)
493515 {
494 if (strcasecmp (commands[i].name, argv[1]) == 0)
516 if (strcasecmp(commands[i].name, argv[1]) == 0)
495517 {
496 printf ("Usage: %s %s\n", commands[i].name, commands[i].usage);
518 printf("Usage: %s %s\n", commands[i].name, commands[i].usage);
497519 return;
498520 }
499521 }
500 command_unknown (argc, argv);
522 command_unknown(argc, argv);
501523 }
502524 else
503525 {
504 printf ("access Display remote access permissions.\n");
505 printf ("close Close the current server connection.\n");
506 printf ("continue Continue paused sounds.\n");
507 printf ("find Search for a sound.\n");
508 printf ("get Retrieve a sound.\n");
509 printf ("help Display help information.\n");
510 printf ("info Display sound information.\n");
511 printf ("list Display various server information.\n");
512 printf ("open Connect to a server.\n");
513 printf ("pause Pause sounds that are playing.\n");
514 printf ("play Play sounds\n");
515 printf ("put Send a sound.\n");
516 printf ("quit Terminate the rptp session.\n");
517 printf ("reset Tell the server to reset itself.\n");
518 printf ("skip Skip sounds in a sound list.\n");
519 printf ("status Display server statistics.\n");
520 printf ("stop Stop sounds that are playing.\n");
521 printf ("version Display the version of the server.\n");
522 printf ("volume Get and set the volume of the audio device.\n");
523 printf ("wait Wait for a spool id, volume change, or command execution.\n");
524 }
525 }
526
527 #ifdef __STDC__
528 void
529 command_list (int argc, char **argv)
530 #else
531 void
532 command_list (argc, argv)
526 printf("access Display remote access permissions.\n");
527 printf("close Close the current server connection.\n");
528 printf("continue Continue paused sounds.\n");
529 printf("find Search for a sound.\n");
530 printf("get Retrieve a sound.\n");
531 printf("help Display help information.\n");
532 printf("info Display sound information.\n");
533 printf("list Display various server information.\n");
534 printf("open Connect to a server.\n");
535 printf("pause Pause sounds that are playing.\n");
536 printf("play Play sounds\n");
537 printf("put Send a sound.\n");
538 printf("quit Terminate the rptp session.\n");
539 printf("reset Tell the server to reset itself.\n");
540 printf("set Change server settings.\n");
541 printf("skip Skip sounds in a sound list.\n");
542 printf("status Display server statistics.\n");
543 printf("stop Stop sounds that are playing.\n");
544 printf("version Display the version of the server.\n");
545 printf("volume Get and set the volume of the audio device.\n");
546 printf("wait Wait for a spool id, volume change, or command execution.\n");
547 }
548 }
549
550 #ifdef __STDC__
551 void
552 command_list(int argc, char **argv)
553 #else
554 void
555 command_list(argc, argv)
533556 int argc;
534557 char **argv;
535558 #endif
536559 {
537560 int n;
538561
539 if (!connected ())
540 {
541 return;
542 }
543
544 argv_to_command (argv);
545
546 switch (rptp_command (rptp_fd, command, response, sizeof (response)))
562 if (!connected())
563 {
564 return;
565 }
566
567 argv_to_command(argv);
568
569 switch (rptp_command(rptp_fd, command, response, sizeof(response)))
547570 {
548571 case -1:
549 rptp_perror (argv[0]);
550 command_close (argc, argv);
572 rptp_perror(argv[0]);
573 command_close(argc, argv);
551574 return;
552575
553576 case 1:
554 do_error (response);
577 do_error(response);
555578 return;
556579
557580 case 0:
558581 if (raw)
559582 {
560 printf ("%s\n", response);
583 printf("%s\n", response);
561584 }
562585 break;
563586 }
564587
565588 for (;;)
566589 {
567 n = rptp_getline (rptp_fd, rptp_buf, sizeof (rptp_buf));
590 n = rptp_getline(rptp_fd, rptp_buf, sizeof(rptp_buf));
568591 if (n < 0)
569592 {
570 rptp_perror ("list");
571 command_close (argc, argv);
593 rptp_perror("list");
594 command_close(argc, argv);
572595 break;
573596 }
574 if (strcmp (rptp_buf, ".") == 0)
597 if (strcmp(rptp_buf, ".") == 0)
575598 {
576599 if (raw)
577600 {
578 printf ("%s\n", rptp_buf);
601 printf("%s\n", rptp_buf);
579602 }
580603 break;
581604 }
582 printf ("%s\n", rptp_buf);
583 }
584 }
585
586 #ifdef __STDC__
587 void
588 command_quit (int argc, char **argv)
589 #else
590 void
591 command_quit (argc, argv)
605 printf("%s\n", rptp_buf);
606 }
607 }
608
609 #ifdef __STDC__
610 void
611 command_quit(int argc, char **argv)
612 #else
613 void
614 command_quit(argc, argv)
592615 int argc;
593616 char **argv;
594617 #endif
595618 {
596619 if (rptp_fd != -1)
597620 {
598 rptp_close (rptp_fd);
599 printf ("Connection closed.\n");
600 }
601 done (0);
602 }
603
604 #ifdef __STDC__
605 void
606 command_put (int argc, char **argv)
607 #else
608 void
609 command_put (argc, argv)
621 rptp_close(rptp_fd);
622 printf("Connection closed.\n");
623 }
624 done(0);
625 }
626
627 #ifdef __STDC__
628 void
629 command_put(int argc, char **argv)
630 #else
631 void
632 command_put(argc, argv)
610633 int argc;
611634 char **argv;
612635 #endif
615638 int size, n, nwritten;
616639 struct stat st;
617640 char line[RPTP_MAX_LINE];
618
619 if (!connected ())
620 {
621 return;
622 }
623
624 if (stat (argv[1], &st) < 0)
625 {
626 perror (argv[1]);
627 return;
628 }
629 fp = fopen (argv[1], "r");
641 int total_size;
642
643 if (!connected())
644 {
645 return;
646 }
647
648 if (stat(argv[1], &st) < 0)
649 {
650 perror(argv[1]);
651 return;
652 }
653 fp = fopen(argv[1], "r");
630654 if (fp == NULL)
631655 {
632 perror (argv[1]);
656 perror(argv[1]);
633657 return;
634658 }
635659 size = st.st_size;
636660
637 sprintf (line, "put sound=%s size=%d", argv[1], size);
638
639 switch (rptp_command (rptp_fd, line, response, sizeof (response)))
661 sprintf(line, "put sound=%s size=%d", argv[1], size);
662
663 switch (rptp_command(rptp_fd, line, response, sizeof(response)))
640664 {
641665 case -1:
642 rptp_perror (argv[0]);
643 command_close (argc, argv);
666 rptp_perror(argv[0]);
667 command_close(argc, argv);
644668 return;
645669
646670 case 1:
647 do_error (response);
671 do_error(response);
648672 return;
649673
650674 case 0:
651675 break;
652676 }
653677
654 printf ("%s\n", raw ? response : response + 1);
655
678 if (raw)
679 {
680 printf("%s\n", response);
681 }
682
683 total_size = size;
656684 while (size > 0)
657685 {
658 n = fread (rptp_buf, 1, sizeof (rptp_buf), fp);
659 nwritten = rptp_write (rptp_fd, rptp_buf, n);
686 n = fread(rptp_buf, 1, sizeof(rptp_buf), fp);
687 nwritten = rptp_write(rptp_fd, rptp_buf, n);
660688 if (nwritten != n)
661689 {
662 rptp_perror ("put");
663 command_close (argc, argv);
690 rptp_perror("put");
691 command_close(argc, argv);
664692 break;
665693 }
666694 size -= nwritten;
667 }
668
669 fclose (fp);
670 }
671
672 #ifdef __STDC__
673 void
674 command_get (int argc, char **argv)
675 #else
676 void
677 command_get (argc, argv)
695
696 sprintf(line, "\r%s %d/%d %d%%", argv[1],
697 total_size - size, total_size,
698 (int)(((float)(total_size-size)/total_size)*100));
699 write(2, line, strlen(line));
700 }
701 write(2, "\n", 1);
702 fclose(fp);
703 }
704
705 #ifdef __STDC__
706 void
707 command_get(int argc, char **argv)
708 #else
709 void
710 command_get(argc, argv)
678711 int argc;
679712 char **argv;
680713 #endif
682715 FILE *fp;
683716 char *filename;
684717 char *p;
685 int size, n, nread;
718 int size, n, nread, total_size;
686719 char line[RPTP_MAX_LINE];
687720
688 if (!connected ())
721 if (!connected())
689722 {
690723 return;
691724 }
700733 filename = argv[1];
701734 }
702735
703 sprintf (line, "get sound=%s", argv[1]);
704
705 switch (rptp_command (rptp_fd, line, response, sizeof (response)))
736 sprintf(line, "get sound=%s", argv[1]);
737
738 switch (rptp_command(rptp_fd, line, response, sizeof(response)))
706739 {
707740 case -1:
708 rptp_perror (argv[0]);
709 command_close (argc, argv);
741 rptp_perror(argv[0]);
742 command_close(argc, argv);
710743 return;
711744
712745 case 1:
713 do_error (response);
746 do_error(response);
714747 return;
715748
716749 case 0:
717750 break;
718751 }
719752
720 printf ("%s\n", raw ? response : response + 1);
721
722 fp = fopen (filename, "w");
753 if (raw)
754 printf("%s\n", response);
755
756 fp = fopen(filename, "w");
723757 if (fp == NULL)
724758 {
725 perror (filename);
726 return;
727 }
728
729 if (strchr (response, '='))
730 {
731 size = atoi (rptp_parse (response, "size"));
759 perror(filename);
760 return;
761 }
762
763 if (strchr(response, '='))
764 {
765 size = atoi(rptp_parse(response, "size"));
732766 }
733767 else
734768 {
735 p = strtok (response + 1, " ");
736 size = atoi (strtok (NULL, "\r\n"));
737 }
738
769 p = strtok(response + 1, " ");
770 size = atoi(strtok(NULL, "\r\n"));
771 }
772
773 total_size = size;
739774 while (size > 0)
740775 {
741 n = MIN (sizeof (rptp_buf), size);
742 nread = rptp_read (rptp_fd, rptp_buf, n);
776 n = MIN(sizeof(rptp_buf), size);
777 nread = rptp_read(rptp_fd, rptp_buf, n);
743778 if (nread != n)
744779 {
745 rptp_perror ("get");
780 rptp_perror("get");
746781 break;
747782 }
748 fwrite (rptp_buf, 1, n, fp);
783 fwrite(rptp_buf, 1, n, fp);
749784 size -= n;
750 }
751
752 fclose (fp);
753 }
754
755 #ifdef __STDC__
756 void
757 command_unknown (int argc, char **argv)
758 #else
759 void
760 command_unknown (argc, argv)
761 int argc;
762 char **argv;
763 #endif
764 {
765 printf ("Unknown command `%s'.\n", argv[0]);
766 }
767
768 #ifdef __STDC__
769 void
770 command_status (int argc, char **argv)
771 #else
772 void
773 command_status (argc, argv)
774 int argc;
775 char **argv;
776 #endif
777 {
778 argv_to_command (argv);
779
780 if (!connected ())
781 {
782 return;
783 }
784
785 switch (rptp_command (rptp_fd, command, response, sizeof (response)))
785
786 sprintf(line, "\r%s %d/%d %d%%", filename,
787 total_size - size, total_size,
788 (int)(((float)(total_size-size)/total_size)*100));
789 write(2, line, strlen(line));
790 }
791 write(2, "\n", 1);
792 fclose(fp);
793 }
794
795 #ifdef __STDC__
796 void
797 command_unknown(int argc, char **argv)
798 #else
799 void
800 command_unknown(argc, argv)
801 int argc;
802 char **argv;
803 #endif
804 {
805 printf("unknown command `%s'.\n", argv[0]);
806 }
807
808 #ifdef __STDC__
809 void
810 command_status(int argc, char **argv)
811 #else
812 void
813 command_status(argc, argv)
814 int argc;
815 char **argv;
816 #endif
817 {
818 argv_to_command(argv);
819
820 if (!connected())
821 {
822 return;
823 }
824
825 switch (rptp_command(rptp_fd, command, response, sizeof(response)))
786826 {
787827 case -1:
788 rptp_perror (argv[0]);
789 command_close (argc, argv);
828 rptp_perror(argv[0]);
829 command_close(argc, argv);
790830 return;
791831
792832 case 1:
793 do_error (response);
833 do_error(response);
794834 return;
795835
796836 case 0:
799839
800840 if (raw)
801841 {
802 printf ("%s\n", response);
842 printf("%s\n", response);
803843 }
804844 else
805845 {
806846 int first = 1;
807847 char *name, *value;
808848
809 while (name = rptp_parse (first ? response : 0, 0))
849 while (name = rptp_parse(first ? response : 0, 0))
810850 {
811851 first = 0;
812 value = rptp_parse (0, name);
813 printf ("%s=%s\n", name, value);
814 }
815 }
816 }
817
818 #ifdef __STDC__
819 void
820 command_volume (int argc, char **argv)
821 #else
822 void
823 command_volume (argc, argv)
852 value = rptp_parse(0, name);
853 printf("%s=%s\n", name, value);
854 }
855 }
856 }
857
858 #ifdef __STDC__
859 void
860 command_volume(int argc, char **argv)
861 #else
862 void
863 command_volume(argc, argv)
824864 int argc;
825865 char **argv;
826866 #endif
827867 {
828868 char *volume;
829869
830 if (!connected ())
870 if (!connected())
831871 {
832872 return;
833873 }
834874
835875 if (argc == 2)
836876 {
837 sprintf (command, "set volume=%s", argv[1]);
877 sprintf(command, "set volume=%s", argv[1]);
838878 }
839879 else
840880 {
841 sprintf (command, "set volume");
842 }
843
844 switch (rptp_command (rptp_fd, command, response, sizeof (response)))
881 sprintf(command, "set volume");
882 }
883
884 switch (rptp_command(rptp_fd, command, response, sizeof(response)))
845885 {
846886 case -1:
847 rptp_perror (argv[0]);
848 command_close (argc, argv);
887 rptp_perror(argv[0]);
888 command_close(argc, argv);
849889 return;
850890
851891 case 1:
852 do_error (response);
892 do_error(response);
853893 return;
854894
855895 case 0:
856896 break;
857897 }
858898
859 volume = rptp_parse (response, "volume");
899 volume = rptp_parse(response, "volume");
860900 if (volume && *volume)
861901 {
862 printf ("volume=%s\n", volume);
902 printf("volume=%s\n", volume);
863903 }
864904 else
865905 {
866 printf ("unknown response `%s'\n", response);
867 }
868 }
869
870 #ifdef __STDC__
871 void
872 command_skip (int argc, char **argv)
873 #else
874 void
875 command_skip (argc, argv)
906 printf("unknown response `%s'\n", response);
907 }
908 }
909
910 #ifdef __STDC__
911 void
912 command_skip(int argc, char **argv)
913 #else
914 void
915 command_skip(argc, argv)
876916 int argc;
877917 char **argv;
878918 #endif
879919 {
880920 char *value;
881921
882 if (!connected ())
883 {
884 return;
885 }
886
887 if (strchr (command, '='))
922 if (!connected())
923 {
924 return;
925 }
926
927 if (strchr(command, '='))
888928 {
889929 /* Leave command alone. */
890930 }
891931 else if (argc == 3)
892932 {
893 sprintf (command, "skip id=%s count=%s", argv[1], argv[2]);
933 sprintf(command, "skip id=%s count=%s", argv[1], argv[2]);
894934 }
895935 else if (argc == 2)
896936 {
897 sprintf (command, "skip id=%s count=1", argv[1]);
937 sprintf(command, "skip id=%s count=1", argv[1]);
898938 }
899939 else
900940 {
901 sprintf (command, "skip id=#0 count=1");
902 }
903
904 switch (rptp_command (rptp_fd, command, response, sizeof (response)))
941 sprintf(command, "skip id=#0 count=1");
942 }
943
944 switch (rptp_command(rptp_fd, command, response, sizeof(response)))
905945 {
906946 case -1:
907 rptp_perror (argv[0]);
908 command_close (argc, argv);
947 rptp_perror(argv[0]);
948 command_close(argc, argv);
909949 return;
910950
911951 case 1:
912 do_error (response);
952 do_error(response);
913953 return;
914954
915955 case 0:
916956 break;
917957 }
918958
919 value = rptp_parse (response, "message");
959 value = rptp_parse(response, "message");
920960 if (value && *value)
921961 {
922 printf ("%s\n", value);
962 printf("%s\n", value);
923963 }
924964 else
925965 {
926 printf ("unknown response `%s'\n", response);
927 }
928 }
929
930 void
931 do_application ()
932 {
933 sprintf (command, "set application=\"rptp %s\"", RPLAY_VERSION);
934
935 switch (rptp_command (rptp_fd, command, response, sizeof (response)))
966 printf("unknown response `%s'\n", response);
967 }
968 }
969
970 #ifdef __STDC__
971 void
972 command_set(int argc, char **argv)
973 #else
974 void
975 command_set(argc, argv)
976 int argc;
977 char **argv;
978 #endif
979 {
980 char *value;
981
982 if (!connected())
983 {
984 return;
985 }
986
987 argv_to_command(argv);
988
989 switch (rptp_command(rptp_fd, command, response, sizeof(response)))
936990 {
937991 case -1:
938 rptp_perror ("application");
939 rptp_close (rptp_fd);
940 rptp_fd = -1;
992 rptp_perror(argv[0]);
993 command_close(argc, argv);
941994 return;
942995
943996 case 1:
944 do_error (response);
997 do_error(response);
945998 return;
946999
9471000 case 0:
9511004
9521005 #ifdef __STDC__
9531006 void
954 do_error (char *response)
955 #else
956 void
957 do_error (response)
1007 command_monitor(int argc, char **argv)
1008 #else
1009 void
1010 command_monitor(argc, argv)
1011 int argc;
1012 char **argv;
1013 #endif
1014 {
1015 char *value, *p;
1016 char buf[8192];
1017 char line[80];
1018 int n, size;
1019 int sample_rate, precision, channels, sample_size;
1020
1021 if (!connected())
1022 {
1023 return;
1024 }
1025
1026 sprintf(command, "monitor");
1027
1028 switch (rptp_command(rptp_fd, command, response, sizeof(response)))
1029 {
1030 case -1:
1031 rptp_perror(argv[0]);
1032 command_close(argc, argv);
1033 return;
1034
1035 case 1:
1036 do_error(response);
1037 return;
1038
1039 case 0:
1040 break;
1041 }
1042
1043 p = strtok(rptp_parse(response, "audio-info"), ",");
1044 // input_format
1045
1046 p = strtok(NULL, ",");
1047 if (p) sample_rate = atoi(p);
1048
1049 p = strtok(NULL, ",");
1050 if (p) precision = atoi(p);
1051
1052 p = strtok(NULL, ",");
1053 if (p) channels = atoi(p);
1054
1055 sample_size = precision/8 * channels;
1056
1057 fprintf(stderr, "%dhz %dbit %s\n", sample_rate, precision,
1058 channels == 2 ? "stereo" : "mono");
1059
1060 while ((n = read(rptp_fd, buf, sizeof(buf))) > 0)
1061 {
1062 write(1, buf, n);
1063 size += n;
1064 }
1065 close(rptp_fd);
1066 }
1067
1068 void
1069 do_application()
1070 {
1071 sprintf(command, "set application=\"rptp %s\"", RPLAY_VERSION);
1072
1073 switch (rptp_command(rptp_fd, command, response, sizeof(response)))
1074 {
1075 case -1:
1076 rptp_perror("application");
1077 rptp_close(rptp_fd);
1078 rptp_fd = -1;
1079 return;
1080
1081 case 1:
1082 do_error(response);
1083 return;
1084
1085 case 0:
1086 break;
1087 }
1088 }
1089
1090 #ifdef __STDC__
1091 void
1092 do_error(char *response)
1093 #else
1094 void
1095 do_error(response)
9581096 char *response;
9591097 #endif
9601098 {
9611099 if (raw)
9621100 {
963 printf ("%s\n", response);
1101 printf("%s\n", response);
9641102 }
9651103 else
9661104 {
9671105 char *error;
9681106
969 error = rptp_parse (response, "error");
1107 error = rptp_parse(response, "error");
9701108 if (!error || !*error)
9711109 {
9721110 error = response;
9731111 }
974 printf ("%s\n", error);
975 }
976 }
977
978 void
979 usage ()
980 {
981 printf ("\nrplay %s\n\n", RPLAY_VERSION);
982 printf ("usage: rptp [options] [command]\n");
983 printf ("--help\n");
984 printf ("\tDisplay helpful information.\n");
985 printf ("\n");
986
987 printf ("-h HOST, --host=HOST\n");
988 printf ("\tSpecify the RPTP host, default = %s.\n",
989 rplay_default_host ());
990 printf ("\n");
991
992 printf ("-p PORT, --port=PORT\n");
993 printf ("\tUse PORT instead of the default RPTP port, default = %d.\n", RPTP_PORT);
994 printf ("\n");
995
996 printf ("-r, --raw\n");
997 printf ("\tEnable raw RPTP mode.\n");
998 printf ("\n");
999
1000 printf ("-v, --version\n");
1001 printf ("\tDisplay rplay version information.\n");
1002 }
1003
1004 #ifdef __STDC__
1005 void
1006 done (int exit_value)
1007 #else
1008 void
1009 done (exit_value)
1112 printf("%s\n", error);
1113 }
1114 }
1115
1116 void
1117 usage()
1118 {
1119 printf("\nrplay %s\n\n", RPLAY_VERSION);
1120 printf("usage: rptp [options] [command]\n");
1121 printf("--help\n");
1122 printf("\tDisplay helpful information.\n");
1123 printf("\n");
1124
1125 printf("-h HOST, --host=HOST\n");
1126 printf("\tSpecify the RPTP host, default = %s.\n",
1127 rplay_default_host());
1128 printf("\n");
1129
1130 printf("-p PORT, --port=PORT\n");
1131 printf("\tUse PORT instead of the default RPTP port, default = %d.\n", RPTP_PORT);
1132 printf("\n");
1133
1134 printf("-r, --raw\n");
1135 printf("\tEnable raw RPTP mode.\n");
1136 printf("\n");
1137
1138 printf("-v, --version\n");
1139 printf("\tDisplay rplay version information.\n");
1140 }
1141
1142 #ifdef __STDC__
1143 void
1144 done(int exit_value)
1145 #else
1146 void
1147 done(exit_value)
10101148 int exit_value;
10111149 #endif
10121150 {
1013 exit (exit_value);
1014 }
1151 exit(exit_value);
1152 }
+0
-44
rx/CVS/Entries less more
0 /COPYING.LIB/1.1.1.1/Tue Jul 14 22:35:25 1998//
1 /ChangeLog/1.1.1.1/Tue Jul 14 22:35:25 1998//
2 /Makefile.in/1.1.1.1/Tue Jul 14 22:35:25 1998//
3 /configure/1.1.1.1/Tue Jul 14 22:35:25 1998//
4 /configure.in/1.1.1.1/Tue Jul 14 22:35:25 1998//
5 D/PLUGIN////
6 /_rx.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
7 /hashrexp.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
8 /inst-rxposix.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
9 /rgx.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
10 /rx.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
11 /rx.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
12 /rxall.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
13 /rxanal.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
14 /rxanal.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
15 /rxbasic.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
16 /rxbasic.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
17 /rxbitset.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
18 /rxbitset.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
19 /rxcontext.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
20 /rxcset.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
21 /rxcset.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
22 /rxdbug.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
23 /rxgnucomp.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
24 /rxgnucomp.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
25 /rxhash.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
26 /rxhash.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
27 /rxnfa.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
28 /rxnfa.h/1.1.1.1/Thu Aug 13 06:09:34 1998//
29 /rxnode.c/1.1.1.1/Thu Aug 13 06:09:34 1998//
30 /rxnode.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
31 /rxposix.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
32 /rxposix.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
33 /rxproto.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
34 /rxsimp.c/1.1.1.1/Thu Aug 13 06:10:47 1998//
35 /rxsimp.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
36 /rxspencer.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
37 /rxspencer.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
38 /rxstr.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
39 /rxstr.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
40 /rxsuper.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
41 /rxsuper.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
42 /rxunfa.c/1.1.1.1/Thu Aug 13 06:09:35 1998//
43 /rxunfa.h/1.1.1.1/Thu Aug 13 06:09:35 1998//
+0
-1
rx/CVS/Repository less more
0 /usr/local/cvsroot/rplay/rx
+0
-1
rx/CVS/Root less more
0 /usr/local/cvsroot
+0
-7
rx/PLUGIN/CVS/Entries less more
0 /OPT/1.1.1.1/Tue Jul 14 22:35:25 1998//
1 /REQ/1.1.1.1/Tue Jul 14 22:35:25 1998//
2 /greet/1.1.1.1/Tue Jul 14 22:35:25 1998//
3 /systas.config/1.1.1.1/Tue Jul 14 22:35:25 1998//
4 /systas.inits/1.1.1.1/Tue Jul 14 22:35:25 1998//
5 /systas.libs/1.1.1.1/Tue Jul 14 22:35:25 1998//
6 D
+0
-1
rx/PLUGIN/CVS/Repository less more
0 /usr/local/cvsroot/rplay/rx/PLUGIN
+0
-1
rx/PLUGIN/CVS/Root less more
0 /usr/local/cvsroot