glmemorypbo: unmap pbo memory on pbo read error

Otherwise we are returning failure with a dangling map!

Also only unset the NEED_DOWNLOAD flag in download_transfer() if the read actually
succeeds.
This commit is contained in:
Matthew Waters 2016-03-31 19:31:00 +11:00 committed by Tim-Philipp Müller
parent ccbf43987f
commit 99dfbf8ed9

View file

@ -305,8 +305,10 @@ _pbo_download_transfer (GstGLMemoryPBO * gl_mem, GstMapInfo * info, gsize size)
return NULL;
}
if (!_read_pixels_to_pbo (gl_mem))
if (!_read_pixels_to_pbo (gl_mem)) {
gst_memory_unmap (GST_MEMORY_CAST (gl_mem->pbo), &info);
return NULL;
}
gst_memory_unmap (GST_MEMORY_CAST (gl_mem->pbo), &info);
}
@ -785,10 +787,11 @@ _download_transfer (GstGLContext * context, GstGLMemoryPBO * gl_mem)
GstGLBaseMemory *mem = (GstGLBaseMemory *) gl_mem;
g_mutex_lock (&mem->lock);
if (_read_pixels_to_pbo (gl_mem))
if (_read_pixels_to_pbo (gl_mem)) {
GST_CAT_TRACE (GST_CAT_GL_MEMORY, "optimistic download of texture %u "
"using pbo %u", gl_mem->mem.tex_id, gl_mem->pbo->id);
GST_MEMORY_FLAG_UNSET (gl_mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
GST_MEMORY_FLAG_UNSET (gl_mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
}
g_mutex_unlock (&mem->lock);
}