diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index d84120b46..aceacfe12 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -157,6 +157,7 @@ struct stream { unsigned int driving:1; unsigned int using_trigger:1; unsigned int trigger:1; + unsigned int early_process:1; int in_set_param; int in_emit_param_changed; }; @@ -1103,7 +1104,7 @@ again: * rate matching node (audioconvert) has been scheduled to * update the values. */ ask_more = !impl->process_rt && impl->rate_match == NULL && - queue_is_empty(impl, &impl->queued) && + (impl->early_process || queue_is_empty(impl, &impl->queued)) && !queue_is_empty(impl, &impl->dequeued); pw_log_trace_fp("%p: pop %d %p ask_more:%u %p", stream, b->id, io, ask_more, impl->rate_match); @@ -1121,7 +1122,7 @@ again: } } else { ask_more = !impl->process_rt && - queue_is_empty(impl, &impl->queued) && + (impl->early_process || queue_is_empty(impl, &impl->queued)) && !queue_is_empty(impl, &impl->dequeued); } @@ -1912,6 +1913,7 @@ pw_stream_connect(struct pw_stream *stream, impl->node_methods.process = impl_node_process_output; impl->process_rt = SPA_FLAG_IS_SET(flags, PW_STREAM_FLAG_RT_PROCESS); + impl->early_process = SPA_FLAG_IS_SET(flags, PW_STREAM_FLAG_EARLY_PROCESS); impl->impl_node.iface = SPA_INTERFACE_INIT( SPA_TYPE_INTERFACE_Node, diff --git a/src/pipewire/stream.h b/src/pipewire/stream.h index f2777bec0..f394eaf0b 100644 --- a/src/pipewire/stream.h +++ b/src/pipewire/stream.h @@ -394,6 +394,11 @@ enum pw_stream_flags { * does a trigger_process() that will then * dequeue/queue a buffer from another process() * function. since 0.3.73 */ + PW_STREAM_FLAG_EARLY_PROCESS = (1 << 11), /**< Call process as soon as there is a buffer + * to dequeue. This is only relevant for + * playback and when not using RT_PROCESS. It + * can be used to keep the maximum number of + * buffers queued. Since 0.3.81 */ }; /** Create a new unconneced \ref pw_stream