summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-08-26 16:07:12 +0000
committerLennart Poettering <lennart@poettering.net>2004-08-26 16:07:12 +0000
commit39ed60f403d82a78ec75dfc8f1ea67c710f7125b (patch)
treeea73b4d82a7c2f96c183550e0f2dccac1be0ce5d
parentf855ed495e161b83f939552d00ba9bd2a95978ff (diff)
make it compile - nothing more
git-svn-id: file:///home/lennart/svn/public/xmms-pulse/trunk@7 ef929aba-56e2-0310-84e0-b7573d389508
-rw-r--r--Makefile.am41
-rwxr-xr-xbootstrap.sh47
-rw-r--r--configure.ac97
-rw-r--r--doc/Makefile.am36
-rw-r--r--doc/README.html.in107
-rw-r--r--doc/style.css34
-rw-r--r--src/Makefile.am27
-rw-r--r--src/plugin.c148
8 files changed, 483 insertions, 54 deletions
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..2dd3060
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,41 @@
+# $Id$
+#
+# This file is part of xmms-polyp.
+#
+# xmms-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.
+#
+# xmms-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 xmms-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/xmms-polyp
+ cp *.tar.gz $$HOME/homepage/private/projects/xmms-polyp
+ cp doc/README.html doc/style.css $$HOME/homepage/private/projects/xmms-polyp
+ cp $$HOME/homepage/private/projects/xmms-polyp/README.html $$HOME/homepage/private/projects/xmms-polyp/index.html
+
+distcleancheck:
+ @:
+
+.PHONY: homepage distcleancheck
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 0000000..dd5d53b
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# $Id$
+
+# This file is part of xmms-polyp.
+#
+# xmms-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.
+#
+# xmms-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 xmms-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..a070ae3
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,97 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+# $Id$
+
+# This file is part of xmms-polyp.
+#
+# xmms-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.
+#
+# xmms-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 xmms-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([xmms-polyp],[0.1],[mzkzzfcbylc (at) 0pointer (dot) de])
+AC_CONFIG_SRCDIR([src/plugin.c])
+AC_CONFIG_HEADERS([config.h])
+AM_INIT_AUTOMAKE([foreign -Wall])
+
+AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/xmms-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)
+
+AC_PATH_PROG(XMMS_CONFIG, xmms-config)
+
+if test "x$XMMS_CONFIG" = "x" ; then
+ AC_MSG_ERROR([*** Please install xmms-config of the xmms-dev package into your \$PATH ***])
+fi
+
+XMMS_CFLAGS=$($XMMS_CONFIG --cflags)
+XMMS_LIBS=$($XMMS_CONFIG --libs)
+XMMS_OUTPUTPLUGINDIR=$($XMMS_CONFIG --output-plugin-dir)
+
+AC_SUBST(XMMS_CFLAGS)
+AC_SUBST(XMMS_LIBS)
+AC_SUBST(XMMS_OUTPUTPLUGINDIR)
+
+# 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 doc/Makefile doc/README.html])
+AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..38651bd
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,36 @@
+# $Id$
+
+# This file is part of xmms-polyp.
+#
+# xmms-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.
+#
+# xmms-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 xmms-polyp; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+noinst_DATA = README.html README
+EXTRA_DIST = $(noinst_DATA) style.css README.html.in
+
+MAINTAINERCLEANFILES = README README.html
+CLEANFILES =
+
+if USE_LYNX
+README: README.html
+ lynx --dump $^ | sed 's,file://localhost/.*/doc/README.html,README,' > $@
+
+CLEANFILES += README
+endif
+
+tidy: README.html
+ tidy -e < README.html
+
+.PHONY: tidy
+
diff --git a/doc/README.html.in b/doc/README.html.in
new file mode 100644
index 0000000..dc7bbb1
--- /dev/null
+++ b/doc/README.html.in
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="iso-8859-1"?> <!-- -*-html-helper-*- -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<title>xmms-polyp @PACKAGE_VERSION@</title>
+<link rel="stylesheet" type="text/css" href="style.css" />
+</head>
+
+<body>
+<h1><a name="top">xmms-polyp @PACKAGE_VERSION@</a></h1>
+
+<p><i>Copyright 2004 Lennart Poettering &lt;@PACKAGE_BUGREPORT@&gt;</i></p>
+
+<ul class="toc">
+ <li><a href="#license">License</a></li>
+ <li><a href="#news">News</a></li>
+ <li><a href="#overview">Overview</a></li>
+ <li><a href="#status">Status</a></li>
+ <li><a href="#documentation">Documentation</a></li>
+ <li><a href="#requirements">Requirements</a></li>
+ <li><a href="#installation">Installation</a></li>
+ <li><a href="#acks">Acknowledgements</a></li>
+ <li><a href="#download">Download</a></li>
+</ul>
+
+<h2><a name="license">License</a></h2>
+
+<p>This program 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.</p>
+
+<p>This program 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.</p>
+
+<p>You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</p>
+
+<h2><a name="news">News</a></h2>
+
+<div class="news-date">Fri Aug 20 2004: </div> <p class="news-text"><a
+href="@PACKAGE_URL@xmms-polyp-0.1.tar.gz">Version 0.1</a> released</p>
+
+<h2><a name="overview">Overview</a></h2>
+
+<p><tt>xmms-polyp</tt> is a <a href="http://www.xiph.org/ao/"><tt>libao</tt></a> driver for the <a href="http://0pointer.de/lennart/projects/polypaudio"><tt>polypaudio</tt></a> sound server.</p>
+
+<h2><a name="status">Status</a></h2>
+
+<p>It works, what is more to say?</p>
+
+<h2><a name="documentation">Documentation</a></h2>
+
+<p>There is not much to say. Just install this software, the driver will then be available under the name <tt>polyp</tt>.</p>
+
+<h2><a name="requirements">Requirements</a></h2>
+
+<p>Currently, <tt>xmms-polyp</tt> is tested on Linux only.</p>
+
+<p><tt>xmms-polyp</tt> was developed and tested on Debian GNU/Linux
+"testing" from July 2004, it should work on most other Linux
+distributions (and maybe Unix versions) since it uses GNU autoconf for
+source code configuration.</p>
+
+<p>Obviously <tt>xmms-polyp</tt> requires an installation of
+<tt>polypaudio</tt> (version 0.2) and <tt>libao</tt> (version 0.8.5
+works, earlier versions probably as well).</p>
+
+<h2><a name="installation">Installation</a></h2>
+
+<p>As this package is made with the GNU autotools you should run
+<tt>./configure</tt> inside the distribution directory for configuring
+the source tree. After that you should run <tt>make</tt> for
+compilation and <tt>make install</tt> (as root) for installation of
+<tt>xmms-polyp</tt>.</p>
+
+<p>Make sure that <tt>xmms-polyp</tt>'s driver files are installed
+into <tt>libao</tt>'s driver directory. The exact path differs from
+distribution to distribution, but is probably something like
+<tt>/usr/lib/ao/plugins-2</tt>. To install <tt>xmms-polyp</tt> to
+that directory make sure to pass <tt>--prefix=/usr</tt> to the
+<tt>configure</tt> command line.</p>
+
+<h2><a name="acks">Acknowledgements</a></h2>
+
+<p>None so far.</p>
+
+<h2><a name="download">Download</a></h2>
+
+<p>The newest release is always available from <a href="@PACKAGE_URL@">@PACKAGE_URL@</a></p>
+
+<p>The current release is <a href="@PACKAGE_URL@xmms-polyp-@PACKAGE_VERSION@.tar.gz">@PACKAGE_VERSION@</a></p>
+
+<p>Get <tt>xmms-polyp</tt>'s development sources from the <a href="http://subversion.tigris.org/">Subversion</a> <a href="https://seth.intheinter.net:8081/svn/xmms-polyp/">repository</a>. (<a href="http://0pointer.de/cgi-bin/viewcvs.cgi/?root=xmms-polyp">viewcvs</a>)</p>
+
+<p>If you want to be notified whenever I release a new version of this software use the subscription feature of <a href="http://freshmeat.net/projects/xmms-polyp/">Freshmeat</a>.</p>
+
+<hr/>
+<address class="grey">Lennart Poettering &lt;@PACKAGE_BUGREPORT@&gt;, August 2004</address>
+<div class="grey"><i>$Id$</i></div>
+
+</body>
+</html>
diff --git a/doc/style.css b/doc/style.css
new file mode 100644
index 0000000..ac4ffa1
--- /dev/null
+++ b/doc/style.css
@@ -0,0 +1,34 @@
+/* $Id$ */
+
+/***
+ * This file is part of xmms-polyp.
+ *
+ * xmms-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.
+ *
+ * xmms-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 xmms-polyp; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ ***/
+
+body { color: black; background-color: white; margin: 0.5cm; }
+a:link, a:visited { color: #900000; }
+p { margin-left: 0.5cm; margin-right: 0.5cm; }
+div.news-date { margin-left: 0.5cm; font-size: 80%; color: #4f0000; }
+p.news-text { margin-left: 1cm; }
+h1 { color: #00009F; }
+h2 { color: #00009F; }
+h3 { color: #00004F; margin-left: 0.5cm; }
+ul { margin-left: .5cm; }
+ol { margin-left: .5cm; }
+pre { margin-left: .5cm; background-color: #f0f0f0; padding: 0.4cm;}
+.grey { color: #afafaf; }
+table { margin-left: 1cm; border:1px solid lightgrey; padding: 0.2cm; }
+td { padding-left:10px; padding-right:10px; }
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..ee1d5fd
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,27 @@
+# $Id$
+#
+# This file is part of xmms-polyp.
+#
+# xmms-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.
+#
+# xmms-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 xmms-polyp; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+xmmsplugindir=$(XMMS_OUTPUTPLUGINDIR)
+
+xmmsplugin_LTLIBRARIES=libpolyp.la
+
+libpolyp_la_SOURCES=plugin.c
+libpolyp_la_LDFLAGS=-module -avoid-version
+libpolyp_la_LIBADD=$(AM_LIBADD) $(POLYP_LIBS) $(XMMS_LIBS)
+libpolyp_la_CFLAGS=$(AM_CFLAGS) $(POLYP_CFLAGS) $(XMMS_CFLAGS)
diff --git a/src/plugin.c b/src/plugin.c
index 4f9b515..640540d 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -1,6 +1,13 @@
+#include <stdio.h>
+#include <assert.h>
#include <pthread.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <plugin.h>
#include <polyp/mainloop.h>
+#include <polyp/polyplib.h>
static pthread_cond_t request_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t request_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -16,7 +23,9 @@ struct request {
MESSAGE_LATENCY,
MESSAGE_WRITABLE,
MESSAGE_TRIGGER,
- } type;
+ MESSAGE_GETVOLUME,
+ MESSAGE_SETVOLUME
+ } message;
void *data;
struct pa_sample_spec ss;
size_t length;
@@ -37,11 +46,17 @@ static struct pa_mainloop_api *mainloop_api = NULL;
static int failed = 0;
static pa_volume_t volume = PA_VOLUME_NORM;
static size_t written = 0;
-static pa_usec_t latency;
static int do_trigger;
+static struct pa_sample_spec sample_spec;
+
+static void *memdup(void *p, size_t l) {
+ void *r = malloc(l);
+ memcpy(r, p, l);
+ return r;
+}
static void finish_request(int success) {
- failed = 1;
+ failed = success;
pthread_mutex_lock(&request_mutex);
@@ -69,18 +84,18 @@ static void subscribe_callback(struct pa_context *c, enum pa_subscription_event_
if (!stream || index != pa_stream_get_index(stream) || t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE))
return;
- pa_operation_unref(pa_context_get_sink_input_info(c, index, info_callback, NULL);
+ pa_operation_unref(pa_context_get_sink_input_info(c, index, info_callback, NULL));
}
static void stream_state_callback(struct pa_stream *s, void *userdata) {
assert(stream == s);
- switch(pa_stream_get_state(c)) {
+ switch(pa_stream_get_state(s)) {
case PA_STREAM_CREATING:
break;
case PA_STREAM_READY:
- assert(current_request && current_request->type == MESSAGE_OPEN);
- pa_operation_unref(pa_context_get_sink_input_info(context, pa_stream_get_index(s), info_callback, NULL);
+ assert(current_request && current_request->message == MESSAGE_OPEN);
+ pa_operation_unref(pa_context_get_sink_input_info(context, pa_stream_get_index(s), info_callback, NULL));
finish_request(1);
break;
default:
@@ -100,12 +115,12 @@ static void context_state_callback(struct pa_context *c, void *userdata) {
case PA_CONTEXT_READY :
assert(!stream && current_request);
pa_context_set_subscribe_callback(context, subscribe_callback, NULL);
- pa_operation_unref(pa_context_subscribe(context, PA_SUBSCRIPTION_MASK_SINK_INPUT, NULL, NULL);
+ pa_operation_unref(pa_context_subscribe(context, PA_SUBSCRIPTION_MASK_SINK_INPUT, NULL, NULL));
- stream = pa_stream_new(c, &current_request->ss);
+ stream = pa_stream_new(c, "xmms", &current_request->ss);
assert(stream);
- pa_stream_set_state(stream, stream_state_callback);
+ pa_stream_set_state_callback(stream, stream_state_callback, NULL);
pa_stream_connect_playback(stream, NULL, NULL);
break;
@@ -131,13 +146,16 @@ static void context_success_callback(struct pa_context *c, int success, void *us
static void latency_callback(struct pa_stream *s, pa_usec_t latency, void *userdata) {
assert(s == stream && s);
- assert(current_request && current_request>type == MESSAGE_LATENCY);
+ assert(current_request && current_request->message == MESSAGE_LATENCY);
current_request->value = latency;
finish_request(latency != (pa_usec_t) -1);
}
-static void request_func(struct pa_mainloop*api, struct pa_io_event *io, enum pa_io_event_flags f, void *userdata) {
+static void request_func(struct pa_mainloop_api*api, struct pa_io_event *io, int fd, enum pa_io_event_flags f, void *userdata) {
char x;
+
+ fprintf(stderr, "REQUEST\n");
+
assert(api && io && f == PA_IO_EVENT_INPUT);
@@ -147,9 +165,9 @@ static void request_func(struct pa_mainloop*api, struct pa_io_event *io, enum pa
if (current_request) {
if (failed) {
- fail();
+ finish_request(0);
} else {
- switch (current_request->type) {
+ switch (current_request->message) {
case MESSAGE_OPEN:
assert(!context && !stream);
context = pa_context_new(api, "xmms");
@@ -183,7 +201,7 @@ static void request_func(struct pa_mainloop*api, struct pa_io_event *io, enum pa
case MESSAGE_PAUSE:
case MESSAGE_UNPAUSE:
assert(context && stream);
- pa_operation_unref(pa_stream_cork(stream, current_request->type == MESSAGE_UNPAUSE, stream_success_callback, NULL));
+ pa_operation_unref(pa_stream_cork(stream, current_request->message == MESSAGE_UNPAUSE, stream_success_callback, NULL));
break;
case MESSAGE_LATENCY:
@@ -238,7 +256,7 @@ static void* thread_func(void *t) {
pa_mainloop_run(m, NULL);
- api->io_free(io);
+ mainloop_api->io_free(io);
pa_mainloop_free(m);
mainloop_api = NULL;
@@ -260,7 +278,6 @@ static void start_thread(void) {
}
static void stop_thread(void) {
- struct request req;
assert(thread_running);
pthread_join(thread_id, NULL);
@@ -273,26 +290,6 @@ static void stop_thread(void) {
pipe_fds[0] = pipe_fds[1] = -1;
}
-static void polyp_get_volume(int *l, int *r) {
- struct request r;
- int v;
-
- r.message = MESSAGE_GET_VOLUME;
- request_execute(&r);
-
- v = (r.volume*100)/PA_VOLUME_NORM;
-
- *r = *l = v > 100 ? 100 : v;
-}
-
-void polyp_set_volume(int l, int r) {
- struct request r;
-
- r.message = MESSAGE_SET_VOLUME;
- r.volume = ((l+r)*PA_VOLUME_NORM)/200;
- request_execute(&r);
-}
-
static void request_execute(struct request *r) {
char x = 'x';
assert(r);
@@ -314,9 +311,34 @@ static void request_execute(struct request *r) {
pthread_mutex_unlock(&request_mutex);
}
+static void polyp_get_volume(int *l, int *r) {
+ struct request req;
+ int v;
+ fprintf(stderr, "get_volume\n");
+
+ req.message = MESSAGE_GETVOLUME;
+ request_execute(&req);
+
+ v = (req.volume*100)/PA_VOLUME_NORM;
+
+ *r = *l = v > 100 ? 100 : v;
+}
+
+void polyp_set_volume(int l, int r) {
+ struct request req;
+ fprintf(stderr, "set_volume\n");
+
+ req.message = MESSAGE_SETVOLUME;
+ req.volume = ((l+r)*PA_VOLUME_NORM)/200;
+ request_execute(&req);
+}
+
+
static void polyp_pause(short b) {
struct request r;
-
+
+ fprintf(stderr, "pause: %s\n", b ? "yes" : "no");
+
r.message = b ? MESSAGE_PAUSE : MESSAGE_UNPAUSE;
request_execute(&r);
}
@@ -324,6 +346,9 @@ static void polyp_pause(short b) {
static int polyp_free(void) {
int ret;
struct request r;
+
+ fprintf(stderr, "free\n");
+
r.message = MESSAGE_WRITABLE;
request_execute(&r);
@@ -340,6 +365,9 @@ static int polyp_free(void) {
static int polyp_playing(void) {
struct request r;
+
+ fprintf(stderr, "playing\n");
+
r.message = MESSAGE_LATENCY;
request_execute(&r);
@@ -347,12 +375,16 @@ static int polyp_playing(void) {
}
static int polyp_get_written_time(void) {
+ fprintf(stderr, "get_written_time\n");
+
return ((written/pa_frame_size(&sample_spec))*1000)/sample_spec.rate;
}
static int polyp_get_output_time(void) {
int t, ms;
struct request r;
+ fprintf(stderr, "get_output_time\n");
+
r.message = MESSAGE_LATENCY;
request_execute(&r);
@@ -367,6 +399,8 @@ static int polyp_get_output_time(void) {
static void polyp_flush(int time) {
struct request r;
+ fprintf(stderr, "flush\n");
+
r.message = MESSAGE_FLUSH;
request_execute(&r);
@@ -375,8 +409,10 @@ static void polyp_flush(int time) {
static void polyp_write(void* ptr, int length) {
struct request r;
+ fprintf(stderr, "write\n");
+
r.message = MESSAGE_WRITE;
- r.data = ptr;
+ r.data = memdup(ptr, length);
r.length = length;
request_execute(&r);
@@ -387,14 +423,15 @@ static void polyp_write(void* ptr, int length) {
static int polyp_open(AFormat fmt, int rate, int nch) {
struct request r;
+ fprintf(stderr, "open\n");
if (fmt == FMT_U8)
r.ss.format = PA_SAMPLE_U8;
else if (fmt == FMT_S16_LE)
r.ss.format = PA_SAMPLE_S16LE;
- else if (fmt == FM_S16_BE)
+ else if (fmt == FMT_S16_BE)
r.ss.format = PA_SAMPLE_S16BE;
- else if (fmt == FM_S16_NE)
+ else if (fmt == FMT_S16_NE)
r.ss.format = PA_SAMPLE_S16NE;
else
return 0;
@@ -405,23 +442,26 @@ static int polyp_open(AFormat fmt, int rate, int nch) {
if (!pa_sample_spec_valid(&r.ss))
return 0;
+ sample_spec = r.ss;
+
start_thread();
r.message = MESSAGE_OPEN;
request_execute(&r);
- if (!r->success) {
+ if (!r.success) {
stop_thread();
return 0;
}
- written = do_trigger = 0;
+ written = do_trigger = failed = 0;
return 1;
}
static void polyp_close(void) {
struct request r;
+ fprintf(stderr, "close\n");
assert(thread_running);
@@ -433,27 +473,27 @@ static void polyp_close(void) {
static void polyp_init(void) {
+ fprintf(stderr, "init\n");
}
static OutputPlugin polyp_plugin = {
NULL,
NULL,
"Polypaudio Output Plugin", /* Description */
- polyp_init, /* done */
+ polyp_init,
NULL, /* polyp_about, */
NULL, /* polyp_configure, */
polyp_get_volume,
polyp_set_volume,
-
- polyp_open, /* done */
- polyp_write, /* done */
- polyp_close, /* done */
- polyp_flush, /* done */
- polyp_pause, /* done */
- polyp_free, /* done */
- polyp_playing, /* done */
- polyp_get_output_time, /* done */
- polyp_get_written_time, /* done */
+ polyp_open,
+ polyp_write,
+ polyp_close,
+ polyp_flush,
+ polyp_pause,
+ polyp_free,
+ polyp_playing,
+ polyp_get_output_time,
+ polyp_get_written_time,
};
OutputPlugin *get_oplugin_info(void) {