mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 04:00:37 +00:00
glememory: only store and act on the map flags on first/last map/unmap
Anytime else, we have no idea how to match up map and unmaps. We also don't know exactly how the calling code is using us. Also fixes the case where we're trying to transfer while someone else is accessing our data pointer or texture resulting in mismatched video frames. https://bugzilla.gnome.org/show_bug.cgi?id=744839
This commit is contained in:
parent
880dcd8039
commit
a4040f2ee9
2 changed files with 9 additions and 4 deletions
|
@ -859,6 +859,8 @@ _gl_mem_map (GstGLMemory * gl_mem, gsize maxsize, GstMapFlags flags)
|
||||||
data = gl_mem->data;
|
data = gl_mem->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* only store the first map flags, subsequent maps must be a subset of this */
|
||||||
|
if (gl_mem->map_count++ == 0)
|
||||||
gl_mem->map_flags = flags;
|
gl_mem->map_flags = flags;
|
||||||
|
|
||||||
g_mutex_unlock (&gl_mem->lock);
|
g_mutex_unlock (&gl_mem->lock);
|
||||||
|
@ -882,12 +884,14 @@ _gl_mem_unmap (GstGLMemory * gl_mem)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&gl_mem->lock);
|
g_mutex_lock (&gl_mem->lock);
|
||||||
|
|
||||||
if (gl_mem->map_flags & GST_MAP_WRITE) {
|
if (gl_mem->map_count <= 1 && gl_mem->map_flags & GST_MAP_WRITE) {
|
||||||
if (!(gl_mem->map_flags & GST_MAP_GL))
|
if (!(gl_mem->map_flags & GST_MAP_GL)) {
|
||||||
gst_gl_context_thread_add (gl_mem->context,
|
gst_gl_context_thread_add (gl_mem->context,
|
||||||
(GstGLContextThreadFunc) _transfer_upload, gl_mem);
|
(GstGLContextThreadFunc) _transfer_upload, gl_mem);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--gl_mem->map_count <= 0)
|
||||||
gl_mem->map_flags = 0;
|
gl_mem->map_flags = 0;
|
||||||
|
|
||||||
g_mutex_unlock (&gl_mem->lock);
|
g_mutex_unlock (&gl_mem->lock);
|
||||||
|
|
|
@ -103,6 +103,7 @@ struct _GstGLMemory
|
||||||
guint tex_width;
|
guint tex_width;
|
||||||
guint transfer_pbo;
|
guint transfer_pbo;
|
||||||
GstMapFlags map_flags;
|
GstMapFlags map_flags;
|
||||||
|
guint map_count;
|
||||||
|
|
||||||
GMutex lock;
|
GMutex lock;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue