[Vorbis-dev] Repeat patch for ogg123

Niels Sandmann Pedersen sandm
Tue Jun 15 09:43:10 PDT 2004


Hi,

I have made a small patch for enabling repeating in ogg123.

It adds the parameter "--repeat n" or "r n" where n indicates how
many times it repeats the playlists. Zero in forever.

Apply it if you like, I find it very convenient.

--
Regards Niels Sandmann
Jabber: sandmann at jabber.dk, Email: sandm at nn.dk
-------------- next part --------------
Only in ogg123: .deps
Only in ogg123: .libs
diff -u ogg123/cmdline_options.c ogg123-mine/cmdline_options.c
--- ogg123/cmdline_options.c	2004-06-15 17:21:18.000000000 +0200
+++ ogg123-mine/cmdline_options.c	2004-06-15 17:26:19.000000000 +0200
@@ -48,6 +48,7 @@
{"shuffle", no_argument, 0, 'z'},
{"list", required_argument, 0, '@'},
{"audio-buffer", required_argument, 0, 0},
+	{"repeat", required_argument, 0, 'r'},
{0, 0, 0, 0}
};

@@ -75,7 +76,7 @@
audio_device_t *current;
int ret;

-  while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:hl:k:K:o:p:qvVx:y:z@:",
+  while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:hl:k:K:o:p:qr:vVx:y:z@:",
long_options, &option_index))) {

switch (ret) {
@@ -187,6 +188,10 @@
ogg123_opts->verbosity = 0;
break;

+	  case 'r':
+	ogg123_opts->repeat = atoi(optarg);
+	break;
+
case 'v':
ogg123_opts->verbosity++;
break;
@@ -308,6 +313,8 @@
"      v to previously specified device (with -d).  See\n"
"      man page for more info.\n"
"  -@, --list=filename   Read playlist of files and URLs from \"filename\"\n"
+	 "  -r n, --repeat n  Repeat playlist 'n' times\n"
+	 "                    If n is zero, the playlist is repeated forever\n"
"  -b n, --buffer n  Use an input buffer of 'n' kilobytes\n"
"  -p n, --prebuffer n  Load n%% of the input buffer before playing\n"
"  -v, --verbose  Display progress and other status information\n"
diff -u ogg123/ogg123.1 ogg123-mine/ogg123.1
--- ogg123/ogg123.1	2004-06-15 17:21:18.000000000 +0200
+++ ogg123-mine/ogg123.1	2004-06-15 18:38:53.000000000 +0200
@@ -59,6 +59,9 @@
Play all of the files named in the file 'playlist'.  The playlist should have
one filename, directory name, or URL per line.  Blank lines are permitted.
Directories will be treated in the same way as on the command line.
+.IP "-r n, --repeat n"
+Repeats the playlists 'n' times.
+If 'n' is zero the playlist is repeated forever
.IP "-b n, --buffer n"
Use an input buffer of approximately 'n' kilobytes.
.IP "-p n, --prebuffer n"
diff -u ogg123/ogg123.c ogg123-mine/ogg123.c
--- ogg123/ogg123.c	2004-06-15 17:21:17.000000000 +0200
+++ ogg123-mine/ogg123.c	2004-06-15 18:34:55.000000000 +0200
@@ -149,6 +149,7 @@

opts->status_freq = 10.0;
opts->playlist = NULL;
+  opts->repeat = 1;

}

@@ -296,6 +297,7 @@
int items;
struct stat stat_buf;
int i;
+  int k;

setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -360,21 +362,6 @@
} else
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);
@@ -382,12 +369,31 @@
signal (SIGTSTP, signal_handler);
signal (SIGCONT, signal_handler);

+  k=0;
+
+  while ((k < options.repeat || options.repeat==0) && !sig_request.exit) {
+    k++;

-  /* Play the files/streams */
-  i = 0;
-  while (i < items && !sig_request.exit) {
-    play(playlist_array[i]);
-    i++;
+    /* 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++;
+    }
}

playlist_array_destroy(playlist_array, items);
Only in ogg123-mine: ogg123.c~
diff -u ogg123/ogg123.h ogg123-mine/ogg123.h
--- ogg123/ogg123.h	2004-06-15 17:21:18.000000000 +0200
+++ ogg123-mine/ogg123.h	2004-06-15 17:08:28.000000000 +0200
@@ -44,6 +44,7 @@
double status_freq;         /* Number of status updates per second */

playlist_t *playlist;       /* List of files to play */
+  int repeat;
} ogg123_options_t;

typedef struct signal_request_t {


More information about the Vorbis-dev mailing list