Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 May 2017 18:59:02 +0000 (UTC)
From:      Tobias Kortkamp <tobik@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r442114 - in head/devel/sdl12: . files
Message-ID:  <201705301859.v4UIx2TI080349@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tobik
Date: Tue May 30 18:59:02 2017
New Revision: 442114
URL: https://svnweb.freebsd.org/changeset/ports/442114

Log:
  Add sndio backend
  
  While here
  
  - Add LICENSE_FILE, USES=localbase
  - Strip library
  - Group audio backend options
  - Use options helpers for VGL
  
  I think the configure script patch needs to be explained.  OpenBSD
  regenerates the configure script from configure.in after patching
  sndio detection into it.  However SDL 1.2 requires an older autoconf
  version (2.59) which is not available on FreeBSD.  Lots of errors when
  using autoconf 2.69.
  
  Since I was unable to regenerate it I opted to edit configure
  manually.  So it does the bare minimum to wire the backend sources
  into the build and make sure that SNDIO_CONFIGURE_ENABLE can do its
  job in enabling/disabling sndio support.
  
  Approved by:	lme (mentor)
  Obtained from:	OpenBSD
  Differential Revision:	https://reviews.freebsd.org/D10658

Added:
  head/devel/sdl12/files/SDL_sndioaudio.c   (contents, props changed)
  head/devel/sdl12/files/SDL_sndioaudio.h   (contents, props changed)
  head/devel/sdl12/files/patch-src_audio_SDL__audio.c   (contents, props changed)
  head/devel/sdl12/files/patch-src_audio_SDL__sysaudio.h   (contents, props changed)
Modified:
  head/devel/sdl12/Makefile
  head/devel/sdl12/files/patch-configure
  head/devel/sdl12/pkg-plist

Modified: head/devel/sdl12/Makefile
==============================================================================
--- head/devel/sdl12/Makefile	Tue May 30 18:41:40 2017	(r442113)
+++ head/devel/sdl12/Makefile	Tue May 30 18:59:02 2017	(r442114)
@@ -3,7 +3,7 @@
 
 PORTNAME=	sdl
 PORTVERSION=	1.2.15
-PORTREVISION=	8
+PORTREVISION=	9
 PORTEPOCH=	2
 CATEGORIES=	devel
 MASTER_SITES=	http://www.libsdl.org/release/
@@ -13,27 +13,27 @@ MAINTAINER=	ports@FreeBSD.org
 COMMENT=	Cross-platform multimedia development API
 
 LICENSE=	LGPL21
+LICENSE_FILE=	${WRKSRC}/COPYING
 
 BUILD_DEPENDS=	nasm:devel/nasm
 
-USES=		gmake iconv libtool pathfix pkgconfig
+USES=		gmake iconv libtool localbase:ldflags pathfix pkgconfig
 USE_LDCONFIG=	yes
 GNU_CONFIGURE=	yes
 CONFIGURE_ENV=	ac_cv_header_libusbhid_h=no
