gst: increase buffers in sink

This commit is contained in:
Wim Taymans 2020-08-06 12:58:13 +02:00
parent 0347a753c9
commit 34334b6ea3

View file

@ -56,6 +56,8 @@ GST_DEBUG_CATEGORY_STATIC (pipewire_sink_debug);
#define DEFAULT_PROP_MODE GST_PIPEWIRE_SINK_MODE_DEFAULT #define DEFAULT_PROP_MODE GST_PIPEWIRE_SINK_MODE_DEFAULT
#define MIN_BUFFERS 8u
enum enum
{ {
PROP_0, PROP_0,
@ -248,8 +250,10 @@ pool_activated (GstPipeWirePool *pool, GstPipeWireSink *sink)
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
SPA_PARAM_BUFFERS_stride, SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX), SPA_PARAM_BUFFERS_stride, SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(SPA_MAX(4u, min_buffers), SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(
SPA_MAX(2u, min_buffers), max_buffers ? max_buffers : INT32_MAX), SPA_MAX(MIN_BUFFERS, min_buffers),
SPA_MAX(MIN_BUFFERS, min_buffers),
max_buffers ? max_buffers : INT32_MAX),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16), SPA_PARAM_BUFFERS_align, SPA_POD_Int(16),
0); 0);
port_params[0] = spa_pod_builder_pop (&b, &f); port_params[0] = spa_pod_builder_pop (&b, &f);
@ -583,13 +587,14 @@ gst_pipewire_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
if (buffer->pool != GST_BUFFER_POOL_CAST (pwsink->pool)) { if (buffer->pool != GST_BUFFER_POOL_CAST (pwsink->pool)) {
GstBuffer *b = NULL; GstBuffer *b = NULL;
GstMapInfo info = { 0, }; GstMapInfo info = { 0, };
GstBufferPoolAcquireParams params = { 0, };
pw_thread_loop_unlock (pwsink->core->loop); pw_thread_loop_unlock (pwsink->core->loop);
if (!gst_buffer_pool_is_active (GST_BUFFER_POOL_CAST (pwsink->pool))) if (!gst_buffer_pool_is_active (GST_BUFFER_POOL_CAST (pwsink->pool)))
gst_buffer_pool_set_active (GST_BUFFER_POOL_CAST (pwsink->pool), TRUE); gst_buffer_pool_set_active (GST_BUFFER_POOL_CAST (pwsink->pool), TRUE);
if ((res = gst_buffer_pool_acquire_buffer (GST_BUFFER_POOL_CAST (pwsink->pool), &b, NULL)) != GST_FLOW_OK) if ((res = gst_buffer_pool_acquire_buffer (GST_BUFFER_POOL_CAST (pwsink->pool), &b, &params)) != GST_FLOW_OK)
goto done; goto done;
gst_buffer_map (b, &info, GST_MAP_WRITE); gst_buffer_map (b, &info, GST_MAP_WRITE);
@ -755,6 +760,7 @@ gst_pipewire_sink_change_state (GstElement * element, GstStateChange transition)
pw_thread_loop_lock (this->core->loop); pw_thread_loop_lock (this->core->loop);
pw_stream_set_active(this->stream, false); pw_stream_set_active(this->stream, false);
pw_thread_loop_unlock (this->core->loop); pw_thread_loop_unlock (this->core->loop);
gst_buffer_pool_set_flushing(GST_BUFFER_POOL_CAST(this->pool), TRUE);
break; break;
default: default:
break; break;
@ -766,6 +772,7 @@ gst_pipewire_sink_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PLAYING_TO_PAUSED: case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break; break;
case GST_STATE_CHANGE_PAUSED_TO_READY: case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_buffer_pool_set_active(GST_BUFFER_POOL_CAST(this->pool), FALSE);
break; break;
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
gst_pipewire_sink_close (this); gst_pipewire_sink_close (this);