diff options
author | Matthew Waters <ystreet00@gmail.com> | 2014-05-01 16:07:05 +1000 |
---|---|---|
committer | Matthew Waters <ystreet00@gmail.com> | 2014-05-02 14:16:49 +1000 |
commit | b903c61cebfba19e975450ca79d5b13e8eed27d0 (patch) | |
tree | 2ee52461e82242bcb8bd8eab458e5511e99740e4 | |
parent | 775e998dab25785380abac2b1cdf5e18a1ca30c9 (diff) | |
download | gstreamer-plugins-bad-b903c61cebfba19e975450ca79d5b13e8eed27d0.tar.gz |
gl/pool: init the upload object on start
Theoretically, set_config could be called multiple times
-rw-r--r-- | gst-libs/gst/gl/gstglbufferpool.c | 35 | ||||
-rw-r--r-- | gst-libs/gst/gl/gstglbufferpool.h | 1 |
2 files changed, 27 insertions, 9 deletions
diff --git a/gst-libs/gst/gl/gstglbufferpool.c b/gst-libs/gst/gl/gstglbufferpool.c index 2a87e9a6a..b3df2a052 100644 --- a/gst-libs/gst/gl/gstglbufferpool.c +++ b/gst-libs/gst/gl/gstglbufferpool.c @@ -50,7 +50,6 @@ struct _GstGLBufferPoolPrivate GstCaps *caps; gint im_format; GstVideoInfo info; - GstGLUpload *upload; gboolean add_videometa; #if GST_GL_HAVE_PLATFORM_EGL gboolean want_eglimage; @@ -133,11 +132,10 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config) #endif if (reset) { - if (priv->upload) - gst_object_unref (priv->upload); + if (glpool->upload) + gst_object_unref (glpool->upload); - priv->upload = gst_gl_upload_new (glpool->context); - gst_gl_upload_init_format (priv->upload, &priv->info); + glpool->upload = gst_gl_upload_new (glpool->context); } return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config); @@ -167,7 +165,25 @@ unknown_format: ("Failed to create output image buffer of %dx%d pixels", priv->info.width, priv->info.height), ("Invalid input caps %" GST_PTR_FORMAT, caps)); - return FALSE;; + return FALSE; + } +} + +static gboolean +gst_gl_buffer_pool_start (GstBufferPool * pool) +{ + GstGLBufferPool *glpool = GST_GL_BUFFER_POOL_CAST (pool); + GstGLBufferPoolPrivate *priv = glpool->priv; + + if (!gst_gl_upload_init_format (glpool->upload, &priv->info)) + goto upload_error; + + return GST_BUFFER_POOL_CLASS (parent_class)->start (pool); + +upload_error: + { + GST_WARNING_OBJECT (glpool, "Failed to initialize upload"); + return FALSE; } } @@ -202,7 +218,7 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, if (!gst_gl_memory_setup_buffer (glpool->context, info, buf)) goto mem_create_failed; - gst_gl_upload_add_video_gl_texture_upload_meta (glpool->priv->upload, buf); + gst_gl_upload_add_video_gl_texture_upload_meta (glpool->upload, buf); *buffer = buf; @@ -311,6 +327,7 @@ gst_gl_buffer_pool_class_init (GstGLBufferPoolClass * klass) gstbufferpool_class->set_config = gst_gl_buffer_pool_set_config; gstbufferpool_class->alloc_buffer = gst_gl_buffer_pool_alloc; gstbufferpool_class->acquire_buffer = gst_gl_buffer_pool_acquire_buffer; + gstbufferpool_class->start = gst_gl_buffer_pool_start; } static void @@ -349,8 +366,8 @@ gst_gl_buffer_pool_finalize (GObject * object) if (priv->caps) gst_caps_unref (priv->caps); - if (priv->upload) - gst_object_unref (priv->upload); + if (pool->upload) + gst_object_unref (pool->upload); G_OBJECT_CLASS (gst_gl_buffer_pool_parent_class)->finalize (object); diff --git a/gst-libs/gst/gl/gstglbufferpool.h b/gst-libs/gst/gl/gstglbufferpool.h index 8d1f0be94..c4dc3ffea 100644 --- a/gst-libs/gst/gl/gstglbufferpool.h +++ b/gst-libs/gst/gl/gstglbufferpool.h @@ -50,6 +50,7 @@ struct _GstGLBufferPool GstBufferPool bufferpool; GstGLContext *context; + GstGLUpload *upload; GstGLBufferPoolPrivate *priv; }; |