-
-CPPFLAGS+=	-I${LOCALBASE}/include
-LDFLAGS+=	-L${LOCALBASE}/lib
-
-CONFIGURE_ARGS+=--disable-alsa --disable-alsatest \
+CONFIGURE_ARGS=	--disable-alsa --disable-alsatest \
 		--disable-arts --disable-video-directfb --disable-video-ggi
 
 EXAMPLES=	test/*.c test/*.bmp test/*.dat test/*.xbm test/*.wav
-DOCS=		BUGS COPYING CREDITS README README-SDL.txt WhatsNew docs.html
+DOCS=		BUGS CREDITS README README-SDL.txt WhatsNew docs.html
 
-OPTIONS_DEFINE=		AALIB DOCS ESOUND EXAMPLES NAS OPENGL OSS \
-			PULSEAUDIO SVGALIB X11
+OPTIONS_DEFINE=		AALIB DOCS EXAMPLES OPENGL SVGALIB X11
 OPTIONS_DEFAULT=	AALIB OPENGL OSS X11
+OPTIONS_GROUP=		AUDIO
+OPTIONS_GROUP_AUDIO=	ESOUND NAS OSS PULSEAUDIO SNDIO
 
+AUDIO_DESC=		Audio backend
+
 .if exists(/usr/lib/libvgl.so)
 OPTIONS_DEFINE+=	VGL
 VGL_DESC=		Video Graphics Lib support
@@ -51,22 +51,23 @@ OPENGL_USE=			GL=yes
 OSS_CONFIGURE_ENABLE=		oss
 PULSEAUDIO_CONFIGURE_ENABLE=	pulseaudio
 PULSEAUDIO_LIB_DEPENDS=		libpulse-simple.so:audio/pulseaudio
+SNDIO_CONFIGURE_ENABLE=		sndio
+SNDIO_LIB_DEPENDS=		libsndio.so:audio/sndio
 SVGALIB_CONFIGURE_ENABLE=	video-svga
 SVGALIB_LIB_DEPENDS=		libvga.so:graphics/svgalib
 VGL_CONFIGURE_ENABLE=		video-vgl
+VGL_VARS_OFF=			PKGMESSAGE=none
 X11_CONFIGURE_ENABLE=		video-x11
 X11_USE=			XORG=x11,xrender,xrandr,xextproto
 
-.include <bsd.port.options.mk>
-
-.if ! ${PORT_OPTIONS:MVGL}
-PKGMESSAGE=		none
-.endif
-
 post-patch:
 	@${REINPLACE_CMD} -e '/EXTRA_LDFLAGS/s/-liconv/${ICONV_LIB}/' \
 		${WRKSRC}/configure
 
+post-patch-SNDIO-on:
+	@${MKDIR} ${WRKSRC}/src/audio/sndio
+	@${CP} ${FILESDIR}/SDL_sndioaudio.* ${WRKSRC}/src/audio/sndio
+
 post-install:
 	${MKDIR} ${STAGEDIR}${DOCSDIR} &&\
 		${INSTALL_DATA} ${DOCS:S,^,${WRKSRC}/,} ${STAGEDIR}${DOCSDIR}/ &&\
@@ -74,5 +75,6 @@ post-install:
 		${COPYTREE_SHARE} docs ${STAGEDIR}${DOCSDIR}/ "! -regex .*/man3.*"
 	${MKDIR} ${STAGEDIR}${EXAMPLESDIR} &&\
 		${INSTALL_DATA} ${EXAMPLES:S,^,${WRKSRC}/,} ${STAGEDIR}${EXAMPLESDIR}/
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/libSDL-1.2.so.0.11.4
 
 .include <bsd.port.mk>

