[vlc-commits] vout: always create vout before calling vout_Request()

Rémi Denis-Courmont git at videolan.org
Sun Feb 24 13:50:09 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Feb 24 12:23:32 2019 +0200| [5f9f228619731209285614f0cb6d96d054b07ec2] | committer: Rémi Denis-Courmont

vout: always create vout before calling vout_Request()

This exposes vout_Create() (within core).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5f9f228619731209285614f0cb6d96d054b07ec2
---

 src/audio_output/filters.c       |  8 +++++++-
 src/input/resource.c             | 11 ++++++++---
 src/video_output/video_output.c  |  4 ++--
 src/video_output/vout_internal.h |  5 +++++
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index de714916e9..7a82c88c4a 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -382,8 +382,14 @@ static int VisualizationCallback (vlc_object_t *obj, const char *var,
 
 vout_thread_t *aout_filter_GetVout(filter_t *filter, const video_format_t *fmt)
 {
+    vout_thread_t *vout = vout_Create(VLC_OBJECT(filter));
+    if (unlikely(vout == NULL))
+        return NULL;
+
     video_format_t adj_fmt = *fmt;
-    vout_configuration_t cfg = { .fmt = &adj_fmt, .dpb_size = 1 };
+    vout_configuration_t cfg = {
+        .vout = vout, .fmt = &adj_fmt, .dpb_size = 1,
+    };
 
     video_format_AdjustColorSpace(&adj_fmt);
 
diff --git a/src/input/resource.c b/src/input/resource.c
index db083c8cd2..0343576e61 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -379,14 +379,18 @@ vout_thread_t *input_resource_GetVout(input_resource_t *p_resource,
     assert(cfg->fmt != NULL);
     vlc_mutex_lock( &p_resource->lock );
 
-    if (cfg->vout == NULL && p_resource->p_vout_free != NULL) {
-        msg_Dbg(p_resource->p_parent, "trying to reuse free vout");
-
+    if (cfg->vout == NULL) {
         cfg_buf = *cfg;
         cfg_buf.vout = p_resource->p_vout_free;
         p_resource->p_vout_free = NULL;
         cfg = &cfg_buf;
 
+        if (cfg_buf.vout == NULL) {
+            cfg_buf.vout = vout = vout_Create(p_resource->p_parent);
+            if (vout == NULL)
+                goto out;
+        } else
+            msg_Dbg(p_resource->p_parent, "trying to reuse free vout");
     }  else if (cfg->vout != NULL) {
         assert(cfg->vout != p_resource->p_vout_free);
 
@@ -415,6 +419,7 @@ vout_thread_t *input_resource_GetVout(input_resource_t *p_resource,
                     .vout = vout,
                 });
     }
+out:
     vlc_mutex_unlock( &p_resource->lock );
     return vout;
 }
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index f1cf88830f..9590bec70b 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1652,7 +1652,7 @@ static void VoutDestructor(vlc_object_t *object)
     video_format_Clean(&vout->p->original);
 }
 
-static vout_thread_t *VoutCreate(vlc_object_t *object)
+vout_thread_t *vout_Create(vlc_object_t *object)
 {
     /* Allocate descriptor */
     vout_thread_t *vout = vlc_custom_create(object,
@@ -1769,7 +1769,7 @@ vout_thread_t *vout_Request(vlc_object_t *object,
 
         vout_ReinitInterlacingSupport(vout);
     } else {
-        vout = VoutCreate(object);
+        vout = vout_Create(object);
         if (vout == NULL)
             return NULL;
     }
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index e51ed7acaf..37d20844dd 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -178,6 +178,11 @@ struct vout_thread_sys_t
 };
 
 /**
+ * Creates a video output.
+ */
+vout_thread_t *vout_Create(vlc_object_t *obj) VLC_USED;
+
+/**
  * Returns a suitable vout or release the given one.
  *
  * If cfg->fmt is non NULL and valid, a vout will be returned, reusing cfg->vout



More information about the vlc-commits mailing list