use sndio instead of ossaudio; small correction and ok jakemsr@

This commit is contained in:
naddy 2009-12-16 20:00:41 +00:00
parent 03d748c4b3
commit aa242e42a2
8 changed files with 248 additions and 75 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.11 2009/10/14 14:27:34 naddy Exp $ # $OpenBSD: Makefile,v 1.12 2009/12/16 20:00:41 naddy Exp $
COMMENT= cross-platform 3D audio API COMMENT= cross-platform 3D audio API
DISTNAME= openal-0.0.8 DISTNAME= openal-0.0.8
PKGNAME= ${DISTNAME}p3 PKGNAME= ${DISTNAME}p4
CATEGORIES= audio CATEGORIES= audio
SHARED_LIBS += openal 1.0 # .0.0 SHARED_LIBS += openal 1.0 # .0.0
@ -21,11 +21,29 @@ MASTER_SITES= http://openbsd.dead-parrot.de/distfiles/
USE_GMAKE= Yes USE_GMAKE= Yes
USE_LIBTOOL= Yes USE_LIBTOOL= Yes
CONFIGURE_STYLE=gnu AUTOCONF_VERSION=2.59
AUTOMAKE_VERSION=1.9
CONFIGURE_STYLE=autoconf automake
CONFIGURE_ARGS= --disable-vorbis \ CONFIGURE_ARGS= --disable-vorbis \
--disable-arts \ --disable-arts \
--disable-mp3 \ --disable-mp3 \
--disable-esd \ --disable-esd \
--disable-sdl --disable-sdl
MODGNU_CONFIG_GUESS_DIRS=${WRKSRC}/admin/autotools
post-extract:
@cp ${FILESDIR}/alc_backend_sndio.c ${WRKSRC}/src/backends/
AUTO_ENV= AUTOCONF_VERSION=${AUTOCONF_VERSION} \
AUTOMAKE_VERSION=${AUTOMAKE_VERSION}
post-patch:
@echo "Running aclocal-${AUTOMAKE_VERSION} in ${WRKSRC}"
@cd ${WRKSRC}; ${AUTO_ENV} aclocal -I admin/autotools/m4
pre-configure:
@echo "Running automake-${AUTOMAKE_VERSION} in ${WRKSRC}"
@cd ${WRKSRC}; ${AUTO_ENV} automake --foreign
.include <bsd.port.mk> .include <bsd.port.mk>

View File

@ -0,0 +1,127 @@
/* -*- mode: C; tab-width:8; c-basic-offset:8 -*-
* vi:set ts=8:
*
* Sndio backend for OpenAL
*
*/
#include "al_siteconfig.h"
#include <AL/al.h>
#include <AL/alext.h>
#include <fcntl.h>
#include <sndio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "al_main.h"
#include "al_debug.h"
#include "backends/alc_backend.h"
void *
alcBackendOpenNative_ (ALC_OpenMode mode)
{
return mode == ALC_OPEN_INPUT_ ?
sio_open(NULL, SIO_REC, 0) : sio_open(NULL, SIO_PLAY, 0);
}
ALboolean
alcBackendSetAttributesNative_ (ALC_OpenMode mode, void *handle,
ALuint *bufsiz, ALenum *fmt, ALuint *speed)
{
struct sio_par par;
unsigned chan;
sio_initpar(&par);
par.bits = _alGetBitsFromFormat(*fmt);
par.sig = par.bits == 8 ? 0 : 1;
par.le = SIO_LE_NATIVE;
chan = _alGetChannelsFromFormat(*fmt);
if (mode == ALC_OPEN_INPUT_)
par.rchan = chan;
else
par.pchan = chan;
par.rate = *speed;
par.appbufsz = *bufsiz / SIO_BPS(par.bits) / chan;
if (!sio_setpar(handle, &par) || !sio_getpar(handle, &par) ||
!sio_start(handle)) {
sio_close(handle);
return AL_FALSE;
}
if (!(par.bits == 16 && par.sig) && !(par.bits == 8 && !par.sig)) {
sio_close(handle);
return AL_FALSE;
}
chan = mode == ALC_OPEN_INPUT_ ? par.rchan : par.pchan;
switch (chan) {
case 1:
*fmt = par.bits == 16 ? AL_FORMAT_MONO16 : AL_FORMAT_MONO8;
break;
case 2:
*fmt = par.bits == 16 ? AL_FORMAT_STEREO16 : AL_FORMAT_STEREO8;
break;
case 4:
*fmt = par.bits == 16 ? AL_FORMAT_QUAD16_LOKI :
AL_FORMAT_QUAD8_LOKI;
break;
default:
sio_close(handle);
return AL_FALSE;
}
*bufsiz = par.appbufsz * par.bps * chan;
*speed = par.rate;
return AL_TRUE;
}
void
native_blitbuffer (void *handle, void *dataptr, int bytes_to_write)
{
sio_write(handle, dataptr, bytes_to_write);
}
void
release_native (void *handle)
{
sio_close(handle);
}
void
pause_native (void *handle)
{
sio_stop(handle);
}
void
resume_native (void *handle)
{
sio_start(handle);
}
ALsizei
capture_native (void *handle, void *capture_buffer, int bufsiz)
{
return sio_read(handle, capture_buffer, bufsiz);
}
ALfloat
get_nativechannel (UNUSED(void *handle), UNUSED(ALuint channel))
{
return 0.0;
}
int
set_nativechannel (UNUSED(void *handle), UNUSED(ALuint channel),
UNUSED(ALfloat volume))
{
return 0;
}

View File

@ -1,15 +1,15 @@
$OpenBSD: patch-admin_pkgconfig_openal-config_in,v 1.1 2009/10/10 22:51:48 sthen Exp $ $OpenBSD: patch-admin_pkgconfig_openal-config_in,v 1.2 2009/12/16 20:00:41 naddy Exp $
--- admin/pkgconfig/openal-config.in.orig Fri Oct 9 22:54:00 2009 --- admin/pkgconfig/openal-config.in.orig Sat Feb 11 10:36:55 2006
+++ admin/pkgconfig/openal-config.in Fri Oct 9 22:54:16 2009 +++ admin/pkgconfig/openal-config.in Thu Oct 15 15:11:54 2009
@@ -9,9 +9,9 @@ PACKAGE_VERSION="@PACKAGE_VERSION@" @@ -9,9 +9,9 @@ PACKAGE_VERSION="@PACKAGE_VERSION@"
# PTHREAD_CFLAGS="@PTHREAD_CFLAGS@" # PTHREAD_CFLAGS="@PTHREAD_CFLAGS@"
# PTHREAD_LIBS="@PTHREAD_LIBS@" # PTHREAD_LIBS="@PTHREAD_LIBS@"
-openal_dynamic_ldflags="-lopenal" -openal_dynamic_ldflags="-lopenal"
+openal_dynamic_ldflags="-lopenal -lossaudio" +openal_dynamic_ldflags="-lopenal -lsndio"
# TODO: configure should provide the following... # TODO: configure should provide the following...
-openal_static_ldflags="-lopenal" -openal_static_ldflags="-lopenal"
+openal_static_ldflags="-lopenal -lossaudio" +openal_static_ldflags="-lopenal -lsndio"
prefix_set=no prefix_set=no
echo_prefix=no echo_prefix=no

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-admin_pkgconfig_openal_pc_in,v 1.2 2009/10/10 22:51:48 sthen Exp $ $OpenBSD: patch-admin_pkgconfig_openal_pc_in,v 1.3 2009/12/16 20:00:41 naddy Exp $
--- admin/pkgconfig/openal.pc.in.orig Sat Feb 11 04:36:55 2006 --- admin/pkgconfig/openal.pc.in.orig Sat Feb 11 10:36:55 2006
+++ admin/pkgconfig/openal.pc.in Fri Oct 9 20:29:07 2009 +++ admin/pkgconfig/openal.pc.in Thu Oct 15 15:12:25 2009
@@ -5,8 +5,8 @@ includedir=@includedir@ @@ -5,8 +5,8 @@ includedir=@includedir@
Name: OpenAL Name: OpenAL
@ -9,6 +9,6 @@ $OpenBSD: patch-admin_pkgconfig_openal_pc_in,v 1.2 2009/10/10 22:51:48 sthen Exp
+Requires: +Requires:
Version: @PACKAGE_VERSION@ Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lopenal -Libs: -L${libdir} -lopenal
+Libs: -L${libdir} -lopenal -lossaudio +Libs: -L${libdir} -lopenal -lsndio
Cflags: -I${includedir} Cflags: -I${includedir}

View File

@ -1,12 +0,0 @@
$OpenBSD: patch-configure,v 1.1 2006/10/30 23:31:37 steven Exp $
--- configure.orig Sat Oct 21 11:10:20 2006
+++ configure Sat Oct 21 11:10:37 2006
@@ -22428,7 +22428,7 @@ _ACEOF
esac
case "$target" in
- *i386* | *i486* | *i586* | *i686* | *x86_64*)
+ *i386* | *i486* | *i586* | *i686* )
openal_x86_support_yn=yes
echo "$as_me:$LINENO: checking for MMX support" >&5

View File

