From 0e0e2b41fb5a372a8f0714efed29bd1c75d8a0a1 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 3 Sep 2013 01:12:40 +0000 Subject: move rounds to read into read_sio --- sio.c | 7 +++---- sio.h | 2 +- spectrogram.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sio.c b/sio.c index 7f388e4..a7d520f 100644 --- a/sio.c +++ b/sio.c @@ -31,7 +31,6 @@ struct sio { int16_t *buffer; size_t bufsz; size_t round; - size_t roundsz; }; struct sio * @@ -68,7 +67,6 @@ init_sio() errx(1, "unsupported audio params"); sio->round = ROUND; - sio->roundsz = sio->round * sio->par.rchan * sizeof(int16_t); bufsz = sio->par.rate / FPS; /* 24 pictures/second */ bufsz -= bufsz % sio->par.round; /* round to block size */ @@ -92,11 +90,12 @@ get_round(struct sio *sio) } int16_t * -read_sio(struct sio *sio) +read_sio(struct sio *sio, size_t n) { int done = 0; char *buffer = (char *)sio->buffer; size_t sz = sio->bufsz; + size_t roundsz = n * sio->par.rchan * sizeof(int16_t); do { done = sio_read(sio->sio, buffer, sz); @@ -110,7 +109,7 @@ read_sio(struct sio *sio) * return a pointer to the latest ROUND samples (the most recent * ones) to minimize latency between picture and sound */ - return (int16_t *)(buffer - sio->roundsz); + return (int16_t *)(buffer - roundsz); } void diff --git a/sio.h b/sio.h index 40d7793..7e085d8 100644 --- a/sio.h +++ b/sio.h @@ -22,7 +22,7 @@ struct sio; struct sio *init_sio(void); unsigned int get_round(struct sio *); -int16_t *read_sio(struct sio *); +int16_t *read_sio(struct sio *, size_t); void del_sio(struct sio *); #endif diff --git a/spectrogram.c b/spectrogram.c index d8f4bb3..5d34687 100644 --- a/spectrogram.c +++ b/spectrogram.c @@ -403,7 +403,7 @@ main(int argc, char **argv) XMapWindow(dsp, win); while (!die) { - buffer = read_sio(sio); + buffer = read_sio(sio, delta); dofft(fft, buffer, left->data, 0); dofft(fft, buffer, right->data, 1); -- cgit v1.2.3