From 322b88412f6a595b1018496e39edc36f5595a60a Mon Sep 17 00:00:00 2001 From: moritz Date: Sat, 29 Aug 2009 09:14:12 +0000 Subject: [PATCH] ... also fix ezstream in this regard: No need to complain when receiving such an empty line, and not receiving any output should not be a fatal error. Consider the latter to be "end-of-playlist", too. git-svn-id: https://svn.xiph.org/trunk/ezstream@16526 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- NEWS | 5 +++++ src/playlist.c | 23 +++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index d52b4b8..5d43f0b 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,11 @@ Changes in 0.5.6, released on XXXX-XX-XX: Failure to open a resource (e.g. a media file) is no longer fatal and operation will continue as far as possible. Idea from dhorton. (Ticket #1585) + * src/playlist.c: + - [MISC] Consider no output from a playlist program to be equivalent to an + empty line, indicating that the end of the playlist is reached. + - [FIX] Do not complain when receiving an empty line from a playlist + program. * examples/: - [NEW] Add a real-world example playlist script with logging feature. diff --git a/src/playlist.c b/src/playlist.c index 3ac461c..7234283 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -499,13 +499,18 @@ playlist_run_program(playlist_t *pl) } if (fgets(buf, (int)sizeof(buf), filep) == NULL) { - if (ferror(filep)) - printf("%s: Error while reading output from program '%s': %s\n", - __progname, pl->filename, strerror(errno)); + int errnum = errno; + pclose(filep); - printf("%s: FATAL: External program '%s' not (or no longer) usable.\n", - __progname, pl->filename); - exit(1); + + if (ferror(filep)) { + printf("%s: Error while reading output from program '%s': %s\n", + __progname, pl->filename, strerror(errnum)); + exit(1); + } + + /* No output (end of playlist.) */ + return (NULL); } pclose(filep); @@ -518,11 +523,9 @@ playlist_run_program(playlist_t *pl) buf[strcspn(buf, "\n")] = '\0'; buf[strcspn(buf, "\r")] = '\0'; - if (buf[0] == '\0') { - printf("%s: Empty line received from program '%s'\n", - __progname, pl->filename); + if (buf[0] == '\0') + /* Empty line (end of playlist.) */ return (NULL); - } if (pl->prog_track != NULL) xfree(pl->prog_track);