1
Fork 0

pulse-server: remove pending_streams list

We can simply use the pending flag and merge the handling of the new
stream with the stream move logic.
This commit is contained in:
Wim Taymans 2023-09-14 12:08:48 +02:00
parent 35cca08d2b
commit 846e732458
5 changed files with 23 additions and 30 deletions

View File

@ -46,7 +46,6 @@ struct client *client_new(struct server *server)
spa_list_init(&client->out_messages);
spa_list_init(&client->operations);
spa_list_init(&client->pending_samples);
spa_list_init(&client->pending_streams);
spa_hook_list_init(&client->listener_list);
spa_list_append(&server->clients, &client->link);

View File

@ -74,8 +74,6 @@ struct client {
struct spa_list pending_samples;
struct spa_list pending_streams;
unsigned int disconnect:1;
unsigned int new_msg_since_last_flush:1;
unsigned int authenticated:1;

View File

@ -832,42 +832,43 @@ static void manager_added(void *data, struct pw_manager_object *o)
}
if (spa_streq(o->type, PW_TYPE_INTERFACE_Link)) {
struct stream *s, *t;
struct pw_manager_object *peer = NULL;
union pw_map_item *item;
pw_array_for_each(item, &client->streams.items) {
struct stream *s = item->data;
const char *peer_name;
if (pw_map_item_is_free(item) || s->pending)
if (pw_map_item_is_free(item))
continue;
if (s->peer_index == SPA_ID_INVALID)
if (!s->pending && s->peer_index == SPA_ID_INVALID)
continue;
peer = find_peer_for_link(manager, o, s->id, s->direction);
if (peer == NULL || peer->props == NULL ||
peer->index == s->peer_index)
if (peer == NULL)
continue;
s->peer_index = peer->index;
peer_name = pw_properties_get(peer->props, PW_KEY_NODE_NAME);
if (peer_name && s->direction == PW_DIRECTION_INPUT &&
pw_manager_object_is_monitor(peer)) {
int len = strlen(peer_name) + 10;
char *tmp = alloca(len);
snprintf(tmp, len, "%s.monitor", peer_name);
peer_name = tmp;
}
if (peer_name != NULL)
stream_send_moved(s, peer->index, peer_name);
}
spa_list_for_each_safe(s, t, &client->pending_streams, link) {
peer = find_peer_for_link(manager, o, s->id, s->direction);
if (peer) {
if (s->pending) {
reply_create_stream(s, peer);
spa_list_remove(&s->link);
s->pending = false;
} else {
if (s->peer_index == peer->index)
continue;
if (peer->props == NULL)
continue;
s->peer_index = peer->index;
peer_name = pw_properties_get(peer->props, PW_KEY_NODE_NAME);
if (peer_name && s->direction == PW_DIRECTION_INPUT &&
pw_manager_object_is_monitor(peer)) {
int len = strlen(peer_name) + 10;
char *tmp = alloca(len);
snprintf(tmp, len, "%s.monitor", peer_name);
peer_name = tmp;
}
if (peer_name != NULL)
stream_send_moved(s, peer->index, peer_name);
}
}
}
@ -1244,7 +1245,6 @@ static void stream_param_changed(void *data, uint32_t id, const struct spa_pod *
if (peer) {
reply_create_stream(stream, peer);
} else {
spa_list_append(&stream->client->pending_streams, &stream->link);
stream->pending = true;
}
}

View File

@ -103,9 +103,6 @@ void stream_free(struct stream *stream)
pw_log_debug("client %p: stream %p channel:%d", client, stream, stream->channel);
if (stream->pending)
spa_list_remove(&stream->link);
if (stream->drain_tag)
reply_error(client, -1, stream->drain_tag, -ENOENT);

View File

@ -34,7 +34,6 @@ enum stream_type {
};
struct stream {
struct spa_list link;
uint32_t create_tag;
uint32_t channel; /* index in map */
uint32_t id; /* id of global */