- make artsd audio output work by linking with libartsc instead

of trying to dlopen() it.  also fix a couple bugs in the artsd
  output module: when artsd is "suspended", it only means that
  it it not accessing the soundcard at the moment, not that it
  will not accept data.  fix output latency by setting parameters
  that actually are settable, instead of trying to set read-only(!)
  parameters.

- allow the default audio output method to be chosen with the
  SDL_AUDIO_DRIVER environment variable.  choices are 'arts',
  'esd' and 'audio'.  'audio' selects audio(4) output, and is
  the default if SDL_AUDIO_DRIVER is not set.

ok pvalchev@
This commit is contained in:
jakemsr 2008-03-19 13:33:29 +00:00
parent 98283b9709
commit 99fccde5bc
4 changed files with 89 additions and 10 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.61 2008/01/27 18:43:20 pvalchev Exp $
# $OpenBSD: Makefile,v 1.62 2008/03/19 13:33:29 jakemsr Exp $
COMMENT= cross-platform multimedia library
VERSION= 1.2.13
DISTNAME= SDL-${VERSION}
PKGNAME= ${DISTNAME:L}p0
PKGNAME= ${DISTNAME:L}p1
CATEGORIES= devel
HOMEPAGE= http://www.libsdl.org/
@ -59,6 +59,7 @@ CONFIGURE_ARGS+= --disable-nasm
.endif
.if ${FLAVOR:L:Mesd}
# used via dlopen()
LIB_DEPENDS+= esd.>=2::audio/esound
CONFIGURE_ARGS+= --enable-esd
.else
@ -67,7 +68,8 @@ CONFIGURE_ARGS+= --disable-esd
.if ${FLAVOR:L:Marts}
LIB_DEPENDS+= artsc::x11/kde/arts3
CONFIGURE_ARGS+= --enable-arts
WANTLIB+= glib-2.0 gmodule-2.0 gthread-2.0 intl pcre stdc++
CONFIGURE_ARGS+= --enable-arts --disable-arts-shared
.else
CONFIGURE_ARGS+= --disable-arts
.endif

View File

@ -1,6 +1,15 @@
$OpenBSD: patch-configure,v 1.16 2008/01/03 17:39:40 pvalchev Exp $
$OpenBSD: patch-configure,v 1.17 2008/03/19 13:33:29 jakemsr Exp $
--- configure.orig Sun Dec 30 21:09:39 2007
+++ configure Wed Jan 2 18:41:16 2008
+++ configure Mon Feb 18 00:21:17 2008
@@ -25578,7 +25578,7 @@ fi
: # arts isn't installed
else
ARTS_CFLAGS=`$ARTSCONFIG --cflags`
- ARTS_LIBS=`$ARTSCONFIG --libs`
+ ARTS_LIBS="`$ARTSCONFIG --libs` -lstdc++"
ARTS_PREFIX=`$ARTSCONFIG --arts-prefix`
{ echo "$as_me:$LINENO: checking for aRts development environment" >&5
echo $ECHO_N "checking for aRts development environment... $ECHO_C" >&6; }
@@ -26333,9 +26333,6 @@ echo "${ECHO_T}$CompileNASM_ret" >&6; }
win32)
NASMFLAGS="-f win32"

View File

