[vlc-commits] [Git][videolan/vlc][master] 2 commits: display: use vlc_module_match()

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Sat Jan 15 09:27:20 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
e9877f68 by Rémi Denis-Courmont at 2022-01-15T08:39:58+00:00
display: use vlc_module_match()

...instead of vlc_module_load(). No functional changes.

- - - - -
658ee05f by Rémi Denis-Courmont at 2022-01-15T08:39:58+00:00
display: try next module if conversion fails

After a display module initialises succesfully, a conversion filter
chain must be built from the source format to the display format.
Currently, this is effectively assumed to succeed. When it fails,
the display module is closed and display creation is given up entirely.

However most display plugins accept practically any source format that
is thrown at them, with little or no consideration for the possibility
of conversion chain failure.

After closing the unusable display module, with this change, the next
display module in decreasing priority is tried.

- - - - -


1 changed file:

- src/video_output/display.c


Changes:

=====================================
src/video_output/display.c
=====================================
@@ -254,25 +254,6 @@ typedef struct {
     picture_pool_t *pool;
 } vout_display_priv_t;
 
-static int vout_display_start(void *func, bool forced, va_list ap)
-{
-    vout_display_open_cb activate = func;
-    vout_display_priv_t *osys = va_arg(ap, vout_display_priv_t *);
-    vout_display_t *vd = &osys->display;
-    vlc_video_context *context = osys->src_vctx;
-
-    /* Picture buffer does not have the concept of aspect ratio */
-    video_format_Copy(&osys->display_fmt, vd->source);
-    vd->obj.force = forced; /* TODO: pass to activate() instead? */
-
-    int ret = activate(vd, &osys->display_fmt, context);
-    if (ret != VLC_SUCCESS) {
-        video_format_Clean(&osys->display_fmt);
-        vlc_objres_clear(VLC_OBJECT(vd));
-    }
-    return ret;
-}
-
 static vlc_decoder_device * DisplayHoldDecoderDevice(vlc_object_t *o, void *sys)
 {
     VLC_UNUSED(o);
@@ -674,19 +655,45 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
     if (owner)
         vd->owner = *owner;
 
-    if (vlc_module_load(vd, "vout display", module, module && *module != '\0',
-                        vout_display_start, osys) == NULL)
-        goto error;
+    if (module == NULL || module[0] == '\0')
+        module = "any";
+
+    module_t **mods;
+    size_t strict;
+    ssize_t n = vlc_module_match("vout display", module, true, &mods, &strict);
+
+    msg_Dbg(vd, "looking for %s module matching \"%s\": %zd candidates",
+            "vout display", module, n);
+
+    for (ssize_t i = 0; i < n; i++) {
+        vout_display_open_cb cb = vlc_module_map(vlc_object_logger(vd),
+                                                 mods[i]);
+        if (cb == NULL)
+            continue;
+
+        /* Picture buffer does not have the concept of aspect ratio */
+        video_format_Copy(&osys->display_fmt, vd->source);
+        vd->obj.force = i < (ssize_t)strict; /* TODO: pass to cb() instead? */
+
+        int ret = cb(vd, &osys->display_fmt, vctx);
+        if (ret == VLC_SUCCESS) {
+            if (VoutDisplayCreateRender(vd) == 0) {
+                msg_Dbg(vd, "using %s module \"%s\"", "vout display",
+                        module_get_object(mods[i]));
+                free(mods);
+                return vd;
+            }
+
+            if (vd->ops->close != NULL)
+                vd->ops->close(vd);
+        }
 
-    if (VoutDisplayCreateRender(vd)) {
-        if (vd->ops->close != NULL)
-            vd->ops->close(vd);
         vlc_objres_clear(VLC_OBJECT(vd));
         video_format_Clean(&osys->display_fmt);
-        goto error;
     }
-    return vd;
-error:
+
+    msg_Dbg(vd, "no %s modules matched with name %s", "vout display", module);
+    free(mods);
     video_format_Clean(&osys->source);
     vlc_object_delete(vd);
     return NULL;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1bc3b6160a1d6aed8d32ccf2fe5545881df35121...658ee05f78e475fde7da07e21b1522200b970863

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1bc3b6160a1d6aed8d32ccf2fe5545881df35121...658ee05f78e475fde7da07e21b1522200b970863
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list