media-session: rework device reservation

Monitor the device reservation objects and mark the device available.
Don't select nodes from devices that are not available.
Acquire the device reservation when a device starts.
Release the device reservation when we suspend the device again.
This commit is contained in:
Wim Taymans 2020-02-19 18:15:57 +01:00
parent 11086f23ea
commit d3634aca7e
6 changed files with 188 additions and 59 deletions

View file

@ -334,6 +334,7 @@ static int find_node(void *data, struct node *node)
struct impl *impl = find->impl;
int priority = 0;
uint64_t plugged = 0;
struct sm_device *device = node->obj->device;
pw_log_debug(NAME " %p: looking at node '%d' enabled:%d state:%d peer:%p exclusive:%d",
impl, node->id, node->enabled, node->obj->info->state, node->peer, node->exclusive);
@ -341,6 +342,11 @@ static int find_node(void *data, struct node *node)
if (!node->enabled || node->type == NODE_TYPE_UNKNOWN)
return 0;
if (device && device->locked) {
pw_log_debug(".. device locked");
return 0;
}
if (node->direction == find->target->direction) {
pw_log_debug(".. same direction");
return 0;