aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sio.c7
-rw-r--r--sio.h2
-rw-r--r--spectrogram.c2
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);