[xiph-commits] r8499 - icecast/trunk/ices0/src/playlist

brendan at motherfish-iii.xiph.org brendan at motherfish-iii.xiph.org
Sun Dec 19 21:00:30 PST 2004


Author: brendan
Date: 2004-12-19 21:00:29 -0800 (Sun, 19 Dec 2004)
New Revision: 8499

Modified:
   icecast/trunk/ices0/src/playlist/pm_builtin.c
Log:
Reshuffle playlist when the end of the shuffled version is reached,
picking up any changes.


Modified: icecast/trunk/ices0/src/playlist/pm_builtin.c
===================================================================
--- icecast/trunk/ices0/src/playlist/pm_builtin.c	2004-12-19 23:02:49 UTC (rev 8498)
+++ icecast/trunk/ices0/src/playlist/pm_builtin.c	2004-12-20 05:00:29 UTC (rev 8499)
@@ -1,7 +1,7 @@
 /* playlist_text.c
  * - Module for simple playlist
  * Copyright (c) 2000 Alexander Haväng
- * Copyright (c) 2001 Brendan Cully
+ * Copyright (c) 2001-4 Brendan Cully
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -72,6 +72,7 @@
   char *out;
   static int level = 0;
   struct stat st;
+  FILE* tmpfp;
 
   /* If the original playlist has changed on disk (and we are not
    * randomising) reload it. */
@@ -82,9 +83,23 @@
     return NULL;
 
   if (feof (fp)) {
-    ices_log_debug ("Reached end of playlist, rewinding");
     lineno = 0;
-    rewind (fp);
+    /* might as well rererandomize here (and pick up any changes) */
+    if (ices_config.pm.randomize) {
+      ices_log_debug ("Reshuffling playlist");
+      tmpfp = fp;
+      if (playlist_builtin_open_playlist(&ices_config.pm)) {
+	playlist_builtin_shuffle_playlist();
+	ices_util_fclose(tmpfp);
+      } else {
+	ices_log_debug("Reshuffling failed, rewinding old list");
+	fp = tmpfp;
+	rewind(fp);
+      }
+    } else {
+      ices_log_debug ("Reached end of playlist, rewinding");
+      rewind (fp);
+    }
   }
 
   if (! (out = ices_util_read_line (fp)))



More information about the commits mailing list