SDL: pipewire: Don't assert if the default capture device is a sink or vice versa

From 9462eec57be74011fb3e602292c21a1bbf8ab9ec Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Tue, 30 Jan 2024 13:12:12 -0500
Subject: [PATCH] pipewire: Don't assert if the default capture device is a
 sink or vice versa

When no source devices are connected, the default source string can contain a sink name. If the default source and sink match, it will be caught as a sink device first and handled correctly, but if the default sink/source don't match, which happens when the sink is an HDMI output and the source is still an onboard audio chipset output name, an assert can result since the requested source device won't be flagged as a capture device. Rather than asserting, simply don't assign default devices that don't match the correct capabilities, as it's not an uncommon scenario and can be handled gracefully.

Additionally, if asserting is a no-op in release mode, sinks can be returned as sources and vice versa, which is incorrect.
 src/audio/pipewire/SDL_pipewire.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c
index 492b0e493dfb..9941f17d1a43 100644
--- a/src/audio/pipewire/SDL_pipewire.c
+++ b/src/audio/pipewire/SDL_pipewire.c
@@ -826,11 +826,13 @@ static void PIPEWIRE_DetectDevices(SDL_AudioDevice **default_output, SDL_AudioDe
     spa_list_for_each (io, &hotplug_io_list, link) {
         SDL_AudioDevice *device = SDL_AddAudioDevice(io->is_capture, io->name, &io->spec, PW_ID_TO_HANDLE(io->id));
         if (pipewire_default_sink_id && SDL_strcmp(io->path, pipewire_default_sink_id) == 0) {
-            SDL_assert(!io->is_capture);
-            *default_output = device;
+            if (!io->is_capture) {
+                *default_output = device;
+            }
         } else if (pipewire_default_source_id && SDL_strcmp(io->path, pipewire_default_source_id) == 0) {
-            SDL_assert(io->is_capture);
-            *default_capture = device;
+            if (io->is_capture) {
+                *default_capture = device;
+            }