Playback only, no volume setting.
disorderfm_DEPENDENCIES=$(LIBOBJS) ../lib/libdisorder.a
disorder_playrtp_SOURCES=playrtp.c playrtp.h playrtp-mem.c
+disorder_playrtp_CFLAGS=$(PULSEAUDIO_CFLAGS) $(PULSEAUDIO_SIMPLE_CFLAGS)
disorder_playrtp_LDADD=$(LIBOBJS) ../lib/libdisorder.a \
$(LIBASOUND) $(LIBPCRE) $(LIBICONV) $(LIBGCRYPT) $(COREAUDIO) \
- $(LIBPTHREAD) -lm
+ $(LIBPTHREAD) $(PULSEAUDIO_SIMPLE_LIBS) $(PULSEAUDIO_LIBS) -lm
disorder_playrtp_DEPENDENCIES=$(LIBOBJS) ../lib/libdisorder.a
rtpmon_SOURCES=rtpmon.c
* the format before we know what it is! */
uaudio_set_format(44100/*Hz*/, 2/*channels*/,
16/*bits/channel*/, 1/*signed*/);
+ uaudio_set("application", "disorder-playrtp");
backend->start(playrtp_callback, NULL);
/* We receive and convert audio data in a background thread */
if((err = pthread_create(<id, 0, listen_thread, 0)))
want_alsa=yes
want_oss=yes
want_coreaudio=yes
+want_pulseaudio=yes
# By default we don't want gtk-osx. But if you ask for --with-gtk-osx...
#
[AS_HELP_STRING([--without-alsa],
[do not build with ALSA support])],
[want_alsa=$withval])
+AC_ARG_WITH([pulseaudio],
+ [AS_HELP_STRING([--without-pulseaudio],
+ [do not build with PulseAudio support])],
+ [want_pulseaudio=$withval])
AC_ARG_WITH([oss],
[AS_HELP_STRING([--without-oss],
[do not build with OSS support])],
AC_CHECK_LIB([asound], [snd_pcm_open],
[AC_SUBST(LIBASOUND,[-lasound])])
fi
+if test $want_pulseaudio = yes; then
+ PKG_CHECK_MODULES([PULSEAUDIO],[libpulse],
+ [AC_DEFINE([HAVE_PULSEAUDIO],[1],[define to 1 for PulseAudio support])],
+ [missing_libraries="$missing_libraries libpulse"])
+ PKG_CHECK_MODULES([PULSEAUDIO_SIMPLE],[libpulse-simple],,
+ [missing_libraries="$missing_libraries libpulse-simple"])
+fi
AC_CHECK_LIB([samplerate],[src_new],
[AC_SUBST([LIBSAMPLERATE],[-lsamplerate])])
if test $want_server = yes; then
popup.h playlists.c multidrag.c multidrag.h autoscroll.c \
autoscroll.h globals.c
disobedience_LDADD=../lib/libdisorder.a $(LIBPCRE) $(LIBGC) $(LIBGCRYPT) \
- $(LIBASOUND) $(COREAUDIO) $(LIBICONV) -lm
+ $(LIBASOUND) $(COREAUDIO) $(LIBICONV) -lm \
+ $(PULSEAUDIO_SIMPLE_LIBS) $(PULSEAUDIO_LIBS)
disobedience_LDFLAGS=$(GTK_LIBS)
install-data-local:
The possibilities are, depending on platform and compilation options:
.RS 8
.TP
+.B pulseaudio
+PulseAudio.
+.TP
.B alsa
ALSA.
Linux only.
tracksort.c \
uaudio.c uaudio-thread.c uaudio.h uaudio-apis.c \
uaudio-oss.c uaudio-alsa.c \
+ uaudio-pulseaudio.c \
uaudio-coreaudio.c \
uaudio-rtp.c uaudio-command.c uaudio-schedule.c \
url.h url.c \
/*
* This file is part of DisOrder.
- * Copyright (C) 2009 Richard Kettlewell
+ * Copyright (C) 2009, 2013 Richard Kettlewell
*
* 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
#if HAVE_COREAUDIO_AUDIOHARDWARE_H
&uaudio_coreaudio,
#endif
+#if HAVE_PULSEAUDIO
+ &uaudio_pulseaudio,
+#endif
#if HAVE_ALSA_ASOUNDLIB_H
&uaudio_alsa,
#endif
--- /dev/null
+/*
+ * This file is part of DisOrder.
+ * Copyright (C) 2013 Richard Kettlewell
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+/** @file lib/uaudio-pulseaudio.c
+ * @brief Support for PulseAudio backend */
+#include "common.h"
+
+#if HAVE_PULSEAUDIO
+
+#include <pulse/simple.h>
+#include <pulse/error.h>
+
+#include "mem.h"
+#include "log.h"
+#include "uaudio.h"
+#include "configuration.h"
+
+static const char *const pulseaudio_options[] = {
+ "application",
+ NULL
+};
+
+static pa_simple *pulseaudio_simple_handle;
+
+/** @brief Open the PulseAudio sound device */
+static void pulseaudio_open() {
+ pa_sample_spec ss;
+ int error;
+ ss.format = -1;
+ switch(uaudio_bits) {
+ case 8:
+ if(!uaudio_signed)
+ ss.format = PA_SAMPLE_U8;
+ break;
+ case 16:
+ if(uaudio_signed)
+ ss.format = PA_SAMPLE_S16NE;
+ break;
+ case 32:
+ if(uaudio_signed)
+ ss.format = PA_SAMPLE_S32NE;
+ break;
+ }
+ if(ss.format == -1)
+ disorder_fatal(0, "unsupported uaudio format (%d, %d)",
+ uaudio_bits, uaudio_signed);
+ ss.channels = uaudio_channels;
+ ss.rate = uaudio_rate;
+ pulseaudio_simple_handle = pa_simple_new(NULL,
+ uaudio_get("application", "DisOrder"),
+ PA_STREAM_PLAYBACK,
+ NULL,
+ "DisOrder",
+ &ss,
+ NULL,
+ NULL,
+ &error);
+ if(!pulseaudio_simple_handle)
+ disorder_fatal(0, "pa_simple_new: %s", pa_strerror(error));
+}
+
+/** @brief Close the PulseAudio sound device */
+static void pulseaudio_close(void) {
+ pa_simple_free(pulseaudio_simple_handle);
+ pulseaudio_simple_handle = NULL;
+}
+
+/** @brief Actually play sound via PulseAudio */
+static size_t pulseaudio_play(void *buffer, size_t samples,
+ unsigned attribute((unused)) flags) {
+ int error;
+ int ret = pa_simple_write(pulseaudio_simple_handle,
+ buffer,
+ samples * uaudio_sample_size,
+ &error);
+ if(ret < 0)
+ disorder_fatal(0, "pa_simple_write: %s", pa_strerror(error));
+ return samples;
+}
+
+static void pulseaudio_start(uaudio_callback *callback,
+ void *userdata) {
+ pulseaudio_open();
+ uaudio_thread_start(callback, userdata, pulseaudio_play,
+ 32 / uaudio_sample_size,
+ 4096 / uaudio_sample_size,
+ 0);
+}
+
+static void pulseaudio_stop(void) {
+ uaudio_thread_stop();
+ pulseaudio_close();
+}
+
+static void pulseaudio_open_mixer(void) {
+ disorder_error(0, "no pulseaudio mixer support yet");
+}
+
+static void pulseaudio_close_mixer(void) {
+}
+
+static void pulseaudio_get_volume(int *left, int *right) {
+ *left = *right = 0;
+}
+
+static void pulseaudio_set_volume(int *left, int *right) {
+ *left = *right = 0;
+}
+
+static void pulseaudio_configure(void) {
+}
+
+const struct uaudio uaudio_pulseaudio = {
+ .name = "pulseaudio",
+ .options = pulseaudio_options,
+ .start = pulseaudio_start,
+ .stop = pulseaudio_stop,
+ .activate = uaudio_thread_activate,
+ .deactivate = uaudio_thread_deactivate,
+ .open_mixer = pulseaudio_open_mixer,
+ .close_mixer = pulseaudio_close_mixer,
+ .get_volume = pulseaudio_get_volume,
+ .set_volume = pulseaudio_set_volume,
+ .configure = pulseaudio_configure,
+ .flags = UAUDIO_API_CLIENT,
+};
+
+#endif
+
+/*
+Local Variables:
+c-basic-offset:2
+comment-column:40
+fill-column:79
+indent-tabs-mode:nil
+End:
+*/
extern const struct uaudio uaudio_oss;
#endif
+#if HAVE_PULSEAUDIO
+extern const struct uaudio uaudio_pulseaudio;
+#endif
+
extern const struct uaudio uaudio_rtp;
extern const struct uaudio uaudio_command;
exports.c ../lib/memgc.c disorder-server.h
disorderd_LDADD=$(LIBOBJS) ../lib/libdisorder.a \
$(LIBPCRE) $(LIBDB) $(LIBGC) $(LIBGCRYPT) $(LIBICONV) \
- $(LIBASOUND) $(COREAUDIO) $(LIBPTHREAD) $(LIBDL)
+ $(LIBASOUND) $(COREAUDIO) $(LIBPTHREAD) $(LIBDL) \
+ $(PULSEAUDIO_SIMPLE_LIBS) $(PULSEAUDIO_LIBS)
disorderd_LDFLAGS=-export-dynamic
disorderd_DEPENDENCIES=../lib/libdisorder.a
disorder_speaker_SOURCES=speaker.c
disorder_speaker_LDADD=$(LIBOBJS) ../lib/libdisorder.a \
$(LIBASOUND) $(LIBPCRE) $(LIBICONV) $(LIBGCRYPT) $(COREAUDIO) \
- $(LIBPTHREAD)
+ $(LIBPTHREAD) \
+ $(PULSEAUDIO_SIMPLE_LIBS) $(PULSEAUDIO_LIBS)
disorder_speaker_DEPENDENCIES=../lib/libdisorder.a
disorder_decode_SOURCES=decode.c decode.h disorder-server.h \
/* backend-specific initialization */
if(backend->configure)
backend->configure();
+ uaudio_set("application", "disorder-speaker");
backend->start(speaker_callback, NULL);
/* create the private socket directory */
byte_xasprintf(&dir, "%s/private", config->home);