[xiph-cvs] r6563 - in trunk/ezstream: . src

oddsock at xiph.org oddsock at xiph.org
Tue May 4 21:24:21 PDT 2004



Author: oddsock
Date: 2004-04-21 09:48:22 -0400 (Wed, 21 Apr 2004)
New Revision: 6563

Removed:
   trunk/ezstream/src/.deps/
Modified:
   trunk/ezstream/configure.in
   trunk/ezstream/src/ezstream.c
Log:
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.

<p>Modified: trunk/ezstream/configure.in
===================================================================
--- trunk/ezstream/configure.in	2004-04-21 01:58:27 UTC (rev 6562)
+++ trunk/ezstream/configure.in	2004-04-21 13:48:22 UTC (rev 6563)
@@ -1,4 +1,4 @@
-AC_INIT([ezstream], [0.1.1], [icecast at xiph.org])
+AC_INIT([ezstream], [0.1.2], [icecast at xiph.org])
 
 AC_PREREQ(2.54)
 AC_CONFIG_SRCDIR(src/ezstream.c)

Modified: trunk/ezstream/src/ezstream.c
===================================================================
--- trunk/ezstream/src/ezstream.c	2004-04-21 01:58:27 UTC (rev 6562)
+++ trunk/ezstream/src/ezstream.c	2004-04-21 13:48:22 UTC (rev 6563)
@@ -12,7 +12,18 @@
 #include "configfile.h"
 
 EZCONFIG	*pezConfig = NULL;
+int rereadPlaylist = 0;
 
+#ifndef WIN32
+#include <signal.h>
+
+void hup_handler(int sig) 
+{
+	rereadPlaylist = 1;	
+	printf("Will reread the playlist on next song\n");
+}
+#endif
+
 typedef struct tag_ID3Tag {
         char tag[3];
         char trackName[30];
@@ -139,6 +150,7 @@
 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 @@
                                 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 @@
 
 
         pezConfig = getEZConfig();
+#ifndef WIN32
+	signal(SIGHUP, hup_handler);
+#endif
 
         shout_init();
 

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list