+ /* whether we can lock the memory exclusively */
+ /* in order to maintain backwards compatibility by not requiring subclasses
+ * to lock the memory themselves and propagate the possible failure in their
+ * mem_share implementation */
+ /* FIXME 2.0: remove and fix gst_memory_init() and/or all memory subclasses
+ * to propagate this failure case */
+ if (!gst_memory_lock (mem, GST_LOCK_FLAG_EXCLUSIVE))
+ return NULL;
+
+ /* double lock to ensure we are not mapped writable without an
+ * exclusive lock. */
+ if (!gst_memory_lock (mem, GST_LOCK_FLAG_EXCLUSIVE)) {
+ gst_memory_unlock (mem, GST_LOCK_FLAG_EXCLUSIVE);
+ return NULL;
+ }
+