Implement explicit buffer-reuse in stream API

This commit is contained in:
Wim Taymans 2017-10-22 15:12:04 +02:00
parent 0f4142f879
commit a3b614fff6
3 changed files with 6 additions and 10 deletions

View file

@ -313,7 +313,8 @@ static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remo
printf("remote state: \"%s\"\n", pw_remote_state_as_string(state));
data->stream = pw_stream_new(remote, "video-play", NULL);
data->stream = pw_stream_new(remote, "video-play",
pw_properties_new("pipewire.client.reuse", "1", NULL));
SDL_GetRendererInfo(data->renderer, &info);

View file

@ -768,9 +768,6 @@ static int spa_proxy_node_process_input(struct spa_node *node)
if (impl->client_reuse)
io->buffer_id = SPA_ID_INVALID;
else
io->buffer_id = impl->transport->inputs[i].buffer_id;
}
pw_client_node_transport_add_message(impl->transport,
&PW_CLIENT_NODE_MESSAGE_INIT(PW_CLIENT_NODE_MESSAGE_PROCESS_INPUT));
@ -831,6 +828,8 @@ static int handle_node_message(struct proxy *this, struct pw_client_node_message
continue;
*io = impl->transport->inputs[i];
if (impl->client_reuse)
io->buffer_id = SPA_ID_INVALID;
pw_log_trace("%d %d", io->status, io->buffer_id);
}
this->callbacks->need_input(this->callbacks_data);

View file

@ -416,14 +416,12 @@ static void add_port_update(struct pw_stream *stream, uint32_t change_mask)
static inline void send_need_input(struct pw_stream *stream)
{
#if 0
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
uint64_t cmd = 1;
pw_client_node_transport_add_message(impl->trans,
&PW_CLIENT_NODE_MESSAGE_INIT(PW_CLIENT_NODE_MESSAGE_NEED_INPUT));
write(impl->rtwritefd, &cmd, 8);
#endif
}
static inline void send_have_output(struct pw_stream *stream)
@ -531,7 +529,6 @@ static void handle_rtnode_message(struct pw_stream *stream, struct pw_client_nod
uint32_t buffer_id;
buffer_id = input->buffer_id;
input->buffer_id = SPA_ID_INVALID;
input->status = SPA_RESULT_NEED_BUFFER;
pw_log_trace("stream %p: process input %d %d", stream, input->status,
@ -1081,8 +1078,6 @@ uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream)
bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id)
{
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
struct pw_client_node_message_reuse_buffer rb = PW_CLIENT_NODE_MESSAGE_REUSE_BUFFER_INIT
(impl->port_id, id);
struct buffer_id *bid;
uint64_t cmd = 1;
@ -1092,7 +1087,8 @@ bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id)
bid->used = false;
spa_list_insert(impl->free.prev, &bid->link);
pw_client_node_transport_add_message(impl->trans, (struct pw_client_node_message *) &rb);
pw_client_node_transport_add_message(impl->trans, (struct pw_client_node_message*)
&PW_CLIENT_NODE_MESSAGE_REUSE_BUFFER_INIT(impl->port_id, id));
write(impl->rtwritefd, &cmd, 8);
return true;