@ -1,7 +1,37 @@
$OpenBSD: patch-src_audio_SDL_audio_c,v 1.12 2007/09/22 01:12:38 pvalchev Exp $
--- src/audio/SDL_audio.c.orig Fri Jul 20 01:52:10 2007
+++ src/audio/SDL_audio.c Sat Sep 8 21:39:59 2007
@@ -518,8 +518,9 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpe
$OpenBSD: patch-src_audio_SDL_audio_c,v 1.13 2008/03/19 13:33:29 jakemsr Exp $
--- src/audio/SDL_audio.c.orig Sun Dec 30 20:47:59 2007
+++ src/audio/SDL_audio.c Mon Feb 18 01:41:22 2008
@@ -341,6 +341,7 @@ int SDL_AudioInit(const char *driver_name)
}
#endif /* SDL_AUDIO_DRIVER_ESD */
if ( audio == NULL ) {
+ char *env_driver = getenv("SDL_AUDIO_DRIVER");
if ( driver_name != NULL ) {
#if 0 /* This will be replaced with a better driver selection API */
if ( SDL_strrchr(driver_name, ':') != NULL ) {
@@ -357,12 +358,16 @@ int SDL_AudioInit(const char *driver_name)
}
} else {
for ( i=0; bootstrap[i]; ++i ) {
- if ( bootstrap[i]->available() ) {
- audio = bootstrap[i]->create(idx);
- if ( audio != NULL ) {
- break;
- }
+ if (env_driver != NULL) {
+ if (SDL_strcasecmp(bootstrap[i]->name, env_driver) == 0)
+ audio = bootstrap[i]->create(idx);
+ } else {
+ if (bootstrap[i]->available())
+ audio = bootstrap[i]->create(idx);
}
+ if ( audio != NULL ) {
+ break;
+ }
}
}
if ( audio == NULL ) {
@@ -518,8 +523,9 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpe
/* See if we need to do any conversion */
if ( obtained != NULL ) {
@ -13,7 +43,7 @@ $OpenBSD: patch-src_audio_SDL_audio_c,v 1.12 2007/09/22 01:12:38 pvalchev Exp $
desired->format != audio->spec.format ||
desired->channels != audio->spec.channels ) {
/* Build an audio conversion block */
@@ -532,7 +533,7 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpe
@@ -532,7 +538,7 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpe
return(-1);
}
if ( audio->convert.needed ) {

View File

@ -0,0 +1,38 @@
$OpenBSD: patch-src_audio_arts_SDL_artsaudio_c,v 1.1 2008/03/19 13:33:29 jakemsr Exp $
--- src/audio/arts/SDL_artsaudio.c.orig Sun Dec 30 20:47:57 2007
+++ src/audio/arts/SDL_artsaudio.c Mon Mar 10 00:04:32 2008
@@ -307,29 +307,21 @@ static int ARTS_OpenAudio(_THIS, SDL_AudioSpec *spec)
SDL_SetError("Unable to initialize ARTS: %s", SDL_NAME(arts_error_text)(error_code));
return(-1);
}
+#if 0
if ( ! SDL_NAME(arts_suspended)() ) {
SDL_SetError("ARTS can not open audio device");
return(-1);
}
+#endif
stream = SDL_NAME(arts_play_stream)(spec->freq, bits, spec->channels, "SDL");
/* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(spec);
- /* Determine the power of two of the fragment size */
- for ( frag_spec = 0; (0x01<<frag_spec) < spec->size; ++frag_spec );
- if ( (0x01<<frag_spec) != spec->size ) {
- SDL_SetError("Fragment size must be a power of two");
- return(-1);
- }
- frag_spec |= 0x00020000; /* two fragments, for low latency */
+ /* set total buffer size (latency) to what we expect */
+ SDL_NAME(arts_stream_set)(stream, ARTS_P_BUFFER_SIZE, spec->size);
-#ifdef ARTS_P_PACKET_SETTINGS
- SDL_NAME(arts_stream_set)(stream, ARTS_P_PACKET_SETTINGS, frag_spec);
-#else
- SDL_NAME(arts_stream_set)(stream, ARTS_P_PACKET_SIZE, frag_spec&0xffff);
- SDL_NAME(arts_stream_set)(stream, ARTS_P_PACKET_COUNT, frag_spec>>16);
-#endif
+ /* and use artsd's preferred write() size */
spec->size = SDL_NAME(arts_stream_get)(stream, ARTS_P_PACKET_SIZE);
/* Allocate mixing buffer */