mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: delay flushing messages
Delay flush of messages to better match pulseaudio. We can later also filter duplicates and redundant events.
This commit is contained in:
parent
55bd34c9e7
commit
0fada77433
1 changed files with 17 additions and 21 deletions
|
|
@ -324,6 +324,8 @@ static int flush_messages(struct client *client)
|
||||||
data = m->data + idx;
|
data = m->data + idx;
|
||||||
size = m->length - idx;
|
size = m->length - idx;
|
||||||
} else {
|
} else {
|
||||||
|
if (debug_messages)
|
||||||
|
message_dump(m);
|
||||||
message_free(client, m, true, false);
|
message_free(client, m, true, false);
|
||||||
client->out_index = 0;
|
client->out_index = 0;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -348,7 +350,7 @@ static int flush_messages(struct client *client)
|
||||||
static int send_message(struct client *client, struct message *m)
|
static int send_message(struct client *client, struct message *m)
|
||||||
{
|
{
|
||||||
struct impl *impl = client->impl;
|
struct impl *impl = client->impl;
|
||||||
int res;
|
int res, mask;
|
||||||
|
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -364,19 +366,13 @@ static int send_message(struct client *client, struct message *m)
|
||||||
m->offset = 0;
|
m->offset = 0;
|
||||||
spa_list_append(&client->out_messages, &m->link);
|
spa_list_append(&client->out_messages, &m->link);
|
||||||
|
|
||||||
if (debug_messages)
|
mask = client->source->mask;
|
||||||
message_dump(m);
|
if (!SPA_FLAG_IS_SET(mask, SPA_IO_OUT)) {
|
||||||
|
|
||||||
res = flush_messages(client);
|
|
||||||
if (res == -EAGAIN) {
|
|
||||||
int mask = client->source->mask;
|
|
||||||
SPA_FLAG_SET(mask, SPA_IO_OUT);
|
SPA_FLAG_SET(mask, SPA_IO_OUT);
|
||||||
pw_loop_update_io(impl->loop, client->source, mask);
|
pw_loop_update_io(impl->loop, client->source, mask);
|
||||||
res = 0;
|
|
||||||
}
|
}
|
||||||
return res;
|
return 0;
|
||||||
error:
|
error:
|
||||||
if (m)
|
|
||||||
message_free(client, m, false, false);
|
message_free(client, m, false, false);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -4750,16 +4746,6 @@ on_client_data(void *data, int fd, uint32_t mask)
|
||||||
res = -EIO;
|
res = -EIO;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (mask & SPA_IO_OUT) {
|
|
||||||
pw_log_trace(NAME" %p: can write", impl);
|
|
||||||
res = flush_messages(client);
|
|
||||||
if (res >= 0) {
|
|
||||||
int mask = client->source->mask;
|
|
||||||
SPA_FLAG_CLEAR(mask, SPA_IO_OUT);
|
|
||||||
pw_loop_update_io(impl->loop, client->source, mask);
|
|
||||||
} else if (res != -EAGAIN)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (mask & SPA_IO_IN) {
|
if (mask & SPA_IO_IN) {
|
||||||
pw_log_trace(NAME" %p: can read", impl);
|
pw_log_trace(NAME" %p: can read", impl);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
@ -4771,6 +4757,16 @@ on_client_data(void *data, int fd, uint32_t mask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mask & SPA_IO_OUT) {
|
||||||
|
pw_log_trace(NAME" %p: can write", impl);
|
||||||
|
res = flush_messages(client);
|
||||||
|
if (res >= 0) {
|
||||||
|
int mask = client->source->mask;
|
||||||
|
SPA_FLAG_CLEAR(mask, SPA_IO_OUT);
|
||||||
|
pw_loop_update_io(impl->loop, client->source, mask);
|
||||||
|
} else if (res != -EAGAIN)
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue