Refined diff at the bottom that includes a fix of the audio assertion
failure [1].

Also removes the workaround from 2018 where SDL2 claims to be Linux
[2]. This isn't needed anymore with updates that have rolled out to FNA
and the associated games and infrastructure.

Tested build and runtime with many consumers, among them:
ffmpeg(ffplay), mpv, ocp, citra, emulationstation, ppsspp, snes9x,
amnesia-tdd, barony, scummvm, blobby, eduke32, hashlink, openmw,
quakespasm, sdl-jstest, teeworlds, shotcut, lagrange.

Additional testing of only the ports build with: wxWidgets, libqrencode,
sdl2-{gfx,mixer,net,ttf}, smpeg2, advancemame, emulators/dolphin.

No issues except for the now fixed audio assertion failure. Also tested
with the XBox 360 gamepad which still works.

Additional testing or comments welcome, but this works well enough so
far that I would probably update it soon.

[1] https://github.com/libsdl-org/SDL/pull/5094
[2] https://marc.info/?l=openbsd-ports-cvs&m=151536581216331&w=2

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/sdl2/Makefile,v
retrieving revision 1.37
diff -u -p -r1.37 Makefile
--- Makefile    15 Nov 2021 20:02:05 -0000      1.37
+++ Makefile    12 Dec 2021 17:27:05 -0000
@@ -2,14 +2,13 @@
 
 COMMENT=       cross-platform multimedia library
 
-V=             2.0.16
+V=             2.0.18
 DISTNAME=      SDL2-${V}
 PKGNAME=       sdl2-${V}
 CATEGORIES=    devel
 MASTER_SITES=  https://www.libsdl.org/release/
-REVISION=      0
 
-SHARED_LIBS=   SDL2            0.10    # 0.16
+SHARED_LIBS=   SDL2            0.11    # 0.18
 
 HOMEPAGE=      https://www.libsdl.org/
 
@@ -22,7 +21,7 @@ PERMIT_PACKAGE=       Yes
 
 WANTLIB+=      X11 Xcursor Xext Xfixes Xi Xinerama Xrandr Xrender Xss
 WANTLIB+=      Xxf86vm m pthread samplerate sndio usbhid xcb
-# GL and X11 libraries are dlopen'd by SDL
+# GL library is dlopen'd
 WANTLIB+=      GL
 
 LIB_DEPENDS=   audio/libsamplerate
Index: distinfo
===================================================================
RCS file: /cvs/ports/devel/sdl2/distinfo,v
retrieving revision 1.12
diff -u -p -r1.12 distinfo
--- distinfo    20 Aug 2021 16:59:32 -0000      1.12
+++ distinfo    12 Dec 2021 17:27:05 -0000
@@ -1,2 +1,2 @@
-SHA256 (SDL2-2.0.16.tar.gz) = Zb6f9gBANLWyzpkntaTbGBSTDxacSy2uCh5GlwdfKHs=
-SIZE (SDL2-2.0.16.tar.gz) = 7227262
+SHA256 (SDL2-2.0.18.tar.gz) = lNQM1z2/oQu26t+8KPNVmSuy1u9nYa2dQHTv+V7lcRw=
+SIZE (SDL2-2.0.18.tar.gz) = 7294032
Index: patches/patch-Makefile_in
===================================================================
RCS file: /cvs/ports/devel/sdl2/patches/patch-Makefile_in,v
retrieving revision 1.10
diff -u -p -r1.10 patch-Makefile_in
--- patches/patch-Makefile_in   20 Aug 2021 16:59:32 -0000      1.10
+++ patches/patch-Makefile_in   12 Dec 2021 17:27:05 -0000
@@ -3,7 +3,7 @@ $OpenBSD: patch-Makefile_in,v 1.10 2021/
 Index: Makefile.in
 --- Makefile.in.orig
 +++ Makefile.in
-@@ -132,7 +132,7 @@ LT_AGE      = @LT_AGE@
+@@ -133,7 +133,7 @@ LT_AGE      = @LT_AGE@
  LT_CURRENT  = @LT_CURRENT@
  LT_RELEASE  = @LT_RELEASE@
  LT_REVISION = @LT_REVISION@
Index: patches/patch-src_SDL_c
===================================================================
RCS file: /cvs/ports/devel/sdl2/patches/patch-src_SDL_c,v
retrieving revision 1.6
diff -u -p -r1.6 patch-src_SDL_c
--- patches/patch-src_SDL_c     20 Aug 2021 16:59:32 -0000      1.6
+++ patches/patch-src_SDL_c     12 Dec 2021 17:27:05 -0000
@@ -1,27 +1,17 @@
 $OpenBSD: patch-src_SDL_c,v 1.6 2021/08/20 16:59:32 thfr Exp $
 
 Disable breaking if no haptic feedback support which disallows gamecontroller 
API
-pretend to be Linux in SDL_GetPlatform to allow compatibility with FNA games
-until OpenBSD support has been rolled out (estimated end of 2018).
 
 Index: src/SDL.c
 --- src/SDL.c.orig
 +++ src/SDL.c
-@@ -280,8 +280,6 @@ SDL_InitSubSystem(Uint32 flags)
-             }
+@@ -279,9 +279,6 @@ SDL_InitSubSystem(Uint32 flags)
          }
-         SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
+         SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
+         flags_initialized |= SDL_INIT_GAMECONTROLLER;
 -#else
--        return SDL_SetError("SDL not built with haptic (force feedback) 
support");
+-        SDL_SetError("SDL not built with joystick support");
+-        goto quit_and_error;
  #endif
      }
  
