On Sun, Dec 21, 2008 at 01:56:09AM +0000, Christian Weisgerber wrote: > Jacob Meuser <[email protected]> wrote: > > > imo, it would just be a whole lot easier to have a separate xmms-sndio > > port/package and have xmms RUN_DEPEND on it. > > That would be pretty weird, considering that the other xmms-* > packages depend on xmms proper. > > We could simplify the port by killing the PSEUDO_FLAVORS.
here's a version to do that and add a device dialog. "AUDIODEVICE" means to use sndio default ... -- [email protected] SDF Public Access UNIX System - http://sdf.lonestar.org Index: Makefile =================================================================== RCS file: /home2/cvs/OpenBSD/ports/audio/xmms/Makefile,v retrieving revision 1.58 diff -u -r1.58 Makefile --- Makefile 14 Jan 2008 01:16:37 -0000 1.58 +++ Makefile 21 Dec 2008 03:25:04 -0000 @@ -10,7 +10,7 @@ VERSION= 1.2.11 DISTNAME= xmms-${VERSION} -PKGNAME-main= xmms-${VERSION}p1 +PKGNAME-main= xmms-${VERSION}p2 PKGNAME-esd= xmms-esd-${VERSION}p0 PKGNAME-vorbis= xmms-vorbis-${VERSION}p0 PKGNAME-mikmod= xmms-mikmod-${VERSION}p0 @@ -21,12 +21,12 @@ MAINTAINER= Robert Nagy <[email protected]> -# GPL +# GPL v2 PERMIT_PACKAGE_CDROM= Yes PERMIT_PACKAGE_FTP= Yes PERMIT_DISTFILES_CDROM= Yes PERMIT_DISTFILES_FTP= Yes -WANTLIB= X11 Xau Xdmcp Xext Xi glib gmodule m +WANTLIB= X11 Xau Xdmcp Xext Xi glib gmodule m sndio V= 1.2.x MASTER_SITES= ${HOMEPAGE}/files/$V/ \ @@ -34,22 +34,7 @@ ftp://ftp.sunet.se/pub/multimedia/xmms/$V/ \ ftp://ftp.stealth.net/xmms/$V/ -PSEUDO_FLAVORS= no_esd no_vorbis no_mikmod no_mp3 -FLAVOR?= - -MULTI_PACKAGES= -main -.if !${FLAVOR:L:Mno_esd} -MULTI_PACKAGES+= -esd -.endif -.if !${FLAVOR:L:Mno_vorbis} -MULTI_PACKAGES+= -vorbis -.endif -.if !${FLAVOR:L:Mno_mikmod} -MULTI_PACKAGES+= -mikmod -.endif -.if !${FLAVOR:L:Mno_mp3} -MULTI_PACKAGES+= -mp3 -.endif +MULTI_PACKAGES= -main -esd -vorbis -mikmod -mp3 .if ${MACHINE_ARCH} == "sparc64" PATCH_LIST= patch-* gcc-* @@ -58,6 +43,7 @@ WANTLIB-main= ${WANTLIB} GL ICE c Xxf86vm SM pthread MODULES= devel/gettext +BUILD_DEPENDS= ${MODGNU_AUTOCONF_DEPENDS} ${MODGNU_AUTOMAKE_DEPENDS} RUN_DEPENDS= :unzip-*:archivers/unzip LIB_DEPENDS= gtk.>=1.2,gdk.>=1.2::x11/gtk+ \ gthread.>=1.2::devel/glib @@ -65,10 +51,15 @@ USE_X11= Yes USE_LIBTOOL= Yes LIBTOOL_FLAGS= --tag=disable-static -CONFIGURE_STYLE= autoconf +CONFIGURE_STYLE= gnu AUTOCONF_VERSION= 2.59 +AUTOMAKE_VERSION= 1.9 CONFIGURE_ARGS= --without-gnome \ - --enable-ipv6 + --enable-ipv6 \ + --with-esd-prefix=${LOCALBASE} \ + --with-ogg-prefix=${LOCALBASE} \ + --with-vorbis-prefix=${LOCALBASE} \ + --with-mikmod-prefix=${LOCALBASE} CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include -I${X11BASE}/include" \ CFLAGS="${CFLAGS:C/ *$//} -I${LOCALBASE}/include -I${X11BASE}/include" \ @@ -92,27 +83,19 @@ LIB_DEPENDS-mp3= ${LIB_DEPENDS} xmms.>=4:xmms-${VERSION}*:${BUILD_PKGPATH} WANTLIB-mp3= ${WANTLIB} z -.if ${MULTI_PACKAGES:M-esd} -CONFIGURE_ARGS+= --with-esd-prefix=${LOCALBASE} -.else -CONFIGURE_ARGS+= --disable-esd -.endif - -.if ${MULTI_PACKAGES:M-vorbis} -CONFIGURE_ARGS+= --with-ogg-prefix=${LOCALBASE} \ - --with-vorbis-prefix=${LOCALBASE} -.else -CONFIGURE_ARGS+= --disable-vorbis -.endif - -.if ${MULTI_PACKAGES:M-mikmod} -CONFIGURE_ARGS+= --with-mikmod-prefix=${LOCALBASE} -.else -CONFIGURE_ARGS+= --disable-mikmod -.endif - -pre-configure: - @cd ${WRKSRC}/libxmms && ${LOCALBASE}/bin/autoconf-${AUTOCONF_VERSION} +post-patch: + @mkdir -p ${WRKSRC}/Output/sndio + @cp ${FILESDIR}/{Makefile.am,audio_sndio.c} ${WRKSRC}/Output/sndio +.for dir in $${WRKSRC} $${WRKSRC}/libxmms + cd ${dir} && env AUTOCONF_VERSION=${AUTOCONF_VERSION} \ + AUTOMAKE_VERSION=${AUTOMAKE_VERSION} aclocal + cd ${dir} && env AUTOCONF_VERSION=${AUTOCONF_VERSION} \ + AUTOMAKE_VERSION=${AUTOMAKE_VERSION} autoheader + cd ${dir} && env AUTOCONF_VERSION=${AUTOCONF_VERSION} \ + AUTOMAKE_VERSION=${AUTOMAKE_VERSION} automake + cd ${dir} && env AUTOCONF_VERSION=${AUTOCONF_VERSION} \ + AUTOMAKE_VERSION=${AUTOMAKE_VERSION} autoconf +.endfor post-install: ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/xmms Index: files/Makefile.am =================================================================== RCS file: files/Makefile.am diff -N files/Makefile.am --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/Makefile.am 21 Dec 2008 03:25:04 -0000 @@ -0,0 +1,17 @@ +if HAVE_SNDIO +sndioltlibs = libsndio.la +sndiosources = audio_sndio.c +else +sndioltlibs = +sndiosources = +endif + +EXTRA_DIST = audio_sndio.c + +libdir = $(plugindir)/$(OUTPUT_PLUGIN_DIR) +lib_LTLIBRARIES = $(sndioltlibs) + +INCLUDES = @GTK_CFLAGS@ -I$(top_builddir)/intl -I$(top_srcdir) +libsndio_la_LDFLAGS = @PLUGIN_LDFLAGS@ +libsndio_la_LIBADD = @GTK_LIBS@ @PTHREAD_LIBS@ @SNDIO_LIBS@ +libsndio_la_SOURCES= $(sndiosources) Index: files/audio_sndio.c =================================================================== RCS file: files/audio_sndio.c diff -N files/audio_sndio.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/audio_sndio.c 21 Dec 2008 03:25:04 -0000 @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2008 Thomas Pfaff <[email protected]> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <stdio.h> + +#include <gtk/gtk.h> +#include <sndio.h> +#include <xmms/plugin.h> +#include <libxmms/util.h> + +#define XMMS_MAXVOL 100 + +static void op_about (void); +static void op_get_volume (int *, int *); +static void op_set_volume (int, int); +static int op_open (AFormat, int, int); +static void op_write (void *, int); +static void op_close (void); +static void op_seek (int); +static void op_pause (short); +static int op_buffer_free (void); +static int op_playing (void); +static int op_get_output_time (void); +static int op_get_written_time (void); + +static void onmove_cb (void *, int); + +static struct sio_par par; +static struct sio_hdl *hdl; +static long long rdpos; +static long long wrpos; +static int paused; +static int volume = XMMS_MAXVOL; +static long bytes_per_sec; + +static OutputPlugin sndio_op = { + NULL, + NULL, + "sndio Output Plugin", + NULL, + op_about, + NULL, + op_get_volume, + op_set_volume, + op_open, + op_write, + op_close, + op_seek, + op_pause, + op_buffer_free, + op_playing, + op_get_output_time, + op_get_written_time +}; + +OutputPlugin * +get_oplugin_info (void) +{ + return &sndio_op; +} + +static void +op_about (void) +{ + static GtkWidget *about; + + if (about != NULL) + return; + + about = xmms_show_message ( + "About sndio Output Plugin", + "XMMS sndio Output Plugin\n\n" + "Written by Thomas Pfaff <[email protected]>\n", + "Ok", FALSE, NULL, NULL); + + gtk_signal_connect (GTK_OBJECT (about), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), &about); +} + +static void +op_get_volume (int *left, int *right) +{ + *left = *right = volume; +} + +static void +op_set_volume (int left, int right) +{ + /* Ignore balance control, so use unattenuated channel. */ + volume = left > right ? left : right; + if (hdl != NULL) + sio_setvol (hdl, volume * SIO_MAXVOL / XMMS_MAXVOL); +} + +static int +op_open (AFormat fmt, int rate, int nch) +{ + struct sio_par askpar; + + if ((hdl = sio_open (NULL, SIO_PLAY, 0)) == NULL) { + fprintf (stderr, "%s: failed to open audio device\n", __func__); + return 0; + } + + sio_initpar (&par); + switch (fmt) { + case FMT_U8: + par.bits = 8; + par.sig = 0; + break; + case FMT_S8: + par.bits = 8; + par.sig = 1; + break; + case FMT_U16_LE: + par.bits = 16; + par.sig = 0; + par.le = 1; + break; + case FMT_U16_BE: + par.bits = 16; + par.sig = 0; + par.le = 0; + break; + case FMT_U16_NE: + par.bits = 16; + par.sig = 0; + par.le = SIO_LE_NATIVE; + break; + case FMT_S16_LE: + par.bits = 16; + par.sig = 1; + par.le = 1; + break; + case FMT_S16_BE: + par.bits = 16; + par.sig = 1; + par.le = 0; + case FMT_S16_NE: + par.bits = 16; + par.sig = 1; + par.le = SIO_LE_NATIVE; + break; + default: + fprintf (stderr, "%s: unknown format requested\n", __func__); + op_close (); + return 0; + } + par.pchan = nch; + par.rate = rate; + + askpar = par; + if (!sio_setpar (hdl, &par) || !sio_getpar (hdl, &par)) { + fprintf (stderr, "%s: failed to set parameters\n", __func__); + op_close (); + return 0; + } + + if ((par.bits == 16 && par.le != askpar.le) || + par.bits != askpar.bits || + par.sig != askpar.sig || + par.pchan != askpar.pchan || + par.rate != askpar.rate) { + fprintf (stderr, "%s: parameters not supported\n", __func__); + xmms_show_message ("Unsupported format", "XMMS requested a " + "format that is not supported by the audio device.\n\n" + "Please try again with the aucat(1) server running.", + "OK", FALSE, NULL, NULL); + op_close (); + return 0; + } + + wrpos = 0; + rdpos = 0; + sio_onmove (hdl, onmove_cb, NULL); + + op_set_volume (volume, volume); + + paused = 0; + if (!sio_start (hdl)) { + fprintf (stderr, "%s: failed to start audio device\n", + __func__); + op_close (); + return 0; + } + + bytes_per_sec = par.bps * par.pchan * par.rate; + return 1; +} + +static void +op_write (void *ptr, int len) +{ + if (!paused) + wrpos += sio_write (hdl, ptr, len); +} + +static void +op_close (void) +{ + if (hdl != NULL) { + sio_close (hdl); + hdl = NULL; + } +} + +static void +op_seek (int time_ms) +{ + int bufused = (rdpos < 0) ? wrpos : wrpos - rdpos; + rdpos = time_ms / 1000 * bytes_per_sec; + wrpos = rdpos + bufused; +} + +static void +op_pause (short flag) +{ + paused = flag; +} + +static int +op_buffer_free (void) +{ +#define MAGIC 1000000 /* See Output/{OSS,sun,esd}/audio.c */ + return paused ? 0 : MAGIC; +} + +static int +op_playing (void) +{ + return paused ? TRUE : FALSE; +} + +static int +op_get_output_time (void) +{ + return hdl ? rdpos * 1000 / bytes_per_sec : 0; +} + +static int +op_get_written_time (void) +{ + return hdl ? wrpos * 1000 / bytes_per_sec : 0; +} + +static void +onmove_cb (void *addr, int delta) +{ + rdpos += delta * (int)(par.bps * par.pchan); +} Index: patches/patch-Output_Makefile_am =================================================================== RCS file: patches/patch-Output_Makefile_am diff -N patches/patch-Output_Makefile_am --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-Output_Makefile_am 21 Dec 2008 03:25:04 -0000 @@ -0,0 +1,7 @@ +$OpenBSD$ +--- Output/Makefile.am.orig Sat Dec 20 02:20:46 2008 ++++ Output/Makefile.am Mon May 19 14:22:06 2003 +@@ -1,2 +1,2 @@ +-ALL_PLUGINS = OSS esd disk_writer solaris sun alsa ++ALL_PLUGINS = OSS esd disk_writer solaris sun alsa sndio + SUBDIRS = @OUTPUT_PLUGINS@ Index: patches/patch-configure_in =================================================================== RCS file: /home2/cvs/OpenBSD/ports/audio/xmms/patches/patch-configure_in,v retrieving revision 1.8 diff -u -r1.8 patch-configure_in --- patches/patch-configure_in 8 Dec 2007 21:54:57 -0000 1.8 +++ patches/patch-configure_in 21 Dec 2008 03:25:04 -0000 @@ -1,7 +1,49 @@ $OpenBSD: patch-configure_in,v 1.8 2007/12/08 21:54:57 ajacoutot Exp $ ---- configure.in.orig Fri Nov 16 22:52:30 2007 -+++ configure.in Fri Nov 23 16:25:25 2007 -@@ -607,7 +607,7 @@ AC_SUBST([GENERAL_PLUGIN_DIR]) +--- configure.in.orig Fri Nov 16 13:52:30 2007 ++++ configure.in Sat Dec 20 19:15:06 2008 +@@ -423,7 +423,8 @@ dnl *** + LIBS_save=$LIBS + CFLAGS_save=$CFLAGS + LDFLAGS_save=$LDFLAGS +-AM_PATH_ALSA([0.9.0], [have_alsa=yes], [have_alsa=no]) ++dnl AM_PATH_ALSA([0.9.0], [have_alsa=yes], [have_alsa=no]) ++have_alsa=no + AM_CONDITIONAL([HAVE_ALSA], [test "x${have_alsa}" = "xyes"]) + LIBS=$LIBS_save + CFLAGS=$CFLAGS_save +@@ -449,7 +450,31 @@ if test "x$xmms_cv_newpcm_driver" = "xyes"; then + AC_DEFINE([HAVE_NEWPCM], [1], [Define if you have the FreeBSD newpcm driver]) + fi + ++dnl *** Check for libsndio ++SNDIO_LIBS= ++AC_ARG_ENABLE([sndio], ++ [ --disable-sndio disable the libsndio output plugin], ++ [have_sndio=$enableval], [have_sndio=yes]) + ++if test "x$have_sndio" = "xauto"; then ++ AC_CHECK_HEADERS([sndio.h]) ++ if test "x${ac_cv_header_sndio_h}" = "xyes"; then ++ have_sndio=yes ++ fi ++ if test "x${have_sndio}" = "xyes"; then ++ AC_CHECK_LIB(sndio, sio_open, [have_sndio=yes], [have_sndio=no]) ++ fi ++fi ++if test "x$have_sndio" = "xyes"; then ++ AC_DEFINE([HAVE_SNDIO], [1], [Define if the libsndio output plugin should be built]) ++ SNDIO_LIBS="$LIBS -lsndio" ++else ++ have_sndio=no ++fi ++AM_CONDITIONAL([HAVE_SNDIO], [test "x$have_sndio" = "xyes"]) ++AC_SUBST(SNDIO_LIBS) ++ ++ + AC_CHECK_HEADERS([linux/cdrom.h]) + AC_CHECK_HEADERS([sys/cdrio.h]) + AC_CHECK_HEADERS([sys/cdio.h]) +@@ -607,7 +632,7 @@ AC_SUBST([GENERAL_PLUGIN_DIR]) AC_SUBST([VISUALIZATION_PLUGIN_DIR]) AC_SUBST([pluginsubs]) @@ -10,3 +52,19 @@ if test "x$enable_user_plugin_dir" = "xno"; then AC_DEFINE(DISABLE_USER_PLUGIN_DIR,, [Define to disable per user plugin directory]) +@@ -635,6 +660,7 @@ Output/Makefile + Output/OSS/Makefile + Output/esd/Makefile + Output/disk_writer/Makefile ++Output/sndio/Makefile + Output/solaris/Makefile + Output/sun/Makefile + Output/alsa/Makefile +@@ -670,6 +696,7 @@ echo " Current xmms $XMMS_PATH" + fi + + echo " Build OSS plugin: $have_oss" ++echo " Build sndio plugin: $have_sndio" + echo " Build esd plugin: $have_esd" + echo " Build Solaris plugin: $have_solaris" + echo " Build BSD Sun plugin: $have_sun" Index: pkg/PLIST-main =================================================================== RCS file: /home2/cvs/OpenBSD/ports/audio/xmms/pkg/PLIST-main,v retrieving revision 1.3 diff -u -r1.3 PLIST-main --- pkg/PLIST-main 8 Dec 2007 21:54:57 -0000 1.3 +++ pkg/PLIST-main 21 Dec 2008 03:25:04 -0000 @@ -1,7 +1,7 @@ @comment $OpenBSD: PLIST-main,v 1.3 2007/12/08 21:54:57 ajacoutot Exp $ @pkgpath audio/xmms -bin/wmxmms -bin/xmms +...@bin bin/wmxmms +...@bin bin/xmms bin/xmms-config include/xmms/ include/xmms/configfile.h @@ -43,6 +43,8 @@ @comment lib/xmms/Output/libdisk_writer.la lib/xmms/Output/libdisk_writer.so @comment lib/xmms/Output/libesdout.la +...@comment lib/xmms/Output/libsndio.la +lib/xmms/Output/libsndio.so @comment lib/xmms/Output/libsun.la lib/xmms/Output/libsun.so lib/xmms/Visualization/
