[xiph-cvs] cvs commit: vorbis-tools/ogg123 cmdline_options.c ogg123.c ogg123.h playlist.c

Stan Seibert volsung at xiph.org
Sat Jul 6 12:12:19 PDT 2002



volsung     02/07/06 12:12:19

  Modified:    ogg123   cmdline_options.c ogg123.c ogg123.h playlist.c
  Log:
  Full playlist support reading from disk.  Playlist files can contain files,
  directories, URLs, and small animals.

Revision  Changes    Path
1.12      +10 -3     vorbis-tools/ogg123/cmdline_options.c

Index: cmdline_options.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/cmdline_options.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- cmdline_options.c	2002/07/03 03:18:31	1.11
+++ cmdline_options.c	2002/07/06 19:12:17	1.12
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: cmdline_options.c,v 1.11 2002/07/03 03:18:31 volsung Exp $
+ last mod: $Id: cmdline_options.c,v 1.12 2002/07/06 19:12:17 volsung Exp $
 
  ********************************************************************/
 
@@ -45,6 +45,7 @@
     {"nth", required_argument, 0, 'x'},
     {"ntimes", required_argument, 0, 'y'},
     {"shuffle", no_argument, 0, 'z'},
+    {"list", required_argument, 0, '@'},
     {0, 0, 0, 0}
 };
 
@@ -61,7 +62,7 @@
   audio_device_t *current;
   int ret;
 
-  while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:hl:k:o:p:qvVx:y:z",
+  while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:hl:k:o:p:qvVx:y:z@:",
                                   long_options, &option_index))) {
 
       switch (ret) {
@@ -194,7 +195,13 @@
       case 'z':
         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"),
+		       optarg);
+	break;
+		
       case '?':
         break;
         

<p><p>1.65      +12 -10    vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- ogg123.c	2002/07/06 16:18:31	1.64
+++ ogg123.c	2002/07/06 19:12:18	1.65
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.64 2002/07/06 16:18:31 volsung Exp $
+ last mod: $Id: ogg123.c,v 1.65 2002/07/06 19:12:18 volsung Exp $
 
  ********************************************************************/
 
@@ -147,6 +147,8 @@
   opts->default_device = NULL;
 
   opts->status_freq = 10.0;
+  opts->playlist = NULL;
+
 }
 
 
@@ -275,7 +277,6 @@
 {
   int optind;
   char **playlist_array;
-  playlist_t *list = playlist_create();
   int items;
   struct stat stat_buf;
   int i;
@@ -290,6 +291,7 @@
   file_options_init(file_opts);
 
   parse_std_configs(file_opts);
+  options.playlist = playlist_create();
   optind = parse_cmdline_options(argc, argv, &options, file_opts);
 
   audio_play_arg.devices = options.devices;
@@ -300,27 +302,27 @@
     if (stat(argv[i], &stat_buf) == 0) {
 
       if (S_ISDIR(stat_buf.st_mode)) {
-	if (playlist_append_directory(list, argv[i]) == 0)
+	if (playlist_append_directory(options.playlist, argv[i]) == 0)
           fprintf(stderr, 
                   _("Warning: Could not read directory %s.\n"), argv[i]);
       } else {
-	playlist_append_file(list, argv[i]);
+	playlist_append_file(options.playlist, argv[i]);
       }
     } else /* If we can't stat it, it might be a non-disk source */
-      playlist_append_file(list, argv[i]);
+      playlist_append_file(options.playlist, argv[i]);
 
 
   }
 
 
   /* Do we have anything left to play? */
-  if (playlist_length(list) == 0) {
+  if (playlist_length(options.playlist) == 0) {
     cmdline_usage();
     exit(1);
   } else {
-    playlist_array = playlist_to_array(list, &items);
-    playlist_destroy(list);
-    list = NULL;
+    playlist_array = playlist_to_array(options.playlist, &items);
+    playlist_destroy(options.playlist);
+    options.playlist = NULL;
   }
 
   /* Don't use status_message until after this point! */
@@ -443,7 +445,7 @@
                                &decoder_callbacks,
                                decoder_callbacks_arg)) == NULL ) {
 
-    // We may have failed because of user command
+    /* We may have failed because of user command */
     if (!sig_request.cancel)
       status_error(_("Error opening %s using the %s module."
                      "  The file may be corrupted.\n"), source_string,

<p><p>1.14      +4 -1      vorbis-tools/ogg123/ogg123.h

Index: ogg123.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ogg123.h	2002/06/02 03:07:11	1.13
+++ ogg123.h	2002/07/06 19:12:18	1.14
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.h,v 1.13 2002/06/02 03:07:11 volsung Exp $
+ last mod: $Id: ogg123.h,v 1.14 2002/07/06 19:12:18 volsung Exp $
 
  ********************************************************************/
 
@@ -20,6 +20,7 @@
 
 #include <ogg/os_types.h>
 #include "audio.h"
+#include "playlist.h"
 
 typedef struct ogg123_options_t {
   long int verbosity;         /* Verbose output if > 1, quiet if 0 */
@@ -40,6 +41,8 @@
   audio_device_t *devices;    /* Audio devices to use */
 
   double status_freq;         /* Number of status updates per second */
+
+  playlist_t *playlist;       /* List of files to play */
 } ogg123_options_t;
 
 typedef struct signal_request_t {

<p><p>1.2       +26 -7     vorbis-tools/ogg123/playlist.c

Index: playlist.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/playlist.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- playlist.c	2002/07/06 03:23:13	1.1
+++ playlist.c	2002/07/06 19:12:18	1.2
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: playlist.c,v 1.1 2002/07/06 03:23:13 volsung Exp $
+ last mod: $Id: playlist.c,v 1.2 2002/07/06 19:12:18 volsung Exp $
 
  ********************************************************************/
 
@@ -172,29 +172,48 @@
 {
   FILE *fp;
   char filename[NAME_MAX+1];
+  struct stat stat_buf;
   int length;
   int i;
 
-  fp = fopen(playlist_filename, "r");
+  if (strcmp(playlist_filename, "-") == 0)
+    fp = stdin;
+  else
+    fp = fopen(playlist_filename, "r");
 
   if (fp == NULL)
     return 0;
 
   while (!feof(fp)) {
-    fgets(filename, NAME_MAX+1 /* no, really! */, fp);
 
+    if ( fgets(filename, NAME_MAX+1 /* no, really! */, fp) == NULL )
+      continue;
+
+    filename[NAME_MAX] = '\0'; /* Just to make sure */
     length = strlen(filename);
 
-    // Skip blank lines
+    /* Skip blank lines */
     for (i = 0; i < length && isspace(filename[i]); i++);
     if (i == length)
       continue;
 
-    // Crop off last \n if present
+    /* Crop off last \n if present */
     if (filename[length - 1] == '\n')
       filename[length - 1] = '\0';
+
+    if (stat(filename, &stat_buf) == 0) {
+
+      if (S_ISDIR(stat_buf.st_mode)) {
+	if (playlist_append_directory(list, filename) == 0)
+	  fprintf(stderr, 
+		  _("Warning from playlist %s: "
+		    "Could not read directory %s.\n"), filename);
+      } else {
+	playlist_append_file(list, filename);
+      }
+    } else /* If we can't stat it, it might be a non-disk source */
+      playlist_append_file(list, filename);
 
-    playlist_append_file(list, filename);
   }
 
   return 1;
@@ -208,7 +227,7 @@
   playlist_element_t *element;
 
   element = list->head;  
-  length = 0; // don't count head node
+  length = 0; /* don't count head node */
   while (element->next != NULL) {
     length++;
     element = element->next;

<p><p><p>--- >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