-@@ -517,7 +515,7 @@ SDL_GetPlatform()
- #elif __NETBSD__
-     return "NetBSD";
- #elif __OPENBSD__
--    return "OpenBSD";
-+    return "Linux";
- #elif __OS2__
-     return "OS/2";
- #elif __OSF__
Index: patches/patch-src_audio_sndio_SDL_sndioaudio_c
===================================================================
RCS file: patches/patch-src_audio_sndio_SDL_sndioaudio_c
diff -N patches/patch-src_audio_sndio_SDL_sndioaudio_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_audio_sndio_SDL_sndioaudio_c      12 Dec 2021 17:27:05 
-0000
@@ -0,0 +1,30 @@
+$OpenBSD$
+
+fix assertion failure with SDL 2.0.18's new hotplugging support
+GH PR https://github.com/libsdl-org/SDL/pull/5094
+
+Index: src/audio/sndio/SDL_sndioaudio.c
+--- src/audio/sndio/SDL_sndioaudio.c.orig
++++ src/audio/sndio/SDL_sndioaudio.c
+@@ -350,6 +350,13 @@ SNDIO_Deinitialize(void)
+     UnloadSNDIOLibrary();
+ }
+ 
++static void
++SNDIO_DetectDevices(void)
++{
++      SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *) 
0x1);
++      SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *) 0x2);
++}
++
+ static int
+ SNDIO_Init(SDL_AudioDriverImpl * impl)
+ {
+@@ -366,6 +373,7 @@ SNDIO_Init(SDL_AudioDriverImpl * impl)
+     impl->CaptureFromDevice = SNDIO_CaptureFromDevice;
+     impl->FlushCapture = SNDIO_FlushCapture;
+     impl->Deinitialize = SNDIO_Deinitialize;
++    impl->DetectDevices = SNDIO_DetectDevices;
+ 
+     impl->AllowsArbitraryDeviceNames = 1;
+     impl->HasCaptureSupport = SDL_TRUE;
Index: patches/patch-src_joystick_SDL_gamecontrollerdb_h
===================================================================
RCS file: 
/cvs/ports/devel/sdl2/patches/patch-src_joystick_SDL_gamecontrollerdb_h,v
retrieving revision 1.2
diff -u -p -r1.2 patch-src_joystick_SDL_gamecontrollerdb_h
--- patches/patch-src_joystick_SDL_gamecontrollerdb_h   20 Aug 2021 16:59:32 
-0000      1.2
+++ patches/patch-src_joystick_SDL_gamecontrollerdb_h   12 Dec 2021 17:27:05 
-0000
@@ -15,7 +15,7 @@ Index: src/joystick/SDL_gamecontrollerdb
      "03000000c82d00000090000001000000,8BitDo FC30 
Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
      "03000000c82d00000090000001000000,8BitDo FC30 
Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
      "03000000c82d00001038000000010000,8BitDo FC30 
Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
-@@ -493,7 +493,7 @@ static const char *s_ControllerMappings [] =
+@@ -494,7 +494,7 @@ static const char *s_ControllerMappings [] =
      "03000000830500006020000000010000,iBuffalo SNES 
Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
      "03000000830500006020000000000000,iBuffalo USB 2-axis 8-button 
Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,",
  #endif
Index: patches/patch-src_joystick_bsd_SDL_bsdjoystick_c
===================================================================
RCS file: 
/cvs/ports/devel/sdl2/patches/patch-src_joystick_bsd_SDL_bsdjoystick_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-src_joystick_bsd_SDL_bsdjoystick_c
--- patches/patch-src_joystick_bsd_SDL_bsdjoystick_c    20 Aug 2021 16:59:32 
-0000      1.3
+++ patches/patch-src_joystick_bsd_SDL_bsdjoystick_c    12 Dec 2021 17:27:05 
-0000
@@ -53,7 +53,7 @@ Index: src/joystick/bsd/SDL_bsdjoystick.
 +    struct usb_device_info di;
 +#endif
  
-     fd = open(path, O_RDONLY);
+     fd = open(path, O_RDONLY | O_CLOEXEC);
      if (fd == -1) {
 @@ -434,6 +446,17 @@ BSD_JoystickOpen(SDL_Joystick *joy, int device_index)
      }
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/devel/sdl2/pkg/PLIST,v
retrieving revision 1.10
diff -u -p -r1.10 PLIST
--- pkg/PLIST   6 Jan 2021 22:32:08 -0000       1.10
+++ pkg/PLIST   12 Dec 2021 17:27:05 -0000
@@ -18,6 +18,7 @@ include/SDL2/SDL_filesystem.h
 include/SDL2/SDL_gamecontroller.h
 include/SDL2/SDL_gesture.h
 include/SDL2/SDL_haptic.h
+include/SDL2/SDL_hidapi.h
 include/SDL2/SDL_hints.h
 include/SDL2/SDL_joystick.h
 include/SDL2/SDL_keyboard.h
@@ -77,6 +78,7 @@ include/SDL2/SDL_video.h
 include/SDL2/SDL_vulkan.h
 include/SDL2/begin_code.h
 include/SDL2/close_code.h
+lib/cmake/
 lib/cmake/SDL2/
 lib/cmake/SDL2/sdl2-config-version.cmake
 lib/cmake/SDL2/sdl2-config.cmake
@@ -88,5 +90,6 @@ lib/libSDL2_test.la
 @static-lib lib/libSDL2main.a
 lib/libSDL2main.la
 lib/pkgconfig/sdl2.pc
+share/aclocal/
 share/aclocal/sdl2.m4
 share/doc/pkg-readmes/${PKGSTEM}

Reply via email to