Added: head/devel/sdl12/files/SDL_sndioaudio.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/sdl12/files/SDL_sndioaudio.c	Tue May 30 18:59:02 2017	(r442114)
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2008 Jacob Meuser <jakemsr@sdf.lonestar.org>
+ *
+ * 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 "SDL_config.h"
+
+/* Allow access to a raw mixing buffer */
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+#include <unistd.h>
+
+#include "SDL_timer.h"
+#include "SDL_audio.h"
+#include "../SDL_audiomem.h"
+#include "../SDL_audio_c.h"
+#include "../SDL_audiodev_c.h"
+#include "SDL_sndioaudio.h"
+
+/* The tag name used by sndio audio */
+#define SNDIO_DRIVER_NAME         "sndio"
+
+/* Audio driver functions */
+static int SNDIO_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void SNDIO_WaitAudio(_THIS);
+static void SNDIO_PlayAudio(_THIS);
+static Uint8 *SNDIO_GetAudioBuf(_THIS);
+static void SNDIO_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	struct sio_hdl *this_hdl;
+	int available = 0;
+
+	if ( (this_hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0)) != NULL ) {
+		sio_close(this_hdl);
+		available = 1;
+	}
+
+	return available;
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	SDL_free(device->hidden);
+	SDL_free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		SDL_memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				SDL_malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			SDL_free(this);
+		}
+		return(0);
+	}
+	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+
+	/* Set the function pointers */
+	this->OpenAudio = SNDIO_OpenAudio;
+	this->WaitAudio = SNDIO_WaitAudio;
+	this->PlayAudio = SNDIO_PlayAudio;
+	this->GetAudioBuf = SNDIO_GetAudioBuf;
+	this->CloseAudio = SNDIO_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	hdl = NULL;
+
+	return this;
+}
+
+AudioBootStrap SNDIO_bootstrap = {
+	SNDIO_DRIVER_NAME, "sndio",
+	Audio_Available, Audio_CreateDevice
+};
+
+
+
+/* This function waits until it is possible to write a full sound buffer */
+static void SNDIO_WaitAudio(_THIS)
+{
+	/* nothing, we're using the blocking api */
+}
+
+static void SNDIO_PlayAudio(_THIS)
+{
+	int written;
+
+	/* Write the audio data */
+	written = sio_write(hdl, mixbuf, mixlen);
+	
+	/* If we couldn't write, assume fatal error for now */
+	if ( written == 0 ) {
+		this->enabled = 0;
+	}
+#ifdef DEBUG_AUDIO
+	fprintf(stderr, "Wrote %d bytes of audio data\n", written);
+#endif
+}
+
+static Uint8 *SNDIO_GetAudioBuf(_THIS)
+{
+	return(mixbuf);
+}
+
+static void SNDIO_CloseAudio(_THIS)
+{
+	if ( mixbuf != NULL ) {
+		SDL_FreeAudioMem(mixbuf);
+		mixbuf = NULL;
+	}
+	if ( hdl != NULL ) {
+		sio_close(hdl);
+		hdl = NULL;
+	}
+}
+
+static int SNDIO_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	struct sio_par par;
+
+	mixbuf = NULL;
+
+	if ((hdl = sio_open(NULL, SIO_PLAY, 0)) == NULL) {
+		SDL_SetError("sio_open() failed");
+		return(-1);
+	}
+
+	sio_initpar(&par);
+
+	switch (spec->format) {
+	case AUDIO_S16LSB:
+		par.bits = 16;
+		par.sig = 1;
+		par.le = 1;
+		break;
+	case AUDIO_S16MSB:
+		par.bits = 16;
+		par.sig = 1;
+		par.le = 0;
+		break;
+	case AUDIO_S8:
+		par.bits = 8;
+		par.sig = 1;
+		break;
+	case AUDIO_U16LSB:
+		par.bits = 16;
+		par.sig = 0;
+		par.le = 1;
+		break;
+	case AUDIO_U16MSB:
+		par.bits = 16;
+		par.sig = 0;
+		par.le = 0;
+		break;
+	case AUDIO_U8:
+		par.bits = 8;
+		par.sig = 0;
+		break;
+	default:
+		SDL_SetError("SNDIO unknown format");
+		return(-1);
+	}
+
+	par.rate = spec->freq;
+	par.pchan = spec->channels;
+	par.round = spec->samples;
+	par.appbufsz = par.round * 2;
+
+	if (sio_setpar(hdl, &par) == 0) {
+		SDL_SetError("sio_setpar() failed");
+		return(-1);
+	}
+
+	if (sio_getpar(hdl, &par) == 0) {
+		SDL_SetError("sio_getpar() failed");
+		return(-1);
+	}
+
+	if (par.bits == 16) {
+		if (par.sig && par.le) {
+			spec->format = AUDIO_S16LSB;
+		} else if (par.sig && !par.le) {
+			spec->format = AUDIO_S16MSB;
+		} else if (!par.sig && par.le) {
+			spec->format = AUDIO_U16LSB;
+		} else 
+			spec->format = AUDIO_U16MSB;
+	} else if (par.bits == 8) {
+		spec->format = par.sig ? AUDIO_S8 : AUDIO_U8;
+	} else {
+		SDL_SetError("SNDIO couldn't configure a suitable format");
+		return(-1);
+	}
+
+	spec->freq = par.rate;
+	spec->channels = par.pchan;
+	spec->samples = par.round;
+
+	SDL_CalculateAudioSpec(spec);
+
+	/* Allocate mixing buffer */
+	mixlen = spec->size;
+	mixbuf = (Uint8 *)SDL_AllocAudioMem(mixlen);
+	if ( mixbuf == NULL ) {
+		return(-1);
+	}
+	SDL_memset(mixbuf, spec->silence, spec->size);
+
+	if ( sio_start(hdl) == 0 ) {
+		SDL_SetError("sio_start() failed");
+		return(-1);
+	}
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}

Added: head/devel/sdl12/files/SDL_sndioaudio.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/sdl12/files/SDL_sndioaudio.h	Tue May 30 18:59:02 2017	(r442114)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2008 Jacob Meuser <jakemsr@sdf.lonestar.org>
+ *
+ * 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 "SDL_config.h"
+
+#ifndef _SDL_sndioaudio_h
+#define _SDL_sndioaudio_h
+
+#include <sndio.h>
+
+#include "../SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The stream descriptor for the audio device */
+	struct sio_hdl *hdl;
+
+	/* The parent process id, to detect when application quits */
+	pid_t parent;
+
+	/* Raw mixing buffer */
+	Uint8 *mixbuf;
+	int    mixlen;
+
+};
+
+/* Old variable names */
+#define stream			(this->hidden->stream)
+#define parent			(this->hidden->parent)
+#define mixbuf			(this->hidden->mixbuf)
+#define mixlen			(this->hidden->mixlen)
+#define hdl			(this->hidden->hdl)
+
+#endif /* _SDL_sndioaudio_h */
+

