Skip to content

Commit aeb223f

Browse files
committed
pipewire: if no devices seen in "preferred" init, try a different backend.
We're seeing people with legit PipeWire installs that don't export any devices, that are also running a (not emulated) PulseAudio install that works. This solution might still get tweaked some more, but it seems to be working so far.
1 parent fafc9f6 commit aeb223f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/audio/pipewire/SDL_pipewire.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,28 @@ static SDL_bool PipewireInitialize(SDL_AudioDriverImpl *impl, SDL_bool check_pre
13261326

13271327
static SDL_bool PIPEWIRE_PREFERRED_Init(SDL_AudioDriverImpl *impl)
13281328
{
1329-
return PipewireInitialize(impl, SDL_TRUE);
1329+
if (!PipewireInitialize(impl, SDL_TRUE)) {
1330+
return SDL_FALSE;
1331+
}
1332+
1333+
// run device detection but don't add any devices to SDL; we're just waiting to see if PipeWire sees any devices. If not, fall back to the next backend.
1334+
PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
1335+
1336+
// Wait until the initial registry enumeration is complete
1337+
if (!hotplug_init_complete) {
1338+
PIPEWIRE_pw_thread_loop_wait(hotplug_loop);
1339+
}
1340+
1341+
const int no_devices = spa_list_is_empty(&hotplug_io_list);
1342+
1343+
PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
1344+
1345+
if (no_devices) {
1346+
PIPEWIRE_Deinitialize();
1347+
return SDL_FALSE;
1348+
}
1349+
1350+
return SDL_TRUE; // this will move on to PIPEWIRE_DetectDevices and reuse hotplug_io_list.
13301351
}
13311352

13321353
static SDL_bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl)

0 commit comments

Comments
 (0)