mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-12 13:30:15 -05:00
stream: improve draining
After we drained, set the io state to NEED_DATA again. This will trigger a new _process callback, if we have new buffers we will exit the drain state and produce more data, if we have no buffers we reenter the drained state and signal the drained event. This effectively provides a way to exit the drain state by pushing a new buffer into the stream.
This commit is contained in:
parent
96fda265e0
commit
1a12d6082a
1 changed files with 7 additions and 2 deletions
|
|
@ -833,10 +833,12 @@ again:
|
|||
|
||||
/* pop new buffer */
|
||||
if ((b = pop_queue(impl, &impl->queued)) != NULL) {
|
||||
impl->drained = false;
|
||||
io->buffer_id = b->id;
|
||||
res = io->status = SPA_STATUS_HAVE_DATA;
|
||||
pw_log_trace(NAME" %p: pop %d %p", stream, b->id, io);
|
||||
} else if (impl->draining) {
|
||||
} else if (impl->draining || impl->drained) {
|
||||
impl->draining = true;
|
||||
impl->drained = true;
|
||||
io->buffer_id = SPA_ID_INVALID;
|
||||
res = io->status = SPA_STATUS_DRAINED;
|
||||
|
|
@ -1135,9 +1137,12 @@ static void context_drained(void *data, struct pw_impl_node *node)
|
|||
struct stream *impl = data;
|
||||
if (impl->node != node)
|
||||
return;
|
||||
if (impl->draining && impl->drained)
|
||||
if (impl->draining && impl->drained) {
|
||||
impl->draining = false;
|
||||
impl->io->status = SPA_STATUS_NEED_DATA;
|
||||
call_drained(impl);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct pw_context_driver_events context_events = {
|
||||
PW_VERSION_CONTEXT_DRIVER_EVENTS,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue