[xiph-commits] r10089 - trunk/vorbis-tools/ogg123

conrad at svn.xiph.org conrad at svn.xiph.org
Wed Sep 28 10:52:35 PDT 2005


Author: conrad
Date: 2005-09-28 10:52:31 -0700 (Wed, 28 Sep 2005)
New Revision: 10089

Modified:
   trunk/vorbis-tools/ogg123/cmdline_options.c
   trunk/vorbis-tools/ogg123/ogg123.1
   trunk/vorbis-tools/ogg123/ogg123.c
   trunk/vorbis-tools/ogg123/ogg123.h
Log:
add -Z, --random option to ogg123. Equivalent to combination of -z and -r,
and reshuffles before each repetition of the playlist.
Merged patch from tim at tim-landscheidt.de, closes ticket:357.


Modified: trunk/vorbis-tools/ogg123/cmdline_options.c
===================================================================
--- trunk/vorbis-tools/ogg123/cmdline_options.c	2005-09-28 17:29:18 UTC (rev 10088)
+++ trunk/vorbis-tools/ogg123/cmdline_options.c	2005-09-28 17:52:31 UTC (rev 10089)
@@ -49,6 +49,7 @@
     {"nth", required_argument, 0, 'x'},
     {"ntimes", required_argument, 0, 'y'},
     {"shuffle", no_argument, 0, 'z'},
+    {"random", no_argument, 0, 'Z'},
     {"list", required_argument, 0, '@'},
     {"audio-buffer", required_argument, 0, 0},
     {"repeat", no_argument, 0, 'r'},
@@ -79,7 +80,7 @@
   audio_device_t *current;
   int ret;
 
-  while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:hl:k:K:o:p:qrvVx:y:z@:",
+  while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:hl:k:K:o:p:qrvVx:y:zZ@:",
 				  long_options, &option_index))) {
 
       switch (ret) {
@@ -225,6 +226,10 @@
 	ogg123_opts->shuffle = 1;
 	break;
 
+      case 'Z':
+        ogg123_opts->repeat = ogg123_opts->shuffle = 1;
+	break;
+
       case '@':
 	if (playlist_append_from_file(ogg123_opts->playlist, optarg) == 0)
 	  status_error(_("--- Cannot open playlist file %s.  Skipped.\n"),
@@ -343,7 +348,8 @@
 	 _("Playlist options\n"
 	 "  -@ file, --list file    Read playlist of files and URLs from \"file\"\n"
 	 "  -r, --repeat            Repeat playlist indefinitely\n"
-	 "  -z, --shuffle           Shuffle play\n"
+	 "  -z, --shuffle           Shuffle list of files before playing\n"
+	 "  -Z, --random            Play files randomly until interrupted\n"
 	 "\n"));
 
   printf (

Modified: trunk/vorbis-tools/ogg123/ogg123.1
===================================================================
--- trunk/vorbis-tools/ogg123/ogg123.1	2005-09-28 17:29:18 UTC (rev 10088)
+++ trunk/vorbis-tools/ogg123/ogg123.1	2005-09-28 17:52:31 UTC (rev 10089)
@@ -9,7 +9,7 @@
 .SH SYNOPSIS
 .B ogg123 
 [
-.B -vqzVh
+.B -vqrzZVh
 ] [
 .B -k
 .I seconds 
@@ -108,6 +108,8 @@
 Repeat playlist indefinitely.
 .IP "-z, --shuffle"
 Play files in pseudo-random order.
+.IP "-Z, --random"
+Play files in pseudo-random order forever.
 
 .SH DEVICES
 

Modified: trunk/vorbis-tools/ogg123/ogg123.c
===================================================================
--- trunk/vorbis-tools/ogg123/ogg123.c	2005-09-28 17:29:18 UTC (rev 10088)
+++ trunk/vorbis-tools/ogg123/ogg123.c	2005-09-28 17:52:31 UTC (rev 10089)
@@ -76,6 +76,8 @@
    &options.default_device, NULL},
   {0, "shuffle",        N_("shuffle playlist"),      opt_type_bool,
    &options.shuffle,        &int_0},
+  {0, "repeat",         N_("repeat playlist forever"),   opt_type_bool,
+   &options.repeat,         &int_0}, 
   {0, NULL,             NULL,                    0,               NULL,                NULL}
 };
 
@@ -367,20 +369,6 @@
     audio_buffer = NULL;
 
 
-  /* Shuffle playlist */
-  if (options.shuffle) {
-    int i;
-    
-    srandom(time(NULL));
-    
-    for (i = 0; i < items; i++) {
-      int j = i + random() % (items - i);
-      char *temp = playlist_array[i];
-      playlist_array[i] = playlist_array[j];
-      playlist_array[j] = temp;
-    }
-  }
-
   /* Setup signal handlers and callbacks */
 
   ATEXIT (exit_cleanup);
@@ -389,15 +377,29 @@
   signal (SIGCONT, signal_handler);
   signal (SIGTERM, signal_handler);
 
-  /* Play the files/streams */
-  i = 0;
-  while (i < items && !sig_request.exit) {
-    play(playlist_array[i]);
-    i++;
-    if(i == items && options.repeat)
-      i = 0;
-  }
+  do {
+    /* Shuffle playlist */
+    if (options.shuffle) {
+      int i;
+    
+      srandom(time(NULL));
+    
+      for (i = 0; i < items; i++) {
+        int j = i + random() % (items - i);
+        char *temp = playlist_array[i];
+        playlist_array[i] = playlist_array[j];
+        playlist_array[j] = temp;
+      }
+    }
 
+    /* Play the files/streams */
+    i = 0;
+    while (i < items && !sig_request.exit) {
+      play(playlist_array[i]);
+      i++;
+    }
+  } while (options.repeat);
+
   playlist_array_destroy(playlist_array, items);
 
   exit (0);

Modified: trunk/vorbis-tools/ogg123/ogg123.h
===================================================================
--- trunk/vorbis-tools/ogg123/ogg123.h	2005-09-28 17:29:18 UTC (rev 10088)
+++ trunk/vorbis-tools/ogg123/ogg123.h	2005-09-28 17:52:31 UTC (rev 10089)
@@ -26,7 +26,7 @@
   long int verbosity;         /* Verbose output if > 1, quiet if 0 */
 
   int shuffle;                /* Should we shuffle playing? */
-  int repeat;                 /* Repeat playlist indefinately? */
+  int repeat;                 /* Repeat playlist indefinitely? */
   ogg_int64_t delay;          /* delay (in millisecs) for skip to next song */
   int nth;                    /* Play every nth chunk */
   int ntimes;                 /* Play every chunk n times */



More information about the commits mailing list