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.
This commit is contained in:
Michael Tretter 2023-10-27 16:56:05 +02:00
parent efa08e9892
commit e4def0ce18

View file

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