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:
Wim Taymans 2020-09-24 17:15:47 +02:00
parent 1cccaaa2bd
commit 9dc1c3b168

View file

@ -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, 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); stream, io->status, io->buffer_id, impl->time.ticks, impl->time.delay);
if (io->status != SPA_STATUS_HAVE_DATA) if (io->status == SPA_STATUS_HAVE_DATA &&
goto done; (b = get_buffer(stream, io->buffer_id)) != NULL) {
if ((b = get_buffer(stream, io->buffer_id)) == NULL)
goto done;
/* 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);
done:
copy_position(impl, impl->dequeued.incount); copy_position(impl, impl->dequeued.incount);
call_process(impl);
}
}
if (io->status != SPA_STATUS_NEED_DATA) {
/* pop buffer to recycle */ /* pop buffer to recycle */
if ((b = pop_queue(impl, &impl->queued))) { if ((b = pop_queue(impl, &impl->queued))) {
pw_log_trace(NAME" %p: recycle buffer %d", stream, b->id); pw_log_trace(NAME" %p: recycle buffer %d", stream, b->id);
} }
io->buffer_id = b ? b->id : SPA_ID_INVALID; io->buffer_id = b ? b->id : SPA_ID_INVALID;
io->status = SPA_STATUS_NEED_DATA; io->status = SPA_STATUS_NEED_DATA;
}
return SPA_STATUS_HAVE_DATA; return SPA_STATUS_NEED_DATA | SPA_STATUS_HAVE_DATA;
} }
static int impl_node_process_output(void *object) static int impl_node_process_output(void *object)