Thu Apr 16 04:12:39 2020 UTC ()
SDL2: Fix build on NetBSD 8


(nia)
diff -r1.49 -r1.50 pkgsrc/devel/SDL2/Makefile
diff -r1.5 -r1.6 pkgsrc/devel/SDL2/patches/patch-src_audio_netbsd_SDL__netbsdaudio.c

cvs diff -r1.49 -r1.50 pkgsrc/devel/SDL2/Makefile (expand / switch to unified diff)

--- pkgsrc/devel/SDL2/Makefile 2020/04/08 14:41:33 1.49
+++ pkgsrc/devel/SDL2/Makefile 2020/04/16 04:12:39 1.50
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1# $NetBSD: Makefile,v 1.49 2020/04/08 14:41:33 nia Exp $ 1# $NetBSD: Makefile,v 1.50 2020/04/16 04:12:39 nia Exp $
2 2
3DISTNAME= SDL2-2.0.12 3DISTNAME= SDL2-2.0.12
4PKGREVISION= 2 4PKGREVISION= 3
5CATEGORIES= devel 5CATEGORIES= devel
6MASTER_SITES= https://www.libsdl.org/release/ 6MASTER_SITES= https://www.libsdl.org/release/
7 7
8MAINTAINER= nia@NetBSD.org 8MAINTAINER= nia@NetBSD.org
9HOMEPAGE= https://www.libsdl.org/ 9HOMEPAGE= https://www.libsdl.org/
10COMMENT= Simple DirectMedia Layer - cross-platform multimedia library 10COMMENT= Simple DirectMedia Layer - cross-platform multimedia library
11LICENSE= zlib 11LICENSE= zlib
12 12
13USE_LANGUAGES= c c++ 13USE_LANGUAGES= c c++
14USE_LIBTOOL= yes 14USE_LIBTOOL= yes
15USE_TOOLS+= gmake pkg-config 15USE_TOOLS+= gmake pkg-config
16GNU_CONFIGURE= yes 16GNU_CONFIGURE= yes
17 17

cvs diff -r1.5 -r1.6 pkgsrc/devel/SDL2/patches/Attic/patch-src_audio_netbsd_SDL__netbsdaudio.c (expand / switch to unified diff)

