mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	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:
		
							parent
							
								
									df3ea8dafa
								
							
						
					
					
						commit
						7b773433f4
					
				
					 3 changed files with 32 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,6 +53,8 @@ struct pw_manager_events {
 | 
			
		|||
	void (*metadata) (void *data, struct pw_manager_object *object,
 | 
			
		||||
			uint32_t subject, const char *key,
 | 
			
		||||
			const char *type, const char *value);
 | 
			
		||||
 | 
			
		||||
	void (*disconnect) (void *data);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct pw_manager {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,7 @@
 | 
			
		|||
 * DEALINGS IN THE SOFTWARE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "pipewire/core.h"
 | 
			
		||||
#define NAME "pulse-server"
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -835,6 +836,21 @@ static void manager_metadata(void *data, struct pw_manager_object *o,
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void do_free_client(void *obj, void *data, int res, uint32_t id)
 | 
			
		||||
{
 | 
			
		||||
	struct client *client = data;
 | 
			
		||||
	client_free(client);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void manager_disconnect(void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct client *client = data;
 | 
			
		||||
	pw_log_debug("manager_disconnect()");
 | 
			
		||||
	pw_work_queue_add(client->impl->work_queue, NULL, 0,
 | 
			
		||||
				do_free_client, client);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const struct pw_manager_events manager_events = {
 | 
			
		||||
	PW_VERSION_MANAGER_EVENTS,
 | 
			
		||||
	.sync = manager_sync,
 | 
			
		||||
| 
						 | 
				
			
			@ -842,6 +858,7 @@ static const struct pw_manager_events manager_events = {
 | 
			
		|||
	.updated = manager_updated,
 | 
			
		||||
	.removed = manager_removed,
 | 
			
		||||
	.metadata = manager_metadata,
 | 
			
		||||
	.disconnect = manager_disconnect
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int do_set_client_name(struct client *client, uint32_t command, uint32_t tag, struct message *m)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue