stream: add EARLY_PROCESS flag

This will call the process function as soon as a new buffer is dequeued.
This can be used to keep the buffer at a certain fill level instead of
the minimal fill level without the flag.

Fixes #3480
This commit is contained in:
Wim Taymans 2023-09-25 10:00:07 +02:00
parent 7f14e14ab7
commit 4be0c5f365
2 changed files with 9 additions and 2 deletions

View file

@ -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,

View file

@ -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