mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
stream: improve the input process loop
Only try to reuse a buffer when the io area is not already in the NEED_DATA state or else we might overwrite a previous buffer reuse and run out of buffers. We also always need more input.
This commit is contained in:
parent
1cccaaa2bd
commit
9dc1c3b168
1 changed files with 16 additions and 21 deletions
|
|
@ -747,28 +747,23 @@ static int impl_node_process_input(void *object)
|
|||
pw_log_trace(NAME" %p: process in status:%d id:%d ticks:%"PRIu64" delay:%"PRIi64,
|
||||
stream, io->status, io->buffer_id, impl->time.ticks, impl->time.delay);
|
||||
|
||||
if (io->status != SPA_STATUS_HAVE_DATA)
|
||||
goto done;
|
||||
|
||||
if ((b = get_buffer(stream, io->buffer_id)) == NULL)
|
||||
goto done;
|
||||
|
||||
/* push new buffer */
|
||||
if (push_queue(impl, &impl->dequeued, b) == 0)
|
||||
call_process(impl);
|
||||
|
||||
done:
|
||||
copy_position(impl, impl->dequeued.incount);
|
||||
|
||||
/* pop buffer to recycle */
|
||||
if ((b = pop_queue(impl, &impl->queued))) {
|
||||
pw_log_trace(NAME" %p: recycle buffer %d", stream, b->id);
|
||||
if (io->status == SPA_STATUS_HAVE_DATA &&
|
||||
(b = get_buffer(stream, io->buffer_id)) != NULL) {
|
||||
/* push new buffer */
|
||||
if (push_queue(impl, &impl->dequeued, b) == 0) {
|
||||
copy_position(impl, impl->dequeued.incount);
|
||||
call_process(impl);
|
||||
}
|
||||
}
|
||||
|
||||
io->buffer_id = b ? b->id : SPA_ID_INVALID;
|
||||
io->status = SPA_STATUS_NEED_DATA;
|
||||
|
||||
return SPA_STATUS_HAVE_DATA;
|
||||
if (io->status != SPA_STATUS_NEED_DATA) {
|
||||
/* pop buffer to recycle */
|
||||
if ((b = pop_queue(impl, &impl->queued))) {
|
||||
pw_log_trace(NAME" %p: recycle buffer %d", stream, b->id);
|
||||
}
|
||||
io->buffer_id = b ? b->id : SPA_ID_INVALID;
|
||||
io->status = SPA_STATUS_NEED_DATA;
|
||||
}
|
||||
return SPA_STATUS_NEED_DATA | SPA_STATUS_HAVE_DATA;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(void *object)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue