diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2022-10-10 23:52:55 +0200 |
---|---|---|
committer | Philip Langdale <github.philipl@overt.org> | 2022-10-24 11:09:34 -0700 |
commit | b9a9e0a6f1c9995b2100d3b68d58f91bb0fc0b51 (patch) | |
tree | 8565cc67a7fee9953efd404016f4c39058f1ed22 | |
parent | e4505ce74443b0ce1b137aadb2d71ec594c902f1 (diff) | |
download | mpv-b9a9e0a6f1c9995b2100d3b68d58f91bb0fc0b51.tar.bz2 mpv-b9a9e0a6f1c9995b2100d3b68d58f91bb0fc0b51.tar.xz |
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
-rw-r--r-- | audio/out/ao_pipewire.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/audio/out/ao_pipewire.c b/audio/out/ao_pipewire.c index d4e71c9c2b..6628cd4b48 100644 --- a/audio/out/ao_pipewire.c +++ b/audio/out/ao_pipewire.c @@ -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: |