[xiph-cvs] cvs commit: ices/src im_playlist.c playlist_basic.c

Karl Heyes karl at xiph.org
Wed Jul 9 16:47:01 PDT 2003



karl        03/07/09 19:47:01

  Modified:    src      im_playlist.c playlist_basic.c
  Log:
  off by one error fixed and allow - as a filename in the playlist to mean
  get from standard input.

Revision  Changes    Path
1.12      +30 -25    ices/src/im_playlist.c

Index: im_playlist.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_playlist.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- im_playlist.c	28 Mar 2003 01:12:59 -0000	1.11
+++ im_playlist.c	9 Jul 2003 23:47:01 -0000	1.12
@@ -1,7 +1,7 @@
 /* playlist.c
  * - Basic playlist functionality
  *
- * $Id: im_playlist.c,v 1.11 2003/03/28 01:12:59 karl Exp $
+ * $Id: im_playlist.c,v 1.12 2003/07/09 23:47:01 karl Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -109,47 +109,53 @@
     {
         pl->nexttrack = 0;
 
-        if(pl->current_file) 
+        if (pl->current_file && strcmp (pl->filename, "-"))
         {
             fclose(pl->current_file);
             pl->current_file = NULL;
         }
 
         newfn = pl->get_filename(pl->data);
-        if(!newfn)
-            return -1; /* No more files available */
-
-        if(pl->filename && !strcmp(pl->filename, newfn))
-        {
-            LOG_ERROR0("Cannot play same file twice in a row, skipping");
-            pl->errors++;
-            return 0;
-        }
-
-        pl->free_filename(pl->data, pl->filename);
-        pl->filename = newfn;
-
-        if(!pl->filename)
+        if (!newfn)
         {
             LOG_INFO0("No more filenames available, end of playlist");
-            return -1;
+            return -1; /* No more files available */
         }
-        
-        pl->current_file = fopen(pl->filename, "rb");
 
-        LOG_INFO1("Currently playing %s", pl->filename);
+        if (strcmp (newfn, "-"))
+        {
+            if (pl->filename && !strcmp(pl->filename, newfn))
+            {
+                LOG_ERROR0("Cannot play same file twice in a row, skipping");
+                pl->errors++;
+                pl->free_filename (pl->data, newfn);
+                return 0;
+            }
+            pl->free_filename(pl->data, pl->filename);
+            pl->filename = newfn;
 
-        if (!pl->current_file) 
+            pl->current_file = fopen(pl->filename, "rb");
+            if (!pl->current_file) 
+            {
+                LOG_WARN2("Error opening file %s: %s",pl->filename, strerror(errno));
+                pl->errors++;
+                return 0;
+            }
+            LOG_INFO1("Currently playing %s", pl->filename);
+        }
+        else
         {
-            LOG_WARN2("Error opening file %s: %s",pl->filename, strerror(errno));
-            pl->errors++;
-            return 0;
+            LOG_INFO0("Currently playing from stdin");
+            pl->current_file = stdin;
+            pl->free_filename(pl->data, pl->filename);
+            pl->filename = newfn;
         }
 
         /* Reinit sync, so that dead data from previous file is discarded */
         ogg_sync_clear(&pl->oy);
         ogg_sync_init(&pl->oy);
     }
+    input_sleep ();
 
     while(1)
     {
@@ -199,7 +205,6 @@
     }
 
     pl->errors=0;
-    input_sleep ();
 
     return rb->len;
 }

<p><p>1.12      +2 -2      ices/src/playlist_basic.c

Index: playlist_basic.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/playlist_basic.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- playlist_basic.c	6 Jul 2003 14:50:19 -0000	1.11
+++ playlist_basic.c	9 Jul 2003 23:47:01 -0000	1.12
@@ -1,7 +1,7 @@
 /* playlist_basic.c
  * - Simple built-in unscripted playlist
  *
- * $Id: playlist_basic.c,v 1.11 2003/07/06 14:50:19 karl Exp $
+ * $Id: playlist_basic.c,v 1.12 2003/07/09 23:47:01 karl Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -171,7 +171,7 @@
 
     ptr = pl->pl [pl->pos++];
 
-    if ((dest = malloc (strlen (ptr))) == NULL)
+    if ((dest = malloc (strlen (ptr)+1)) == NULL)
         return NULL;
     strcpy (dest, ptr);
     return dest;

<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