summaryrefslogtreecommitdiff
path: root/audio/cava/files/patch-input_sndio.c
blob: 2e0d49c01f4f1f5e267e6e5f64897d5ae71cf97b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Stop using uninitialized variable after lazy refactoring upstream

--- input/sndio.c.orig	2020-05-29 23:20:44 UTC
+++ input/sndio.c
@@ -8,14 +8,13 @@ void *input_sndio(void *data) {
     struct sio_par par;
     struct sio_hdl *hdl;
     int16_t buf[256];
-    unsigned int channels;
 
     sio_initpar(&par);
     par.sig = 1;
     par.bits = 16;
     par.le = 1;
     par.rate = 44100;
-    par.rchan = 2;
+    par.rchan = audio->channels;
     par.appbufsz = sizeof(buf) / par.rchan;
 
     if ((hdl = sio_open(audio->source, SIO_REC, 0)) == NULL) {
@@ -34,7 +33,7 @@ void *input_sndio(void *data) {
         exit(EXIT_FAILURE);
     }
 
-    uint16_t frames = (sizeof(buf) / sizeof(buf[0])) / channels;
+    uint16_t frames = (sizeof(buf) / sizeof(buf[0])) / audio->channels;
     while (audio->terminate != 1) {
         if (sio_read(hdl, buf, sizeof(buf)) == 0) {
             fprintf(stderr, __FILE__ ": sio_read() failed: %s\n", strerror(errno));