--- pkgsrc/devel/SDL2/patches/Attic/patch-src_audio_netbsd_SDL__netbsdaudio.c 2020/04/08 14:41:33 1.5
+++ pkgsrc/devel/SDL2/patches/Attic/patch-src_audio_netbsd_SDL__netbsdaudio.c 2020/04/16 04:12:39 1.6
@@ -1,65 +1,69 @@ @@ -1,65 +1,69 @@
1$NetBSD: patch-src_audio_netbsd_SDL__netbsdaudio.c,v 1.5 2020/04/08 14:41:33 nia Exp $ 1$NetBSD: patch-src_audio_netbsd_SDL__netbsdaudio.c,v 1.6 2020/04/16 04:12:39 nia Exp $
2 2
3Use the preferred hardware sample rate 3Use the preferred hardware sample rate
4https://bugzilla.libsdl.org/show_bug.cgi?id=5080 4https://bugzilla.libsdl.org/show_bug.cgi?id=5080
5 5
6Support 32-bit LPCM 6Support 32-bit LPCM
7https://bugzilla.libsdl.org/show_bug.cgi?id=5076 7https://bugzilla.libsdl.org/show_bug.cgi?id=5076
8 8
9--- src/audio/netbsd/SDL_netbsdaudio.c.orig 2020-03-11 01:36:18.000000000 +0000 9--- src/audio/netbsd/SDL_netbsdaudio.c.orig 2020-03-11 01:36:18.000000000 +0000
10+++ src/audio/netbsd/SDL_netbsdaudio.c 10+++ src/audio/netbsd/SDL_netbsdaudio.c
11@@ -205,7 +205,7 @@ static int 11@@ -205,7 +205,7 @@ static int
12 NETBSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) 12 NETBSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
13 { 13 {
14 SDL_AudioFormat format = 0; 14 SDL_AudioFormat format = 0;
15- audio_info_t info; 15- audio_info_t info;
16+ audio_info_t info, hwinfo; 16+ audio_info_t info, hwinfo;
17 struct audio_prinfo *prinfo = iscapture ? &info.record : &info.play; 17 struct audio_prinfo *prinfo = iscapture ? &info.record : &info.play;
18  18
19 /* We don't care what the devname is...we'll try to open anything. */ 19 /* We don't care what the devname is...we'll try to open anything. */
20@@ -232,8 +232,16 @@ NETBSDAUDIO_OpenDevice(_THIS, void *hand 20@@ -232,8 +232,20 @@ NETBSDAUDIO_OpenDevice(_THIS, void *hand
21 } 21 }
22  22
23 AUDIO_INITINFO(&info); 23 AUDIO_INITINFO(&info);
24+ AUDIO_INITINFO(&hwinfo); 24+ AUDIO_INITINFO(&hwinfo);
25+ 25+
 26+#ifdef AUDIO_GETFORMAT
26+ if (ioctl(this->hidden->audio_fd, AUDIO_GETFORMAT, &hwinfo) == -1) { 27+ if (ioctl(this->hidden->audio_fd, AUDIO_GETFORMAT, &hwinfo) == -1) {
27+ return SDL_SetError("Couldn't get device format %s: %s", devname, strerror(errno)); 28+ return SDL_SetError("Couldn't get device format %s: %s", devname, strerror(errno));
28+ } 29+ }
 30+#else
 31+ hwinfo.record.sample_rate = hwinfo.play.sample_rate = 48000;
 32+#endif
29  33
30 prinfo->encoding = AUDIO_ENCODING_NONE; 34 prinfo->encoding = AUDIO_ENCODING_NONE;
31+ prinfo->channels = this->spec.channels; 35+ prinfo->channels = this->spec.channels;
32+ prinfo->sample_rate = this->spec.freq = iscapture ? 36+ prinfo->sample_rate = this->spec.freq = iscapture ?
33+ hwinfo.record.sample_rate : hwinfo.play.sample_rate; 37+ hwinfo.record.sample_rate : hwinfo.play.sample_rate;
34  38
35 for (format = SDL_FirstAudioFormat(this->spec.format); format;) { 39 for (format = SDL_FirstAudioFormat(this->spec.format); format;) {
36 switch (format) { 40 switch (format) {
37@@ -261,6 +269,14 @@ NETBSDAUDIO_OpenDevice(_THIS, void *hand 41@@ -261,6 +273,14 @@ NETBSDAUDIO_OpenDevice(_THIS, void *hand
38 prinfo->encoding = AUDIO_ENCODING_ULINEAR_BE; 42 prinfo->encoding = AUDIO_ENCODING_ULINEAR_BE;
39 prinfo->precision = 16; 43 prinfo->precision = 16;
40 break; 44 break;
41+ case AUDIO_S32LSB: 45+ case AUDIO_S32LSB:
42+ prinfo->encoding = AUDIO_ENCODING_SLINEAR_LE; 46+ prinfo->encoding = AUDIO_ENCODING_SLINEAR_LE;
43+ prinfo->precision = 32; 47+ prinfo->precision = 32;
44+ break; 48+ break;
45+ case AUDIO_S32MSB: 49+ case AUDIO_S32MSB:
46+ prinfo->encoding = AUDIO_ENCODING_SLINEAR_BE; 50+ prinfo->encoding = AUDIO_ENCODING_SLINEAR_BE;
47+ prinfo->precision = 32; 51+ prinfo->precision = 32;
48+ break; 52+ break;
49 } 53 }
50 if (prinfo->encoding != AUDIO_ENCODING_NONE) { 54 if (prinfo->encoding != AUDIO_ENCODING_NONE) {
51 break; 55 break;
52@@ -274,21 +290,18 @@ NETBSDAUDIO_OpenDevice(_THIS, void *hand 56@@ -274,21 +294,18 @@ NETBSDAUDIO_OpenDevice(_THIS, void *hand
53  57
54 this->spec.format = format; 58 this->spec.format = format;
55  59
56- /* Calculate spec parameters based on our chosen format */ 60- /* Calculate spec parameters based on our chosen format */
57- SDL_CalculateAudioSpec(&this->spec); 61- SDL_CalculateAudioSpec(&this->spec);
58- 62-
59 info.mode = iscapture ? AUMODE_RECORD : AUMODE_PLAY; 63 info.mode = iscapture ? AUMODE_RECORD : AUMODE_PLAY;
60- info.blocksize = this->spec.size; 64- info.blocksize = this->spec.size;
61 info.hiwat = 5; 65 info.hiwat = 5;
62 info.lowat = 3; 66 info.lowat = 3;
63- prinfo->sample_rate = this->spec.freq; 67- prinfo->sample_rate = this->spec.freq;
64- prinfo->channels = this->spec.channels; 68- prinfo->channels = this->spec.channels;
65 (void) ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info); 69 (void) ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info);