Modified: head/devel/sdl12/files/patch-configure
==============================================================================
--- head/devel/sdl12/files/patch-configure	Tue May 30 18:41:40 2017	(r442113)
+++ head/devel/sdl12/files/patch-configure	Tue May 30 18:59:02 2017	(r442114)
@@ -22,3 +22,28 @@
          BASE_LDFLAGS=""
          ;;
  esac
+@@ -20999,6 +20993,16 @@
+         fi
+     fi
+ }
++ 
++CheckSndio()
++{
++if test "x${enable_sndio}" = "xyes"; then :
++  SOURCES="$SOURCES $srcdir/src/audio/sndio/SDL_sndioaudio.c"
++  EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_AUDIO_DRIVER_SNDIO=1"
++  EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lsndio"
++  have_audio=yes
++fi
++}
+ 
+ CheckPulseAudio()
+ {
+@@ -29551,6 +29555,7 @@
+         CheckALSA
+         CheckARTSC
+         CheckESD
++        CheckSndio
+         CheckPulseAudio
+         CheckNAS
+         CheckX11

Added: head/devel/sdl12/files/patch-src_audio_SDL__audio.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/sdl12/files/patch-src_audio_SDL__audio.c	Tue May 30 18:59:02 2017	(r442114)
@@ -0,0 +1,19 @@
+$OpenBSD: patch-src_audio_SDL_audio_c,v 1.17 2012/03/02 09:10:38 dcoppa Exp $
+--- src/audio/SDL_audio.c.orig	2012-01-19 06:30:06 UTC
++++ src/audio/SDL_audio.c
+@@ -36,11 +36,15 @@
+ 
+ /* Available audio drivers */
+ static AudioBootStrap *bootstrap[] = {
++
+ #if SDL_AUDIO_DRIVER_PULSE
+ 	&PULSE_bootstrap,
+ #endif
+ #if SDL_AUDIO_DRIVER_ALSA
+ 	&ALSA_bootstrap,
++#endif
++#if SDL_AUDIO_DRIVER_SNDIO
++	&SNDIO_bootstrap,
+ #endif
+ #if SDL_AUDIO_DRIVER_BSD
+ 	&BSD_AUDIO_bootstrap,

Added: head/devel/sdl12/files/patch-src_audio_SDL__sysaudio.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/sdl12/files/patch-src_audio_SDL__sysaudio.h	Tue May 30 18:59:02 2017	(r442114)
@@ -0,0 +1,13 @@
+$OpenBSD: patch-src_audio_SDL_sysaudio_h,v 1.6 2012/03/02 09:10:38 dcoppa Exp $
+--- src/audio/SDL_sysaudio.h.orig	2012-01-19 06:30:06 UTC
++++ src/audio/SDL_sysaudio.h
+@@ -105,6 +105,9 @@ typedef struct AudioBootStrap {
+ #if SDL_AUDIO_DRIVER_BSD
+ extern AudioBootStrap BSD_AUDIO_bootstrap;
+ #endif
++#if SDL_AUDIO_DRIVER_SNDIO
++extern AudioBootStrap SNDIO_bootstrap;
++#endif
+ #if SDL_AUDIO_DRIVER_PULSE
+ extern AudioBootStrap PULSE_bootstrap;
+ #endif

Modified: head/devel/sdl12/pkg-plist
==============================================================================
--- head/devel/sdl12/pkg-plist	Tue May 30 18:41:40 2017	(r442113)
+++ head/devel/sdl12/pkg-plist	Tue May 30 18:59:02 2017	(r442114)
@@ -213,7 +213,6 @@ man/man3/SDL_mutexP.3.gz
 man/man3/SDL_mutexV.3.gz
 share/aclocal/sdl.m4
 %%PORTDOCS%%%%DOCSDIR%%/BUGS
-%%PORTDOCS%%%%DOCSDIR%%/COPYING
 %%PORTDOCS%%%%DOCSDIR%%/CREDITS
 %%PORTDOCS%%%%DOCSDIR%%/README
 %%PORTDOCS%%%%DOCSDIR%%/README-SDL.txt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705301859.v4UIx2TI080349>