[vlc-devel] [PATCH 1/3] mmal/vout: Configure latency target

Julian Scheel julian at jusst.de
Fri Aug 29 09:25:19 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/hw/mmal/vout.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index c58fd89..db0cb85 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -153,6 +153,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;
@@ -202,6 +212,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.1.0




More information about the vlc-devel mailing list