From c2534ab86610b3c1bccb07ccfecb703b32e33505 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Thu, 26 Jan 2017 11:01:06 +0200 Subject: Initialize fifo->base with info->ts --- glcapture.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/glcapture.c b/glcapture.c index 751f9f6..5ecb574 100644 --- a/glcapture.c +++ b/glcapture.c @@ -271,7 +271,7 @@ check_and_prepare_stream(struct fifo *fifo, const struct frame_info *info) if (!write_rawmux_header(fifo)) return false; - fifo->base = get_time_ns(); + fifo->base = info->ts; } return true; @@ -280,13 +280,12 @@ check_and_prepare_stream(struct fifo *fifo, const struct frame_info *info) static void write_data_unsafe(struct fifo *fifo, const struct frame_info *info, const void *buffer, const size_t size) { - if (!check_and_prepare_stream(fifo, info)) + if (!check_and_prepare_stream(fifo, info) || info->ts < fifo->base) return; - const uint64_t ts = (fifo->base > info->ts ? fifo->base : info->ts); const uint64_t den[STREAM_LAST] = { 1e6, 1e9 }; const uint64_t rate = (info->stream == STREAM_VIDEO ? info->video.fps : info->audio.rate); - const uint64_t pts = (ts - fifo->base) / (den[info->stream] / rate); + const uint64_t pts = (info->ts - fifo->base) / (den[info->stream] / rate); #if 0 WARNX("PTS: (%u) %llu", info->stream, pts); -- cgit v1.2.3-70-g09d2