From b85a6a2ca35dc5dfd43aa4e4fe8d2d672fead80e Mon Sep 17 00:00:00 2001 From: oddsock Date: Wed, 21 Apr 2004 13:48:22 +0000 Subject: [PATCH] added ability to send a signal (SIGHUP) which will re-read the current playlist (m3u) that is being processed. When this happens, ezstream will pick up from the last track that was played. git-svn-id: https://svn.xiph.org/trunk/ezstream@6563 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- configure.in | 2 +- src/.deps/configfile.Po | 143 -------------------------------------- src/.deps/ezstream.Po | 148 ---------------------------------------- src/ezstream.c | 49 +++++++++++++ 4 files changed, 50 insertions(+), 292 deletions(-) delete mode 100644 src/.deps/configfile.Po delete mode 100644 src/.deps/ezstream.Po diff --git a/configure.in b/configure.in index 4ceb590..62eac44 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -AC_INIT([ezstream], [0.1.1], [icecast@xiph.org]) +AC_INIT([ezstream], [0.1.2], [icecast@xiph.org]) AC_PREREQ(2.54) AC_CONFIG_SRCDIR(src/ezstream.c) diff --git a/src/.deps/configfile.Po b/src/.deps/configfile.Po deleted file mode 100644 index 7f7f82a..0000000 --- a/src/.deps/configfile.Po +++ /dev/null @@ -1,143 +0,0 @@ -configfile.o: configfile.c /usr/include/string.h /usr/include/features.h \ - /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ - /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ - /usr/include/bits/string.h /usr/include/bits/string2.h \ - /usr/include/endian.h /usr/include/bits/endian.h \ - /usr/include/bits/types.h /usr/include/bits/wordsize.h \ - /usr/include/bits/typesizes.h /usr/include/stdlib.h configfile.h \ - /usr/include/libxml2/libxml/parser.h \ - /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ - /usr/include/libxml2/libxml/xmlversion.h \ - /usr/include/libxml2/libxml/xmlexports.h \ - /usr/include/libxml2/libxml/tree.h /usr/include/stdio.h \ - /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ - /usr/include/bits/wchar.h /usr/include/gconv.h \ - /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ - /usr/include/bits/stdio.h /usr/include/libxml2/libxml/xmlregexp.h \ - /usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \ - /usr/include/libxml2/libxml/valid.h \ - /usr/include/libxml2/libxml/xmlerror.h \ - /usr/include/libxml2/libxml/list.h \ - /usr/include/libxml2/libxml/xmlautomata.h \ - /usr/include/libxml2/libxml/entities.h \ - /usr/include/libxml2/libxml/encoding.h /usr/include/iconv.h \ - /usr/include/libxml2/libxml/xmlIO.h \ - /usr/include/libxml2/libxml/globals.h /usr/include/libxml2/libxml/SAX.h \ - /usr/include/sys/types.h /usr/include/time.h /usr/include/sys/select.h \ - /usr/include/bits/select.h /usr/include/bits/sigset.h \ - /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ - /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ - /usr/include/alloca.h /usr/include/libxml2/libxml/xlink.h \ - /usr/include/libxml2/libxml/SAX2.h \ - /usr/include/libxml2/libxml/xmlmemory.h \ - /usr/include/libxml2/libxml/threads.h - -/usr/include/string.h: - -/usr/include/features.h: - -/usr/include/sys/cdefs.h: - -/usr/include/gnu/stubs.h: - -/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h: - -/usr/include/bits/string.h: - -/usr/include/bits/string2.h: - -/usr/include/endian.h: - -/usr/include/bits/endian.h: - -/usr/include/bits/types.h: - -/usr/include/bits/wordsize.h: - -/usr/include/bits/typesizes.h: - -/usr/include/stdlib.h: - -configfile.h: - -/usr/include/libxml2/libxml/parser.h: - -/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h: - -/usr/include/libxml2/libxml/xmlversion.h: - -/usr/include/libxml2/libxml/xmlexports.h: - -/usr/include/libxml2/libxml/tree.h: - -/usr/include/stdio.h: - -/usr/include/libio.h: - -/usr/include/_G_config.h: - -/usr/include/wchar.h: - -/usr/include/bits/wchar.h: - -/usr/include/gconv.h: - -/usr/include/bits/stdio_lim.h: - -/usr/include/bits/sys_errlist.h: - -/usr/include/bits/stdio.h: - -/usr/include/libxml2/libxml/xmlregexp.h: - -/usr/include/libxml2/libxml/dict.h: - -/usr/include/libxml2/libxml/hash.h: - -/usr/include/libxml2/libxml/valid.h: - -/usr/include/libxml2/libxml/xmlerror.h: - -/usr/include/libxml2/libxml/list.h: - -/usr/include/libxml2/libxml/xmlautomata.h: - -/usr/include/libxml2/libxml/entities.h: - -/usr/include/libxml2/libxml/encoding.h: - -/usr/include/iconv.h: - -/usr/include/libxml2/libxml/xmlIO.h: - -/usr/include/libxml2/libxml/globals.h: - -/usr/include/libxml2/libxml/SAX.h: - -/usr/include/sys/types.h: - -/usr/include/time.h: - -/usr/include/sys/select.h: - -/usr/include/bits/select.h: - -/usr/include/bits/sigset.h: - -/usr/include/bits/time.h: - -/usr/include/sys/sysmacros.h: - -/usr/include/bits/pthreadtypes.h: - -/usr/include/bits/sched.h: - -/usr/include/alloca.h: - -/usr/include/libxml2/libxml/xlink.h: - -/usr/include/libxml2/libxml/SAX2.h: - -/usr/include/libxml2/libxml/xmlmemory.h: - -/usr/include/libxml2/libxml/threads.h: diff --git a/src/.deps/ezstream.Po b/src/.deps/ezstream.Po deleted file mode 100644 index a57a073..0000000 --- a/src/.deps/ezstream.Po +++ /dev/null @@ -1,148 +0,0 @@ -ezstream.o: ezstream.c /usr/include/stdio.h /usr/include/features.h \ - /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ - /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ - /usr/include/bits/types.h /usr/include/bits/wordsize.h \ - /usr/include/bits/typesizes.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ - /usr/include/gconv.h \ - /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ - /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ - /usr/include/bits/stdio.h /usr/include/stdlib.h \ - /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/sys/select.h \ - /usr/include/bits/select.h /usr/include/bits/sigset.h \ - /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ - /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ - /usr/include/alloca.h /usr/include/string.h /usr/include/bits/string.h \ - /usr/include/bits/string2.h /usr/local/include/shout/shout.h getopt.h \ - configfile.h /usr/include/libxml2/libxml/parser.h \ - /usr/include/libxml2/libxml/xmlversion.h \ - /usr/include/libxml2/libxml/xmlexports.h \ - /usr/include/libxml2/libxml/tree.h \ - /usr/include/libxml2/libxml/xmlregexp.h \ - /usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \ - /usr/include/libxml2/libxml/valid.h \ - /usr/include/libxml2/libxml/xmlerror.h \ - /usr/include/libxml2/libxml/list.h \ - /usr/include/libxml2/libxml/xmlautomata.h \ - /usr/include/libxml2/libxml/entities.h \ - /usr/include/libxml2/libxml/encoding.h /usr/include/iconv.h \ - /usr/include/libxml2/libxml/xmlIO.h \ - /usr/include/libxml2/libxml/globals.h /usr/include/libxml2/libxml/SAX.h \ - /usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \ - /usr/include/libxml2/libxml/xmlmemory.h \ - /usr/include/libxml2/libxml/threads.h - -/usr/include/stdio.h: - -/usr/include/features.h: - -/usr/include/sys/cdefs.h: - -/usr/include/gnu/stubs.h: - -/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h: - -/usr/include/bits/types.h: - -/usr/include/bits/wordsize.h: - -/usr/include/bits/typesizes.h: - -/usr/include/libio.h: - -/usr/include/_G_config.h: - -/usr/include/wchar.h: - -/usr/include/bits/wchar.h: - -/usr/include/gconv.h: - -/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h: - -/usr/include/bits/stdio_lim.h: - -/usr/include/bits/sys_errlist.h: - -/usr/include/bits/stdio.h: - -/usr/include/stdlib.h: - -/usr/include/sys/types.h: - -/usr/include/time.h: - -/usr/include/endian.h: - -/usr/include/bits/endian.h: - -/usr/include/sys/select.h: - -/usr/include/bits/select.h: - -/usr/include/bits/sigset.h: - -/usr/include/bits/time.h: - -/usr/include/sys/sysmacros.h: - -/usr/include/bits/pthreadtypes.h: - -/usr/include/bits/sched.h: - -/usr/include/alloca.h: - -/usr/include/string.h: - -/usr/include/bits/string.h: - -/usr/include/bits/string2.h: - -/usr/local/include/shout/shout.h: - -getopt.h: - -configfile.h: - -/usr/include/libxml2/libxml/parser.h: - -/usr/include/libxml2/libxml/xmlversion.h: - -/usr/include/libxml2/libxml/xmlexports.h: - -/usr/include/libxml2/libxml/tree.h: - -/usr/include/libxml2/libxml/xmlregexp.h: - -/usr/include/libxml2/libxml/dict.h: - -/usr/include/libxml2/libxml/hash.h: - -/usr/include/libxml2/libxml/valid.h: - -/usr/include/libxml2/libxml/xmlerror.h: - -/usr/include/libxml2/libxml/list.h: - -/usr/include/libxml2/libxml/xmlautomata.h: - -/usr/include/libxml2/libxml/entities.h: - -/usr/include/libxml2/libxml/encoding.h: - -/usr/include/iconv.h: - -/usr/include/libxml2/libxml/xmlIO.h: - -/usr/include/libxml2/libxml/globals.h: - -/usr/include/libxml2/libxml/SAX.h: - -/usr/include/libxml2/libxml/xlink.h: - -/usr/include/libxml2/libxml/SAX2.h: - -/usr/include/libxml2/libxml/xmlmemory.h: - -/usr/include/libxml2/libxml/threads.h: diff --git a/src/ezstream.c b/src/ezstream.c index 6616346..a9e0695 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -12,6 +12,17 @@ #include "configfile.h" EZCONFIG *pezConfig = NULL; +int rereadPlaylist = 0; + +#ifndef WIN32 +#include + +void hup_handler(int sig) +{ + rereadPlaylist = 1; + printf("Will reread the playlist on next song\n"); +} +#endif typedef struct tag_ID3Tag { char tag[3]; @@ -139,6 +150,7 @@ int streamFile(shout_t *shout, char *fileName) { int streamPlaylist(shout_t *shout, char *fileName) { FILE *filep = NULL; char streamFileName[8096] = ""; + char lastStreamFileName[8096] = ""; int loop = 1; filep = fopen(fileName, "r"); @@ -152,11 +164,45 @@ int streamPlaylist(shout_t *shout, char *fileName) { fgets(streamFileName, sizeof(streamFileName), filep); streamFileName[strlen(streamFileName)-1] = '\000'; if (strlen(streamFileName) > 0) { + memset(lastStreamFileName, '\000', sizeof(lastStreamFileName)); + strcpy(lastStreamFileName, streamFileName); /* Skip entries that begin with a # */ if (strncmp(streamFileName, "#", 1)) { streamFile(shout, streamFileName); } } + if (rereadPlaylist) { + rereadPlaylist = 0; + fclose(filep); + printf("Reopening playlist\n"); + filep = fopen(fileName, "r"); + if (filep == 0) { + printf("Cannot open %s\n", fileName); + return(0); + } + else { + int loop2 = 1; + printf("Repositioning to (%s)\n", lastStreamFileName); + while (loop2) { + /* If we reach the end before finding + our last spot, we will start over at the + beginning */ + if (feof(filep)) { + loop2 = 0; + } + else { + memset(streamFileName, '\000', sizeof(streamFileName)); + fgets(streamFileName, sizeof(streamFileName), filep); + streamFileName[strlen(streamFileName)-1] = '\000'; + if (!strcmp(streamFileName, lastStreamFileName)) { + /* If we found our last position, then bump out of the loop */ + loop2 = 0; + } + } + } + + } + } } rewind(filep); } @@ -174,6 +220,9 @@ int main(int argc, char **argv) pezConfig = getEZConfig(); +#ifndef WIN32 + signal(SIGHUP, hup_handler); +#endif shout_init();