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

Steve Lhomme robux4 at ycbcr.xyz
Wed Oct 2 16:23:32 CEST 2019


---
 include/vlc_picture.h       |  3 +++
 src/input/decoder_helpers.c | 15 +++++++++++++++
 src/libvlccore.sym          |  2 ++
 src/video_output/display.c  |  8 ++++++--
 4 files changed, 26 insertions(+), 2 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 eac988f85db..f5926b4851e 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -181,3 +181,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 2037763178d..84347ea0474 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -945,3 +945,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 9051eb52480..0ecf794972c 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -770,11 +770,11 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
     if (owner)
         vd->owner = *owner;
 
-    vlc_video_context fake_vtcx = { .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_vtcx) == NULL)
+                        fake_vctx) == NULL)
         goto error;
 
 #if defined(__OS2__)
@@ -796,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