muroar-0.1.13/0000755000175000017500000000000012320263561011223 5ustar phiphimuroar-0.1.13/AUTHORS0000644000175000017500000000027111347514300012271 0ustar phiphi--- Main Developer: * Philipp 'ph3-der-loewe' Schafft --- Suggestions and other improvements: * Patrick Matthäi --- Testers: * A lot people around the world :) muroar-0.1.13/COPYING.LGPL0000644000175000017500000001672511263672405013034 0ustar phiphi GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. muroar-0.1.13/ChangeLog0000644000175000017500000000676312320263426013011 0ustar phiphiv. 0.1.13 - Sun Apr 06 2014 16:38 CEST * Check commandlion of muroarstream for right number of arguments (Closes: DEB#716122) * Updates of copyright and license headers. v. 0.1.12 - Wed Mar 20 2013 13:01 CET * Corrected typos. * Reported to OpenBSD. * Updated copyright statements. v. 0.1.11 - Mon Dec 10 2012 13:02 CET * Updated win32 port (corrected order of symlink/target creation). v. 0.1.10 - Sat Jul 28 2012 13:08 CEST * Code cleanup * Corrected handling of $HOME (Closes: #279) * Corrected manpage for muroarstream(1). v. 0.1.9 - Tue Jul 10 2012 18:25 CEST * Updated and fixed the manpages. * Updated TODO list. * Added manpage libmuroar(7). * Updated ckport data. v. 0.1.8 - Mon Apr 16 2012 21:50 CEST * Support using non default port for TCP based servers. * Added support for "+default", "+invalid" and "+abstract" (Closes: #214) * Detect local DECnet based server (Closes: #213) * muroar.c has been split into multiple files (Closes: #215) * Added muroar_setvolume() to allow applications to set volume of streams (mono/stereo). * Updated and fixed the manpages. * Do some more porting to YIFF. v. 0.1.7 - Tue Nov 08 2011 11:41 CET * Mark server address and client name const. * Converted functions from int handle to muroar_t (int on POSIX). * Started to port to YIFF. * Updated error handling (muroar_noop() and muroarstream). v. 0.1.6 - Sun Sep 11 2011 23:46 CEST * Corrected ChangeLog entry for version 0.1.5 * Fixed invalid pointer aliasing (Closes: #175) * Added support for symbolic names to muroarstream (Closes: #166) * Added support to muroarstream to read from or write to file (Closes: #165) v. 0.1.5 - Fri Aug 18 2011 27:21 CEST * Some documentation updates. v. 0.1.4 - Sun Feb 13 2011 26:20 CET * Updated ckport database. * Fixed bug in NEW_STREAM (needed to set mixerid = -1) v. 0.1.3 - Mon Nov 29 2010 22:28 CET * added ckport(1) database * Ported to OpenVMS * Updated command list * Updated reassigned commands (GET_ACL->AUTHCTL, SET_ACL->ACLCTL) v. 0.1.2 - Mon Jul 05 2010 21:12 CEST * a bit work on the comments in the code * added more codec consts * moved BEEP command into seperate file * added NOOP command * added DECnet support * fixed endianess problems on some platforms v. 0.1.1 - Mon May 03 2010 20:54 CEST * Some Code cleanup * Updated Makefile so we do not build muroarstream 'staticly' * corrected wrong name of two CMD consts * corrected a lot typos * Added a lot comments * Use own IO functions v. 0.1.0 - Mon Mar 15 2010 21:33 CET * fixed copyright statements * get better in sync with Debian package * added additional consts * added support for autof* options * small -fPIC fix for win32 * added manpages for all public functions of this lib * added completion file for bash * added support for /etc/roarserver symlink v. 0.1rc2 - Sun Feb 28 2010 17:08 CET * added use of SONAME * added support for AF_UNIX sockets * started with Debian control files * some small fixes * added manpage for muroarstream(1) * added very simple support for beeps v. 0.1rc1 - Sat Feb 06 2010 26:27 CET * Added tool muroarstream v. 0.1rc0 - Fri Oct 30 2009 21:09 CET * Added install/semi-install/uninstall * Added a function needed to test for server * Wrote some Docs * Less magic numbers v. 0.1beta1 - Wed Oct 14 2009 22:12 CEST * added TODO list * wrote a simple configure * reduced memory usage (> 800 byte less) v. 0.1beta0 - Fri Oct 09 2009 22:42 CEST * first release * basic support for streams * basic magics * basic IO abstraktion muroar-0.1.13/Makefile0000644000175000017500000000601712047273153012673 0ustar phiphiinclude Makefile.conf LIBNAME=libmuroar SOVERSION = 0 SLIB_BASE=$(LIBNAME)$(SHARED_SUFFIX) SLIB=$(SLIB_BASE).$(SOVERSION) ALIB=$(LIBNAME).a BIN = muroarstream MANPAGES_1=$(BIN).1 MANPAGES_3=muroar_noop.3 muroar_beep.3 muroar_quit.3 muroar_close.3 muroar_connect.3 muroar_stream.3 muroar_write.3 muroar_read.3 muroar_setvolume.3 MANPAGES_7=libmuroar.7 TARGETS=$(SLIB) $(ALIB) $(BIN) HEADER=muroar.h OBJS=muroar.o muroario.o muroar_quit.o muroar_noop.o muroar_beep.o muroar_stream.o muroar_close.o muroar_setvolume.o CFLAGS += -Wall -Wextra -g $(fPIC) $(def_dnet) $(def_header_endian_h) LDFLAGS += -Wall -Wextra -g NETLIBS = $(lib_dnet) $(lib_wsock32) $(lib_ws2_32) LIBS += $(NETLIBS) all: prepare ${TARGETS} clean: rm -f ${TARGETS} *.o rm -f '$(SLIB_BASE)' distclean: clean rm -f Makefile.conf config.log prepare: $(SLIB_BASE) $(SLIB_BASE): $(SLIB) ln -fs '$(SLIB)' '$(SLIB_BASE)' new: clean all prep-install-dirs: mkdir -p '$(DESTDIR)$(PREFIX_BIN)' mkdir -p '$(DESTDIR)$(PREFIX_LIB)' mkdir -p '$(DESTDIR)$(PREFIX_INC)' mkdir -p '$(DESTDIR)$(PREFIX_MAN)/man1' mkdir -p '$(DESTDIR)$(PREFIX_MAN)/man3' mkdir -p '$(DESTDIR)$(PREFIX_MAN)/man7' install: all prep-install-dirs cp $(cp_v) $(SLIB) '$(DESTDIR)$(PREFIX_LIB)' cp $(cp_v) $(ALIB) '$(DESTDIR)$(PREFIX_LIB)' cp $(cp_v) $(BIN) '$(DESTDIR)$(PREFIX_BIN)' cp $(cp_v) $(HEADER) '$(DESTDIR)$(PREFIX_INC)' set -e; for p in $(MANPAGES_1); do cp $(cp_v) $$p '$(DESTDIR)$(PREFIX_MAN)/man1/'; done set -e; for p in $(MANPAGES_3); do cp $(cp_v) $$p '$(DESTDIR)$(PREFIX_MAN)/man3/'; done set -e; for p in $(MANPAGES_7); do cp $(cp_v) $$p '$(DESTDIR)$(PREFIX_MAN)/man7/'; done ln -fs '$(SLIB)' '$(DESTDIR)$(PREFIX_LIB)$(SLIB_BASE)' semi-install: all prep-install-dirs ln -fs `pwd`/$(SLIB) '$(DESTDIR)$(PREFIX_LIB)' ln -fs `pwd`/$(ALIB) '$(DESTDIR)$(PREFIX_LIB)' ln -fs `pwd`/$(BIN) '$(DESTDIR)$(PREFIX_BIN)' ln -fs `pwd`/$(HEADER) '$(DESTDIR)$(PREFIX_INC)' set -e; for p in $(MANPAGES_1); do ln -fs `pwd`/$$p '$(DESTDIR)$(PREFIX_MAN)/man1/'; done set -e; for p in $(MANPAGES_3); do ln -fs `pwd`/$$p '$(DESTDIR)$(PREFIX_MAN)/man3/'; done set -e; for p in $(MANPAGES_7); do ln -fs `pwd`/$$p '$(DESTDIR)$(PREFIX_MAN)/man7/'; done ln -fs '$(DESTDIR)$(PREFIX_LIB)$(SLIB)' '$(DESTDIR)$(PREFIX_LIB)$(SLIB_BASE)' uninstall: rm -f '$(DESTDIR)$(PREFIX_BIN)'/$(BIN) rm -f '$(DESTDIR)$(PREFIX_LIB)'/$(SLIB) rm -f '$(DESTDIR)$(PREFIX_LIB)'/$(SLIB_BASE) rm -f '$(DESTDIR)$(PREFIX_LIB)'/$(ALIB) rm -f '$(DESTDIR)$(PREFIX_INC)'/$(HEADER) rm -f '$(DESTDIR)$(PREFIX_MAN)'/man1/$(MANPAGE) set -e; for p in $(MANPAGES_1); do rm -f '$(DESTDIR)$(PREFIX_MAN)'/man1/$$p; done set -e; for p in $(MANPAGES_3); do rm -f '$(DESTDIR)$(PREFIX_MAN)'/man3/$$p; done set -e; for p in $(MANPAGES_7); do rm -f '$(DESTDIR)$(PREFIX_MAN)'/man7/$$p; done $(SLIB): ${OBJS} ${CC} ${LDFLAGS} $(SHARED) -Wl,-soname,$(SLIB) -o $(SLIB) ${OBJS} ${LIBS} $(ALIB): ${OBJS} ${AR} cru $(ALIB) ${OBJS} ${RANLIB} $(ALIB) muroarstream: muroarstream.o ${CC} ${LDFLAGS} -o muroarstream muroarstream.o -L. -lmuroar ${LIBS} muroar-0.1.13/README0000644000175000017500000000300412320263002012066 0ustar phiphi µRoar --------------------- --- What is µRoar?: µRoar is a minimalistic library to create streams to a RoarAudio Sound Server. --- Build: -- Build requirements: A POSIX system or mingw, win32/msys. -- How to build: POSIX: $ ./configure $ make For win32, build with mingw: $ CC=...mingw32...gcc ./configure --target-win32 $ make On OpenVMS, with HP C compiler: $ @build --- Tested platforms: OPERATING SYSTEM ARCH COMPILER TESTED M/STATUS COMMENT AND VERSION VERSION --------------------------------------------------------------------------------------------------- Debian Etch ix86 gcc 4.1.2 last s/OK Debian Etch x86_64 gcc 4.1.2 0.1.12 s/OK Debian Lenny ix86 gcc 4.3.2 0.1.2 s/OK Debian Wheezy x86_64 gcc 4.7.2 0.1.13 s/OK Debian Sid ix86 clang 2.7 0.1.4 s/OK Debian Sid ix86 gcc 4.4.5 0.1.8 M/OK Debian unstable * * * M/OK OpenBSD 4.4 ix86 gcc 3.3.5 0.1.12 s/OK -Wextra needs to be removed from the Makefile. Windows XP Home ix86 mingw 3.4.5 0.1.2 s/OK Wine 0.9.25 ix86 mingw 3.4.5 0.1.8 s/OK OpenVMS V8.3 Alpha HP C V7.3-009 0.1.3 s/OK WinXP/MSys ix86 mingw 4.7.0 0.1.12 m/OK Automatic Build Bot. Tested Version: Current: Current as listed on Homepage last: Last released version (This system is on release checklist) *b*: Beta Status: Maintenance/testing Status: Maintenance: s = your are on your own, sources. m = package in work, beta package M = maintained S = maintained source package B = maintained binary package muroar-0.1.13/TODO0000644000175000017500000000022211755653467011732 0ustar phiphiThings we need to do: Things we should do: Things it would be nice to have: * write a test target * work on the manual to make it even better muroar-0.1.13/bash_completion0000644000175000017500000000451511743070064014323 0ustar phiphi# Debian GNU/Linux muroarstream(1) completion # Copyright 2002 Baruch Even # Copyright 2009-2011 Philipp Schafft # License: GNU GPL v3 or later #################################################### # This is a copy from the RoarAudio package. # # Only the names are changed so we do not conflict # #################################################### _muroar_server() { COMPREPLY=( $(_muroar_server_exec "$1") ) } _muroar_server_exec() { local cur link words nodes stdsocks x11sock cur="$1" link=$(readlink /etc/roarserver 2> /dev/null) nodes=$(grep '^\(node\|executor\)' /etc/decnet.conf 2> /dev/null | sed 's/^.*\tname\t\t*//; s/\t.*$//; s/$/::/') stdsocks="/tmp/roar $HOME/.roar localhost :: +default +abstract +invalid"; x11sock=$(xprop -root 2>/dev/null | grep '^ROAR_SERVER(STRING) = ' | sed 's/^[^"]*"//; s/"$//') words="$link $nodes $stdsocks $x11sock" compgen -A hostname $cur compgen -W "$words" $cur } #################################################### # end of copy. # #################################################### _muroarstream() { local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" opts="--help --file -f --server --rate -R --channels -C --bits -B --codec -E --play --monitor --wave --midi --light" case "${prev}" in '--bits'|'-B') COMPREPLY=($(compgen -W "8 16 24 32" -- ${cur})) return 0 ;; '--channels'|'-C') COMPREPLY=($(compgen -W "default mono stereo 1 2 3 4 5 6 7 8 9" -- ${cur})) return 0 ;; '--rate'|'-R') COMPREPLY=($(compgen -W "8000 16000 32000 11025 22050 44100 48000 96000" -- ${cur})) return 0 ;; '--codec'|'-E') COMPREPLY=($(compgen -W "default pcm pcm_s pcm_u alaw mulaw ulaw ogg_vorbis vorbis dmx512 roardmx midi" -- ${cur})) return 0 ;; '--file'|'-f') _filedir return 0 ;; '--server') _muroar_server "${COMP_WORDS[COMP_CWORD]}" return 0 ;; *) ;; esac COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 } complete -F _muroarstream muroarstream # vim:ft=sh: muroar-0.1.13/build.com0000644000175000017500000000232311743001220013010 0ustar phiphi$WRITE SYS$OUTPUT "Building muRoar..." $ $WRITE SYS$OUTPUT "[CC] muroar.c" $CC /DEFINE=(NO_STDINT_H,NO_AF_UNIX) muroar.c $WRITE SYS$OUTPUT "[CC] muroar_beep.c" $CC /DEFINE=(NO_STDINT_H,NO_AF_UNIX) muroar_beep.c $WRITE SYS$OUTPUT "[CC] muroar_noop.c" $CC /DEFINE=(NO_STDINT_H,NO_AF_UNIX) muroar_noop.c $WRITE SYS$OUTPUT "[CC] muroario.c" $CC /DEFINE=(NO_STDINT_H,NO_AF_UNIX) muroario.c $WRITE SYS$OUTPUT "[CC] muroar_close.c" $CC /DEFINE=(NO_STDINT_H,NO_AF_UNIX) muroar_close.c $WRITE SYS$OUTPUT "[CC] muroar_quit.c" $CC /DEFINE=(NO_STDINT_H,NO_AF_UNIX) muroar_quit.c $WRITE SYS$OUTPUT "[CC] muroar_stream.c" $CC /DEFINE=(NO_STDINT_H,NO_AF_UNIX) muroar_stream.c $WRITE SYS$OUTPUT "[CC] muroar_setvolume.c" $CC /DEFINE=(NO_STDINT_H,NO_AF_UNIX) muroar_setvolume.c $WRITE SYS$OUTPUT "[LIBRARY] muroar.olb" $LIBRARY/CREATE/INSERT muroar muroar, muroario, muroar_noop, muroar_beep, muroar_close, muroar_quit, muroar_stream, muroar_setvolume $ $WRITE SYS$OUTPUT "[CC] muroarstream.c" $CC /DEFINE=(NO_STDINT_H,NO_AF_UNIX) muroarstream.c $WRITE SYS$OUTPUT "[LINK] muroarstream.obj" $LINK muroarstream, muroar/LIBRARY $ $WRITE SYS$OUTPUT "Build done." $ $WRITE SYS$OUTPUT "" $WRITE SYS$OUTPUT "Link your programs with: link ..., muroar/library" muroar-0.1.13/configure0000755000175000017500000001237712063430455013146 0ustar phiphi#!/bin/sh TF_C=testit.c TF_E=./testit PREFIX='/usr/local' PREFIX_BIN='' PREFIX_LIB='' PREFIX_INC='' PREFIX_MAN='' SHARED='-shared' SHARED_CF='' SHARED_SUFFIX='.so' fPIC=true TARGET_WIN32=false echo -n "checking for C compiler... " if [ "$CC" != '' ] then echo $CC else CC=$(which gcc cc 2> /dev/null | grep ^/ | head -n 1) if [ "$CC" = '' ] then echo 'none' exit 1; fi echo $CC fi echo -n "checking for ranlib... " if [ "$RANLIB" != '' ] then echo $RANLIB else _guess=`echo $CC | sed 's/[gp]*cc\(-.*\)*//'` RANLIB=$(which ${_guess}ranlib ranlib 2> /dev/null | grep ^/ | head -n 1) if [ "$RANLIB" = '' ] then echo 'none' fi echo $RANLIB fi echo -n "checking for sysname... " SYSNAME=$(uname -s) echo "$SYSNAME" while [ "$1" != '' ] do case "$1" in '--help'|'-h') echo '--help - This Help' echo echo '--prefix DIR - Set general prefix (default: '"$PREFIX"')' echo '--prefix-bin DIR - Set prefix for binaries (default: $PREFIX/bin)' echo '--prefix-lib DIR - Set prefix for libraries (default: $PREFIX/lib)' echo '--prefix-inc DIR - Set prefix for include files (default: $PREFIX/include)' echo '--prefix-man DIR - Set prefix for manpages (default: $PREFIX/share/man)' echo echo '--target-win32 - Compile for win32' exit 0; ;; '--prefix') PREFIX="$2" shift; ;; '--prefix-bin') PREFIX_BIN="$2" shift; ;; '--prefix-lib') PREFIX_LIB="$2" shift; ;; '--prefix-inc') PREFIX_INC="$2" shift; ;; '--prefix-man') PREFIX_MAN="$2" shift; ;; #################################### # autof* options block: '--prefix=*') PREFIX=$(echo "$1" | cut -d= -f2) ;; '--prefix-bin=*') PREFIX_BIN=$(echo "$1" | cut -d= -f2) ;; '--prefix-lib=*') PREFIX_LIB=$(echo "$1" | cut -d= -f2) ;; '--prefix-inc=*') PREFIX_INC=$(echo "$1" | cut -d= -f2) ;; '--prefix-man=*') PREFIX_MAN=$(echo "$1" | cut -d= -f2) ;; #################################### '--target-win32') TARGET_WIN32=true ;; *) echo "Error: unknown option: $1" >&2; echo "Try: $0 --help" >&2; exit 1; ;; esac; shift; done exec 4> Makefile.conf 5> config.log TARGET_WIN32=`echo "$SYSNAME" | if grep MINGW32 > /dev/null; then echo true; else echo $TARGET_WIN32; fi` if $TARGET_WIN32 then echo "Adding win32 build arguments..." fPIC=false SHARED_SUFFIX='.dll' fi [ "$PREFIX_BIN" = '' ] && PREFIX_BIN="$PREFIX/bin/" [ "$PREFIX_LIB" = '' ] && PREFIX_LIB="$PREFIX/lib/" [ "$PREFIX_INC" = '' ] && PREFIX_INC="$PREFIX/include/" [ "$PREFIX_MAN" = '' ] && PREFIX_MAN="$PREFIX/share/man/" { echo "SHARED=$SHARED" echo "SHARED_CF=$SHARED_CF" echo "SHARED_SUFFIX=$SHARED_SUFFIX" $fPIC && echo 'fPIC=-fPIC' echo echo "CC=$CC" echo "RANLIB=$RANLIB" # echo "LDPATH=$LDPATH" # echo "INCPATH=$INCPATH" echo echo "PREFIX=$PREFIX" echo "PREFIX_BIN=$PREFIX_BIN" echo "PREFIX_LIB=$PREFIX_LIB" echo "PREFIX_INC=$PREFIX_INC" echo "PREFIX_MAN=$PREFIX_MAN" echo } >&4 CCTF="$CC $CFLAGS $LDFLAGS $LDPATH $INCPATH -I. -o $TF_E $TF_C" { cat <<'EOF' //config.log: /* * Logfile for configure script $Revision: 1.15 $ of µRoar */ EOF echo '/* uname: ' $(uname -a) '*/' echo '/* Date : ' $(date) '*/' echo echo echo echo "ARGS(): $_CARGS" for i in PATH SHELL CC RANLIB PKG_CONFIG SYSNAME \ TARGET_WIN32 do eval echo "BASICCONF\($i\): \$$i"; done echo echo } >&5 test_lib () { echo > $TF_C name="$1" echo -n "checking for $name... " echo "TEST LIB: $name" >&5 shift; lib="$1" LIBS='' HEADER='' while [ "$1" != '--' ] do case "$1" in 'c'|'-lc') :; # no need to do anything ;; '-'*) LIBS="$LIBS $1" ;; *) LIBS="-l$1" ;; esac shift; done shift; echo "LIB($name) IS TESTED USING LIBS: $LIBS" >&5 while [ "$1" != '' ] do echo "#include <$1>" >> $TF_C HEADER="$HEADER $1" shift; done echo 'int main (void) { return 0; }' >> $TF_C echo "LIB($name) IS TESTED USING TEST CODE:" >&5 echo "--- BEGIN OF CODE BLOCK ---" >&5 cat $TF_C >&5 echo "--- END OF CODE BLOCK ---" >&5 echo "LIB($name) HAS COMPILER/LINKER OUTPUT:" >&5 echo "--- BEGIN OF CHILD OUTPUT BLOCK ---" >&5 $CCTF $LIBS >&5 2>&5; R=$? echo "--- END OF CHILD OUTPUT BLOCK ---" >&5 echo >&4 echo "# config for lib $name" >&4 if [ "$R" = '0' ] then echo 'yes' echo "LIB($name) WAS FOUND" >&5 # write config for headers: for h in $HEADER do hn=`echo $h | tr A-Z/. a-z__` hd=`echo $h | tr a-z/. A-Z__` echo "header_$hn=$h" >&4 echo "def_header_$hn=-DHAVE_HEADER_$hd" >&4 done # write config for libs: if [ "$lib" != 'c' ] then echo "lib_$lib=$LIBS" >&4 echo "def_$lib=-DHAVE_LIB_"`echo $lib | tr a-z A-Z` >&4 fi else echo 'no' echo "# lib $name not found" >&4 echo "LIB($name) NOT FOUND" >&5 fi return $R } test_lib endian.h c -- endian.h test_lib DECnet dnet -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h test_lib WinSockP0 wsock32 -- winsock2.h test_lib WinSockP1 ws2_32 -- winsock2.h echo >&4 echo -n 'checking if cp supports -v... ' if cp -v --help > /dev/null 2> /dev/null then echo "cp_v=-v" >&4 echo yes else echo "cp_v=" >&4 echo no fi echo >&5 echo '//ll' >&5 rm -f $TF_C $TF_E #ll muroar-0.1.13/libmuroar.70000644000175000017500000001232011755665053013322 0ustar phiphi.\" RoarAudio .TH "libmuroar" "7" "May 2012" "RoarAudio" "System Manager's Manual: MuRoar" .SH NAME libmuroar \- minimalist RoarAudio sound library .SH SYNOPSIS #include .SH "DESCRIPTION" \fBlibmuroar\fR is a client side implementation of the RoarAudio protocol. It is used to comunicate with RoarAudio servers. As the name suggests it only supports a subset of the protocol. This is by design. Any application needing more features of the protocol needs to use \fBlibroar\fR(7) or any other client library implementation providing the features they need. .SH "LICENSE" \fBlibmuroar\fR is licensed under the GNU LGPL version 3 (with "or later" option). This allows non-free applications to use this library while libroar doesn't. See the license text for details. .SH "EXAMPLES" The source code of the provided program \fBmuroarstream\fR(1) can be used as example how to use this library. \".SH "TUTORIALS" \""Tutorials can be found in \fBroartut\fR(7). .SH "SERVER ADDRESS" Depending on which features are compiled into MuRoar diffrent server address types are supported. For UNIX Domain Sockets the address is in form /path/to/sock. At least one slash needs to be included. For TCP/IP connections host:port is used. While the port (and the colon) is optional. For DECnet connections the address is in form node::object. Both node and object are optional. When they are not given defaults are used (local node, and default object). In addition the special addresses "+default", "+invalid" and "+abstract" are suppored. The "+default" address does the same as passing a NULL pointer but is used to work around applications not letting the user to pass a NULL pointer in some way. The "+invalid" address is used to tell the connection to always fail. This is usefull for testing and debugging. The "+abstract" address is a special kind of UNIX Domain Socket, requesting to connect to the abstract namespace. .SH "PROTOCOL FEATURES" The following features are supported by this library. Some of them may not be compiled in depending on the build time configuration and target Operating System. .TP \fBProtocol constants\fR A lot protcol constants are exported in the header. This includes default server addresses, default audio profiles, command IDs, flags needed by commands, stream direction parameter and codec IDs. The exported constants are not limited to what this library needs internally. .TP \fBOpening a control connection\fR Control connections to a server can be opend using \fBmuroar_connect\fR(3). The function does all the basic protocol setup including sending client name. .TP \fBClosing a control or data connection\fR The functions \fBmuroar_quit\fR(3) and \fBmuroar_close\fR(3) close a control or data connection. .TP \fBOpening a data connection\fR The function \fBmuroar_stream\fR(3) is used to transform a control connection into a data connection (using the EXEC command). .TP \fBNotify Beeps\fR Notify Beeps (sounds) can be send using \fBmuroar_beep\fR(3). This function requests the server to emit a beep to notify the user about some event. .TP \fBPinging and Keep-Alive\fR The server can be pinged via \fBmuroar_noop\fR(3). This can be used to messure effective latency between the client and server. It can also be used as Keep-Alive on long living connections. .TP \fBSetting volume\fR Using \fBmuroar_setvolume\fR(3) the volume of a stream can be set. This function is limited to setting mono or stereo volumes but not limited to mono and stereo streams. If the number of channels does not match the volume is set using the UNMAPPED mode in which the channel setup is converted automatically (the developer do not need to care). (Since version 0.1.8.) .TP \fBI/O Abstraction\fR The functions \fBmuroar_write\fR(3) and \fBmuroar_read\fR(3) are provided to do portable I/O on the data connection as provided by this library. They should be used. See section PORTABILITY NOTES for details. .SH "PORTABILITY NOTES" This library is designed to be portable. It should work well on all kind of POSIX systems including UNIX and GNU/Linux. It is also maintained for Win32 and was ported to OpenVMS. Porting to YIFF is work in process. It should work on all CPUs only depending on the Operating System to provided the needed interfaces. The library exports most of it's internal I/O-abstraction to enable writing portable clients. This should be used and seems to be important on Win32. .SH "ENVIRONMENT VARIABLES" The following variables are used in libmuroar itself so they are common to all clients using libmuroar. .TP \fBHOME\fR The user's home directory. This is used to locate the user's local socket ($HOME/.roar). .TP \fBROAR_SERVER\fR The address of the server to use. See section SERVER ADDRESS for details. .SH "FILES" .TP \fB/etc/roarserver\fR This is a symlink to the server socket. If all types of server addresses are supported. Example: ln \-s /tmp/roar /etc/roarserver ln \-s somehost /etc/roarserver ln \-s mynode:: /etc/roarserver .SH "NOTES" This library should not be confused with the similar named server implementation "MuRoarD". .SH "SEE ALSO" \fBmuroarstream\fR(1), \fBlibroar\fR(7). .SH "HISTORY" MuRoar was first released on Fri Oct 09 2009 at 22:42 CEST. SONAME has been changed last in 0.1rc2 on Sun Feb 28 2010 at 17:08 CET. .\"ll muroar-0.1.13/libmuroar.ckport0000644000175000017500000000070311743067365014457 0ustar phiphi#ckport(1) database for µRoar (libmuroar) !NAME: µRoar (libmuroar) !TARGET: libmuroar0 !TYPE: func #Control connection handling: muroar_connect ok muroar_quit ok #Control connection commands: muroar_noop ok muroar_beep ok muroar_setvolume ok #Data connection handling: muroar_stream ok muroar_close ok #read and write data: muroar_read ok muroar_write ok # Internal stuff: muroar_open_socket internal muroar_open_socket_bsd internal #ll muroar-0.1.13/muroar.c0000644000175000017500000002313212320263256012676 0ustar phiphi//muroar.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ /* ckport options: * ckport: ignore-symbol: strcpy of target security -- length is check before the function is called. * ckport: ignore-symbol: atoi of target security -- returned by functions ensuring tailing \0. * ckport: ignore-symbol: strdup of target security -- Caller is enforced to pass valid buffer. */ #include "muroar.h" #include "private.h" #include #ifndef NO_STDINT_H #include #endif #include #include /* for snprintf() */ #define MUROAR_IOBUF 128 #define _MU_STR "\265" #define _DEFAULT_CLIENT_NAME _MU_STR "Roar Client"; /* Format of RoarAudio Message format 0: * * | 0 | 1 | 2 | 3 | Byte * +--------+--------+--------+--------+------ * |Version |Command | Stream ID | 0-3 * +--------+--------+--------+--------+------ * | Stream Position | 4-7 * +--------+--------+--------+--------+------ * | Data Length | Data .... | 7-11 * +--------+--------+--------+--------+------ * * All data is in network byte order. * Version : Version number of message, always 0. * Command : Command, one of MUROAR_CMD_*. * Stream ID : ID of Stream we use this command on, * or -1 (0xFFFF) on non-stream commands. * Stream Position : Position of Stream in units depending on stream type. For waveform streams samples (not frames) played. * Data Length : Length of data in the data part of this message in bytes. */ // Need to init the network layer on win32 because of it's // broken design. #ifdef __WIN32 static void muroar_init_win32 (void) { static int inited = 0; WSADATA wsadata; if ( !inited ) { WSAStartup(MAKEWORD(1,1) , &wsadata); inited++; } } #endif // Open Socket to server. static int muroar_open_socket_bsd (const char * server) { struct hostent * he; struct sockaddr_in in; #ifdef HAVE_AF_UNIX struct sockaddr_un un; #endif int fh = -1; char * buf = NULL; char * object; #ifdef HAVE_LIB_DNET char * node; static char localnode[16] = {0}; struct dn_naddr *binaddr; struct nodeent *dp; #endif #ifdef __WIN32 muroar_init_win32(); #endif if ( !strcmp(server, MUROAR_ABSTRACT) || (strstr(server, "/") != NULL && strstr(server, "::") == NULL) ) { // Handle AF_UNIX Sockets, // do not build on broken systems like win32 not // supporting the AF_UNIX sockets. #ifdef HAVE_AF_UNIX if ( (fh = socket(AF_UNIX, SOCK_STREAM, 0)) == -1 ) return -1; un.sun_family = AF_UNIX; if ( !strcmp(server, MUROAR_ABSTRACT) ) { memset(un.sun_path, 0, sizeof(un.sun_path)); strncpy(un.sun_path + 1, "RoarAudio/UNIX/Abstract/1", sizeof(un.sun_path) - 2); } else { strncpy(un.sun_path, server, sizeof(un.sun_path) - 1); } if ( connect(fh, (struct sockaddr *)&un, sizeof(struct sockaddr_un)) == -1 ) { __CLOSE(fh); return -1; } return fh; #else return -1; #endif } else if ( strstr(server, "::") != NULL ) { #ifdef HAVE_LIB_DNET // alloc a temp buffer so we can change the string at will: buf = strdup(server); // cut node::object into buf and object object = strstr(buf, "::"); *object = 0; object += 2; // use default if we have a zero-size node name: if ( *buf == 0 ) { if ( !localnode[0] ) { if ( (binaddr=getnodeadd()) == NULL) { free(buf); return -1; } if ( (dp = getnodebyaddr((char*)binaddr->a_addr, binaddr->a_len, AF_DECnet)) == NULL ) { free(buf); return -1; } strncpy(localnode, dp->n_name, sizeof(localnode)-1); localnode[sizeof(localnode)-1] = 0; } node = localnode; } else { node = buf; } // use default if we have a zero size object name: if ( *object == 0 ) { object = MUROAR_OBJECT; } fh = dnet_conn(node, object, SOCK_STREAM, NULL, 0, NULL, 0); // free buffer when we are done. free(buf); return fh; #else return -1; #endif } if ( strstr(server, ":") != NULL ) { buf = strdup(server); server = buf; object = strstr(buf, ":"); *object = 0; object++; if ( !*object ) /* finnaly check if this is just a tailing :, in that case we assume the default port */ object = NULL; } else { object = NULL; } if ( (he = gethostbyname(server)) == NULL ) { if ( buf != NULL ) free(buf); return -1; } memcpy((struct in_addr *)&(in.sin_addr), he->h_addr, sizeof(struct in_addr)); in.sin_family = AF_INET; if ( object != NULL ) { in.sin_port = htons(atoi(object)); } else { in.sin_port = htons(MUROAR_PORT); } if ( buf != NULL ) free(buf); if ( (fh = socket(AF_INET, SOCK_STREAM, 0)) == -1 ) return -1; if ( connect(fh, (const struct sockaddr *)&in, sizeof(in)) == -1 ) { __CLOSE(fh); return -1; } return fh; } static muroar_t muroar_open_socket (const char * server) { #if MUROAR_HDLTYPE == MUROAR_HDLTYPE_YIFF_VIO yiff_identifier_t fh = -1; #else int fh = muroar_open_socket_bsd(server); #endif muroar_t ret; if ( fh == -1 ) return MUROAR_HANDLE_INVALID; #if MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_SYSIO || MUROAR_HDLTYPE == MUROAR_HDLTYPE_WIN32_SOCKET ret = fh; #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_STDIO ret = fdopen(fh, "a+"); #else #error Unsupported value for MUROAR_HDLTYPE #endif if ( ret == MUROAR_HANDLE_INVALID ) { __CLOSE(fh); return MUROAR_HANDLE_INVALID; } return ret; } // Open Control connection muroar_t muroar_connect(const char * server, const char * name) { char useraddr[80] = MUROAR_INVALID; char * addr[] = {useraddr, MUROAR_GSOCK, MUROAR_HOST, "::" MUROAR_OBJECT, MUROAR_ABSTRACT, NULL}; const char * home; unsigned char buf[MUROAR_IOBUF]; uint16_t tmpu16; uint16_t pid; muroar_t fh = MUROAR_HANDLE_INVALID; int i; #if !defined(__WIN32) ssize_t len; #endif // Prepare server address: if ( server != NULL && *server == 0 ) server = NULL; if ( server == NULL ) server = getenv("ROAR_SERVER"); #if !defined(__WIN32) if ( server == NULL ) { if ( (len = readlink("/etc/roarserver", useraddr, sizeof(useraddr))) != -1 ) { useraddr[len < (ssize_t)sizeof(useraddr) ? (size_t)len : sizeof(useraddr)-1] = 0; server = useraddr; } } #endif if ( server != NULL ) { // "+default" is an alias to NULL. if ( !strcmp(server, MUROAR_DEFAULT) ) { server = NULL; // "+invalid" always return an invalid handle. } else if ( !strcmp(server, MUROAR_INVALID) ) { #ifdef ECANCELED _SET_ERRNO(ECANCELED); #else _SET_ERRNO(EINVAL); #endif return MUROAR_HANDLE_INVALID; } } // Connect to server: if ( server != NULL ) { if ( (fh = muroar_open_socket(server)) == MUROAR_HANDLE_INVALID ) return MUROAR_HANDLE_INVALID; } else { // build string for ~/.roar home = getenv("HOME"); if ( home != NULL && home[0] == '/' && strlen(home) < (sizeof(useraddr) - 7) ) { snprintf(useraddr, sizeof(useraddr), "%s/.roar", home); useraddr[sizeof(useraddr)-1] = 0; } // go thru list of possible defaults: for (i = 0; fh == MUROAR_HANDLE_INVALID && addr[i] != NULL; i++) { if ( !strcmp(addr[i], MUROAR_INVALID) ) continue; fh = muroar_open_socket(addr[i]); } if ( fh == MUROAR_HANDLE_INVALID ) { _SET_ERRNO(ENOENT); return MUROAR_HANDLE_INVALID; } } // Prepare client name: if ( name == NULL || *name == 0 ) name = _DEFAULT_CLIENT_NAME; // Send IDENTIFY command to server: memset(buf, 0, sizeof(buf)); buf[1] = MUROAR_CMD_IDENTIFY; // Calculate the length for the data part of the package. // Its 5 bytes plus the length of the name string. tmpu16 = strlen(name) + 5; // check if we have space for 5 bytes + length of name + tailing \0 // in the buffer. if ( tmpu16 >= MUROAR_IOBUF ) { _CLOSE(fh); _SET_ERRNO(EINVAL); return MUROAR_HANDLE_INVALID; } buf[8] = (tmpu16 & 0xFF00) >> 8; buf[9] = (tmpu16 & 0x00FF); if ( muroar_write(fh, buf, 10) != 10 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } buf[0] = 1; pid = getpid(); buf[1] = (pid & 0xFF000000UL) >> 24; buf[2] = (pid & 0x00FF0000UL) >> 16; buf[3] = (pid & 0x0000FF00UL) >> 8; buf[4] = (pid & 0x000000FFUL) >> 0; // sizes are already checked. strcpy((char*)&(buf[5]), name); if ( muroar_write(fh, buf, tmpu16) != tmpu16 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } if ( muroar_read(fh, buf, 10) != 10 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } if ( buf[1] != MUROAR_CMD_OK ) { _CLOSE(fh); _SET_ERRNO(EACCES); return MUROAR_HANDLE_INVALID; } // Send AUTH command to server: // We send zero-byte AUTH command // (type=NONE). memset(buf, 0, 10); buf[1] = MUROAR_CMD_AUTH; if ( muroar_write(fh, buf, 10) != 10 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } if ( muroar_read(fh, buf, 10) != 10 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } if ( buf[1] != MUROAR_CMD_OK ) { _CLOSE(fh); _SET_ERRNO(EACCES); return MUROAR_HANDLE_INVALID; } // We now have a working control connection, return it. return fh; } //ll muroar-0.1.13/muroar.h0000644000175000017500000001670712320263256012715 0ustar phiphi//muroar.h: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #ifndef _MUROAR_H_ #define _MUROAR_H_ #ifdef __cplusplus extern "C" { #endif #ifndef __YIFF__ // types: #include // BYTE_ORDER and friends: #ifdef HAVE_HEADER_ENDIAN_H #include #endif #endif // types of IO: #define MUROAR_HDLTYPE_POSIX_SYSIO 1 #define MUROAR_HDLTYPE_POSIX_STDIO 2 #define MUROAR_HDLTYPE_WIN32_SOCKET 3 #define MUROAR_HDLTYPE_YIFF_SYSIO 4 #define MUROAR_HDLTYPE_YIFF_VIO 5 #ifdef __WIN32 #define MUROAR_HDLTYPE MUROAR_HDLTYPE_WIN32_SOCKET #elif defined(__YIFF__) #define MUROAR_HDLTYPE MUROAR_HDLTYPE_YIFF_VIO #else #define MUROAR_HDLTYPE MUROAR_HDLTYPE_POSIX_SYSIO #endif #if MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_SYSIO || MUROAR_HDLTYPE == MUROAR_HDLTYPE_WIN32_SOCKET typedef int muroar_t; #define MUROAR_HANDLE_INVALID -1 #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_STDIO #include typedef FILE* muroar_t; #define MUROAR_HANDLE_INVALID NULL #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_YIFF_VIO /* yiff stuff */ #include #include #include /* for stuff like NULL */ #include typedef yiffc_vio_t * muroar_t; #define MUROAR_HANDLE_INVALID NULL #error Unsupported value for MUROAR_HDLTYPE (WIP) #else #error Unsupported value for MUROAR_HDLTYPE #endif // Some defaults: #define MUROAR_PORT 16002 #define MUROAR_HOST "localhost" #define MUROAR_GSOCK "/tmp/roar" #define MUROAR_OBJECT "roar" #define MUROAR_DEFAULT "+default" #define MUROAR_INVALID "+invalid" #define MUROAR_ABSTRACT "+abstract" // AID = Audio Info Defaults #define MUROAR_AID_RATE 44100 #define MUROAR_AID_BITS 16 #define MUROAR_AID_CHANNELS MUROAR_CM_STEREO #define MUROAR_CM_MONO 1 #define MUROAR_CM_STEREO 2 #define MUROAR_CMD_NOOP 0 #define MUROAR_CMD_IDENTIFY 1 #define MUROAR_CMD_AUTH 2 #define MUROAR_CMD_NEW_STREAM 3 #define MUROAR_CMD_SET_META 4 #define MUROAR_CMD_EXEC_STREAM 5 #define MUROAR_CMD_QUIT 6 #define MUROAR_CMD_GET_STANDBY 7 #define MUROAR_CMD_SET_STANDBY 8 #define MUROAR_CMD_SERVER_INFO 9 #define MUROAR_CMD_SERVER_STATS 10 #define MUROAR_CMD_SERVER_OINFO 11 #define MUROAR_CMD_ADD_DATA 12 #define MUROAR_CMD_EXIT 13 #define MUROAR_CMD_LIST_STREAMS 14 #define MUROAR_CMD_LIST_CLIENTS 15 #define MUROAR_CMD_GET_CLIENT 16 #define MUROAR_CMD_GET_STREAM 17 #define MUROAR_CMD_KICK 18 #define MUROAR_CMD_SET_VOL 19 #define MUROAR_CMD_GET_VOL 20 #define MUROAR_CMD_CON_STREAM 21 #define MUROAR_CMD_GET_META 22 #define MUROAR_CMD_LIST_META 23 #define MUROAR_CMD_BEEP 24 #define MUROAR_CMD_AUTHCTL 25 #define MUROAR_CMD_ACLCTL 26 #define MUROAR_CMD_GET_STREAM_PARA 27 #define MUROAR_CMD_SET_STREAM_PARA 28 #define MUROAR_CMD_ATTACH 29 #define MUROAR_CMD_PASSFH 30 #define MUROAR_CMD_GETTIMEOFDAY 31 #define MUROAR_CMD_WHOAMI 32 #define MUROAR_CMD_DEVCTL 33 /* send control messages to devices */ #define MUROAR_CMD_CAPS 34 /* send caps */ #define MUROAR_CMD_WAIT 35 /* wait for an event */ #define MUROAR_CMD_NOTIFY 36 /* asyncronus notify of events */ #define MUROAR_CMD_SEEK 37 /* seek in stream */ #define MUROAR_CMD_CLIENTCTL 38 /* like stream ctl, just for client connections */ #define MUROAR_CMD_LOOKUP 39 /* lookup??? */ #define MUROAR_CMD_CONCTL 40 /* change parameter for current connection */ // special CMDs: #define MUROAR_CMD_OK 254 /* return value OK */ #define MUROAR_CMD_ERROR 255 /* return value ERROR */ // consts for CAPS command: #define MUROAR_CF_REQUEST 0x0001 #define MUROAR_CT_CAPS 0 #define MUROAR_CT_STANDARDS 1 // stream directions: #define MUROAR_PLAY_WAVE 1 #define MUROAR_PLAY_MIDI 12 #define MUROAR_PLAY_LIGHT 14 #define MUROAR_RECORD_WAVE 2 #define MUROAR_MONITOR_WAVE 3 #define MUROAR_MONITOR_MIDI 13 #define MUROAR_MONITOR_LIGHT 15 #define MUROAR_FILTER_WAVE 4 // Codecs: #define MUROAR_CODEC_PCM_S_LE 0x01 #define MUROAR_CODEC_PCM_S_BE 0x02 #define MUROAR_CODEC_PCM_S_PDP 0x03 #define MUROAR_CODEC_PCM_U_LE 0x05 #define MUROAR_CODEC_PCM_U_BE 0x06 #define MUROAR_CODEC_PCM_U_PDP 0x07 #define MUROAR_CODEC_OGG_VORBIS 0x10 #define MUROAR_CODEC_FLAC 0x11 #define MUROAR_CODEC_OGG_SPEEX 0x12 #define MUROAR_CODEC_OGG_FLAC 0x14 #define MUROAR_CODEC_OGG_CELT 0x16 #define MUROAR_CODEC_ROAR_CELT 0x1a #define MUROAR_CODEC_ROAR_SPEEX 0x1b #define MUROAR_CODEC_RIFF_WAVE 0x20 #define MUROAR_CODEC_RIFX 0x22 #define MUROAR_CODEC_AU 0x24 #define MUROAR_CODEC_AIFF 0x28 #define MUROAR_CODEC_ALAW 0x30 #define MUROAR_CODEC_MULAW 0x34 #define MUROAR_CODEC_GSM 0x38 #define MUROAR_CODEC_GSM49 0x39 #define MUROAR_CODEC_MIDI 0x60 #define MUROAR_CODEC_DMX512 0x70 #define MUROAR_CODEC_ROARDMX 0x71 #ifdef __WIN32 #define MUROAR_CODEC_PCM_S MUROAR_CODEC_PCM_S_LE #define MUROAR_CODEC_PCM_U MUROAR_CODEC_PCM_U_LE #else #if BYTE_ORDER == BIG_ENDIAN #define MUROAR_CODEC_PCM_S MUROAR_CODEC_PCM_S_BE #define MUROAR_CODEC_PCM_U MUROAR_CODEC_PCM_U_BE #elif BYTE_ORDER == LITTLE_ENDIAN #define MUROAR_CODEC_PCM_S MUROAR_CODEC_PCM_S_LE #define MUROAR_CODEC_PCM_U MUROAR_CODEC_PCM_U_LE #else // most likely a PDP #define MUROAR_CODEC_PCM_S MUROAR_CODEC_PCM_S_PDP #define MUROAR_CODEC_PCM_U MUROAR_CODEC_PCM_U_PDP #endif #endif #define MUROAR_CODEC_PCM MUROAR_CODEC_PCM_S // muroar.c: muroar_t muroar_connect(const char * server, const char * name); // muroar_close.c: int muroar_close (muroar_t fh); // muroar_quit.c: int muroar_quit (muroar_t fh); // muroar_beep.c: int muroar_beep (muroar_t fh); // muroar_stream.c: muroar_t muroar_stream (muroar_t fh, int dir, int * stream, int codec, int rate, int channels, int bits); // muroario.c: ssize_t muroar_write (muroar_t fh, const void * buf, size_t len); ssize_t muroar_read (muroar_t fh, void * buf, size_t len); // muroar_noop.c: int muroar_noop (muroar_t fh); // muroar_setvolume.c: // We use (long unsigned int) here because we need a portable 16 bit type without . // (long unsigned int) should be big enough on all kind of archs. int muroar_setvolume (muroar_t fh, int stream, long unsigned int left, long unsigned int right); #ifdef __cplusplus } #endif #endif //ll muroar-0.1.13/muroar_beep.30000644000175000017500000000232111743002424013602 0ustar phiphi.\" muroar_beep.3 .TH "muroar_beep" "3" "April 2012" "muRoar" "muRoar Programmer's Manual" .SH NAME muroar_beep \- Send notify beep to RoarAudio sound daemon .SH SYNOPSIS #include int muroar_beep (muroar_t fh); .SH "DESCRIPTION" This function sends a notify beep to the sound daemon \fBfh\fR is connected to. \fBfh\fR need to be connected using \fBmuroar_connect\fR(3) to a sound server supporting the RoarAudio protocol and the BEEP command. .SH "RETURN VALUE" On success this call return 0. On error, \-1 is returned. .SH NOTES The beep is canceld at the server side as soon as the connection is closed. This means that you should not close the connection before the beep is played completely. .SH BUGS This commands requests the server for a default beep. No other kind of beep can be send. There is in addition no way to tell the actual length of the beep. The application should at least wait a bit more than 512ms before closing the socket. In case possible it is good to wait a minimum of about one secound to be really sure the beep ended. .SH HISTORY This function first appeared in muRoar version 0.1rc2. .SH "SEE ALSO" \fBmuroar_connect\fR(3), \fBmuroar_quit\fR(3), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroar_beep.c0000644000175000017500000000257412320263257013701 0ustar phiphi//muroar.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #include "muroar.h" // Set errno in case we have it #ifdef _HAVE_ERRNO #define _SET_ERRNO(x) (errno = (x)) #else #define _SET_ERRNO(x) #endif // Send notify beep. // We only support no-data default beeps. int muroar_beep (muroar_t fh) { unsigned char beep[] = "\0\30\0\0\0\0\0\0\0\0"; // BEEP command if ( fh == MUROAR_HANDLE_INVALID ) { _SET_ERRNO(EBADF); return -1; } if ( muroar_write(fh, beep, 10) != 10 ) return -1; if ( muroar_read(fh, beep, 10) != 10 ) return -1; if ( beep[1] != MUROAR_CMD_OK ) return -1; return 0; } //ll muroar-0.1.13/muroar_close.30000644000175000017500000000152011743002424013774 0ustar phiphi.\" muroar_beep.3 .TH "muroar_close" "3" "April 2012" "muRoar" "muRoar Programmer's Manual" .SH NAME muroar_close \- Disconnect stream from RoarAudio sound server .SH SYNOPSIS #include int muroar_close(muroar_t fh); .SH "DESCRIPTION" This function disconnects a data connection (stream) from the sound server in a clean way. The socket is closed by this function. No additional \fBclose\fR(2) is needed. Open control connections which are not created by \fBmuroar_stream\fR(3) must not be closed using this function. They must be closed using \fBmuroar_quit\fR(3). .SH "RETURN VALUE" On success this call return 0. On error, \-1 is returned. .SH HISTORY This function first appeared in muRoar version 0.1beta0. .SH "SEE ALSO" \fBmuroar_connect\fR(3), \fBmuroar_stream\fR(3), \fBmuroar_quit\fR(3), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroar_close.c0000644000175000017500000000204712320263257014066 0ustar phiphi//muroar_close.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #include "muroar.h" #include "private.h" // Close a data connection int muroar_close(muroar_t fh) { if ( fh == MUROAR_HANDLE_INVALID ) { _SET_ERRNO(EBADF); return -1; } _CLOSE(fh); return 0; } //ll muroar-0.1.13/muroar_connect.30000644000175000017500000000225111743002424014322 0ustar phiphi.\" muroar_beep.3 .TH "muroar_connect" "3" "April 2012" "muRoar" "muRoar Programmer's Manual" .SH NAME muroar_connect \- Opens a connection to a RoarAudio sound daemon .SH SYNOPSIS #include muroar_t muroar_connect(const char * server, const char * name); .SH "DESCRIPTION" This function opens a connection to sound server supporting the RoarAudio protocol. .SH "PARAMETERS" .TP \fBserver\fR The address of the server to connect to. May be set to NULL to connect to the default server. .TP \fBname\fB The name for the application. Should be set to some a string the user will recognize. For example use "OpenOffice Impress" not "soffice.bin" (process name). This can be set to NULL to use a generaic default string. However it is strongly recommented to set this to some useful string. .SH "RETURN VALUE" On success this call returns a file handle to a open connection. On error, MUROAR_HANDLE_INVALID is returned. .SH BUGS This function does currently not support DECnet (UNIX Sockets and IPv4 is supported). .SH HISTORY This function first appeared in muRoar version 0.1beta0. .SH "SEE ALSO" \fBmuroar_connect\fR(3), \fBmuroar_quit\fR(3), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroar_noop.30000644000175000017500000000154211743002424013646 0ustar phiphi.\" muroar_noop.3 .TH "muroar_noop" "3" "April 2012" "muRoar" "muRoar Programmer's Manual" .SH NAME muroar_noop \- Send no-operation command to RoarAudio sound daemon .SH SYNOPSIS #include int muroar_noop (muroar_t fh); .SH "DESCRIPTION" This function sends a no-operation command to the sound daemon \fBfh\fR is connected to. \fBfh\fR need to be connected using \fBmuroar_connect\fR(3) to a sound server supporting the RoarAudio protocol and the NOOP command. This function can be used to "ping" the server. It may for example be used as keep-alive for long running connections where no data is transfered. .SH "RETURN VALUE" On success this call return 0. On error, \-1 is returned. .SH HISTORY This function first appeared in muRoar version 0.1.2. .SH "SEE ALSO" \fBmuroar_connect\fR(3), \fBmuroar_quit\fR(3), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroar_noop.c0000644000175000017500000000247712320263257013743 0ustar phiphi//muroar_noop.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #include "muroar.h" // Set errno in case we have it #ifndef __WIN32 #include #define _SET_ERRNO(x) (errno = (x)) #else #define _SET_ERRNO(x) #endif int muroar_noop (muroar_t fh) { unsigned char msg[10] = "\0\0\0\0\0\0\0\0\0\0"; if ( fh == MUROAR_HANDLE_INVALID ) { _SET_ERRNO(EBADF); return -1; } if ( muroar_write(fh, msg, 10) != 10 ) return -1; if ( muroar_read(fh, msg, 10) != 10 ) return -1; if ( msg[1] != MUROAR_CMD_OK ) return -1; return 0; } //ll muroar-0.1.13/muroar_quit.30000644000175000017500000000145611743002424013661 0ustar phiphi.\" muroar_beep.3 .TH "muroar_quit" "3" "April 2012" "muRoar" "muRoar Programmer's Manual" .SH NAME muroar_quit \- Disconnect from RoarAudio sound server .SH SYNOPSIS #include int muroar_quit (muroar_t fh); .SH "DESCRIPTION" This function disconnects a control connection from the sound server in a clean way. The socket is closed by this function. No additional \fBclose\fR(2) is needed. Open data connections (streams) which are created by \fBmuroar_stream\fR(3) must not be closed using this function. They must be closed using \fBmuroar_close\fR(3). .SH "RETURN VALUE" On success this call return 0. On error, \-1 is returned. .SH HISTORY This function first appeared in muRoar version 0.1rc0. .SH "SEE ALSO" \fBmuroar_connect\fR(3), \fBmuroar_close\fR(3), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroar_quit.c0000644000175000017500000000255712320263257013751 0ustar phiphi//muroar_quit.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #include "muroar.h" #include "private.h" // Close a control connection by sending QUIT command. int muroar_quit (muroar_t fh) { char quit[] = "\0\6\0\0\0\0\0\0\0\0"; // QUIT command int ret = 0; if ( fh == MUROAR_HANDLE_INVALID ) { _SET_ERRNO(EBADF); return -1; } if ( muroar_write(fh, quit, 10) != 10 ) ret = -1; // read in case the server response // ignore errors as the server do not necessary // response to our request. muroar_read(fh, quit, 10); if ( muroar_close(fh) == -1 ) ret = -1; return ret; } //ll muroar-0.1.13/muroar_read.30000644000175000017500000000233611743002424013610 0ustar phiphi.\" muroar_beep.3 .TH "muroar_read" "3" "April 2012" "muRoar" "muRoar Programmer's Manual: IO Extension" .SH NAME muroar_read \- Read data from a stream in a portable way .SH SYNOPSIS #include ssize_t muroar_read (muroar_t fh, void * buf, size_t len); .SH "DESCRIPTION" This function reads data from a stream connected to a sound server. It exists to have a portable way to read data from the sound server that does not depend on the underlying operating system. .SH "PARAMETERS" .TP \fBfh\fR The stream file handle connected to the server. This must be opend using \fBmuroar_stream\fB(3). .TP \fBbuf\fR A pointer to the block of data that should be read. .TP \fBlen\fR The total length in byte of the data that should be read. .SH "RETURN VALUE" On success this call return the number of bytes successful read. On error, \-1 is returned. .SH NOTES This function calls the underlying read function in a loop. If this returns less than the given length you should not re-try directly but wait at least some milisecunds. .SH HISTORY This function first appeared in muRoar version 0.1beta0. .SH "SEE ALSO" \fBread\fR(2), \fBmuroar_write\fR(3), \fBmuroar_stream\fR(3), \fBmuroar_close\fR(3), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroar_setvolume.30000644000175000017500000000312111755653171014727 0ustar phiphi.\" muroar_beep.3 .TH "muroar_setvolume" "3" "April 2012" "muRoar" "muRoar Programmer's Manual" .SH NAME muroar_setvolume \- Set volume of a stream on a RoarAudio sound server .SH SYNOPSIS #include int muroar_setvolume (muroar_t fh, int stream, long unsigned int left, long unsigned int right); .SH "DESCRIPTION" This function sets the volume of a stream on a sound server supporting the RoarAudio protocol. It takes a connected control connection created with \fBroar_connect\fR(3) and used it to comunicate with the already connected server. In addition it takes the stream ID and the volume for the left and right channel. This function supports both mono and stereo streams. It also supports setting volume to multi-channel streams if the server supports UNMAPPED mode. To set a volume in mono just provide the same volume for both (left and right channel) channels. .SH "PARAMETERS" .TP \fBfh\fR The connected control connection. .TP \fBstream\fR This is the ID of the stream to set the volume for. .TP \fBleft\fR, \fBright\fR This is the volume of the corresponding channel. The value is a 16 bit unsigned number so it has the range from 0 (truely muted, -InfdB) to 65535 (full volume, 0dB). .SH "RETURN VALUE" On success this call return 0. On error, \-1 is returned. .SH BUGS In failure where is no way to tell was was going wrong. In case of failture the control connection needs to be closed with \fBmuroar_close\fR(3). .SH HISTORY This function first appeared in muRoar version 0.1.8. .SH "SEE ALSO" \fBmuroar_connect\fR(3), \fBmuroar_close\fR(3), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroar_setvolume.c0000644000175000017500000000446012320263257015005 0ustar phiphi//muroar_setvolume.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #include "muroar.h" #include "private.h" // for memset(): #include int muroar_setvolume (muroar_t fh, int stream, long unsigned int left, long unsigned int right) { unsigned char buf[20]; unsigned char ans[10]; int channels; int mode; size_t len; if ( fh == MUROAR_HANDLE_INVALID ) { _SET_ERRNO(EBADF); return -1; } if ( stream < 0 ) { _SET_ERRNO(EINVAL); return -1; } memset(buf, 0, sizeof(buf)); // header: buf[1] = MUROAR_CMD_SET_VOL; buf[2] = (stream & 0xFF00) >> 8; buf[3] = (stream & 0x00FF); // body: buf[10] = 0; // Version MSB buf[11] = 1; // Version LSB buf[12] = 0xFF; // scale MSB buf[13] = 0xFF; // scale LSB buf[14] = 0; // mode MSB for (channels = 2; channels > 0; channels--) { len = 10 + 6 + 2*channels; // total request length. buf[9] = len - 10; // body length LSB, the 10 is thhe header length for (mode = 4; mode > 0; mode -= 3) { buf[15] = mode; // mode LSB buf[16] = (left & 0xFF00) >> 8; // channel 0 MSB buf[17] = (left & 0x00FF); // channel 0 LSB buf[18] = (right & 0xFF00) >> 8; // channel 1 MSB buf[19] = (right & 0x00FF); // channel 1 LSB // send request: if ( muroar_write(fh, buf, len) != (ssize_t)len ) { return -1; } if ( muroar_read(fh, ans, 10) != 10 ) { return -1; } if ( ans[1] == MUROAR_CMD_OK ) return 0; } left = left/2 + right/2; } #ifdef ENOTSUP _SET_ERRNO(ENOTSUP); #else _SET_ERRNO(ENOSYS); #endif return -1; } //ll muroar-0.1.13/muroar_stream.30000644000175000017500000000431711743002424014171 0ustar phiphi.\" muroar_beep.3 .TH "muroar_stream" "3" "April 2012" "muRoar" "muRoar Programmer's Manual" .SH NAME muroar_stream \- Create a stream connected to a RoarAudio sound server .SH SYNOPSIS #include muroar_t muroar_stream (muroar_t fh, int dir, int * stream, int codec, int rate, int channels, int bits); .SH "DESCRIPTION" This function connects a stream to a sound server supporting the RoarAudio protocol. It takes a connected control connection created with \fBroar_connect\fR(3) and converts it into a connected stream. The socket can no longer be used as control connection. .SH "PARAMETERS" .TP \fBfh\fR The connected control connection. .TP \fBdir\fR The stream direction for the new stream. For playback of a waveform stream (PCM data) this is MUROAR_PLAY_WAVE. For all possible values see the offical muRoar manual. .TP \fBstream\fR This is a pointer to an integer muRoar stores the stream ID in. If your application does not need to know the stream ID of the new stream this can be set to NULL. .TP \fBcodec\fR This is the codec to be used for the new stream. For signed PCM in host byte order use MUROAR_CODEC_PCM or MUROAR_CODEC_PCM_S. For unsigned PCM use MUROAR_CODEC_PCM_U. There are a lot other codecs defined. However using a codec not supported by the server will result an failure of this call. For all possible values see the offical muRoar manual. .TP \fBrate\fR This is the sample/frame rate the new stream will use. For streams this setting does not make any sense set this to zero. .TP \fBchannels\fR This is the number of channels for the new stream. For streams this setting does not make any sense set this to zero. .TP \fBbits\fR This is the number of bits per sample to be used by the data. For streams this setting does not make any sense set this to zero. .SH "RETURN VALUE" On success this call return the new stream IO handle. This may be the same as the control connection or a new one and the control connection is closed. On error, MUROAR_HANDLE_INVALID is returned. .SH BUGS In failure where is no way to tell was was going wrong. .SH HISTORY This function first appeared in muRoar version 0.1beta0. .SH "SEE ALSO" \fBmuroar_connect\fR(3), \fBmuroar_close\fR(3), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroar_stream.c0000644000175000017500000000545012320263257014255 0ustar phiphi//muroar_stream.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #include "muroar.h" #include "private.h" // for memset(): #include // Open a Stream muroar_t muroar_stream(muroar_t fh, int dir, int * stream, int codec, int rate, int channels, int bits) { unsigned char buf[24]; uint16_t sid; uint32_t * data = (uint32_t*)buf; int i; if ( fh == MUROAR_HANDLE_INVALID ) { _SET_ERRNO(EBADF); return MUROAR_HANDLE_INVALID; } // Send NEW_STREAM command: memset(buf, 0, 10); buf[1] = MUROAR_CMD_NEW_STREAM; buf[2] = 0xFF; // byte 2 and 3 are mixer ID (must be -1) buf[3] = 0xFF; buf[9] = 24; // 6 * int32 = 24 Byte if ( muroar_write(fh, buf, 10) != 10 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } data[0] = dir; // Stream Direction data[1] = -1; // Rel Pos ID data[2] = rate; // Sample Rate data[3] = bits; // Bits per Sample data[4] = channels; // Number of Channels data[5] = codec; // Used Codec for (i = 0; i < 6; i++) data[i] = htonl(data[i]); if ( muroar_write(fh, buf, 24) != 24 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } if ( muroar_read(fh, buf, 10) != 10 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } if ( buf[1] != MUROAR_CMD_OK ) { _CLOSE(fh); _SET_ERRNO(EINVAL); return MUROAR_HANDLE_INVALID; } // Stream ID of new stream is in byte 2 and 3 of header, // encoded in network byte order. sid = (buf[2] << 8) | buf[3]; // Send EXEC_STREAM command: memset(buf, 0, 10); buf[1] = MUROAR_CMD_EXEC_STREAM; // set Stream ID: buf[2] = (sid & 0xFF00) >> 8; buf[3] = (sid & 0x00FF); if ( muroar_write(fh, buf, 10) != 10 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } if ( muroar_read(fh, buf, 10) != 10 ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } if ( buf[1] != MUROAR_CMD_OK ) { _CLOSE(fh); return MUROAR_HANDLE_INVALID; } // Set Stream ID in case caller want to know (passed non-NULL): if ( stream != NULL ) *stream = sid; // we converted the control connection to a stream connection, // return it. return fh; } //ll muroar-0.1.13/muroar_write.30000644000175000017500000000234711743002424014031 0ustar phiphi.\" muroar_beep.3 .TH "muroar_write" "3" "April 2012" "muRoar" "muRoar Programmer's Manual: IO Extension" .SH NAME muroar_write \- Write data to a stream in a portable way .SH SYNOPSIS #include ssize_t muroar_write (muroar_t fh, const void * buf, size_t len); .SH "DESCRIPTION" This function writes a block of data to a connected stream. It exists to have a portable way to send the data to the sound server that does not depend on the underlying operating system. .SH "PARAMETERS" .TP \fBfh\fR The stream file handle connected to the server. This must be opend using \fBmuroar_stream\fB(3). .TP \fBbuf\fR A pointer to the block of data that should be written. .TP \fBlen\fR The total length in byte of the data that should be written. .SH "RETURN VALUE" On success this call return the number of successful written bytes. On error, \-1 is returned. .SH NOTES This function calls the underlying write function in a loop. If this returns less than the given length you should not re-try directly but wait at least some milisecunds. .SH HISTORY This function first appeared in muRoar version 0.1beta0. .SH "SEE ALSO" \fBwrite\fR(2), \fBmuroar_read\fR(3), \fBmuroar_stream\fR(3), \fBmuroar_close\fR(3), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroario.c0000644000175000017500000000545312320263260013227 0ustar phiphi//muroario.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #include "muroar.h" #ifdef __WIN32 #include #include #elif !defined(__YIFF__) #include #include #endif /* The following IO functions write or read data in a loop * unless a they wrote or read all the requested size or * IO error occurs. * This may be needed as underlying IO layer may only work * with sizes less than the one we try to use or got interrupted * while the operation or something else happens leading in * incomplete processing of the block of data. * This was first written because of bugs in win32's network * stack. */ ssize_t muroar_write (muroar_t fh, const void * buf, size_t len) { ssize_t ret; ssize_t done = 0; if ( fh == MUROAR_HANDLE_INVALID || buf == NULL ) return -1; while (len) { #if MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_SYSIO || MUROAR_HDLTYPE == MUROAR_HDLTYPE_WIN32_SOCKET if ( (ret = send(fh, buf, len, 0)) < 1 ) return done; #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_STDIO if ( (ret = fwrite(buf, 1, len, fh)) < 1 ) return done; #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_YIFF_VIO if ( (ret = yiffc_write(fh, buf, len)) < 1 ) return done; #else #error Unsupported value for MUROAR_HDLTYPE #endif done += ret; buf = (const char *)buf + ret; len -= ret; } return done; } ssize_t muroar_read (muroar_t fh, void * buf, size_t len) { ssize_t ret; ssize_t done = 0; if ( fh == MUROAR_HANDLE_INVALID || buf == NULL ) return -1; while (len) { #if MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_SYSIO || MUROAR_HDLTYPE == MUROAR_HDLTYPE_WIN32_SOCKET if ( (ret = recv(fh, buf, len, 0)) < 1 ) return done; #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_STDIO if ( (ret = fread(buf, 1, len, fh)) < 1 ) return done; #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_YIFF_VIO if ( (ret = yiffc_read(fh, buf, len)) < 1 ) return done; #else #error Unsupported value for MUROAR_HDLTYPE #endif done += ret; buf = (char *)buf + ret; len -= ret; } return done; } //ll muroar-0.1.13/muroarstream.10000644000175000017500000000416212004743724014034 0ustar phiphi.\" muroarstream.1: .TH "muroarstream" "1" "22 February 2010" "muRoar" "System User's Manual: muroarstream" .SH NAME muroarstream \- Simple RoarAudio client .SH SYNOPSIS muroarstream [OPTIONS] .SH DESCRIPTION muroarstream is a simple client for the RoarAudio sound system. It is based on muRoar (libmuroar). It can only be used to send data to or get data from the server. No control functionality is supported. .SH "OPTIONS" .TP \fB--help\fR Display a brief help. .TP \fB-f \-\-file FILE\fR Sets the file to read from or write to. .TP \fB--server SERVER\fR Sets the server to SERVER. Default is to auto detect the server. (see below) .TP \fB-R \-\-rate RATE\fR Sets the sample rate. This defaults to 44100Hz. .TP \fB-C \-\-channels CHANS\fR Sets the number of channels. this defaults to 2 channels (stereo). Symbolic names "mono" and "stereo" as well as "default" can be used. .TP \fB-B \-\-bits BITS\fR Sets the number of bits per sample. The default is 16bit per sample. .TP \fB-E \-\-codec CODEC\fR Sets the codec to use. The default depends on used subsystem. For Waveform it uses Signed native PCM, for Light DMX512 and for MIDI MIDI. The following symbolic names can be used: default, pcm, pcm_s, pcm_u, ogg_vorbis, vorbis, alaw, mulaw, ulaw, dmx512, roardmx, midi. .TP \fB--play\fR Use Playback mode (send data to the server). This is the default. .TP \fB--monitor\fR Use monitor mode (get a copy of the played data from the server). .TP \fB--wave\fR Use Waveform subsystem (default). .TP \fB--midi\fR Use MIDI subsystem. .TP \fB--light\fR Use Light Control subsystem. .SH "AUTO DETECTION" The server will be auto located if no server name is given. First it will look for the environment variable $ROAR_SERVER. If this variable is non existing libmuroar will do the auto location based on a list of possible server locations. This list contains the user's private socket address, the global UNIX socket address, an entry for localhost using TCP/IP, the local default DECnet object address as well as an entry for the abstract UNIX namespace (+abstract). .SH "SEE ALSO" \fBroarcat\fR(1), \fBRoarAudio\fR(7). .\" ll muroar-0.1.13/muroarstream.c0000644000175000017500000001556212320263260014115 0ustar phiphi//muroarstream.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #include "muroar.h" #ifndef __WIN32 #include #endif #include #include #include #include #include #ifndef O_LARGEFILE #define O_LARGEFILE 0 #endif #define NAME "muroarstream" static int str2chans(const char * chans) { if ( !strcasecmp(chans, "stereo") ) return MUROAR_CM_STEREO; if ( !strcasecmp(chans, "mono") ) return MUROAR_CM_MONO; if ( !strcasecmp(chans, "default") ) return MUROAR_AID_CHANNELS; return atoi(chans); } static int str2codec(const char * codec) { if ( !strcasecmp(codec, "default") ) return -1; if ( !strcasecmp(codec, "pcm") || !strcasecmp(codec, "pcm_s") ) return MUROAR_CODEC_PCM_S; if ( !strcasecmp(codec, "pcm_u") ) return MUROAR_CODEC_PCM_U; if ( !strcasecmp(codec, "alaw") ) return MUROAR_CODEC_ALAW; if ( !strcasecmp(codec, "mulaw") || !strcasecmp(codec, "ulaw") ) return MUROAR_CODEC_MULAW; if ( !strcasecmp(codec, "ogg_vorbis") || !strcasecmp(codec, "vorbis") ) return MUROAR_CODEC_OGG_VORBIS; if ( !strcasecmp(codec, "dmx512") ) return MUROAR_CODEC_DMX512; if ( !strcasecmp(codec, "roardmx") ) return MUROAR_CODEC_ROARDMX; if ( !strcasecmp(codec, "midi") ) return MUROAR_CODEC_MIDI; return atoi(codec); } void usage (char * progname) { printf("Usage: %s [OPTIONS]\n", progname); printf("\n"); printf("Options:\n"); printf(" --help - Display this help.\n" " -f --file FILE - File to read from or write to. (default: stdin/stdout)\n" " --server SERVER - Sets the server. (default: autodetect)\n" " -R --rate RATE - Sets the sample rate (default: 44100Hz)\n" " -C --channels CHANS - Sets the number of channels (default: 2 channels)\n" " -B --bits BITS - Sets the number of bits per sample (default: 16bit)\n" " -E --codec CODEC - Set codec to use (default: depend on used subsystem)\n" " --play - Use Playback mode (send data to the server) (default)\n" " --monitor - Use monitor mode (get a copy of the played data from the server)\n" " --wave - Use Waveform subsystem (default)\n" " --midi - Use MIDI subsystem\n" " --light - Use Light Control subsystem\n" ); } void run_stream(muroar_t stream, int file, int tx) { char buf[1024]; ssize_t len; if ( tx ) { if ( file == -1 ) file = STDIN_FILENO; while ((len = read(file, buf, sizeof(buf))) > 0) if ( muroar_write(stream, buf, len) != len ) return; } else { if ( file == -1 ) file = STDOUT_FILENO; while ((len = muroar_read(stream, buf, sizeof(buf))) > 0) if ( write(file, buf, len) != len ) return; } } #define __check_argc(num) if ( (argc - i) <= (num) ) { fprintf(stderr, "Error: Invalid number of arguments.\n"); \ return 64; } #ifdef __YIFF__ yiff_uint_least16_t yiff_main(yiff_usize_t argc, char * argv[]) { #else int main (int argc, char *argv[]) { #endif muroar_t fh; int filefh = -1; int dir = MUROAR_PLAY_WAVE; int codec = -1; /* use default depending in dir */ int rate = MUROAR_AID_RATE; int chans = MUROAR_AID_CHANNELS; int bits = MUROAR_AID_BITS; int tx = 1; #ifdef __YIFF__ yiff_usize_t i; #else int i; #endif char * k; const char * server = NULL; const char * file = NULL; for (i = 1; i < argc; i++) { k = argv[i]; if ( !strcmp(k, "--help") ) { usage(argv[0]); return 0; } else if ( !strcmp(k, "--file") || !strcmp(k, "-f") ) { __check_argc(1) file = argv[++i]; } else if ( !strcmp(k, "--server") ) { __check_argc(1) server = argv[++i]; } else if ( !strcmp(k, "--rate") || !strcmp(k, "-R") ) { __check_argc(1) rate = atoi(argv[++i]); } else if ( !strcmp(k, "--channels") || !strcmp(k, "-C") ) { __check_argc(1) chans = str2chans(argv[++i]); } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) { __check_argc(1) bits = atoi(argv[++i]); } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) { __check_argc(1) codec = str2codec(argv[++i]); } else if ( !strcmp(k, "--play") ) { tx = 1; } else if ( !strcmp(k, "--monitor") ) { tx = 0; } else if ( !strcmp(k, "--wave") ) { dir = MUROAR_PLAY_WAVE; } else if ( !strcmp(k, "--midi") ) { dir = MUROAR_PLAY_MIDI; } else if ( !strcmp(k, "--light") ) { dir = MUROAR_PLAY_LIGHT; } else { fprintf(stderr, "%s: Unknown argument: %s\n", argv[0], k); return 4; } } // Set codec depending on dir in case codec is default (-1): if ( codec == -1 ) { switch (dir) { case MUROAR_PLAY_WAVE: codec = MUROAR_CODEC_PCM; break; case MUROAR_PLAY_MIDI: codec = MUROAR_CODEC_MIDI; break; case MUROAR_PLAY_LIGHT: codec = MUROAR_CODEC_DMX512; break; } } // Correct dir in case we do not transmit to MONITOR dirs: if ( !tx ) { switch (dir) { case MUROAR_PLAY_WAVE: dir = MUROAR_MONITOR_WAVE; break; case MUROAR_PLAY_MIDI: dir = MUROAR_MONITOR_MIDI; break; case MUROAR_PLAY_LIGHT: dir = MUROAR_MONITOR_LIGHT; break; } } if ( file != NULL ) { filefh = open(file, O_LARGEFILE|(tx ? O_RDONLY : O_WRONLY|O_CREAT|O_TRUNC), 0666); if ( filefh == -1 ) { fprintf(stderr, "Error: Can not open file: %s\n", file); return 5; } } // Connect to server: if ( (fh = muroar_connect(server, NAME)) == MUROAR_HANDLE_INVALID ) { #ifndef __WIN32 fprintf(stderr, "Error: Can not connect to server: %s: %s.\n", server == NULL ? "(default)" : server, strerror(errno)); #else fprintf(stderr, "Error: Can not connect to server.\n"); #endif return 1; } if ( (fh = muroar_stream(fh, dir, NULL, codec, rate, chans, bits)) == MUROAR_HANDLE_INVALID ) { #ifndef __WIN32 fprintf(stderr, "Error: Can not connect stream to server: %s\n", strerror(errno)); #else fprintf(stderr, "Error: Can not connect stream to server.\n"); #endif // We do not need to close fh here as it is already closed by muroar_stream(). return 2; } run_stream(fh, filefh, tx); muroar_close(fh); if ( filefh != -1 ) close(filefh); return 0; } //ll muroar-0.1.13/private.h0000644000175000017500000000467212320263260013053 0ustar phiphi//private.h: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2014 * * This file is part of µRoar, * a minimalist library to access a RoarAudio Sound Server. * * µRoar is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * µRoar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with µRoar. If not, see . */ #ifndef _PRIVATE_H_ #define _PRIVATE_H_ #include "muroar.h" #ifdef __YIFF__ #include #include #include #include #include #elif defined(__WIN32) #include #include #else #include /* for errno keeping in _CLOSE() */ #define _HAVE_ERRNO #include #include #if !defined(__WIN32) && defined(AF_UNIX) && !defined(NO_AF_UNIX) #define HAVE_AF_UNIX #include #endif #include #endif #ifdef HAVE_LIB_DNET #include #include #endif // Win32 needs different close function for sockets because of // it's broken design. #ifdef __WIN32 #define __CLOSE(x) closesocket((x)) #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_YIFF_VIO #define __CLOSE(x) { yiffc_error_t __olderr = yiffc_error; yiffc_id_unref((x)); yiffc_error = __olderr; } #else #define __CLOSE(x) { int __olderr = errno; close((x)); errno = __olderr; } #endif #if MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_SYSIO #define _CLOSE(x) __CLOSE((x)) #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_POSIX_STDIO #define _CLOSE(x) { int __olderr = errno; fclose((x)); errno = __olderr; } #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_WIN32_SOCKET #define _CLOSE(x) __CLOSE((x)) #elif MUROAR_HDLTYPE == MUROAR_HDLTYPE_YIFF_VIO #define _CLOSE(x) { yiffc_error_t __olderr = yiffc_error; yiffc_close((x)); yiffc_error = __olderr; } #else #error Unsupported value for MUROAR_HDLTYPE #endif // Set errno in case we have it #ifdef _HAVE_ERRNO #define _SET_ERRNO(x) (errno = (x)) #else #define _SET_ERRNO(x) #endif #endif //ll muroar-0.1.13/dist/0000755000175000017500000000000012320263553012167 5ustar phiphimuroar-0.1.13/dist/OpenBSD/0000755000175000017500000000000012320263553013421 5ustar phiphimuroar-0.1.13/dist/OpenBSD/pkg/0000755000175000017500000000000012320263553014202 5ustar phiphimuroar-0.1.13/dist/OpenBSD/pkg/DESCR0000644000175000017500000000032211304220410014744 0ustar phiphiµRoar is a minimalist library used to send music and other data to a RoarAudio server. This library is written for programs that are not compatible with GPL. GPL compatible programs should use libroar instead. muroar-0.1.13/dist/OpenBSD/pkg/PLIST0000644000175000017500000000017011342315357015021 0ustar phiphi@bin bin/muroarstream @man man/man1/muroarstream.1 include/muroar.h lib/libmuroar.so.0 lib/libmuroar.so lib/libmuroar.a muroar-0.1.13/dist/OpenBSD/Makefile0000644000175000017500000000125611342315366015070 0ustar phiphiCOMMENT = minimalist library to access RoarAudio V = 0.1rc2 DISTNAME = muroar-$V CATEGORIES = audio HOMEPAGE = http://roaraudio.keep-cool.org/ MASTER_SITES = ${HOMEPAGE}dl/ MAINTAINER = Philipp ph3-der-loewe Schafft # LGPLv3 PERMIT_DISTFILES_CDROM = Yes PERMIT_DISTFILES_FTP = Yes PERMIT_PACKAGE_CDROM = Yes PERMIT_PACKAGE_FTP = Yes LIB_DEPENDS = c WANTLIB = c USE_GMAKE = Yes NO_REGRESS = Yes CONFIGURE_STYLE = simple CONFIGURE_ARGS += --prefix ${WRKINST}${PREFIX} \ --prefix-man ${WRKINST}${PREFIX}/man .include