From e4def0ce1824180d9e19ee028307373a78e669ca Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Fri, 27 Oct 2023 16:56:05 +0200 Subject: [PATCH] pipewiresink: use maximum size of buffers to configure pool For encoded formats, buffer size is the size of the actual data in the buffer and may change for each frame depending on the content. Thus, configuring the buffer pool of the pipewiresrc with the size of the first buffer may be insufficient for later buffers. Configure the buffer pool to the maximum size of the first upstream buffer and assume that the following buffers will be allocated with the same size as the first buffer. --- src/gst/gstpipewiresink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c index b20bf469a..36d158095 100644 --- a/src/gst/gstpipewiresink.c +++ b/src/gst/gstpipewiresink.c @@ -677,7 +677,11 @@ gst_pipewire_sink_render (GstBaseSink * bsink, GstBuffer * buffer) config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pwsink->pool)); gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers, &max_buffers); - size = (size == 0) ? gst_buffer_get_size (buffer) : size; + if (size == 0) { + gsize maxsize; + gst_buffer_get_sizes (buffer, NULL, &maxsize); + size = maxsize; + } gst_buffer_pool_config_set_params (config, caps, size, min_buffers, max_buffers); gst_buffer_pool_set_config (GST_BUFFER_POOL_CAST (pwsink->pool), config);