From 26a9c9cc528a96053db4a518f9bce76e349fbc6f Mon Sep 17 00:00:00 2001 From: jakemsr Date: Fri, 20 Jul 2007 05:23:41 +0000 Subject: [PATCH] - use the sun audio interface instead of the OpenBSD interface - sync patches with update-patches - bump PKGNAME the sun interface keeps fewer samples in the play buffer, and with less fluctuation than the OpenBSD interface. results in better audio-video synchronization in e.g. ffplay and gnash go for it -pval --- devel/sdl/Makefile | 8 +- devel/sdl/patches/patch-configure_in | 19 ++- ...patch-src_audio_openbsd_SDL_openbsdaudio_c | 14 ++- .../patch-src_audio_sun_SDL_sunaudio_c | 118 ++++++++++++++++++ .../patch-src_joystick_bsd_SDL_sysjoystick_c | 8 +- .../patch-src_video_x11_SDL_x11modes_c | 14 +-- 6 files changed, 159 insertions(+), 22 deletions(-) create mode 100644 devel/sdl/patches/patch-src_audio_sun_SDL_sunaudio_c diff --git a/devel/sdl/Makefile b/devel/sdl/Makefile index 7a935753ef1..92a6392d8ed 100644 --- a/devel/sdl/Makefile +++ b/devel/sdl/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.51 2007/04/08 15:31:01 sturm Exp $ +# $OpenBSD: Makefile,v 1.52 2007/07/20 05:23:41 jakemsr Exp $ # Uses pthreads COMMENT= "cross-platform multimedia library" VERSION= 1.2.9 DISTNAME= SDL-${VERSION} -PKGNAME= ${DISTNAME:L}p4 +PKGNAME= ${DISTNAME:L}p5 CATEGORIES= devel HOMEPAGE= http://www.libsdl.org/ @@ -60,9 +60,9 @@ CONFIGURE_ARGS+= --disable-nasm .endif .if ${FLAVOR:L:Msun} -CONFIGURE_ARGS+= --enable-openbsdaudio +CONFIGURE_ARGS+= --enable-sunaudio .else -CONFIGURE_ARGS+= --disable-openbsdaudio +CONFIGURE_ARGS+= --disable-sunaudio .endif .if ${FLAVOR:L:Mesd} diff --git a/devel/sdl/patches/patch-configure_in b/devel/sdl/patches/patch-configure_in index df15c5ce0fd..00359612ff0 100644 --- a/devel/sdl/patches/patch-configure_in +++ b/devel/sdl/patches/patch-configure_in @@ -1,6 +1,6 @@ -$OpenBSD: patch-configure_in,v 1.27 2006/10/19 00:26:34 pvalchev Exp $ ---- configure.in.orig Sun Aug 28 00:31:18 2005 -+++ configure.in Sat Sep 10 20:34:34 2005 +$OpenBSD: patch-configure_in,v 1.28 2007/07/20 05:23:41 jakemsr Exp $ +--- configure.in.orig Sat Aug 27 23:31:18 2005 ++++ configure.in Sun Jul 8 01:07:57 2007 @@ -535,9 +535,6 @@ CheckNASM() win32) NASMFLAGS="-f win32" @@ -50,6 +50,19 @@ $OpenBSD: patch-configure_in,v 1.27 2006/10/19 00:26:34 pvalchev Exp $ CFLAGS="$CFLAGS -DUSE_DLOPEN" AC_CHECK_LIB(c, dlopen, SYSTEM_LIBS="$SYSTEM_LIBS", AC_CHECK_LIB(dl, dlopen, SYSTEM_LIBS="$SYSTEM_LIBS -ldl", +@@ -2115,9 +2109,9 @@ case "$target" in + CheckRPATH + # Set up files for the audio library + if test x$enable_audio = xyes; then +- CFLAGS="$CFLAGS -DOPENBSD_AUDIO_SUPPORT" +- AUDIO_SUBDIRS="$AUDIO_SUBDIRS openbsd" +- AUDIO_DRIVERS="$AUDIO_DRIVERS openbsd/libaudio_openbsd.la" ++ CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT" ++ AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun" ++ AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la" + fi + # OpenBSD needs linking with ossaudio emulation library + if test x$have_oss = xyes; then @@ -2764,6 +2758,9 @@ if test "x$enable_rpath" = "xyes"; then else SDL_RLD_FLAGS="" diff --git a/devel/sdl/patches/patch-src_audio_openbsd_SDL_openbsdaudio_c b/devel/sdl/patches/patch-src_audio_openbsd_SDL_openbsdaudio_c index c5437d803f0..076f035037f 100644 --- a/devel/sdl/patches/patch-src_audio_openbsd_SDL_openbsdaudio_c +++ b/devel/sdl/patches/patch-src_audio_openbsd_SDL_openbsdaudio_c @@ -1,6 +1,6 @@ -$OpenBSD: patch-src_audio_openbsd_SDL_openbsdaudio_c,v 1.7 2006/10/19 00:26:34 pvalchev Exp $ ---- src/audio/openbsd/SDL_openbsdaudio.c.orig 2003-12-28 19:42:30.000000000 +0100 -+++ src/audio/openbsd/SDL_openbsdaudio.c 2003-12-28 19:43:45.000000000 +0100 +$OpenBSD: patch-src_audio_openbsd_SDL_openbsdaudio_c,v 1.8 2007/07/20 05:23:41 jakemsr Exp $ +--- src/audio/openbsd/SDL_openbsdaudio.c.orig Sun Jan 4 08:49:15 2004 ++++ src/audio/openbsd/SDL_openbsdaudio.c Sat Jul 7 19:05:13 2007 @@ -262,21 +262,21 @@ OBSD_Status(_THIS) return; } @@ -38,7 +38,7 @@ $OpenBSD: patch-src_audio_openbsd_SDL_openbsdaudio_c,v 1.7 2006/10/19 00:26:34 p info.play.buffer_size, info.play.sample_rate, info.play.channels, -@@ -290,14 +290,14 @@ active : %s +@@ -290,19 +290,19 @@ active : %s info.play.waiting ? "yes" : "no", info.play.active ? "yes": "no"); @@ -61,3 +61,9 @@ $OpenBSD: patch-src_audio_openbsd_SDL_openbsdaudio_c,v 1.7 2006/10/19 00:26:34 p info.monitor_gain, info.blocksize, info.hiwat, info.lowat, + (info.mode == AUMODE_PLAY) ? "PLAY" +- : (info.mode = AUMODE_RECORD) ? "RECORD" ++ : (info.mode == AUMODE_RECORD) ? "RECORD" + : (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" + : "?")); + } diff --git a/devel/sdl/patches/patch-src_audio_sun_SDL_sunaudio_c b/devel/sdl/patches/patch-src_audio_sun_SDL_sunaudio_c new file mode 100644 index 00000000000..75855dbac28 --- /dev/null +++ b/devel/sdl/patches/patch-src_audio_sun_SDL_sunaudio_c @@ -0,0 +1,118 @@ +$OpenBSD: patch-src_audio_sun_SDL_sunaudio_c,v 1.1 2007/07/20 05:23:41 jakemsr Exp $ +--- src/audio/sun/SDL_sunaudio.c.orig Sun Jan 4 08:49:15 2004 ++++ src/audio/sun/SDL_sunaudio.c Sat Jul 14 15:54:19 2007 +@@ -32,7 +32,7 @@ static char rcsid = + #include + #include + #include +-#ifdef __NetBSD__ ++#if defined(__NetBSD__) || defined(__OpenBSD__) + #include + #include + #endif +@@ -141,12 +141,18 @@ void CheckUnderflow(_THIS) + void DSP_WaitAudio(_THIS) + { + #ifdef AUDIO_GETINFO +-#define SLEEP_FUDGE 10 /* 10 ms scheduling fudge factor */ ++#define SLEEP_FUDGE 100 /* 100 ms scheduling fudge factor */ + audio_info_t info; + Sint32 left; + ++#ifdef AUDIO_WSEEK ++ ioctl(audio_fd, AUDIO_WSEEK, &left); ++ left = left / (this->spec.channels * (this->spec.format & 0xff) / 8); ++#else ++ /* OpenBSD and NetBSD return bytes, not samples in info.play.samples */ + ioctl(audio_fd, AUDIO_GETINFO, &info); + left = (written - info.play.samples); ++#endif + if ( left > fragsize ) { + Sint32 sleepy; + +@@ -221,9 +227,22 @@ void DSP_PlayAudio(_THIS) + #ifdef DEBUG_AUDIO + CheckUnderflow(this); + #endif +- if ( write(audio_fd, mixbuf, this->spec.size) < 0 ) { ++ while ( write(audio_fd, mixbuf, this->spec.size) < 0 ) { ++#ifdef DEBUG_AUDIO ++ fprintf(stderr, "audio write error: %s\n", strerror(errno)); ++#endif ++#ifndef AUDIO_GETINFO + /* Assume fatal error, for now */ + this->enabled = 0; ++ break; ++#else ++ /* no guarantee against EAGAIN doing our own timing */ ++ if (!((errno == EAGAIN) && (OPEN_FLAGS & O_NONBLOCK))) { ++ /* Assume fatal error, for now */ ++ this->enabled = 0; ++ break; ++ } ++#endif + } + written += fragsize; + } +@@ -266,16 +285,28 @@ int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec) + case 8: { /* Unsigned 8 bit audio data */ + spec->format = AUDIO_U8; + #ifdef AUDIO_SETINFO ++#ifdef __OpenBSD__ ++ enc = AUDIO_ENCODING_ULINEAR; ++#else + enc = AUDIO_ENCODING_LINEAR8; + #endif ++#endif + } + break; + + case 16: { /* Signed 16 bit audio data */ + spec->format = AUDIO_S16SYS; + #ifdef AUDIO_SETINFO ++#ifdef __OpenBSD__ ++#if BYTE_ORDER == LITTLE_ENDIAN ++ enc = AUDIO_ENCODING_SLINEAR_LE; ++#else ++ enc = AUDIO_ENCODING_SLINEAR_BE; ++#endif ++#else + enc = AUDIO_ENCODING_LINEAR; + #endif ++#endif + } + break; + +@@ -324,13 +355,22 @@ int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec) + } + + switch(enc) { ++#ifdef __OpenBSD__ ++ case AUDIO_ENCODING_ULINEAR: ++#else + case AUDIO_ENCODING_LINEAR8: ++#endif + /* unsigned 8bit apparently not supported here */ + enc = AUDIO_ENCODING_LINEAR; + spec->format = AUDIO_S16SYS; + break; /* try again */ + ++#ifdef __OpenBSD__ ++ case AUDIO_ENCODING_SLINEAR_LE: ++ case AUDIO_ENCODING_SLINEAR_BE: ++#else + case AUDIO_ENCODING_LINEAR: ++#endif + /* linear 16bit didn't work either, resort to µ-law */ + enc = AUDIO_ENCODING_ULAW; + spec->channels = 1; +@@ -348,6 +388,9 @@ int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec) + } + #endif /* AUDIO_SETINFO */ + written = 0; ++ ++ /* reset counters */ ++ ioctl(audio_fd, AUDIO_FLUSH, NULL); + + /* We can actually convert on-the-fly to U-Law */ + if ( ulaw_only ) { diff --git a/devel/sdl/patches/patch-src_joystick_bsd_SDL_sysjoystick_c b/devel/sdl/patches/patch-src_joystick_bsd_SDL_sysjoystick_c index c96ead9342b..24293676eb9 100644 --- a/devel/sdl/patches/patch-src_joystick_bsd_SDL_sysjoystick_c +++ b/devel/sdl/patches/patch-src_joystick_bsd_SDL_sysjoystick_c @@ -1,6 +1,6 @@ -$OpenBSD: patch-src_joystick_bsd_SDL_sysjoystick_c,v 1.8 2006/10/19 00:26:34 pvalchev Exp $ ---- src/joystick/bsd/SDL_sysjoystick.c.orig Mon Dec 13 18:54:32 2004 -+++ src/joystick/bsd/SDL_sysjoystick.c Fri Dec 17 16:36:39 2004 +$OpenBSD: patch-src_joystick_bsd_SDL_sysjoystick_c,v 1.9 2007/07/20 05:23:41 jakemsr Exp $ +--- src/joystick/bsd/SDL_sysjoystick.c.orig Fri Nov 12 13:24:46 2004 ++++ src/joystick/bsd/SDL_sysjoystick.c Sat Jul 7 18:07:10 2007 @@ -60,7 +60,7 @@ static char rcsid = #include #endif @@ -10,7 +10,7 @@ $OpenBSD: patch-src_joystick_bsd_SDL_sysjoystick_c,v 1.8 2006/10/19 00:26:34 pva #include #endif -@@ -370,7 +370,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joy +@@ -370,7 +370,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joy) int nbutton, naxe = -1; Sint32 v; diff --git a/devel/sdl/patches/patch-src_video_x11_SDL_x11modes_c b/devel/sdl/patches/patch-src_video_x11_SDL_x11modes_c index df08f9a4a48..e96c0f4b8d8 100644 --- a/devel/sdl/patches/patch-src_video_x11_SDL_x11modes_c +++ b/devel/sdl/patches/patch-src_video_x11_SDL_x11modes_c @@ -1,6 +1,6 @@ -$OpenBSD: patch-src_video_x11_SDL_x11modes_c,v 1.7 2006/10/19 00:26:34 pvalchev Exp $ ---- src/video/x11/SDL_x11modes.c.orig Mon Dec 13 18:54:37 2004 -+++ src/video/x11/SDL_x11modes.c Fri Dec 17 16:36:39 2004 +$OpenBSD: patch-src_video_x11_SDL_x11modes_c,v 1.8 2007/07/20 05:23:41 jakemsr Exp $ +--- src/video/x11/SDL_x11modes.c.orig Fri Nov 12 13:25:42 2004 ++++ src/video/x11/SDL_x11modes.c Sat Jul 7 18:07:10 2007 @@ -44,6 +44,8 @@ static char rcsid = #endif @@ -10,7 +10,7 @@ $OpenBSD: patch-src_video_x11_SDL_x11modes_c,v 1.7 2006/10/19 00:26:34 pvalchev #ifdef XFREE86_VM Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidModeModeInfo) *info) -@@ -92,6 +94,82 @@ static int cmpmodes(const void *va, cons +@@ -92,6 +94,82 @@ static int cmpmodes(const void *va, const void *vb) } #endif @@ -93,7 +93,7 @@ $OpenBSD: patch-src_video_x11_SDL_x11modes_c,v 1.7 2006/10/19 00:26:34 pvalchev static void get_real_resolution(_THIS, int* w, int* h); static void set_best_resolution(_THIS, int width, int height) -@@ -103,9 +181,11 @@ static void set_best_resolution(_THIS, i +@@ -103,9 +181,11 @@ static void set_best_resolution(_THIS, int width, int int i; int best_width = 0, best_height = 0; int nmodes; @@ -106,7 +106,7 @@ $OpenBSD: patch-src_video_x11_SDL_x11modes_c,v 1.7 2006/10/19 00:26:34 pvalchev #ifdef XFREE86_DEBUG printf("Available modes (unsorted):\n"); for ( i = 0; i < nmodes; ++i ) { -@@ -117,14 +197,16 @@ static void set_best_resolution(_THIS, i +@@ -117,14 +197,16 @@ static void set_best_resolution(_THIS, int width, int #endif for ( i = 0; i < nmodes ; i++ ) { if ( (modes[i]->hdisplay == width) && @@ -125,7 +125,7 @@ $OpenBSD: patch-src_video_x11_SDL_x11modes_c,v 1.7 2006/10/19 00:26:34 pvalchev best_width = modes[i]->hdisplay; best_height = modes[i]->vdisplay; } -@@ -142,6 +224,7 @@ static void set_best_resolution(_THIS, i +@@ -142,6 +224,7 @@ static void set_best_resolution(_THIS, int width, int SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]); } XFree(modes);