mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
Support for "client-reuse" streams
Add a PW property "pipewire.client.reuse". If set, the client-node doesn't immediately reuse a buffer after sending PW_CLIENT_NODE_MESSAGE_PROCESS_INPUT to the client. Instead, it waits for reuse-buffer from the client. The SPA_GRAPH_NODE_FLAG_ASYNC is used for this, together with adapted logic in process_input(). In stream.c, if the property is set, the handling of incoming buffers for PW_DIRECTION_INPUT streams is changed. Each buffer has to be recycled, so we make sure new_buffer is emitted for each intermediate buffer, if buffer_id in the IO area has moved past some buffers. Change-Id: I137a12b702b857cc73369930d7029ecbd69d63ff
This commit is contained in:
parent
de8e0c8f8c
commit
28bf6137d3
2 changed files with 58 additions and 9 deletions
|
|
@ -31,11 +31,13 @@
|
|||
#include "spa/node.h"
|
||||
#include "spa/format-builder.h"
|
||||
#include "spa/lib/format.h"
|
||||
#include "spa/graph.h"
|
||||
|
||||
#include "pipewire/pipewire.h"
|
||||
#include "pipewire/interfaces.h"
|
||||
|
||||
#include "pipewire/core.h"
|
||||
#include "pipewire/private.h"
|
||||
#include "modules/spa/spa-node.h"
|
||||
#include "client-node.h"
|
||||
#include "transport.h"
|
||||
|
|
@ -126,6 +128,8 @@ struct impl {
|
|||
|
||||
int fds[2];
|
||||
int other_fds[2];
|
||||
|
||||
bool client_reuse;
|
||||
};
|
||||
|
||||
/** \endcond */
|
||||
|
|
@ -762,13 +766,19 @@ static int spa_proxy_node_process_input(struct spa_node *node)
|
|||
pw_log_trace("%d %d", io->status, io->buffer_id);
|
||||
|
||||
impl->transport->inputs[i] = *io;
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
|
||||
if (impl->client_reuse) {
|
||||
io->status = SPA_RESULT_OK;
|
||||
io->buffer_id = SPA_ID_INVALID;
|
||||
} else {
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
}
|
||||
}
|
||||
pw_client_node_transport_add_message(impl->transport,
|
||||
&PW_CLIENT_NODE_MESSAGE_INIT(PW_CLIENT_NODE_MESSAGE_PROCESS_INPUT));
|
||||
do_flush(this);
|
||||
|
||||
if (this->callbacks->need_input)
|
||||
if (this->callbacks->need_input || impl->client_reuse)
|
||||
return SPA_RESULT_OK;
|
||||
else
|
||||
return SPA_RESULT_NEED_BUFFER;
|
||||
|
|
@ -1149,6 +1159,7 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
|||
const struct spa_support *support;
|
||||
uint32_t n_support;
|
||||
const char *name = "client-node";
|
||||
const char *str;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
if (impl == NULL)
|
||||
|
|
@ -1178,6 +1189,13 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
|||
if (this->node == NULL)
|
||||
goto error_no_node;
|
||||
|
||||
str = pw_properties_get(properties, "pipewire.client.reuse");
|
||||
impl->client_reuse = str && strcmp(str, "1") == 0;
|
||||
if (impl->client_reuse)
|
||||
this->node->rt.node.flags |= SPA_GRAPH_NODE_FLAG_ASYNC;
|
||||
else
|
||||
this->node->rt.node.flags &= ~SPA_GRAPH_NODE_FLAG_ASYNC;
|
||||
|
||||
pw_resource_add_listener(this->resource,
|
||||
&impl->resource_listener,
|
||||
&resource_events,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue