jack: lock for accessing the globals

This commit is contained in:
Wim Taymans 2020-09-22 13:10:58 +02:00
parent 3f844f7b09
commit 136f556d79

View file

@ -2012,7 +2012,9 @@ static int metadata_property(void *object, uint32_t id,
if (key == NULL || strcmp(key, "default.audio.source") == 0) if (key == NULL || strcmp(key, "default.audio.source") == 0)
c->metadata->default_audio_source = val; c->metadata->default_audio_source = val;
} else { } else {
pthread_mutex_lock(&c->context.lock);
o = pw_map_lookup(&c->context.globals, id); o = pw_map_lookup(&c->context.globals, id);
pthread_mutex_unlock(&c->context.lock);
if (o == NULL) if (o == NULL)
return -EINVAL; return -EINVAL;
@ -2148,9 +2150,9 @@ static void registry_event_global(void *data, uint32_t id,
pthread_mutex_lock(&c->context.lock); pthread_mutex_lock(&c->context.lock);
spa_list_append(&c->context.ports, &o->link); spa_list_append(&c->context.ports, &o->link);
ot = pw_map_lookup(&c->context.globals, node_id);
pthread_mutex_unlock(&c->context.lock); pthread_mutex_unlock(&c->context.lock);
ot = pw_map_lookup(&c->context.globals, node_id);
if (ot == NULL || ot->type != INTERFACE_Node) if (ot == NULL || ot->type != INTERFACE_Node)
goto exit_free; goto exit_free;
@ -2274,7 +2276,9 @@ static void registry_event_global_remove(void *object, uint32_t id)
c->metadata->default_audio_source = SPA_ID_INVALID; c->metadata->default_audio_source = SPA_ID_INVALID;
} }
pthread_mutex_lock(&c->context.lock);
o = pw_map_lookup(&c->context.globals, id); o = pw_map_lookup(&c->context.globals, id);
pthread_mutex_unlock(&c->context.lock);
if (o == NULL) if (o == NULL)
return; return;