stream: add ASYNC flag

Add ASYNC flag that sets SPA_NODE_FLAG_ASYNC.

This ensure we allocate at least 2 buffers. We need 2 buffers at least
because we don't dequeue/queue a buffer in the process function when
async and we run out of buffers if we have only 1 buffer.
This commit is contained in:
Wim Taymans 2023-06-27 13:00:39 +02:00
parent 88bb0bd7cc
commit 1466982c60
4 changed files with 18 additions and 2 deletions

View file

@ -1632,7 +1632,9 @@ pw_filter_connect(struct pw_filter *filter,
impl->info = SPA_NODE_INFO_INIT();
impl->info.max_input_ports = UINT32_MAX;
impl->info.max_output_ports = UINT32_MAX;
impl->info.flags = impl->process_rt ? SPA_NODE_FLAG_RT : 0;
impl->info.flags = SPA_NODE_FLAG_RT;
if (!impl->process_rt || SPA_FLAG_IS_SET(flags, PW_FILTER_FLAG_ASYNC))
impl->info.flags |= SPA_NODE_FLAG_ASYNC;
impl->info.props = &filter->properties->dict;
impl->params[NODE_PropInfo] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, 0);
impl->params[NODE_Props] = SPA_PARAM_INFO(SPA_PARAM_Props, SPA_PARAM_INFO_WRITE);

View file

@ -109,6 +109,13 @@ enum pw_filter_flags {
* needs to be called. This can be used
* when the filter depends on processing
* of other filters. */
PW_FILTER_FLAG_ASYNC = (1 << 5), /**< Buffers will not be dequeued/queued from
* the realtime process() function. This is
* assumed when RT_PROCESS is unset but can
* also be the case when the process() function
* does a trigger_process() that will then
* dequeue/queue a buffer from another process()
* function. since 0.3.73 */
};
enum pw_filter_port_flags {

View file

@ -1957,7 +1957,7 @@ pw_stream_connect(struct pw_stream *stream,
impl->info.flags = SPA_NODE_FLAG_RT;
/* if the callback was not marked RT_PROCESS, we will offload
* the process callback in the main thread and we are ASYNC */
if (!impl->process_rt)
if (!impl->process_rt || SPA_FLAG_IS_SET(flags, PW_STREAM_FLAG_ASYNC))
impl->info.flags |= SPA_NODE_FLAG_ASYNC;
impl->info.props = &stream->properties->dict;
impl->params[NODE_PropInfo] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, 0);

View file

@ -378,6 +378,13 @@ enum pw_stream_flags {
* needs to be called. This can be used
* when the output of the stream depends
* on input from other streams. */
PW_STREAM_FLAG_ASYNC = (1 << 10), /**< Buffers will not be dequeued/queued from
* the realtime process() function. This is
* assumed when RT_PROCESS is unset but can
* also be the case when the process() function
* does a trigger_process() that will then
* dequeue/queue a buffer from another process()
* function. since 0.3.73 */
};
/** Create a new unconneced \ref pw_stream