hwcontext: Do not call device_init again when deriving an existing device
authorMark Thompson <sw@jkqxz.net>
Mon, 14 May 2018 21:58:56 +0000 (22:58 +0100)
committerMark Thompson <sw@jkqxz.net>
Tue, 15 May 2018 21:16:03 +0000 (22:16 +0100)
The change in 309d660775e2b47af6723a0477c4d753bc0c54f4 to call device_init
when doing derivation missed this case - we should only call it if we
actually made a new device.

libavutil/hwcontext.c

index 70c556e..745016e 100644 (file)
@@ -646,6 +646,9 @@ int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
                     ret = AVERROR(ENOMEM);
                     goto fail;
                 }
+                ret = av_hwdevice_ctx_init(dst_ref);
+                if (ret < 0)
+                    goto fail;
                 goto done;
             }
             if (ret != AVERROR(ENOSYS))
@@ -658,10 +661,6 @@ int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
     goto fail;
 
 done:
-    ret = av_hwdevice_ctx_init(dst_ref);
-    if (ret < 0)
-        goto fail;
-
     *dst_ref_ptr = dst_ref;
     return 0;