mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-08 13:30:08 -05:00
stream: add capture queued time calculation
Take the size of a newly captured buffer as the difference between previous and current tick and use this to calculate the queued size.
This commit is contained in:
parent
b67fb6fa5b
commit
892b57c55d
2 changed files with 18 additions and 7 deletions
|
|
@ -657,9 +657,12 @@ static int impl_node_process_input(struct spa_node *node)
|
||||||
struct pw_stream *stream = &impl->this;
|
struct pw_stream *stream = &impl->this;
|
||||||
struct spa_io_buffers *io = impl->io;
|
struct spa_io_buffers *io = impl->io;
|
||||||
struct buffer *b;
|
struct buffer *b;
|
||||||
|
uint64_t size;
|
||||||
|
|
||||||
pw_log_trace("stream %p: process in %d %d %"PRIu64" %"PRIi64, stream,
|
size = impl->time.ticks - impl->dequeued.incount;
|
||||||
io->status, io->buffer_id, impl->time.ticks, impl->time.delay);
|
|
||||||
|
pw_log_trace("stream %p: process in %d %d %"PRIu64" %"PRIi64" %"PRIu64, stream,
|
||||||
|
io->status, io->buffer_id, impl->time.ticks, impl->time.delay, size);
|
||||||
|
|
||||||
if (io->status != SPA_STATUS_HAVE_BUFFER)
|
if (io->status != SPA_STATUS_HAVE_BUFFER)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -667,6 +670,8 @@ static int impl_node_process_input(struct spa_node *node)
|
||||||
if ((b = get_buffer(stream, io->buffer_id)) == NULL)
|
if ((b = get_buffer(stream, io->buffer_id)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
b->this.size = size;
|
||||||
|
|
||||||
/* push new buffer */
|
/* push new buffer */
|
||||||
if (push_queue(impl, &impl->dequeued, b) == 0)
|
if (push_queue(impl, &impl->dequeued, b) == 0)
|
||||||
call_process(impl);
|
call_process(impl);
|
||||||
|
|
@ -1138,9 +1143,11 @@ int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
|
||||||
} while (impl->seq1 != seq);
|
} while (impl->seq1 != seq);
|
||||||
|
|
||||||
if (impl->direction == SPA_DIRECTION_INPUT)
|
if (impl->direction == SPA_DIRECTION_INPUT)
|
||||||
time->queued = time->queued - impl->dequeued.outcount;
|
time->queued = (int64_t)(time->queued - impl->dequeued.outcount);
|
||||||
else
|
else
|
||||||
time->queued = impl->queued.incount - time->queued;
|
time->queued = (int64_t)(impl->queued.incount - time->queued);
|
||||||
|
|
||||||
|
pw_log_trace("%ld %d/%d %ld", time->ticks, time->rate.num, time->rate.denom, time->queued);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -164,9 +164,13 @@ enum pw_stream_state {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pw_buffer {
|
struct pw_buffer {
|
||||||
struct spa_buffer *buffer; /* the spa buffer */
|
struct spa_buffer *buffer; /**< the spa buffer */
|
||||||
void *user_data; /* user data attached to the buffer */
|
void *user_data; /**< user data attached to the buffer */
|
||||||
uint64_t size; /* size to keep track of queued size */
|
uint64_t size; /**< For input streams, this field is set by pw_stream
|
||||||
|
* with the duration of the buffer in ticks.
|
||||||
|
* For output streams, this field is set by the user.
|
||||||
|
* This field is added for all queued buffers and
|
||||||
|
* returned in the time info. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Events for a stream */
|
/** Events for a stream */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue