gboolean
GstQSGMaterial::setBuffer (GstBuffer * buffer)
{
- GST_LOG ("%p setBuffer %" GST_PTR_FORMAT, this, buffer);
+ GstGLContext *qt_context;
+ gboolean ret = FALSE;
+
/* FIXME: update more state here */
- if (!gst_buffer_replace (&this->buffer_, buffer))
- return FALSE;
+ if (gst_buffer_replace (&this->buffer_, buffer)) {
+ GST_LOG ("%p setBuffer new buffer %" GST_PTR_FORMAT, this, buffer);
- this->buffer_was_bound = FALSE;
+ this->buffer_was_bound = FALSE;
+ ret = TRUE;
+ }
- g_weak_ref_set (&this->qt_context_ref_, gst_gl_context_get_current ());
+ qt_context = gst_gl_context_get_current ();
+ GST_DEBUG ("%p setBuffer with qt context %" GST_PTR_FORMAT, this, qt_context);
- return TRUE;
+ g_weak_ref_set (&this->qt_context_ref_, qt_context);
+
+ return ret;
}
/* only called from the streaming thread with scene graph thread blocked */
GstQSGMaterial::bind(GstQSGMaterialShader *shader, GstVideoFormat v_format)
{
const GstGLFuncs *gl;
- GstGLContext *context, *qt_context;
+ GstGLContext *context, *qt_context = NULL;
GstGLSyncMeta *sync_meta;
GstMemory *mem;
gboolean use_dummy_tex = TRUE;
memset (&this->v_frame, 0, sizeof (this->v_frame));
}
- qt_context = GST_GL_CONTEXT (g_weak_ref_get (&this->qt_context_ref_));
- if (!qt_context)
- goto out;
-
if (!this->buffer_)
goto out;
if (GST_VIDEO_INFO_FORMAT (&this->v_info) == GST_VIDEO_FORMAT_UNKNOWN)
if (!this->mem_)
goto out;
+ qt_context = GST_GL_CONTEXT (g_weak_ref_get (&this->qt_context_ref_));
+ if (!qt_context)
+ goto out;
+
gl = qt_context->gl_vtable;
/* FIXME: should really lock the memory to prevent write access */
goto out;
}
+ GST_DEBUG ("%p attempting to bind with context %" GST_PTR_FORMAT, this, qt_context);
+
mem = gst_buffer_peek_memory (this->buffer_, 0);
g_assert (gst_is_gl_memory (mem));
gboolean
GstQSGMaterial::setBuffer (GstBuffer * buffer)
{
- GST_LOG ("%p setBuffer %" GST_PTR_FORMAT, this, buffer);
+ GstGLContext *qt_context = gst_gl_context_get_current ();
+
+ GST_LOG ("%p setBuffer %" GST_PTR_FORMAT " with qt context %" GST_PTR_FORMAT,
+ this, buffer, qt_context);
/* FIXME: update more state here */
+
+ g_weak_ref_set (&this->qt_context_ref_, qt_context);
+
if (!gst_buffer_replace (&this->buffer_, buffer))
return FALSE;
this->buffer_was_bound = false;
- g_weak_ref_set (&this->qt_context_ref_, gst_gl_context_get_current ());
-
if (this->v_frame.buffer) {
gst_video_frame_unmap (&this->v_frame);
memset (&this->v_frame, 0, sizeof (this->v_frame));
QSGTexture *
GstQSGMaterial::bind(GstQSGMaterialShader *shader, QRhi * rhi, QRhiResourceUpdateBatch *res_updates, guint plane, GstVideoFormat v_format)
{
- GstGLContext *qt_context, *context;
+ GstGLContext *qt_context = NULL, *context;
GstMemory *mem;
GstGLMemory *gl_mem;
GstGLSyncMeta *sync_meta;
QRhiTexture *rhi_tex;
QSize tex_size;
- qt_context = GST_GL_CONTEXT (g_weak_ref_get (&this->qt_context_ref_));
- if (!qt_context)
- goto out;
-
if (!this->buffer_)
goto out;
if (GST_VIDEO_INFO_FORMAT (&this->v_info) == GST_VIDEO_FORMAT_UNKNOWN)
goto out;
+ qt_context = GST_GL_CONTEXT (g_weak_ref_get (&this->qt_context_ref_));
+ if (!qt_context)
+ goto out;
+
+ GST_DEBUG ("%p attempting to bind with context %" GST_PTR_FORMAT, this, qt_context);
+
mem = gst_buffer_peek_memory (this->buffer_, plane);
g_assert (gst_is_gl_memory (mem));
gl_mem = (GstGLMemory *) mem;