avdevice: use av_gettime_relative() for elapsed time calculations

av_gettime_relative() is using the monotonic clock therefore more suitable for
elapsed time calculations. Packet timestamps are still kept absolute, although
that should be configurable in the future.

Related to ticket #9089.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2021-02-07 00:55:25 +01:00
parent 529bf5daf2
commit 2d32aed85c
5 changed files with 15 additions and 13 deletions

View file

@ -268,7 +268,7 @@ static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt)
int64_t now;
int err;
now = av_gettime();
now = av_gettime_relative();
if (ctx->frame_last) {
int64_t delay;
while (1) {
@ -276,10 +276,11 @@ static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt)
if (delay <= 0)
break;
av_usleep(delay);
now = av_gettime();
now = av_gettime_relative();
}
}
ctx->frame_last = now;
now = av_gettime();
plane = drmModeGetPlane(ctx->hwctx->fd, ctx->plane_id);
if (!plane) {