summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am43
-rwxr-xr-xbootstrap.sh47
-rw-r--r--configure.ac83
-rw-r--r--src/Makefile.am27
-rw-r--r--src/ao_polyp.c185
5 files changed, 385 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..3d03e36
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,43 @@
+# $Id$
+#
+# This file is part of libao-polyp.
+#
+# libao-polyp is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# libao-polyp 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with libao-polyp; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+EXTRA_DIST = bootstrap.sh
+#README LICENSE
+SUBDIRS=src
+# doc
+
+#MAINTAINERCLEANFILES=README
+#noinst_DATA = README
+
+README:
+ rm -f README
+ $(MAKE) -C doc README
+ cd $(srcdir) && ln -s doc/README README
+
+homepage: all dist
+ test -d $$HOME/homepage/private
+ mkdir -p $$HOME/homepage/private/projects/paman
+ cp *.tar.gz $$HOME/homepage/private/projects/paman
+ cp doc/README.html doc/screenshot.png doc/style.css $$HOME/homepage/private/projects/paman
+ cp $$HOME/homepage/private/projects/paman/README.html $$HOME/homepage/private/projects/paman/index.html
+
+distcleancheck:
+ @:
+
+.PHONY: homepage distcleancheck
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 0000000..c2e8bbc
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# $Id$
+
+# This file is part of libao-polyp.
+#
+# libao-polyp is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# libao-polyp 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with libao-polyp; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+run_versioned() {
+ local P
+ type -p "$1-$2" &> /dev/null && P="$1-$2" || local P="$1"
+
+ shift 2
+ "$P" "$@"
+}
+
+if [ "x$1" = "xam" ] ; then
+ set -ex
+ run_versioned automake 1.7 -a -c --foreign
+ ./config.status
+else
+ set -ex
+
+ rm -rf autom4te.cache
+ rm -f config.cache
+
+ run_versioned aclocal 1.7
+ libtoolize -c --force
+ autoheader
+ run_versioned automake 1.7 -a -c --foreign
+ autoconf -Wall
+
+ CFLAGS="-g -O0" ./configure --sysconfdir=/etc "$@"
+
+ make clean
+fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..42cb2ca
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,83 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+# $Id$
+
+# This file is part of libao-polyp.
+#
+# libao-polyp is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# libao-polyp 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with libao-polyp; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+AC_PREREQ(2.57)
+AC_INIT([libao-polyp],[0.1],[mzyvonbcbylc (at) 0pointer (dot) de])
+AC_CONFIG_SRCDIR([src/ao_polyp.c])
+AC_CONFIG_HEADERS([config.h])
+AM_INIT_AUTOMAKE([foreign -Wall])
+
+AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/libao-polyp/])
+
+if type -p stow > /dev/null && test -d /usr/local/stow ; then
+ AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
+ ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
+fi
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_LN_S
+AC_PROG_LIBTOOL
+
+AC_TYPE_SIGNAL
+AC_HEADER_STDC
+AC_CHECK_FUNCS([memset strdup])
+AC_C_CONST
+AC_FUNC_MALLOC
+
+if test -d ../polypaudio ; then
+ POLYP_CFLAGS='-I$(top_srcdir)/../polypaudio'
+ POLYP_LIBS='-L$(top_srcdir)/../polypaudio/polyp -lpolyp-simple'
+ echo "*** Found polypaudio in ../polypaudio, using that version ***"
+else
+ PKG_CHECK_MODULES(POLYP, [ polyplib-simple ])
+fi
+
+AC_SUBST(POLYP_LIBS)
+AC_SUBST(POLYP_CFLAGS)
+
+# If using GCC specifiy some additional parameters
+if test "x$GCC" = "xyes" ; then
+ CFLAGS="$CFLAGS -pipe -Wall -W -Wno-unused-parameter"
+fi
+
+# LYNX documentation generation
+AC_ARG_ENABLE(lynx,
+ AS_HELP_STRING(--disable-lynx,Turn off lynx usage for documentation generation),
+[case "${enableval}" in
+ yes) lynx=yes ;;
+ no) lynx=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-lynx) ;;
+esac],[lynx=yes])
+
+if test x$lynx = xyes ; then
+ AC_CHECK_PROG(have_lynx, lynx, yes, no)
+
+ if test x$have_lynx = xno ; then
+ AC_MSG_ERROR([*** Sorry, you have to install lynx or use --disable-lynx ***])
+ fi
+fi
+
+AM_CONDITIONAL([USE_LYNX], [test "x$lynx" = xyes])
+
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..80795ce
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,27 @@
+# $Id$
+#
+# This file is part of libao-polyp.
+#
+# libao-polyp is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# libao-polyp 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with libao-polyp; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+aolibdir=$(libdir)/ao/plugins-2
+
+aolib_LTLIBRARIES=libpolyp.la
+
+libpolyp_la_SOURCES=ao_polyp.c
+libpolyp_la_LDFLAGS=-module -avoid-version
+libpolyp_la_LIBADD=$(AM_LIBADD) $(POLYP_LIBS)
+libpolyp_la_CFLAGS=$(AM_CFLAGS) $(POLYP_CLAGS)
diff --git a/src/ao_polyp.c b/src/ao_polyp.c
new file mode 100644
index 0000000..dd0b43c
--- /dev/null
+++ b/src/ao_polyp.c
@@ -0,0 +1,185 @@
+/* $Id$ */
+
+/***
+ This file is part of libao-polyp.
+
+ libao-polyp is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ libao-polyp 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libao-polyp; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#include <assert.h>
+#include <string.h>
+#include <signal.h>
+
+#include <polyp/polyplib-simple.h>
+#include <ao/ao.h>
+#include <ao/plugin.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* Unfortunately libao doesn't allow "const" for these structures... */
+static char * ao_polyp_options[] = {
+ "server",
+ "sink"
+};
+
+static ao_info ao_polyp_info = {
+ AO_TYPE_LIVE,
+ "polypaudio output",
+ "polyp",
+ PACKAGE_BUGREPORT,
+ "Outputs to the Polypaudio Sound Server",
+ AO_FMT_NATIVE,
+ 41,
+ ao_polyp_options,
+ 2
+};
+
+typedef struct ao_polyp_internal {
+ struct pa_simple *simple;
+ char *server, *sink;
+} ao_polyp_internal;
+
+/* Yes, this is very ugly, but required... */
+static void disable_sigpipe(void) {
+ struct sigaction sa;
+
+ sigaction(SIGPIPE, NULL, &sa);
+ if (sa.sa_handler != SIG_IGN) {
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = SA_RESTART;
+ sigaction(SIGPIPE, &sa, NULL);
+ }
+}
+
+int ao_plugin_test(void) {
+ struct pa_simple *s;
+ static const struct pa_sample_spec ss = {
+ .format = PA_SAMPLE_S16LE,
+ .rate = 44100,
+ .channels = 2
+ };
+
+ disable_sigpipe();
+
+ if (getenv("POLYP_SERVER") || getenv("POLYP_SINK"))
+ return 1;
+
+ if (!(s = pa_simple_new(NULL, "libao", PA_STREAM_PLAYBACK, NULL, "libao test", &ss, NULL, NULL)))
+ return 0;
+
+ pa_simple_free(s);
+ return 1;
+}
+
+ao_info *ao_plugin_driver_info(void) {
+ return &ao_polyp_info;
+}
+
+int ao_plugin_device_init(ao_device *device) {
+ ao_polyp_internal *internal;
+ assert(device);
+
+ internal = (ao_polyp_internal *) malloc(sizeof(ao_polyp_internal));
+
+ if (internal == NULL)
+ return 0;
+
+ internal->simple = NULL;
+ internal->server = NULL;
+ internal->sink = NULL;
+ device->internal = internal;
+
+ return 1;
+}
+
+int ao_plugin_set_option(ao_device *device, const char *key, const char *value) {
+ ao_polyp_internal *internal;
+ assert(device && device->internal && key && value);
+ internal = (ao_polyp_internal *) device->internal;
+
+ if (!strcmp(key, "server")) {
+ free(internal->server);
+ internal->server = strdup(value);
+ } else if (!strcmp(key, "sink")) {
+ free(internal->sink);
+ internal->sink = strdup(value);
+ } else
+ return 0;
+
+ return 1;
+}
+
+int ao_plugin_open(ao_device *device, ao_sample_format *format) {
+ ao_polyp_internal *internal;
+ struct pa_sample_spec ss;
+
+ assert(device && device->internal && format);
+
+ internal = (ao_polyp_internal *) device->internal;
+
+ if (format->bits == 8)
+ ss.format = PA_SAMPLE_U8;
+ else if (format->bits == 16)
+ ss.format = PA_SAMPLE_S16NE;
+ else
+ return 0;
+
+ if (format->channels <= 0)
+ return 0;
+
+ ss.channels = format->channels;
+ ss.rate = format->rate;
+
+ disable_sigpipe();
+
+ if (!(internal->simple = pa_simple_new(internal->server, "libao", PA_STREAM_PLAYBACK, internal->sink, "libao Playback Stream", &ss, NULL, NULL)))
+ return 0;
+
+ device->driver_byte_format = AO_FMT_NATIVE;
+ return 1;
+}
+
+int ao_plugin_play(ao_device *device, const char* output_samples, uint_32 num_bytes) {
+ assert(device && device->internal);
+ ao_polyp_internal *internal = (ao_polyp_internal *) device->internal;
+
+ return pa_simple_write(internal->simple, output_samples, num_bytes, NULL) >= 0;
+}
+
+
+int ao_plugin_close(ao_device *device) {
+ assert(device && device->internal);
+ ao_polyp_internal *internal = (ao_polyp_internal *) device->internal;
+
+ pa_simple_drain(internal->simple, NULL);
+ pa_simple_free(internal->simple);
+ internal->simple = NULL;
+
+ return 1;
+}
+
+void ao_plugin_device_clear(ao_device *device) {
+ assert(device && device->internal);
+ ao_polyp_internal *internal = (ao_polyp_internal *) device->internal;
+
+ free(internal->server);
+ free(internal->sink);
+ free(internal);
+ device->internal = NULL;
+}