@ -0,0 +1,76 @@
$OpenBSD: patch-configure_ac,v 1.1 2009/12/16 20:00:41 naddy Exp $
--- configure.ac.orig Sat Feb 11 10:36:55 2006
+++ configure.ac Thu Oct 15 15:00:10 2009
@@ -365,7 +365,7 @@ esac
dnl Special objs for architectures
case "$target" in
- *i386* | *i486* | *i586* | *i686* | *x86_64*)
+ *i386* | *i486* | *i586* | *i686* )
openal_x86_support_yn=yes
AC_MSG_CHECKING([for MMX support])
@@ -637,7 +637,7 @@ OPENAL_ENABLE([aRts backend], [openal_backend_arts_sup
# check for native BSD/OSS backend #############################################
-# ToDo: Hmmm, OpenBSD/FreeBSD are using OSS, too, just like Linux. Perhaps some
+# ToDo: Hmmm, FreeBSD is using OSS, too, just like Linux. Perhaps some
# re-use is possible?
AC_ARG_ENABLE([bsd],
@@ -648,6 +648,10 @@ if test "x$enable_bsd" = xno; then
openal_backend_bsd_support=disabled
else
case "$target" in
+ *openbsd*) openal_backend_bsd_support=none
+ if test "x$enable_bsd" = xyes; then
+ AC_MSG_WARN([--enabled-bsd ignored in favor of sndio.])
+ fi ;;
*bsd*) openal_backend_bsd_support=static ;;
*) openal_backend_bsd_support=none
if test "x$enable_bsd" = xyes; then
@@ -941,6 +945,43 @@ fi
OPENAL_ENABLE([native Solaris backend], [openal_backend_solaris_support],
[USE_BACKEND_NATIVE_SOLARIS], [USEBACKENDNATIVESOLARIS])
+
+# check for native sndio backend ###############################################
+
+AC_ARG_ENABLE([sndio],
+[AS_HELP_STRING([--enable-sndio],
+ [enable native sndio backend @<:@default=auto@:>@])])
+
+if test "x$enable_sndio" = xno; then
+ openal_backend_sndio_support=disabled
+else
+ AC_CHECK_HEADER([sndio.h],
+ [openal_libs_sndio="-lsndio"
+ openal_saved_LIBS=$LIBS
+ LIBS="$openal_libs_sndio $LIBS"
+ AC_CACHE_CHECK([for sio_open], [openal_cv_func_sio_open],
+ [AC_LINK_IFELSE([AC_LANG_CALL([], [sio_open])],
+ [openal_cv_func_sio_open=yes],
+ [openal_cv_func_sio_open=no])])
+ if test "x$openal_cv_func_sio_open" = xyes; then
+ openal_backend_sndio_support=static
+ LIBS="$openal_libs_sndio $LIBS"
+ else
+ openal_backend_sndio_support=none
+ LIBS=$openal_saved_LIBS
+ if test "x$enable_sndio" = xyes; then
+ AC_MSG_WARN([--enable-sndio ignored because the sndio library could not be found.])
+ fi
+ fi],
+ [openal_backend_sndio_support=none
+ if test "x$enable_sndio" = xyes; then
+ AC_MSG_WARN([--enable-sndio ignored because the sndio header could not be found.])
+ fi],
+ [AC_INCLUDES_DEFAULT([])])
+fi
+
+OPENAL_ENABLE([native sndio backend], [openal_backend_sndio_support],
+ [USE_BACKEND_NATIVE_SNDIO], [USEBACKENDNATIVESNDIO])
# check for WAVE backend #######################################################

View File

@ -0,0 +1,15 @@
$OpenBSD: patch-src_Makefile_am,v 1.1 2009/12/16 20:00:41 naddy Exp $
--- src/Makefile.am.orig Thu Jan 19 21:58:50 2006
+++ src/Makefile.am Thu Oct 15 14:47:15 2009
@@ -119,6 +119,11 @@ libopenal_la_SOURCES += \
backends/alc_backend_solaris.c
endif
+if USEBACKENDNATIVESNDIO
+libopenal_la_SOURCES += \
+ backends/alc_backend_sndio.c
+endif
+
if USEBACKENDWAVEOUT
libopenal_la_SOURCES += \
backends/alc_backend_wave.c

View File

@ -1,51 +0,0 @@
$OpenBSD: patch-src_backends_alc_backend_bsd_c,v 1.1 2006/10/30 23:31:37 steven Exp $
--- src/backends/alc_backend_bsd.c.orig Thu Jan 5 16:11:20 2006
+++ src/backends/alc_backend_bsd.c Thu Oct 26 21:51:24 2006
@@ -10,14 +10,16 @@
#include "al_siteconfig.h"
#include <AL/al.h>
+#include <AL/alext.h>
#include <assert.h>
#include <fcntl.h>
-#include <sys/soundcard.h>
+#include <soundcard.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
+#include <sys/select.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -112,7 +114,7 @@ static int AL2BSDFMT(int fmt)
*
*/
static void *grab_write_native(void) {
- const char *dsppath = "/dev/dsp";
+ const char *dsppath = "/dev/audio";
int divisor = _alSpot(_AL_DEF_BUFSIZ) | (2<<16);
dsp_fd = open(dsppath, O_WRONLY | O_NONBLOCK);
@@ -146,9 +148,11 @@ int grab_mixerfd(void) {
mixer_fd = open("/dev/mixer", O_WRONLY | O_NONBLOCK);
if(mixer_fd > 0) {
+#if 0
if(fcntl(mixer_fd, F_SETFL, ~O_NONBLOCK) == -1) {
perror("fcntl");
}
+#endif
return mixer_fd;
} else {
@@ -210,7 +214,7 @@ void release_native(void *handle) {
handle_fd = *(int *) handle;
- if(ioctl(handle_fd, SNDCTL_DSP_RESET) < 0) {
+ if(ioctl(handle_fd, SNDCTL_DSP_RESET, NULL) < 0) {
#ifdef DEBUG_MAXIMUS
fprintf(stderr, "Couldn't reset dsp\n");
#endif