pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/devel/SDL2 SDL2: Audio changes!
details: https://anonhg.NetBSD.org/pkgsrc/rev/03e08a3cffbc
branches: trunk
changeset: 396202:03e08a3cffbc
user: nia <nia%pkgsrc.org@localhost>
date: Fri May 24 18:13:36 2019 +0000
description:
SDL2: Audio changes!
SDL_netbsdaudio.c:
* Rework the NetBSD audio driver significantly. Use blocking i/o as
suggested on the SDL bug tracker. Rework the intialization steps
since they were very wrong. All calls to Delay now removed.
* Fixes the horrible stuttering on my system.
* Performance now approximately matches SDL_AUDIODRIVER=dsp. Code
is also closer to SDL_dspaudio.
* Tested with multimedia/mpv, games/etlegacy, emulators/retroarch,
wip/tesseract-game, using SDL audio outputs.
options.mk:
* Add "jack" option, disabled by default.
* Enable ALSA by default on Linux.
* Fix some whitespace problems.
Bump PKGREVISION.
diffstat:
devel/SDL2/Makefile | 4 +-
devel/SDL2/distinfo | 4 +-
devel/SDL2/options.mk | 27 +-
devel/SDL2/patches/patch-src_audio_netbsd_SDL__netbsdaudio.c | 258 ++++++++++-
4 files changed, 264 insertions(+), 29 deletions(-)
diffs (truncated from 381 to 300 lines):
diff -r 9935e757e291 -r 03e08a3cffbc devel/SDL2/Makefile
--- a/devel/SDL2/Makefile Fri May 24 16:15:17 2019 +0000
+++ b/devel/SDL2/Makefile Fri May 24 18:13:36 2019 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.34 2018/12/30 14:47:04 maya Exp $
+# $NetBSD: Makefile,v 1.35 2019/05/24 18:13:36 nia Exp $
DISTNAME= SDL2-2.0.9
-PKGREVISION= 2
+PKGREVISION= 3
CATEGORIES= devel
MASTER_SITES= http://www.libsdl.org/release/
diff -r 9935e757e291 -r 03e08a3cffbc devel/SDL2/distinfo
--- a/devel/SDL2/distinfo Fri May 24 16:15:17 2019 +0000
+++ b/devel/SDL2/distinfo Fri May 24 18:13:36 2019 +0000
@@ -1,11 +1,11 @@
-$NetBSD: distinfo,v 1.32 2018/12/30 14:47:04 maya Exp $
+$NetBSD: distinfo,v 1.33 2019/05/24 18:13:36 nia Exp $
SHA1 (SDL2-2.0.9.tar.gz) = 4354c6baad9a48486182656a7506abfb63e9bff5
RMD160 (SDL2-2.0.9.tar.gz) = db2efabf55af41cddf015db0b5213b11ef22b9d0
SHA512 (SDL2-2.0.9.tar.gz) = a78a4708b2bb5b35a7c7b7501eb3bd60a9aa3bb95a3d84e57763df4a377185e7312a94b66321eef7ca0d17255e4b402fc950e83ef0dbbd08f14ff1194107dc10
Size (SDL2-2.0.9.tar.gz) = 5246942 bytes
SHA1 (patch-configure) = 1631314dab18886ea553ee53fac89e16718cacab
-SHA1 (patch-src_audio_netbsd_SDL__netbsdaudio.c) = 7a1f32ea7029f8dc99aecfaead7c68f2fd6cb230
+SHA1 (patch-src_audio_netbsd_SDL__netbsdaudio.c) = a495f5ede3ab1bd01b0703b50081748a0e57f1c4
SHA1 (patch-src_joystick_bsd_SDL__sysjoystick.c) = 152b5df76a91c7e7acde126b1464fdd464cf1ba2
SHA1 (patch-src_video_cocoa_SDL__cocoawindow.m) = 1d5ac9c17ceadf668925734b5cad311e26f2fc58
SHA1 (patch-src_video_x11_SDL__x11opengl.c) = 70b63021c12c52760c0811c673b259844bdfcdc0
diff -r 9935e757e291 -r 03e08a3cffbc devel/SDL2/options.mk
--- a/devel/SDL2/options.mk Fri May 24 16:15:17 2019 +0000
+++ b/devel/SDL2/options.mk Fri May 24 18:13:36 2019 +0000
@@ -1,10 +1,11 @@
-# $NetBSD: options.mk,v 1.10 2018/12/24 16:25:30 nia Exp $
+# $NetBSD: options.mk,v 1.11 2019/05/24 18:13:36 nia Exp $
-PKG_OPTIONS_VAR= PKG_OPTIONS.SDL2
+PKG_OPTIONS_VAR= PKG_OPTIONS.SDL2
PKG_OPTIONS_REQUIRED_GROUPS= gl
-PKG_SUPPORTED_OPTIONS= alsa dbus esound nas oss pulseaudio x11
-PKG_OPTIONS_GROUP.gl= opengl
-PKG_SUGGESTED_OPTIONS+= oss
+PKG_SUPPORTED_OPTIONS= alsa dbus esound nas oss jack pulseaudio x11
+PKG_OPTIONS_GROUP.gl= opengl
+PKG_SUGGESTED_OPTIONS+= oss
+PKG_SUGGESTED_OPTIONS.Linux+= alsa
.if ${OPSYS} != "Darwin"
PKG_SUGGESTED_OPTIONS+= x11
@@ -13,7 +14,7 @@
.include "../../mk/bsd.fast.prefs.mk"
.if !empty(MACHINE_ARCH:M*arm*)
-PKG_OPTIONS_GROUP.gl+= rpi
+PKG_OPTIONS_GROUP.gl+= rpi
PKG_SUGGESTED_OPTIONS+= rpi
.else
PKG_SUGGESTED_OPTIONS+= opengl
@@ -39,6 +40,12 @@
CONFIGURE_ARGS+= --disable-esd
.endif
+.if !empty(PKG_OPTIONS:Mjack)
+.include "../../audio/jack/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-jack
+.endif
+
.if !empty(PKG_OPTIONS:Mnas)
.include "../../audio/nas/buildlink3.mk"
.else
@@ -78,10 +85,10 @@
.if !empty(PKG_OPTIONS:Mrpi)
LOWER_VENDOR= raspberry
-SUBST_CLASSES+= vc
-SUBST_STAGE.vc= pre-configure
-SUBST_MESSAGE.vc= Fixing path to VideoCore libraries.
-SUBST_FILES.vc= configure
+SUBST_CLASSES+= vc
+SUBST_STAGE.vc= pre-configure
+SUBST_MESSAGE.vc= Fixing path to VideoCore libraries.
+SUBST_FILES.vc= configure
SUBST_SED.vc+= -e "s;/opt/vc;${PREFIX};g"
.include "../../misc/raspberrypi-userland/buildlink3.mk"
.endif
diff -r 9935e757e291 -r 03e08a3cffbc devel/SDL2/patches/patch-src_audio_netbsd_SDL__netbsdaudio.c
--- a/devel/SDL2/patches/patch-src_audio_netbsd_SDL__netbsdaudio.c Fri May 24 16:15:17 2019 +0000
+++ b/devel/SDL2/patches/patch-src_audio_netbsd_SDL__netbsdaudio.c Fri May 24 18:13:36 2019 +0000
@@ -1,15 +1,28 @@
-$NetBSD: patch-src_audio_netbsd_SDL__netbsdaudio.c,v 1.1 2017/09/26 13:10:56 adam Exp $
+$NetBSD: patch-src_audio_netbsd_SDL__netbsdaudio.c,v 1.2 2019/05/24 18:13:36 nia Exp $
-Remove delay as there is already an inherent delay in writing audio.
+Remove delays and use blocking i/o
https://bugzilla.libsdl.org/show_bug.cgi?id=3177
audio_prinfo needs 'struct' on NetBSD.
-Use correct prinfo.
-Inform upper layer of blocksize
+Use correct prinfo type (play/record)
+Rework initialization
---- src/audio/netbsd/SDL_netbsdaudio.c.orig 2017-09-26 12:34:35.000000000 +0000
+--- src/audio/netbsd/SDL_netbsdaudio.c.orig 2018-10-31 15:07:22.000000000 +0000
+++ src/audio/netbsd/SDL_netbsdaudio.c
-@@ -63,14 +63,14 @@ NETBSDAUDIO_Status(_THIS)
+@@ -43,12 +43,7 @@
+ #include "../SDL_audiodev_c.h"
+ #include "SDL_netbsdaudio.h"
+
+-/* Use timer for synchronization */
+-/* #define USE_TIMER_SYNC */
+-
+ /* #define DEBUG_AUDIO */
+-/* #define DEBUG_AUDIO_STREAM */
+-
+
+ static void
+ NETBSDAUDIO_DetectDevices(void)
+@@ -63,14 +58,14 @@ NETBSDAUDIO_Status(_THIS)
#ifdef DEBUG_AUDIO
/* *INDENT-OFF* */
audio_info_t info;
@@ -26,19 +39,159 @@
fprintf(stderr, "\n"
"[%s info]\n"
-@@ -184,10 +184,6 @@ NETBSDAUDIO_PlayDevice(_THIS)
- fprintf(stderr, "Wrote %d bytes of audio data\n", written);
+@@ -115,90 +110,37 @@ NETBSDAUDIO_Status(_THIS)
+ (info.mode == AUMODE_PLAY) ? "PLAY"
+ : (info.mode = AUMODE_RECORD) ? "RECORD"
+ : (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?"));
++
++ fprintf(stderr, "\n"
++ "[audio spec]\n"
++ "format : 0x%x\n"
++ "size : %u\n"
++ "",
++ this->spec.format,
++ this->spec.size);
+ /* *INDENT-ON* */
+ #endif /* DEBUG_AUDIO */
+ }
+
+
+-/* This function waits until it is possible to write a full sound buffer */
+-static void
+-NETBSDAUDIO_WaitDevice(_THIS)
+-{
+-#ifndef USE_BLOCKING_WRITES /* Not necessary when using blocking writes */
+- /* See if we need to use timed audio synchronization */
+- if (this->hidden->frame_ticks) {
+- /* Use timer for general audio synchronization */
+- Sint32 ticks;
+-
+- ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
+- if (ticks > 0) {
+- SDL_Delay(ticks);
+- }
+- } else {
+- /* Use SDL_IOReady() for audio synchronization */
+-#ifdef DEBUG_AUDIO
+- fprintf(stderr, "Waiting for audio to get ready\n");
+-#endif
+- if (SDL_IOReady(this->hidden->audio_fd, SDL_TRUE, 10 * 1000)
+- <= 0) {
+- const char *message =
+- "Audio timeout - buggy audio driver? (disabled)";
+- /* In general we should never print to the screen,
+- but in this case we have no other way of letting
+- the user know what happened.
+- */
+- fprintf(stderr, "SDL: %s\n", message);
+- SDL_OpenedAudioDeviceDisconnected(this);
+- /* Don't try to close - may hang */
+- this->hidden->audio_fd = -1;
+-#ifdef DEBUG_AUDIO
+- fprintf(stderr, "Done disabling audio\n");
+-#endif
+- }
+-#ifdef DEBUG_AUDIO
+- fprintf(stderr, "Ready!\n");
+-#endif
+- }
+-#endif /* !USE_BLOCKING_WRITES */
+-}
+-
+ static void
+ NETBSDAUDIO_PlayDevice(_THIS)
+ {
+- int written, p = 0;
++ struct SDL_PrivateAudioData *h = this->hidden;
++ int written;
+
+- /* Write the audio data, checking for EAGAIN on broken audio drivers */
+- do {
+- written = write(this->hidden->audio_fd,
+- &this->hidden->mixbuf[p], this->hidden->mixlen - p);
+-
+- if (written > 0)
+- p += written;
+- if (written == -1 && errno != 0 && errno != EAGAIN && errno != EINTR) {
+- /* Non recoverable error has occurred. It should be reported!!! */
+- perror("audio");
+- break;
+- }
++ /* Write the audio data */
++ written = write(h->audio_fd, h->mixbuf, h->mixlen);
++ if (written == -1) {
++ /* Non recoverable error has occurred. It should be reported!!! */
++ SDL_OpenedAudioDeviceDisconnected(this);
++ perror("audio");
++ return;
++ }
+
+ #ifdef DEBUG_AUDIO
+- fprintf(stderr, "Wrote %d bytes of audio data\n", written);
++ fprintf(stderr, "Wrote %d bytes of audio data\n", written);
#endif
-
+-
- if (p < this->hidden->mixlen
- || ((written < 0) && ((errno == 0) || (errno == EAGAIN)))) {
- SDL_Delay(1); /* Let a little CPU time go by */
- }
- } while (p < this->hidden->mixlen);
+- } while (p < this->hidden->mixlen);
+-
+- /* If timer synchronization is enabled, set the next write frame */
+- if (this->hidden->frame_ticks) {
+- this->hidden->next_frame += this->hidden->frame_ticks;
+- }
+-
+- /* If we couldn't write, assume fatal error for now */
+- if (written < 0) {
+- SDL_OpenedAudioDeviceDisconnected(this);
+- }
+ }
+
+ static Uint8 *
+@@ -212,28 +154,19 @@ static int
+ NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen)
+ {
+ Uint8 *buffer = (Uint8 *) _buffer;
+- int br, p = 0;
++ int br;
- /* If timer synchronization is enabled, set the next write frame */
-@@ -274,7 +270,7 @@ NETBSDAUDIO_OpenDevice(_THIS, void *hand
- const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
+- /* Capture the audio data, checking for EAGAIN on broken audio drivers */
+- do {
+- br = read(this->hidden->audio_fd, buffer + p, buflen - p);
+- if (br > 0)
+- p += br;
+- if (br == -1 && errno != 0 && errno != EAGAIN && errno != EINTR) {
+- /* Non recoverable error has occurred. It should be reported!!! */
+- perror("audio");
+- return p ? p : -1;
+- }
++ br = read(this->hidden->audio_fd, buffer, buflen);
++ if (br == -1) {
++ /* Non recoverable error has occurred. It should be reported!!! */
++ perror("audio");
++ return -1;
++ }
+
+ #ifdef DEBUG_AUDIO
+- fprintf(stderr, "Captured %d bytes of audio data\n", br);
++ fprintf(stderr, "Captured %d bytes of audio data\n", br);
+ #endif
+-
+- if (p < buflen
+- || ((br < 0) && ((errno == 0) || (errno == EAGAIN)))) {
+- SDL_Delay(1); /* Let a little CPU time go by */
+- }
+- } while (p < buflen);
++ return 0;
+ }
+
+ static void
+@@ -271,10 +204,9 @@ NETBSDAUDIO_CloseDevice(_THIS)
+ static int
+ NETBSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
+ {
+- const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
SDL_AudioFormat format = 0;
audio_info_t info;
- audio_prinfo *prinfo = iscapture ? &info.play : &info.record;
@@ -46,11 +199,86 @@
/* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */
-@@ -366,6 +362,7 @@ NETBSDAUDIO_OpenDevice(_THIS, void *hand
+@@ -294,25 +226,16 @@ NETBSDAUDIO_OpenDevice(_THIS, void *hand
+ SDL_zerop(this->hidden);
+
Home |
Main Index |
Thread Index |
Old Index