[vlc-devel] [PATCH 14/42] video_output: add vout_ChangeSource to set a new source for the display

Steve Lhomme robux4 at ycbcr.xyz
Wed Oct 16 16:58:49 CEST 2019


It may not work, in which case a new display/thread should be created to handle
the new format.

No functional changes.
---
 src/video_output/video_output.c  | 31 ++++++++++++++++++++++---------
 src/video_output/vout_internal.h |  8 ++++++++
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 32586291455..48b416043c0 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1944,6 +1944,24 @@ vout_thread_t *vout_Hold(vout_thread_t *vout)
     return vout;
 }
 
+int vout_ChangeSource( vout_thread_t *vout, const video_format_t *original, unsigned dpb_size )
+{
+    vout_thread_sys_t *sys = vout->p;
+
+     /* TODO: If dimensions are equal or slightly smaller, update the aspect
+     * ratio and crop settings, instead of recreating a display.
+     */
+    if (video_format_IsSimilar(original, &sys->original)) {
+        if (dpb_size <= sys->dpb_size) {
+            /* It is assumed that the SPU input matches input already. */
+            return 0;
+        }
+        msg_Warn(vout, "DPB need to be increased");
+    }
+
+    return -1;
+}
+
 static int vout_EnableWindow(const vout_configuration_t *cfg, const video_format_t *original,
                              vlc_decoder_device **pp_dec_device)
 {
@@ -2002,15 +2020,10 @@ int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device *dec_dev, i
     video_format_t original;
     VoutFixFormat(&original, cfg->fmt);
 
-    /* TODO: If dimensions are equal or slightly smaller, update the aspect
-     * ratio and crop settings, instead of recreating a display.
-     */
-    if (video_format_IsSimilar(&original, &sys->original)) {
-        if (cfg->dpb_size <= sys->dpb_size) {
-            video_format_Clean(&original);
-            return 0;
-        }
-        msg_Warn(vout, "DPB need to be increased");
+    if (vout_ChangeSource(vout, &original, cfg->dpb_size) == 0)
+    {
+        video_format_Clean(&original);
+        return 0;
     }
 
     if (vout_EnableWindow(cfg, &original, NULL) != 0)
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 713751c26d7..747f8934f71 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -242,6 +242,14 @@ void vout_StopDisplay(vout_thread_t *);
  */
 void vout_Close( vout_thread_t *p_vout );
 
+/**
+ * Set the new source format for a started vout
+ *
+ * \retval 0 on success
+ * \retval -1 on error, the vout needs to be restarted to handle the format
+ */
+int vout_ChangeSource( vout_thread_t *p_vout, const video_format_t *fmt, unsigned dpb_size );
+
 /* TODO to move them to vlc_vout.h */
 void vout_ChangeFullscreen(vout_thread_t *, const char *id);
 void vout_ChangeWindowed(vout_thread_t *);
-- 
2.17.1



More information about the vlc-devel mailing list