mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
media-session: add option to configure suspend timeout
Set the property on the node and use the value when suspending the node. a timeout of 0 disables suspend.
This commit is contained in:
parent
38e0ff55cd
commit
6079830591
4 changed files with 14 additions and 20 deletions
|
|
@ -101,11 +101,20 @@ static void add_idle_timeout(struct node *node)
|
|||
struct timespec value;
|
||||
struct impl *impl = node->impl;
|
||||
struct pw_loop *main_loop = pw_context_get_main_loop(impl->context);
|
||||
const char *str;
|
||||
|
||||
if (node->obj->info && node->obj->info->props &&
|
||||
(str = spa_dict_lookup(node->obj->info->props, "session.suspend-timeout-seconds")) != NULL)
|
||||
value.tv_sec = atoi(str);
|
||||
else
|
||||
value.tv_sec = DEFAULT_IDLE_SECONDS;
|
||||
|
||||
if (value.tv_sec == 0)
|
||||
return;
|
||||
|
||||
if (node->idle_timeout == NULL)
|
||||
node->idle_timeout = pw_loop_add_timer(main_loop, idle_timeout, node);
|
||||
|
||||
value.tv_sec = DEFAULT_IDLE_SECONDS;
|
||||
value.tv_nsec = 0;
|
||||
pw_loop_update_timer(main_loop, node->idle_timeout, &value, NULL, false);
|
||||
}
|
||||
|
|
@ -200,10 +209,8 @@ static void session_create(void *data, struct sm_object *object)
|
|||
else
|
||||
res = 0;
|
||||
|
||||
if (res < 0) {
|
||||
if (res < 0)
|
||||
pw_log_warn(NAME" %p: can't handle global %d", impl, object->id);
|
||||
} else
|
||||
sm_media_session_schedule_rescan(impl->session);
|
||||
}
|
||||
|
||||
static void session_remove(void *data, struct sm_object *object)
|
||||
|
|
@ -213,24 +220,9 @@ static void session_remove(void *data, struct sm_object *object)
|
|||
|
||||
if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) {
|
||||
struct node *node;
|
||||
|
||||
if ((node = sm_object_get_data(object, SESSION_KEY)) != NULL)
|
||||
destroy_node(impl, node);
|
||||
}
|
||||
|
||||
sm_media_session_schedule_rescan(impl->session);
|
||||
}
|
||||
|
||||
static void session_rescan(void *data, int seq)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
struct node *node;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &impl->now);
|
||||
pw_log_debug(NAME" %p: rescan", impl);
|
||||
|
||||
spa_list_for_each(node, &impl->node_list, link) {
|
||||
}
|
||||
}
|
||||
|
||||
static void session_destroy(void *data)
|
||||
|
|
@ -244,7 +236,6 @@ static const struct sm_media_session_events session_events = {
|
|||
SM_VERSION_MEDIA_SESSION_EVENTS,
|
||||
.create = session_create,
|
||||
.remove = session_remove,
|
||||
.rescan = session_rescan,
|
||||
.destroy = session_destroy,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue