Skip to content

dispmanx vsync callback is called 4 times per frame #218

Closed
@ali1234

Description

@ali1234

The following example runs for 1 second and measures the time between calls to the vsync callback in microseconds. With PAL composite out, the time between each call should be 20000 microseconds if the vsync happens per field.

The callback fires correctly about 20 times, then it starts firing 4 times per field. Same happens when using HDMI output.

Test code:

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
#include <assert.h>
#include <unistd.h>
#include <sys/time.h>

#include "bcm_host.h"

static DISPMANX_DISPLAY_HANDLE_T   display;
unsigned long lasttime = 0;

void vsync(DISPMANX_UPDATE_HANDLE_T u, void* arg) {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    unsigned long microseconds = (tv.tv_sec*1000000)+tv.tv_usec;
    printf("sync %lu\n", microseconds-lasttime);
    lasttime = microseconds;
}

int main(void)
{
    bcm_host_init();
    display = vc_dispmanx_display_open( 0 );

    vc_dispmanx_vsync_callback(display, vsync, NULL);
    sleep(1);
    vc_dispmanx_vsync_callback(display, NULL, NULL); // disable callback

    vc_dispmanx_display_close( display );
    return 0;
}

Output:

sync 1084946804
sync 19968
sync 19949
sync 20027
sync 19964
sync 20056
sync 19934
sync 20069
sync 19936
sync 20026
sync 19992
sync 20050
sync 19945
sync 20019
sync 19989
sync 20031
sync 19934
sync 20025
sync 19978
sync 20053
sync 19974
sync 20070
sync 200
sync 136
sync 56
sync 19585
sync 202
sync 137
sync 56
sync 19610
sync 202
sync 135
sync 55
sync 19574
sync 206
sync 137
sync 50
sync 19665
sync 194
sync 132
sync 56
sync 19561
sync 203
sync 137
sync 52
sync 19638
sync 203
sync 136
sync 52
sync 19600
sync 203
sync 132
sync 52
sync 19624
sync 200
sync 138
sync 52
sync 19573
sync 203
sync 135
sync 52
sync 19664
sync 200
sync 137
sync 56
sync 19565
sync 203
sync 132
sync 53
sync 19630
sync 202
sync 134
sync 52
sync 19603
sync 200
sync 133
sync 52
sync 19632
sync 203
sync 136
sync 52
sync 19572
sync 197
sync 139
sync 52
sync 19671
sync 200
sync 134
sync 53
sync 19561
sync 198
sync 138
sync 52
sync 19634
sync 200
sync 135
sync 52
sync 19612
sync 204
sync 134
sync 54
sync 19618
sync 202
sync 131
sync 52
sync 19579
sync 197
sync 136
sync 54
sync 19669
sync 202
sync 134
sync 52
sync 19563
sync 195
sync 135
sync 54
sync 19640
sync 198
sync 134
sync 51
sync 19608
sync 199
sync 142
sync 52
sync 19622
sync 204
sync 135
sync 52
sync 19568
sync 198
sync 134
sync 55
sync 19655
sync 202
sync 133
sync 52

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions