[vlc-devel] [PATCH 1/6] video_output/mmal: Configure latency target

Julian Scheel julian at jusst.de
Thu Jun 19 11:22:16 CEST 2014


The mmal video_render element allows to configure a latency target. Although
the parameter is named AUDIO_LATENCY_TARGET it is not actually related to
audio but synchronizes frame draws with hdmi vsync. It tries to center the
updates in the vsync period so that no frames are duplicated or dropped.

Signed-off-by: Julian Scheel <julian at jusst.de>
---
 modules/video_output/mmal.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/modules/video_output/mmal.c b/modules/video_output/mmal.c
index b8ca3e1..93c32cf 100644
--- a/modules/video_output/mmal.c
+++ b/modules/video_output/mmal.c
@@ -161,6 +161,16 @@ static void show_background(vout_display_t *vd, bool enable);
 
 static int Open(vlc_object_t *object)
 {
+    MMAL_PARAMETER_AUDIO_LATENCY_TARGET_T latency_target = {
+        .hdr = { MMAL_PARAMETER_AUDIO_LATENCY_TARGET, sizeof(latency_target) },
+        .enable = MMAL_TRUE,
+        .filter = 2,
+        .target = 4000,
+        .shift = 3,
+        .speed_factor = -135,
+        .inter_factor = 500,
+        .adj_cap = 20
+    };
     vout_display_t *vd = (vout_display_t *)object;
     vout_display_sys_t *sys;
     uint32_t buffer_pitch, buffer_height;
@@ -210,6 +220,15 @@ static int Open(vlc_object_t *object)
 
     sys->input = sys->component->input[0];
     sys->input->userdata = (struct MMAL_PORT_USERDATA_T *)vd;
+
+    status = mmal_port_parameter_set(sys->input, &latency_target.hdr);
+    if (status != MMAL_SUCCESS) {
+        msg_Err(vd, "Failed to configure latency target on input port %s (status=%"PRIx32" %s)",
+                        sys->input->name, status, mmal_status_to_string(status));
+        ret = VLC_EGENERIC;
+        goto out;
+    }
+
     if (sys->opaque)
         sys->input->format->encoding = MMAL_ENCODING_OPAQUE;
     else
-- 
2.0.0




More information about the vlc-devel mailing list