mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: implement OBJECT_LINGER
Use OBJECT_LINGER in module-load to make sure the module stays loaded after the client disconnects. Implement linger in adapter and node-factory
This commit is contained in:
parent
0fe77d39ce
commit
1934df7307
3 changed files with 15 additions and 3 deletions
|
|
@ -63,6 +63,7 @@ struct node_data {
|
|||
struct pw_impl_node *node;
|
||||
struct spa_hook node_listener;
|
||||
struct spa_hook resource_listener;
|
||||
unsigned int linger:1;
|
||||
};
|
||||
|
||||
static void resource_destroy(void *data)
|
||||
|
|
@ -70,7 +71,7 @@ static void resource_destroy(void *data)
|
|||
struct node_data *nd = data;
|
||||
pw_log_debug("node %p", nd);
|
||||
spa_hook_remove(&nd->resource_listener);
|
||||
if (nd->node)
|
||||
if (nd->node && !nd->linger)
|
||||
pw_impl_node_destroy(nd->node);
|
||||
}
|
||||
|
||||
|
|
@ -103,10 +104,11 @@ static void *create_object(void *_data,
|
|||
struct factory_data *data = _data;
|
||||
struct pw_context *context = data->context;
|
||||
struct pw_impl_node *node;
|
||||
const char *factory_name;
|
||||
const char *factory_name, *str;
|
||||
struct node_data *nd;
|
||||
int res;
|
||||
struct pw_impl_client *client;
|
||||
bool linger;
|
||||
|
||||
if (properties == NULL)
|
||||
goto error_properties;
|
||||
|
|
@ -124,6 +126,8 @@ static void *create_object(void *_data,
|
|||
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d",
|
||||
pw_global_get_id(pw_impl_client_get_global(client)));
|
||||
}
|
||||
str = pw_properties_get(properties, PW_KEY_OBJECT_LINGER);
|
||||
linger = str ? pw_properties_parse_bool(str) : false;
|
||||
|
||||
node = pw_spa_node_load(context,
|
||||
factory_name,
|
||||
|
|
@ -136,6 +140,7 @@ static void *create_object(void *_data,
|
|||
nd = pw_spa_node_get_user_data(node);
|
||||
nd->data = data;
|
||||
nd->node = node;
|
||||
nd->linger = linger;
|
||||
spa_list_append(&data->node_list, &nd->link);
|
||||
|
||||
pw_impl_node_add_listener(node, &nd->node_listener, &node_events, nd);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue