From 8658babe3c2996c2b7780b93f4c94620be926586 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Jun 2006 18:41:09 +0000 Subject: s/polyp/pulse/g git-svn-id: file:///home/lennart/svn/public/libao-pulse/trunk@27 a8d83910-18e2-0310-866c-8ed7f9518005 --- Makefile.am | 16 ++--- bootstrap.sh | 8 +-- configure.ac | 28 ++++---- doc/Makefile.am | 8 +-- doc/style.css | 8 +-- src/Makefile.am | 18 ++--- src/ao_polyp.c | 204 -------------------------------------------------------- src/ao_pulse.c | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 247 insertions(+), 247 deletions(-) delete mode 100644 src/ao_polyp.c create mode 100644 src/ao_pulse.c diff --git a/Makefile.am b/Makefile.am index 31883d3..3b200e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,19 +1,19 @@ # $Id$ # -# This file is part of libao-polyp. +# This file is part of libao-pulse. # -# libao-polyp is free software; you can redistribute it and/or modify +# libao-pulse 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 +# libao-pulse 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 +# along with libao-pulse; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. @@ -30,9 +30,9 @@ README: homepage: all dist test -d $$HOME/homepage/private - mkdir -p $$HOME/homepage/private/projects/libao-polyp - cp libao-polyp-@PACKAGE_VERSION@.tar.gz $$HOME/homepage/private/projects/libao-polyp - cp doc/README.html doc/style.css $$HOME/homepage/private/projects/libao-polyp - ln -sf README.html $$HOME/homepage/private/projects/libao-polyp/index.html + mkdir -p $$HOME/homepage/private/projects/libao-pulse + cp libao-pulse-@PACKAGE_VERSION@.tar.gz $$HOME/homepage/private/projects/libao-pulse + cp doc/README.html doc/style.css $$HOME/homepage/private/projects/libao-pulse + ln -sf README.html $$HOME/homepage/private/projects/libao-pulse/index.html .PHONY: homepage diff --git a/bootstrap.sh b/bootstrap.sh index 3272fae..34d28d2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,20 +1,20 @@ #!/bin/bash # $Id$ -# This file is part of libao-polyp. +# This file is part of libao-pulse. # -# libao-polyp is free software; you can redistribute it and/or modify it +# libao-pulse 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 +# libao-pulse 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, +# along with libao-pulse; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. VERSION=1.9 diff --git a/configure.ac b/configure.ac index fe2bb00..3d04abf 100644 --- a/configure.ac +++ b/configure.ac @@ -3,29 +3,29 @@ # $Id$ -# This file is part of libao-polyp. +# This file is part of libao-pulse. # -# libao-polyp is free software; you can redistribute it and/or modify it +# libao-pulse 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 +# libao-pulse 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, +# along with libao-pulse; 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.9.0],[mzyvonbcbylc (at) 0pointer (dot) de]) -AC_CONFIG_SRCDIR([src/ao_polyp.c]) +AC_INIT([libao-pulse],[0.9.0],[mzyvonbcbylc (at) 0pointer (dot) de]) +AC_CONFIG_SRCDIR([src/ao_pulse.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign 1.9 -Wall]) -AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/libao-polyp/]) +AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/libao-pulse/]) 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} ***]) @@ -46,16 +46,16 @@ AC_FUNC_MALLOC PKG_PROG_PKG_CONFIG -if test -d ../polypaudio ; then - POLYP_CFLAGS='-I$(top_srcdir)/../polypaudio/src' - POLYP_LIBS='-L$(top_srcdir)/../polypaudio/src/.libs -lpolyp-simple' - echo "*** Found polypaudio in ../polypaudio, using that version ***" +if test -d ../pulseaudio ; then + PULSE_CFLAGS='-I$(top_srcdir)/../pulseaudio/src' + PULSE_LIBS='-L$(top_srcdir)/../pulseaudio/src/.libs -lpulse-simple' + echo "*** Found pulseaudio in ../pulseaudio, using that version ***" else - PKG_CHECK_MODULES(POLYP, [ polyplib-simple >= 0.9.0 ]) + PKG_CHECK_MODULES(PULSE, [ libpulse-simple >= 0.9.0 ]) fi -AC_SUBST(POLYP_LIBS) -AC_SUBST(POLYP_CFLAGS) +AC_SUBST(PULSE_LIBS) +AC_SUBST(PULSE_CFLAGS) PKG_CHECK_MODULES(LIBAO, [ ao >= 0.8.5 ]) LIBAO_MODDIR=`pkg-config --variable=libdir ao`/ao/plugins-2 diff --git a/doc/Makefile.am b/doc/Makefile.am index 4bd909f..d1d06b2 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,19 +1,19 @@ # $Id$ -# This file is part of libao-polyp. +# This file is part of libao-pulse. # -# libao-polyp is free software; you can redistribute it and/or modify it +# libao-pulse 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 +# libao-pulse 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, +# along with libao-pulse; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. noinst_DATA = README.html README diff --git a/doc/style.css b/doc/style.css index 76f07f5..2195faf 100644 --- a/doc/style.css +++ b/doc/style.css @@ -1,20 +1,20 @@ /* $Id$ */ /*** - * This file is part of libao-polyp. + * This file is part of libao-pulse. * - * libao-polyp is free software; you can redistribute it and/or modify it + * libao-pulse 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 + * libao-pulse 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, + * along with libao-pulse; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ diff --git a/src/Makefile.am b/src/Makefile.am index 8ba4980..e3c1881 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,27 +1,27 @@ # $Id$ # -# This file is part of libao-polyp. +# This file is part of libao-pulse. # -# libao-polyp is free software; you can redistribute it and/or modify +# libao-pulse 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 +# libao-pulse 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 +# along with libao-pulse; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. aolibdir=$(LIBAO_MODDIR) -aolib_LTLIBRARIES=libpolyp.la +aolib_LTLIBRARIES=libpulse.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_CFLAGS) $(LIBAO_CFLAGS) +libpulse_la_SOURCES=ao_pulse.c +libpulse_la_LDFLAGS=-module -avoid-version +libpulse_la_LIBADD=$(AM_LIBADD) $(PULSE_LIBS) +libpulse_la_CFLAGS=$(AM_CFLAGS) $(PULSE_CFLAGS) $(LIBAO_CFLAGS) diff --git a/src/ao_polyp.c b/src/ao_polyp.c deleted file mode 100644 index 7a45605..0000000 --- a/src/ao_polyp.c +++ /dev/null @@ -1,204 +0,0 @@ -/* $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. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include -#include - -#include -#include - -/* 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 nonetheless... */ -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) { - char p[PATH_MAX], t[256], t2[256]; - const char *fn = NULL; - 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 (pa_get_binary_name(p, sizeof(p))) { - fn = pa_path_get_filename(p); - snprintf(t, sizeof(t), "libao[%s]", fn); - snprintf(t2, sizeof(t2), "libao[%s] test", fn); - } - - if (!(s = pa_simple_new(NULL, fn ? t : "libao", PA_STREAM_PLAYBACK, NULL, fn ? t2 : "libao test", &ss, NULL, 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) { - char p[PATH_MAX], t[256], t2[256]; - const char *fn = NULL; - 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 (pa_get_binary_name(p, sizeof(p))) { - fn = pa_path_get_filename(p); - snprintf(t, sizeof(t), "libao[%s]", fn); - snprintf(t2, sizeof(t2), "libao[%s] playback stream", fn); - } - - if (!(internal->simple = pa_simple_new(internal->server, fn ? t : "libao", PA_STREAM_PLAYBACK, internal->sink, fn ? t2 : "libao playback stream", &ss, NULL, 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; -} diff --git a/src/ao_pulse.c b/src/ao_pulse.c new file mode 100644 index 0000000..c2a1f54 --- /dev/null +++ b/src/ao_pulse.c @@ -0,0 +1,204 @@ +/* $Id$ */ + +/*** + This file is part of libao-pulse. + + libao-pulse 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-pulse 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-pulse; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include +#include + +#include +#include + +/* Unfortunately libao doesn't allow "const" for these structures... */ +static char * ao_pulse_options[] = { + "server", + "sink" +}; + +static ao_info ao_pulse_info = { + AO_TYPE_LIVE, + "PulseAudio Output", + "pulse", + PACKAGE_BUGREPORT, + "Outputs to the PulseAudio Sound Server", + AO_FMT_NATIVE, + 41, + ao_pulse_options, + 2 +}; + +typedef struct ao_pulse_internal { + struct pa_simple *simple; + char *server, *sink; +} ao_pulse_internal; + +/* Yes, this is very ugly, but required nonetheless... */ +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) { + char p[PATH_MAX], t[256], t2[256]; + const char *fn = NULL; + struct pa_simple *s; + static const struct pa_sample_spec ss = { + .format = PA_SAMPLE_S16LE, + .rate = 44100, + .channels = 2 + }; + + disable_sigpipe(); + + if (getenv("PULSE_SERVER") || getenv("PULSE_SINK")) + return 1; + + if (pa_get_binary_name(p, sizeof(p))) { + fn = pa_path_get_filename(p); + snprintf(t, sizeof(t), "libao[%s]", fn); + snprintf(t2, sizeof(t2), "libao[%s] test", fn); + } + + if (!(s = pa_simple_new(NULL, fn ? t : "libao", PA_STREAM_PLAYBACK, NULL, fn ? t2 : "libao test", &ss, NULL, NULL, NULL))) + return 0; + + pa_simple_free(s); + return 1; +} + +ao_info *ao_plugin_driver_info(void) { + return &ao_pulse_info; +} + +int ao_plugin_device_init(ao_device *device) { + ao_pulse_internal *internal; + assert(device); + + internal = (ao_pulse_internal *) malloc(sizeof(ao_pulse_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_pulse_internal *internal; + assert(device && device->internal && key && value); + internal = (ao_pulse_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) { + char p[PATH_MAX], t[256], t2[256]; + const char *fn = NULL; + ao_pulse_internal *internal; + struct pa_sample_spec ss; + + assert(device && device->internal && format); + + internal = (ao_pulse_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 (pa_get_binary_name(p, sizeof(p))) { + fn = pa_path_get_filename(p); + snprintf(t, sizeof(t), "libao[%s]", fn); + snprintf(t2, sizeof(t2), "libao[%s] playback stream", fn); + } + + if (!(internal->simple = pa_simple_new(internal->server, fn ? t : "libao", PA_STREAM_PLAYBACK, internal->sink, fn ? t2 : "libao playback stream", &ss, NULL, 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_pulse_internal *internal = (ao_pulse_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_pulse_internal *internal = (ao_pulse_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_pulse_internal *internal = (ao_pulse_internal *) device->internal; + + free(internal->server); + free(internal->sink); + free(internal); + device->internal = NULL; +} -- cgit