diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2022-09-27 21:13:45 +0200 |
---|---|---|
committer | Philip Langdale <github.philipl@overt.org> | 2022-09-28 15:53:05 -0700 |
commit | 5e49c09f2ea2bcf6d993abf0fe839d5d7e0cad15 (patch) | |
tree | f8e6ade2013cf88aed82999675d3ecf1ca5016b9 /audio | |
parent | eba4ce5c2d103cb79c2bf7491e5de9a65190e7c2 (diff) | |
download | mpv-5e49c09f2ea2bcf6d993abf0fe839d5d7e0cad15.tar.bz2 mpv-5e49c09f2ea2bcf6d993abf0fe839d5d7e0cad15.tar.xz |
ao_pipewire: use target.object
Specifying the id of the target node during stream connect is
deprecated. Instead the property target.object should be used to link
by target serial or name. Using the name allows us to drop a bunch of
custom code.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/out/ao_pipewire.c | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/audio/out/ao_pipewire.c b/audio/out/ao_pipewire.c index 58868dfc0c..2563ddda30 100644 --- a/audio/out/ao_pipewire.c +++ b/audio/out/ao_pipewire.c @@ -380,35 +380,6 @@ unlock_loop: return ret; } - -static void get_target_id_cb(struct ao *ao, uint32_t id, const struct spa_dict *props, void *ctx) -{ - int32_t *target_id = ctx; - - const char *name = spa_dict_lookup(props, PW_KEY_NODE_NAME); - if (!name) - return; - - if (strcmp(name, ao->device) == 0) { - *target_id = id; - } -} - -static uint32_t get_target_id(struct ao *ao) -{ - uint32_t target_id = 0; - - if (ao->device == NULL) - return PW_ID_ANY; - - if (for_each_sink(ao, get_target_id_cb, &target_id) < 0 && target_id == 0) { - MP_WARN(ao, "Could not iterate devices to find target, using default device\n"); - return PW_ID_ANY; - } - - return target_id; -} - static int pipewire_init_boilerplate(struct ao *ao) { struct priv *p = ao->priv; @@ -461,6 +432,7 @@ static int init(struct ao *ao) PW_KEY_APP_ID, ao->client_name, PW_KEY_APP_ICON_NAME, ao->client_name, PW_KEY_NODE_ALWAYS_PROCESS, "true", + PW_KEY_TARGET_OBJECT, ao->device, NULL ); @@ -514,17 +486,8 @@ static int init(struct ao *ao) &p->stream_listener, &stream_events, ao); - pw_thread_loop_unlock(p->loop); - - uint32_t target_id = get_target_id(ao); - if (target_id == 0) - goto error; - - pw_thread_loop_lock(p->loop); - if (pw_stream_connect(p->stream, - PW_DIRECTION_OUTPUT, - target_id, + PW_DIRECTION_OUTPUT, PW_ID_ANY, PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_INACTIVE | PW_STREAM_FLAG_MAP_BUFFERS | |