[Vorbis-dev] ogg123 pipe patch

Jack Moffitt jack at xiph.org
Wed Aug 3 13:26:51 PDT 2005


For over a year, ogg123 has been broken for pipe playback.  I'm not sure
why this easy bug was here so long, but I've finally fixed it.  The
patch is attached, and I've committed it to HEAD.

This fixes Debian Bug#237187.  It would be nice if Chris uploaded an
updated package that closes this.

jack.
-------------- next part --------------
Index: ogg123/file_transport.c
===================================================================
--- ogg123/file_transport.c	(revision 9695)
+++ ogg123/file_transport.c	(working copy)
@@ -26,6 +26,7 @@
 typedef struct file_private_t {
   FILE *fp;
   data_source_stats_t stats;
+  int seekable;
 } file_private_t;
 
 
@@ -51,6 +52,7 @@
     source->transport = &file_transport;
     source->private = private;
     
+    private->seekable = 1;
     private->stats.transfer_rate = 0;
     private->stats.bytes_read = 0;
     private->stats.input_buffer_used = 0;
@@ -60,9 +62,10 @@
   }
 
   /* Open file */
-  if (strcmp(source_string, "-") == 0)
+  if (strcmp(source_string, "-") == 0) {
     private->fp = stdin;
-  else
+    private->seekable = 0;
+  } else
     private->fp = fopen(source_string, "r");
 
   if (private->fp == NULL) {
@@ -84,6 +87,8 @@
   int items;
   long start;
 
+  if (!private->seekable) return 0;
+
   /* Record where we are */
   start = ftell(fp);
 
@@ -118,6 +123,8 @@
   file_private_t *private = source->private;
   FILE *fp = private->fp;
 
+  if (!private->seekable) return -1;
+
   return fseek(fp, offset, whence);  
 }
 
@@ -135,6 +142,8 @@
   file_private_t *private = source->private;
   FILE *fp = private->fp;
 
+  if (!private->seekable) return -1;
+
   return ftell(fp);
 }
 


More information about the Vorbis-dev mailing list