Browse Source

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.
Frank Praznik 1 year ago
parent
commit
9462eec57b
1 changed files with 6 additions and 4 deletions
  1. 6 4
      src/audio/pipewire/SDL_pipewire.c

+ 6 - 4
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;
+            }
         }
     }