SDL: Merge commit 'a5f3ea14487f1a36b1d421d02e86f25704f8bdc8' into main

From a5f3ea14487f1a36b1d421d02e86f25704f8bdc8 Mon Sep 17 00:00:00 2001
From: nia <[EMAIL REDACTED]>
Date: Wed, 10 Mar 2021 09:36:46 +0100
Subject: [PATCH] netbsdaudio: Handle ioctls failing

A user reported that the mpv video player hangs after attempting to
set an unsupported number of channels with the SDL audio output,
because it thinks it's successfully opened the device. This makes
the failure graceful.
---
 src/audio/netbsd/SDL_netbsdaudio.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c
index 6abf253d1..32817abf4 100644
--- a/src/audio/netbsd/SDL_netbsdaudio.c
+++ b/src/audio/netbsd/SDL_netbsdaudio.c
@@ -295,9 +295,13 @@ NETBSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
 
     info.hiwat = 5;
     info.lowat = 3;
-    (void) ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info);
+    if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) < 0) {
+        return SDL_SetError("AUDIO_SETINFO failed for %s: %s", devname, strerror(errno));
+    }
 
-    (void) ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info);
+    if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 0) {
+        return SDL_SetError("AUDIO_GETINFO failed for %s: %s", devname, strerror(errno));
+    }
 
     /* Final spec used for the device. */
     this->spec.format = format;