pulse-server: connect in the set_client_name

connect after we get the client_name call so that we have all
the client properties.
This commit is contained in:
Wim Taymans 2020-10-09 16:44:55 +02:00
parent 391fa81fa8
commit 8f953dfdde

View file

@ -438,8 +438,16 @@ static int do_set_client_name(struct client *client, uint32_t command, uint32_t
return res; return res;
changed++; changed++;
} }
if (changed) if (client->core == NULL) {
client->core = pw_context_connect(impl->context,
pw_properties_copy(client->props), 0);
if (client->core == NULL) {
res = -errno;
goto error;
}
} else {
pw_core_update_properties(client->core, &client->props->dict); pw_core_update_properties(client->core, &client->props->dict);
}
pw_log_info(NAME" %p: SET_CLIENT_NAME %s", impl, pw_log_info(NAME" %p: SET_CLIENT_NAME %s", impl,
pw_properties_get(client->props, "application.name")); pw_properties_get(client->props, "application.name"));
@ -452,6 +460,10 @@ static int do_set_client_name(struct client *client, uint32_t command, uint32_t
TAG_INVALID); TAG_INVALID);
} }
return send_message(client, reply); return send_message(client, reply);
error:
pw_log_error(NAME" %p: failed to connect client: %m", impl);
return res;
} }
static int do_subscribe(struct client *client, uint32_t command, uint32_t tag, struct message *m) static int do_subscribe(struct client *client, uint32_t command, uint32_t tag, struct message *m)
@ -2538,10 +2550,6 @@ static int do_read(struct client *client)
res = -EPROTO; res = -EPROTO;
goto exit; goto exit;
} }
} else {
} }
if (client->message) if (client->message)
message_free(client, client->message, false); message_free(client, client->message, false);
@ -2600,6 +2608,7 @@ error:
else else
pw_log_error(NAME" %p: client %p error %d (%s)", impl, pw_log_error(NAME" %p: client %p error %d (%s)", impl,
client, res, spa_strerror(res)); client, res, spa_strerror(res));
reply_error(client, -1, ERR_PROTOCOL);
client_free(client); client_free(client);
} }
@ -2644,11 +2653,6 @@ on_connect(void *data, int fd, uint32_t mask)
if (client->source == NULL) if (client->source == NULL)
goto error; goto error;
client->core = pw_context_connect(impl->context,
pw_properties_copy(client->props), 0);
if (client->core == NULL)
goto error;
return; return;
error: error:
pw_log_error(NAME" %p: failed to create client: %m", impl); pw_log_error(NAME" %p: failed to create client: %m", impl);