diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2017-01-26 11:01:06 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2017-01-26 11:23:53 +0200 |
commit | c2534ab86610b3c1bccb07ccfecb703b32e33505 (patch) | |
tree | 17d59485b783b3c152f34d7d16f9bd842b2771b6 | |
parent | cd749a6adcc9116190cb42b1937c4d83bdc1ff31 (diff) |
Initialize fifo->base with info->ts
-rw-r--r-- | glcapture.c | 7 |
1 files 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); |