{
mini_object->type = type;
mini_object->refcount = 1;
- mini_object->lockstate =
- (flags & GST_MINI_OBJECT_FLAG_LOCK_READONLY ? GST_LOCK_FLAG_READ : 0);
+ mini_object->lockstate = 0;
mini_object->flags = flags;
mini_object->copy = copy_func;
g_return_val_if_fail (object != NULL, FALSE);
g_return_val_if_fail (GST_MINI_OBJECT_IS_LOCKABLE (object), FALSE);
+ if (G_UNLIKELY (object->flags & GST_MINI_OBJECT_FLAG_LOCK_READONLY &&
+ flags & GST_LOCK_FLAG_WRITE))
+ return FALSE;
+
do {
access_mode = flags & FLAG_MASK;
newstate = state = g_atomic_int_get (&object->lockstate);
fail_if (gst_memory_map (mem, &info, GST_MAP_WRITE));
+ /* Make sure mapping anxd unmapping it doesn't change it's locking state */
+ fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
+ gst_memory_unmap (mem, &info);
+
+ fail_if (gst_memory_map (mem, &info, GST_MAP_WRITE));
+
mem2 = gst_memory_copy (mem, 0, -1);
fail_unless (GST_MEMORY_IS_READONLY (mem));
fail_if (GST_MEMORY_IS_READONLY (mem2));