From f36eeaf4e8bc937928b36bf7067976c30e83dfb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 29 Aug 2022 21:08:43 +0200 Subject: ao_pipewire: use proper hotplug init APIs --- audio/out/ao_pipewire.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_pipewire.c b/audio/out/ao_pipewire.c index c94d411262..8fba681030 100644 --- a/audio/out/ao_pipewire.c +++ b/audio/out/ao_pipewire.c @@ -646,19 +646,22 @@ static void add_device_to_list(struct ao *ao, uint32_t id, const struct spa_dict ao_device_list_add(list, ao, &(struct ao_device_desc){name, description}); } -static void list_devs(struct ao *ao, struct ao_device_list *list) +static int hotplug_init(struct ao *ao) { - // we are not using hotplug_{,un}init() because the AO core will only call - // the hotplug functions of a single AO. That will probably be ao_pulse. - if (pipewire_init_boilerplate(ao) < 0) - return; + return pipewire_init_boilerplate(ao); +} + +static void hotplug_uninit(struct ao *ao) +{ + uninit(ao); +} +static void list_devs(struct ao *ao, struct ao_device_list *list) +{ ao_device_list_add(list, ao, &(struct ao_device_desc){}); if (for_each_sink(ao, add_device_to_list, list) < 0) MP_WARN(ao, "Could not list devices, list may be incomplete\n"); - - uninit(ao); } #define OPT_BASE_STRUCT struct priv @@ -674,7 +677,9 @@ const struct ao_driver audio_out_pipewire = { .control = control, - .list_devs = list_devs, + .hotplug_init = hotplug_init, + .hotplug_uninit = hotplug_uninit, + .list_devs = list_devs, .priv_size = sizeof(struct priv), .priv_defaults = &(const struct priv) -- cgit v1.2.3