Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
xvimagesink: Delay pool creation until it's needed.
Buffer pool is created every time setcaps() is called, but it's
required only when upstream doesn't use it, so it's only needed to
copy frames onto XV buffers.

This patch delay the creation of the buffer pool until it's frame copy
is required.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1088>
  • Loading branch information
ceyusa committed Apr 28, 2021
1 parent c16412d commit c38bede
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions sys/xvimage/xvimagesink.c
Expand Up @@ -704,7 +704,7 @@ gst_xv_image_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
{
GstXvImageSink *xvimagesink;
GstXvContext *context;
GstBufferPool *newpool, *oldpool;
GstBufferPool *oldpool;
GstVideoInfo info;
guint32 im_format = 0;
gint video_par_n, video_par_d; /* video's PAR */
Expand Down Expand Up @@ -820,12 +820,9 @@ gst_xv_image_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
* doesn't cover the same area */
xvimagesink->redraw_border = TRUE;

/* create a new pool for the new configuration */
newpool = gst_xv_image_sink_create_pool (xvimagesink, caps, info.size, 2);

/* we don't activate the internal pool yet as it may not be needed */
/* destroy current pool */
oldpool = xvimagesink->pool;
xvimagesink->pool = newpool;
xvimagesink->pool = NULL;
g_mutex_unlock (&xvimagesink->flow_lock);

/* deactivate and unref the old internal pool */
Expand Down Expand Up @@ -962,9 +959,17 @@ gst_xv_image_sink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
/* if we have one... */
GST_LOG_OBJECT (xvimagesink, "buffer %p not from our pool, copying", buf);

/* we should have a pool, configured in setcaps */
if (xvimagesink->pool == NULL)
goto no_pool;
if (xvimagesink->pool == NULL) {
GstCaps *caps = gst_video_info_to_caps (&xvimagesink->info);

GST_DEBUG_OBJECT (xvimagesink, "create new pool");
xvimagesink->pool = gst_xv_image_sink_create_pool (xvimagesink, caps,
xvimagesink->info.size, 2);
if (xvimagesink->pool == NULL)
goto no_pool;

gst_caps_unref (caps);
}

if (!gst_buffer_pool_set_active (xvimagesink->pool, TRUE))
goto activate_failed;
Expand Down

0 comments on commit c38bede

Please sign in to comment.