glbasememory: rollback map state when subclass map fails

Otherwise our state doesn't reflect reality.
This commit is contained in:
Matthew Waters 2016-03-31 19:35:09 +11:00 committed by Tim-Philipp Müller
parent 99dfbf8ed9
commit f1737c8ad7

View file

@ -226,6 +226,8 @@ _map_data_gl (GstGLContext * context, struct map_data *transfer)
GstGLBaseMemoryAllocatorClass *alloc_class;
GstGLBaseMemory *mem = transfer->mem;
GstMapInfo *info = transfer->info;
guint prev_map_flags;
guint prev_gl_map_count;
alloc_class =
GST_GL_BASE_MEMORY_ALLOCATOR_GET_CLASS (transfer->mem->mem.allocator);
@ -234,6 +236,9 @@ _map_data_gl (GstGLContext * context, struct map_data *transfer)
g_mutex_lock (&mem->lock);
prev_map_flags = mem->map_flags;
prev_gl_map_count = mem->gl_map_count;
GST_CAT_LOG (GST_CAT_GL_BASE_MEMORY, "mapping mem %p flags %04x", mem,
info->flags);
@ -267,6 +272,11 @@ _map_data_gl (GstGLContext * context, struct map_data *transfer)
GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD);
GST_MEMORY_FLAG_UNSET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
}
} else {
/* undo state tracking on error */
mem->map_flags = prev_map_flags;
mem->gl_map_count = prev_gl_map_count;
mem->map_count--;
}
g_mutex_unlock (&mem->lock);