pipewire-pulse: add manager disconnect event

Drop client connections when pipewire goes away. pipewire-pulse daemon can remain running and pulseaudio clients will be able to connect again once pipewire is up and running.
This commit is contained in:
Nicolai Syvertsen 2021-11-10 13:46:29 +01:00 committed by Wim Taymans
parent df3ea8dafa
commit 7b773433f4
3 changed files with 32 additions and 0 deletions

View file

@ -31,6 +31,7 @@
#include <pipewire/extensions/metadata.h>
#include "log.h"
#include "module-protocol-pulse/server.h"
#define MAX_PARAMS 32
@ -39,6 +40,7 @@
#define manager_emit_updated(m,o) spa_hook_list_call(&m->hooks, struct pw_manager_events, updated, 0, o)
#define manager_emit_removed(m,o) spa_hook_list_call(&m->hooks, struct pw_manager_events, removed, 0, o)
#define manager_emit_metadata(m,o,s,k,t,v) spa_hook_list_call(&m->hooks, struct pw_manager_events, metadata,0,o,s,k,t,v)
#define manager_emit_disconnect(m) spa_hook_list_call(&m->hooks, struct pw_manager_events, disconnect, 0)
struct object;
@ -688,10 +690,21 @@ static void on_core_done(void *data, uint32_t id, int seq)
}
}
static void on_core_error(void *data, uint32_t id, int seq, int res, const char *message)
{
struct manager *m = data;
if (id == PW_ID_CORE) {
pw_log_debug("connection error: %d, %s", res, message);
manager_emit_disconnect(m);
}
}
static const struct pw_core_events core_events = {
PW_VERSION_CORE_EVENTS,
.done = on_core_done,
.info = on_core_info,
.error = on_core_error
};
struct pw_manager *pw_manager_new(struct pw_core *core)