[vlc-devel] [PATCH 16/31] video context: add a Create/Release function for the video context

Steve Lhomme robux4 at ycbcr.xyz
Mon Sep 23 17:01:21 CEST 2019


---
 include/vlc_picture.h       |  3 +++
 src/input/decoder_helpers.c | 15 +++++++++++++++
 src/libvlccore.sym          |  2 ++
 src/video_output/display.c  | 10 ++++++----
 4 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index c314c9c2075..99495ca43a4 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -85,6 +85,9 @@ typedef struct vlc_video_context
     vlc_decoder_device *device;
 } vlc_video_context;
 
+VLC_API vlc_video_context * vlc_video_context_Create(vlc_decoder_device *);
+VLC_API void vlc_video_context_Release(vlc_video_context *);
+
 /**
  * Video picture
  */
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index 51e097961b9..666f0f83034 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -187,3 +187,18 @@ vlc_decoder_device_Release(vlc_decoder_device *device)
         vlc_object_delete(device);
     }
 }
+
+/* video context */
+
+vlc_video_context * vlc_video_context_Create(vlc_decoder_device *device)
+{
+    vlc_video_context *vctx = malloc(sizeof(*vctx));
+    if (unlikely(vctx == NULL))
+        return NULL;
+    vctx->device = device;
+    return vctx;
+}
+void vlc_video_context_Release(vlc_video_context *vctx)
+{
+    free(vctx);
+}
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index fb2952ee5ef..ab065f94bf4 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -941,3 +941,5 @@ vlc_media_tree_Unlock
 vlc_media_tree_Find
 vlc_media_tree_Preparse
 vlc_viewpoint_to_4x4
+vlc_video_context_Create
+vlc_video_context_Release
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 97603317d17..7b550334dba 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -770,13 +770,11 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
     if (owner)
         vd->owner = *owner;
 
-    vlc_video_context fake_vctx = {
-        .device = dec_device,
-    };
+    vlc_video_context *fake_vctx = vlc_video_context_Create(dec_device);
 
     if (vlc_module_load(vd, "vout display", module, module && *module != '\0',
                         vout_display_start, vd, &osys->cfg, &vd->fmt,
-                        &fake_vctx) == NULL)
+                        fake_vctx) == NULL)
         goto error;
 
 #if defined(__OS2__)
@@ -798,8 +796,12 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
         video_format_Clean(&vd->fmt);
         goto error;
     }
+    if (fake_vctx)
+        vlc_video_context_Release(fake_vctx);
     return vd;
 error:
+    if (fake_vctx)
+        vlc_video_context_Release(fake_vctx);
     video_format_Clean(&vd->source);
     vlc_object_delete(vd);
     return NULL;
-- 
2.17.1



More information about the vlc-devel mailing list