summaryrefslogtreecommitdiff
path: root/glcapture.c
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2017-01-22 22:26:37 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2017-01-22 22:26:37 +0200
commitca9cb0ca289575e0224e5359046ee924e46e710d (patch)
treed8bfb5970460038b02351a9e81256dac9e58dc2d /glcapture.c
parent8f4379c29d4cbae652f74bb9eb4fa935f542d826 (diff)
Synchronize to single base time
Audio / Video can now delay by any amount but still be in sync.
Diffstat (limited to 'glcapture.c')
-rw-r--r--glcapture.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/glcapture.c b/glcapture.c
index 1907ef6..6df1d7d 100644
--- a/glcapture.c
+++ b/glcapture.c
@@ -93,9 +93,9 @@ struct frame_info {
struct fifo {
struct {
struct frame_info info;
- uint64_t base;
bool ready;
} stream[STREAM_LAST];
+ uint64_t base;
size_t size;
int fd;
bool created;
@@ -196,13 +196,14 @@ write_data_unsafe(struct fifo *fifo, const struct frame_info *info, const void *
WARNX("stream ready, writing headers");
write(fifo->fd, header, (p + 1) - header);
+ fifo->base = get_time_ns();
}
- if (!fifo->stream[info->stream].base)
- fifo->stream[info->stream].base = info->ts;
+ if (fifo->base > info->ts)
+ return;
const uint64_t rate = 1e9 / (info->stream == STREAM_VIDEO ? info->video.fps : info->audio.rate);
- const uint64_t pts = (info->ts - fifo->stream[info->stream].base) / rate;
+ const uint64_t pts = (info->ts - fifo->base) / rate;
uint8_t frame[] = {
info->stream,