From b3d4ab007276b800413e1c0c1cbe531ff081177b Mon Sep 17 00:00:00 2001 From: ratchov Date: Thu, 14 Aug 2008 09:46:36 +0000 Subject: [PATCH] add a bytes counter to abuf structures to count the number of bytes that entered the FIFO. The counter may overflow, so it should be used with "modulo 2^32" arithmetic. The counter will be used later to synchronize playback to record. No behaviour change. ok jakemsr --- usr.bin/aucat/abuf.c | 4 +++- usr.bin/aucat/abuf.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/aucat/abuf.c b/usr.bin/aucat/abuf.c index a6f2ebc1bc9..e6f4803b382 100644 --- a/usr.bin/aucat/abuf.c +++ b/usr.bin/aucat/abuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: abuf.c,v 1.4 2008/08/14 09:44:15 ratchov Exp $ */ +/* $OpenBSD: abuf.c,v 1.5 2008/08/14 09:46:36 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -61,6 +61,7 @@ abuf_new(unsigned nfr, unsigned bpf) buf->len = len; buf->used = 0; buf->start = 0; + buf->abspos = 0; buf->silence = 0; buf->drop = 0; buf->rproc = NULL; @@ -113,6 +114,7 @@ abuf_rdiscard(struct abuf *buf, unsigned count) buf->start += count; if (buf->start >= buf->len) buf->start -= buf->len; + buf->abspos += count; } /* diff --git a/usr.bin/aucat/abuf.h b/usr.bin/aucat/abuf.h index 860a6c5be6b..71be396016b 100644 --- a/usr.bin/aucat/abuf.h +++ b/usr.bin/aucat/abuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: abuf.h,v 1.6 2008/08/14 09:44:15 ratchov Exp $ */ +/* $OpenBSD: abuf.h,v 1.7 2008/08/14 09:46:36 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -49,6 +49,7 @@ struct abuf { unsigned start; /* offset where data starts */ unsigned used; /* valid data */ unsigned len; /* size of the ring */ + unsigned abspos; /* frame number of the start position */ unsigned silence; /* silence to insert on next write */ unsigned drop; /* frames to drop on next read */ struct aproc *rproc; /* reader */ -- 2.20.1