From: Andre Noll Date: Sun, 5 Jul 2009 08:44:23 +0000 (+0200) Subject: gui: Use variable-sized input buffer for the audiod pipe. X-Git-Tag: v0.4.0~64 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=bced94f9f81fdf355b61738e968aa8b61bfc36e7 gui: Use variable-sized input buffer for the audiod pipe. The previous fixed size of 8192 might be too small if the audio file contains large tags. OTOH, 8192 is much too large for the bulk of all audio files. So use a small buffer that gets increased on demand. --- diff --git a/gui.c b/gui.c index 6806cc8f..21770ca8 100644 --- 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;