mirror of
https://github.com/mpv-player/mpv
synced 2025-01-15 19:42:53 +00:00
ao_pipewire: test for session to contain audio sinks
The pure presence of PipeWire does not mean that it is actually driving the audio session. For example it could only be meant for video. Currently there is no proper API to detect this (see [0]), so we check for the presence of audio sinks. As soon as a proper API exists, we should use that. [0] https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1835
This commit is contained in:
parent
e4505ce744
commit
b9a9e0a6f1
@ -384,6 +384,22 @@ unlock_loop:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void have_sink(struct ao *ao, uint32_t id, const struct spa_dict *props, void *ctx)
|
||||
{
|
||||
bool *b = ctx;
|
||||
*b = true;
|
||||
}
|
||||
|
||||
static bool session_has_sinks(struct ao *ao)
|
||||
{
|
||||
bool b = false;
|
||||
|
||||
if (for_each_sink(ao, have_sink, &b) < 0)
|
||||
MP_WARN(ao, "Could not list devices, sink detection may be wrong\n");
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
static int pipewire_init_boilerplate(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
@ -416,6 +432,12 @@ static int pipewire_init_boilerplate(struct ao *ao)
|
||||
}
|
||||
|
||||
pw_thread_loop_unlock(p->loop);
|
||||
|
||||
if (!session_has_sinks(ao)) {
|
||||
MP_VERBOSE(ao, "PipeWire does not have any audio sinks, skipping\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
Loading…
Reference in New Issue
Block a user