mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
pulse-server: simplify latency handling
We don't need to use the minreq field. The fragsize is only updated when adjust_latency is used.
This commit is contained in:
parent
ad214dde2e
commit
9c34a923db
1 changed files with 8 additions and 10 deletions
|
|
@ -669,14 +669,12 @@ static uint32_t fix_record_buffer_attr(struct stream *s, struct buffer_attr *att
|
||||||
attr->fragsize = SPA_MAX(attr->fragsize, minfrag);
|
attr->fragsize = SPA_MAX(attr->fragsize, minfrag);
|
||||||
|
|
||||||
/* pulseaudio configures the source to half of the fragsize. It also
|
/* pulseaudio configures the source to half of the fragsize. It also
|
||||||
* immediately sends chunks to clients. We use the minreq field to
|
* immediately sends chunks to clients. Configure a 2/3 of the fragsize
|
||||||
* keep this info and use it to configure half the fragsize latency */
|
* as the latency. */
|
||||||
attr->minreq = attr->fragsize * 2 / 3;
|
latency = attr->fragsize * 2 / 3;
|
||||||
attr->minreq = SPA_ROUND_UP(attr->minreq, frame_size);
|
|
||||||
latency = attr->minreq;
|
|
||||||
|
|
||||||
if (s->adjust_latency)
|
if (s->adjust_latency)
|
||||||
attr->fragsize = latency;
|
attr->fragsize = SPA_ROUND_UP(latency, frame_size);
|
||||||
|
|
||||||
attr->tlength = attr->prebuf = 0;
|
attr->tlength = attr->prebuf = 0;
|
||||||
|
|
||||||
|
|
@ -1327,18 +1325,18 @@ do_process_done(struct spa_loop *loop,
|
||||||
stream, client->name, index, avail);
|
stream, client->name, index, avail);
|
||||||
} else {
|
} else {
|
||||||
if ((uint32_t)avail > stream->attr.maxlength) {
|
if ((uint32_t)avail > stream->attr.maxlength) {
|
||||||
uint32_t skip = avail - stream->attr.minreq;
|
uint32_t skip = avail - stream->attr.fragsize;
|
||||||
/* overrun, catch up to latest fragment and send it */
|
/* overrun, catch up to latest fragment and send it */
|
||||||
pw_log_warn("%p: [%s] overrun recover read:%u avail:%d max:%u skip:%u",
|
pw_log_warn("%p: [%s] overrun recover read:%u avail:%d max:%u skip:%u",
|
||||||
stream, client->name, index, avail, stream->attr.maxlength, skip);
|
stream, client->name, index, avail, stream->attr.maxlength, skip);
|
||||||
index += skip;
|
index += skip;
|
||||||
stream->read_index += skip;
|
stream->read_index += skip;
|
||||||
avail = stream->attr.minreq;
|
avail = stream->attr.fragsize;
|
||||||
}
|
}
|
||||||
pw_log_trace("avail:%d index:%u", avail, index);
|
pw_log_trace("avail:%d index:%u", avail, index);
|
||||||
|
|
||||||
while ((uint32_t)avail >= stream->attr.minreq) {
|
while ((uint32_t)avail >= stream->attr.fragsize) {
|
||||||
towrite = SPA_MIN((uint32_t)avail, stream->attr.minreq);
|
towrite = SPA_MIN((uint32_t)avail, stream->attr.fragsize);
|
||||||
|
|
||||||
msg = message_alloc(impl, stream->channel, towrite);
|
msg = message_alloc(impl, stream->channel, towrite);
|
||||||
if (msg == NULL)
|
if (msg == NULL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue