]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - gui.c
gui: Use variable-sized input buffer for the audiod pipe.
[paraslash.git] / gui.c
diff --git a/gui.c b/gui.c
index 6806cc8fcc662435cf53a3c01a7b1f6b4607386f..21770ca86a368e177b5d9923f51743fe1932999c 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -682,13 +682,20 @@ static int update_item(int item_num, char *buf)
 
 static int read_audiod_pipe(int fd)
 {
-       static char buf[8192];
-       static int loaded;
+       static char *buf;
+       static int bufsize, loaded;
        int ret;
 
-       if (loaded >= sizeof(buf)) /* overflow */
-               return 0;
-       ret = read(fd, buf + loaded, sizeof(buf) - loaded);
+       if (loaded >= bufsize) {
+               if (bufsize > 1000 * 1000) {
+                       loaded = 0;
+                       return 0;
+               }
+               bufsize += bufsize + 1000;
+               buf = para_realloc(buf, bufsize);
+       }
+       assert(loaded < bufsize);
+       ret = read(fd, buf + loaded, bufsize - loaded);
        if (ret <= 0)
                return ret;
        loaded += ret;