[xiph-cvs] cvs commit: ices/src cue.c icestypes.h id3.c mp3.c stream.c

Brendan brendan at xiph.org
Sun Mar 16 00:32:34 PST 2003



brendan     03/03/16 03:32:34

  Modified:    .        TODO
               src      cue.c icestypes.h id3.c mp3.c stream.c
  Log:
  Big code movements. For the record, the 3/15 snapshot is very stable on
  my server. I'd recommend using that until this new code is shaken out.
  
  * Removed redundant input_stream_t.canseek flag (if we have file size, we can
    seek).
  * Minor fix to error handling in ID3v2 parsing (not exercised)
  * Reworked MP3 buffer filling/peeking. This lets me peek the second frame in
    an MP3 stream as a sanity check on the first one.
  * It also lets me fully sanity-check FIFO sources (including VBR). Except
    for ID3v1 (which can't be done),  FIFOs are first-class input streams now.
  * stream.c: Small reorganisation for readability. Much more needs to be done
    here.

Revision  Changes    Path
1.4       +2 -2      ices/TODO

Index: TODO
===================================================================
RCS file: /cvs/ice/ices/TODO,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TODO	16 Mar 2003 05:50:34 -0000	1.3
+++ TODO	16 Mar 2003 08:32:34 -0000	1.4
@@ -1,9 +1,9 @@
 * Improved error handling
 * Make the scripting engines, and vorbis and MP3 reencoding, run-time linkable
 * Investigate preventing chirps. These can happen if the previous file ended in
-  the middle frame. Possibly padding out to the frame length with NULL would fix it.
+  the middle of a frame. Possibly padding out to the frame length with NULL would fix it.
   A really cheap hack would be to just dump the maximum possible frame size worth of
   NULLs into the stream. In practice, this might not be any different since the
   player should just ignore everything up until the next sync word.
 
-$Id: TODO,v 1.3 2003/03/16 05:50:34 brendan Exp $
+$Id: TODO,v 1.4 2003/03/16 08:32:34 brendan Exp $

<p><p>1.12      +1 -1      ices/src/cue.c

Index: cue.c
===================================================================
RCS file: /cvs/ice/ices/src/cue.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- cue.c	23 Jun 2001 17:46:10 -0000	1.11
+++ cue.c	16 Mar 2003 08:32:34 -0000	1.12
@@ -59,7 +59,7 @@
 
   fprintf (fp, "%s\n%d\n%d\n%s\n%f\n%d\n%s\n%s\n", source->path,
            source->filesize, source->bitrate,
-	   ices_util_nullcheck (ices_util_file_time (source->bitrate, source->filesize, buf)),
+       ices_util_file_time (source->bitrate, source->filesize, buf),
            ices_util_percent (source->bytes_read, source->filesize),
            ices_cue_lineno, artist, title);
 

<p><p>1.22      +0 -1      ices/src/icestypes.h

Index: icestypes.h
===================================================================
RCS file: /cvs/ice/ices/src/icestypes.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- icestypes.h	13 Mar 2003 19:29:24 -0000	1.21
+++ icestypes.h	16 Mar 2003 08:32:34 -0000	1.22
@@ -99,7 +99,6 @@
 
   char* path;
   int fd;
-  int canseek;
   size_t filesize;
   size_t bytes_read;
   unsigned int bitrate;

<p><p>1.26      +4 -9      ices/src/id3.c

Index: id3.c
===================================================================
RCS file: /cvs/ice/ices/src/id3.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- id3.c	16 Mar 2003 04:41:31 -0000	1.25
+++ id3.c	16 Mar 2003 08:32:34 -0000	1.26
@@ -76,7 +76,7 @@
   char title[31];
   int i;
 
-  if (! source->canseek)
+  if (! source->filesize)
     return;
 
   buffer[30] = '\0';
@@ -159,9 +159,7 @@
   while (remaining > ID3V2_FRAME_LEN(&tag) && (tag.artist == NULL || tag.title == NULL)) {
     if ((rv = id3v2_read_frame (source, &tag)) < 0) {
       ices_log ("Error reading ID3v2 frames, skipping to end of ID3v2 tag");
-      id3v2_skip_data (source, &tag, tag.len - tag.pos);
-
-      return;
+      break;
     }
     /* found padding */
     if (rv == 0)
@@ -177,11 +175,8 @@
   ices_util_free (tag.title);
 
   remaining = tag.len - tag.pos;
-  if (remaining) {
-    ices_log_debug ("ID3v2: Skipping %d bytes to end of tag", remaining);
-
+  if (remaining)
     id3v2_skip_data (source, &tag, remaining);
-  }
 }
 
 static int
@@ -251,7 +246,7 @@
     while (len2) {
       if ((rlen = source->read (source, buf, len)) < 0) {
         ices_log ("Error reading ID3v2 frame data");
-	free (buf);
+        free (buf);
       
         return -1;
       }

<p><p>1.26      +103 -64   ices/src/mp3.c

Index: mp3.c
===================================================================
RCS file: /cvs/ice/ices/src/mp3.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- mp3.c	15 Mar 2003 20:58:54 -0000	1.25
+++ mp3.c	16 Mar 2003 08:32:34 -0000	1.26
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: mp3.c,v 1.25 2003/03/15 20:58:54 brendan Exp $
+ * $Id: mp3.c,v 1.26 2003/03/16 08:32:34 brendan Exp $
  */
 
 #include "definitions.h"
@@ -85,6 +85,7 @@
                                  int16_t* left, int16_t* right);
 #endif
 static int ices_mp3_close (input_stream_t* self);
+static int mp3_fill_buffer (input_stream_t* self, size_t len);
 static int mp3_parse_frame(const unsigned char* buf, mp3_header_t* header);
 static int mp3_check_vbr(input_stream_t* source, mp3_header_t* header);
 static size_t mp3_frame_length(mp3_header_t* header);
@@ -113,16 +114,10 @@
   if (! strncmp ("ID3", mp3_data->buf, 3))
     ices_id3v2_parse (source);
 
-  /* refill buffer if ID3v2 parsing consumed it */
-  if (!mp3_data->buf) {
-    buffer = (unsigned char*) malloc (MP3_BUFFER_SIZE);
-    len = source->read (source, buffer, MP3_BUFFER_SIZE);
-    mp3_data->buf = buffer;
-    mp3_data->len = len;
-    mp3_data->pos = 0;
-  }
-
-  if (mp3_data->len < 4) {
+  /* ensure we have at least 4 bytes in the read buffer */
+  if (!mp3_data->buf || mp3_data->len - mp3_data->pos < 4)
+    mp3_fill_buffer (source, MP3_BUFFER_SIZE);
+  if (mp3_data->len - mp3_data->pos < 4) {
     ices_log_error("Short file");
     return  -1;
   }
@@ -145,8 +140,41 @@
     }
 
     /* we must be able to read at least 4 bytes of header */
-    while (mp3_data->len - mp3_data->pos >= 4
-        && !(rc = mp3_parse_frame(buffer + mp3_data->pos, &mh))) {
+    while (mp3_data->len - mp3_data->pos >= 4) {
+      if ((rc = mp3_parse_frame(buffer + mp3_data->pos, &mh))) {
+        size_t framelen;
+        mp3_header_t next_header;
+
+        source->samplerate = mh.samplerate;
+        source->bitrate = mh.bitrate;
+
+        if (mp3_check_vbr (source, &mh)) {
+          source->bitrate = 0;
+          break;
+        }
+
+        /* check next frame if possible */
+        if ((framelen = mp3_frame_length (&mh)) <= 0)
+          break;
+        if (mp3_fill_buffer (source, framelen + 4) <= 0)
+          break;
+
+        /* if we can't find the second frame, we assume the first frame was junk */
+        if ((rc = mp3_parse_frame(mp3_data->buf + mp3_data->pos + framelen, &next_header))) {
+          if (mh.version != next_header.version || mh.layer != next_header.layer
+              || mh.samplerate != next_header.samplerate) {
+            rc = 0;
+          /* fallback VBR check if VBR tag is missing */
+          } else if (mh.bitrate != next_header.bitrate) {
+            ices_log_debug ("Bit rate of first frame (%d) doesn't match second frame (%d), assuming VBR",
+                mh.bitrate, next_header.bitrate);
+            source->bitrate = 0;
+          }
+          break;
+        }
+        if (!rc)
+          ices_log_debug ("Bad frame at offset %d", source->bytes_read);
+      }
       mp3_data->pos++;
       off++;
     }
@@ -160,13 +188,6 @@
   if (off)
     ices_log_debug("Skipped %d bytes of garbage before MP3", off);
 
-  source->samplerate = mh.samplerate;
-  source->bitrate = mh.bitrate;
-
-  /* bitrate of zero ensures that lazy reencoding won't be lazy */
-  if (mp3_check_vbr(source, &mh) > 0)
-    source->bitrate = 0;
-
   if (source->bitrate)
     ices_log_debug ("%s layer %s, %d kbps, %d Hz, %s", version_names[mh.version],
                     layer_names[mh.layer - 1], mh.bitrate, mh.samplerate, mode_names[mh.mode]);
@@ -245,7 +266,7 @@
     }
   } else {
     /* we don't just use EOF because we'd like to avoid the ID3 tag */
-    if (self->canseek && self->filesize - self->bytes_read < len)
+    if (self->filesize && self->filesize - self->bytes_read < len)
       len = self->filesize - self->bytes_read;
     if (len)
       rlen = read (self->fd, buf, len);
@@ -287,6 +308,58 @@
   return close (self->fd);
 }
 
+/* make sure source buffer has at least len bytes.
+ * returns: 1: success, 0: EOF before len, -1: malloc error, -2: read error */
+static int mp3_fill_buffer (input_stream_t* self, size_t len) {
+  ices_mp3_in_t* mp3_data = (ices_mp3_in_t*) self->data;
+  char errbuf[1024];
+  char* buffer;
+  size_t buflen;
+  ssize_t rlen;
+  size_t needed;
+
+  buflen = mp3_data->len - mp3_data->pos;
+
+  if (mp3_data->buf && len < buflen)
+    return 1;
+
+  if (self->filesize && len > buflen + self->filesize - self->bytes_read)
+    return 0;
+
+  /* put off adjusting mp3_data->len until read succeeds. len indicates how much valid
+   * data is in the buffer, not how much has been allocated. We don't need to track
+   * that for free or even realloc, although in the odd case that we can't fill the
+   * extra memory we may end up reallocing when we don't strictly have to. */
+  if (!mp3_data->buf) {
+    needed = len;
+    if (!(mp3_data->buf = malloc(needed)))
+      return -1;
+    mp3_data->pos = 0;
+    mp3_data->len = 0;
+  } else {
+    needed = len - buflen;
+    if (!(buffer = realloc(mp3_data->buf, mp3_data->len + needed)))
+      return -1;
+    mp3_data->buf = buffer;
+  }
+
+  while (needed && (rlen = read(self->fd, mp3_data->buf + mp3_data->len, needed)) > 0) {
+    mp3_data->len += rlen;
+    self->bytes_read += rlen;
+    needed -= rlen;
+  }
+
+  if (!needed)
+    return 1;
+
+  if (!rlen)
+    return 0;
+
+  ices_log_error ("Error filling read buffer: %s",
+    ices_util_strerror (errno, errbuf, sizeof (errbuf)));
+  return -1;
+}
+
 static int mp3_parse_frame(const unsigned char* buf, mp3_header_t* header) {
   int bitrate_idx, samplerate_idx;
 
@@ -333,19 +406,10 @@
   return 1;
 }
 
-/* TODO: check without seeking */
 static int mp3_check_vbr(input_stream_t* source, mp3_header_t* header) {
   ices_mp3_in_t* mp3_data = (ices_mp3_in_t*) source->data;
-  char buf[4];
-  mp3_header_t next_header;
-  ssize_t framelen;
-  off_t cur;
   int offset;
 
-  if (!source->canseek)
-    return -1;
-
-  cur = lseek(source->fd, 0, SEEK_CUR);
   /* check for VBR tag */
   /* Tag offset varies (but FhG VBRI is always MPEG1 Layer III 160 kbps stereo) */
   if (header->version == 0) {
@@ -359,44 +423,19 @@
     else
       offset = 21;
   }
-
-  offset -= mp3_data->len - mp3_data->pos;
-  lseek(source->fd, offset, SEEK_CUR);
-  if (read(source->fd, buf, 4) == 4) {
-    if (!strncmp("VBRI", buf, 4) || !strncmp("Xing", buf, 4)) {
-      ices_log_debug("VBR tag found");
-      lseek(source->fd, cur, SEEK_SET);
-      return 1;
-    }
-  } else {
-    ices_log_debug("Error trying to read VBR tag");
-    lseek(source->fd, cur, SEEK_SET);
+  /* only needed if frame length can't be calculated (free bitrate) */
+  if (mp3_fill_buffer (source, offset + 4) <= 0) {
+    ices_log_debug ("Error trying to read VBR tag");
     return -1;
   }
 
-  /* otherwise check next frame if possible */
-  offset = mp3_data->len - mp3_data->pos;
-  lseek(source->fd, cur, SEEK_SET);
-  if ((framelen = mp3_frame_length(header))) {
-    ices_log_debug("Frame length expected: %d bytes", framelen);
-    lseek(source->fd, framelen - offset, SEEK_CUR);
-    if (read(source->fd, buf, 4) == 4) {
-      if (!mp3_parse_frame(buf, &next_header))
-        ices_log_debug("Couldn't find second frame header");
-      else {
-        ices_log_debug("Second frame: %s layer %s, %d kbps, %d Hz", 
-                       version_names[next_header.version],
-                       layer_names[next_header.layer - 1], next_header.bitrate,
-	               next_header.samplerate);
-        /* if bit rates don't match assume VBR */
-        if (header->bitrate != next_header.bitrate)
-	  return 1;
-      }
-    } else
-      ices_log_debug("Error reading next frame");
-    lseek(source->fd, cur, SEEK_SET);
+  offset += mp3_data->pos;
+  if (!strncmp("VBRI", mp3_data->buf + offset, 4)
+      || !strncmp("Xing", mp3_data->buf + offset, 4)) {
+    ices_log_debug("VBR tag found");
+    return 1;
   }
-  
+
   return 0;
 }
 

<p><p>1.51      +97 -104   ices/src/stream.c

Index: stream.c
===================================================================
RCS file: /cvs/ice/ices/src/stream.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- stream.c	13 Mar 2003 23:29:11 -0000	1.50
+++ stream.c	16 Mar 2003 08:32:34 -0000	1.51
@@ -77,12 +77,6 @@
     ices_metadata_set (NULL, NULL);
 
     source.path = ices_playlist_get_next ();
-    source.bytes_read = 0;
-    source.filesize = 0;
-
-    source.read = NULL;
-    source.readpcm = NULL;
-    source.close = NULL;
 
     /* keep track of the line numbers */
     linenum_old = linenum_new;
@@ -110,9 +104,9 @@
          second. Usually caused by a playlist handler that produces only
          invalid file names. */
     if (consecutive_errors > 10) {
-	ices_log ("Exiting after 10 consecutive errors.");
-	ices_util_free (source.path);
-	ices_setup_shutdown ();
+      ices_log ("Exiting after 10 consecutive errors.");
+      ices_util_free (source.path);
+      ices_setup_shutdown ();
     }
 
     if (stream_open_source (&source) < 0) {
@@ -124,13 +118,13 @@
 
     if (!source.read)
       for (stream = config->streams; stream; stream = stream->next)
-	if (!stream->reencode) {
-	  ices_log ("Cannot play %s without reencoding", source.path);
-	  source.close (&source);
-	  ices_util_free (source.path);
-	  consecutive_errors++;
-	  continue;
-	}
+        if (!stream->reencode) {
+          ices_log ("Cannot play %s without reencoding", source.path);
+          source.close (&source);
+          ices_util_free (source.path);
+          consecutive_errors++;
+          continue;
+	    }
 
     rc = stream_send (config, &source);
     source.close (&source);
@@ -148,7 +142,6 @@
       consecutive_errors = 0;
     }
                 
-    /* Free the dynamically allocated filename */
     ices_util_free (source.path);
   }
 }
@@ -188,16 +181,16 @@
     /* only actually decode/reencode if the bitrate of the stream != source */
     for (stream = config->streams; stream; stream = stream->next)
       if (stream->bitrate != source->bitrate) {
-	decode = 1;
-	ices_reencode_reset (source);
-	break;
+        decode = 1;
+        ices_reencode_reset (source);
+        break;
       }
 
     if (decode) {
       obuf.len = OUTPUT_BUFSIZ;
       if (!(obuf.data = malloc(OUTPUT_BUFSIZ))) {
         ices_log_error("Error allocating encode buffer");
-	return -1;
+        return -1;
       }
     }
 #endif
@@ -212,100 +205,98 @@
   finish_send = 0;
   while (! finish_send) {
     len = samples = 0;
+    /* fetch input buffer */
     if (source->read) {
       len = source->read (source, ibuf, sizeof (ibuf));
 #ifdef HAVE_LIBLAME
       if (decode)
-	samples = ices_reencode_decode (ibuf, len, sizeof (left), left, right);
+        samples = ices_reencode_decode (ibuf, len, sizeof (left), left, right);
     } else if (source->readpcm) {
       len = samples = source->readpcm (source, sizeof (left), left, right);
 #endif
     }
 
-    if (len > 0) {
-      do_sleep = 1;
-      while (do_sleep) {
-	rc = olen = 0;
-	for (stream = config->streams; stream; stream = stream->next) {
-	  /* don't reencode if the source is MP3 and the same bitrate */
-	  if (!stream->reencode || (source->read &&
-				    (stream->bitrate == source->bitrate))) {
-	    rc = stream_send_data (stream, ibuf, len);
-	  }
+    if (len == 0) {
+      ices_log_debug ("Done sending");
+      break;
+    }
+    if (len < 0) {
+      ices_log_error ("Read error: %s", ices_util_strerror (errno, namespace, 1024));
+      goto err;
+    }
+    
+    do_sleep = 1;
+    while (do_sleep) {
+      rc = olen = 0;
+      for (stream = config->streams; stream; stream = stream->next) {
+        /* don't reencode if the source is MP3 and the same bitrate */
+        if (!stream->reencode || (source->read && (stream->bitrate == source->bitrate))) {
+          rc = stream_send_data (stream, ibuf, len);
 #ifdef HAVE_LIBLAME
-	  else {
-	    if (samples > 0) {
-	      if (obuf.len < 7200 + samples + samples / 4) {
-	        char *tmpbuf;
-
-		/* pessimistic estimate from lame.h */
-                obuf.len = 7200 + 5 * samples / 2;
-		if (!(tmpbuf = realloc(obuf.data, obuf.len))) {
-		  ices_log_error ("Error growing output buffer, aborting track");
-		  goto err;
-		}
-		obuf.data = tmpbuf;
-		ices_log_debug ("Grew output buffer to %d bytes", obuf.len);
-	      }
-	      if ((olen = ices_reencode (stream, samples, left, right, obuf.data,
-	          obuf.len)) < -1) {
-	        ices_log_error ("Reencoding error, aborting track");
-		goto err;
-	      } else if (olen == -1) {
-	        char *tmpbuf;
+        } else {
+          if (samples > 0) {
+            if (obuf.len < 7200 + samples + samples / 4) {
+              char *tmpbuf;
+
+              /* pessimistic estimate from lame.h */
+              obuf.len = 7200 + 5 * samples / 2;
+              if (!(tmpbuf = realloc(obuf.data, obuf.len))) {
+	            ices_log_error ("Error growing output buffer, aborting track");
+                goto err;
+	          }
+	          obuf.data = tmpbuf;
+	          ices_log_debug ("Grew output buffer to %d bytes", obuf.len);
+	        }
+	        if ((olen = ices_reencode (stream, samples, left, right, obuf.data,
+	            obuf.len)) < -1) {
+	          ices_log_error ("Reencoding error, aborting track");
+	          goto err;
+	        } else if (olen == -1) {
+	          char *tmpbuf;
 
-		if ((tmpbuf = realloc(obuf.data, obuf.len + OUTPUT_BUFSIZ))) {
+	          if ((tmpbuf = realloc(obuf.data, obuf.len + OUTPUT_BUFSIZ))) {
                   obuf.data = tmpbuf;
-		  obuf.len += OUTPUT_BUFSIZ;
-		  ices_log_debug ("Grew output buffer to %d bytes", obuf.len);
-		} else
-		  ices_log_debug ("%d byte output buffer is too small", obuf.len);
-              } else if (olen > 0) {
-                rc = stream_send_data (stream, obuf.data, olen);
-              }
+	            obuf.len += OUTPUT_BUFSIZ;
+	            ices_log_debug ("Grew output buffer to %d bytes", obuf.len);
+	          } else
+	            ices_log_debug ("%d byte output buffer is too small", obuf.len);
+            } else if (olen > 0) {
+              rc = stream_send_data (stream, obuf.data, olen);
             }
-	  }
+          }
+        }
 #endif
 
-	  if (rc < 0) {
-	    if (stream->errs > 10) {
-	      ices_log ("Too many stream errors, giving up");
-	      goto err;
-	    }
-	    ices_log ("Error during send: %s", ices_log_get_error ());
-	  } else {
-	    do_sleep = 0;
-	  }
-	  /* this is so if we have errors on every stream we pause before
-	   * attempting to reconnect */
-	  if (do_sleep) {
-	    struct timeval delay;
-	    delay.tv_sec = 0;
-	    delay.tv_usec = ERROR_DELAY * 1000;
-
-	    select (1, NULL, NULL, NULL, &delay);
-	  }
-	}
+        if (rc < 0) {
+          if (stream->errs > 10) {
+            ices_log ("Too many stream errors, giving up");
+            goto err;
+          }
+          ices_log ("Error during send: %s", ices_log_get_error ());
+        } else {
+	      do_sleep = 0;
+        }
+        /* this is so if we have errors on every stream we pause before
+         * attempting to reconnect */
+        if (do_sleep) {
+          struct timeval delay;
+          delay.tv_sec = ERROR_DELAY / 1000;
+          delay.tv_usec = ERROR_DELAY % 1000 * 1000;
+
+          select (1, NULL, NULL, NULL, &delay);
+        }
       }
-    } else if (len == 0) {
-      ices_log_debug ("Done sending");
-      finish_send = 1;
-    } else {
-      ices_log_error ("Read error: %s",
-		      ices_util_strerror (errno, namespace, 1024));
-      goto err;
     }
-
     ices_cue_update (source);
   }
 
 #ifdef HAVE_LIBLAME
   for (stream = config->streams; stream; stream = stream->next)
-    if (stream->reencode && (!source->read ||
-	(source->bitrate != stream->bitrate))) {
+    if (stream->reencode && (!source->read
+        || (source->bitrate != stream->bitrate))) {
       len = ices_reencode_flush (stream, obuf.data, obuf.len);
       if (len > 0)
-	rc = shout_send (stream->conn, obuf.data, len);
+        rc = shout_send (stream->conn, obuf.data, len);
     }
 
   if (obuf.data)
@@ -313,6 +304,7 @@
 #endif
 
   return 0;
+
 err:
 #ifdef HAVE_LIBLAME
   if (obuf.data)
@@ -330,6 +322,9 @@
   int fd;
   int rc;
 
+  source->filesize = 0;
+  source->bytes_read = 0;
+
   if ((fd = open (source->path, O_RDONLY)) < 0) {
     ices_util_strerror (errno, buf, sizeof (buf));
     ices_log_error ("Error opening: %s", buf);
@@ -339,33 +334,31 @@
 
   source->fd = fd;
 
-  if (lseek (fd, SEEK_SET, 0) == -1)
-    source->canseek = 0;
-  else {
-    source->canseek = 1;
-    source->filesize = ices_util_fd_size (fd);
+  if ((rc = lseek (fd, 0, SEEK_END)) >= 0) {
+    source->filesize = rc;
+    lseek (fd, 0, SEEK_SET);
   }
 
   if ((len = read (fd, buf, sizeof (buf))) <= 0) {
     ices_util_strerror (errno, buf, sizeof (buf));
     ices_log_error ("Error reading header: %s", source->path, buf);
-    
+
+    close (fd);
     return -1;
   }
 
   if (!(rc = ices_mp3_open (source, buf, len)))
     return 0;
-  if (rc < 0)
-    goto err;
+  if (rc < 0) {
+    close (fd);
+    return -1;
+  }
 
 #ifdef HAVE_LIBVORBISFILE
   if (!(rc = ices_vorbis_open (source, buf, len)))
     return 0;
-  if (rc < 0)
-    goto err;
 #endif
 
-err:
   close (fd);
   return -1;
 }
@@ -417,8 +410,8 @@
   }
 
   ices_log ("Mounted on http://%s:%d%s%s", shout_get_host (stream->conn),
-                  shout_get_port (stream->conn),
-                  (mount && mount[0] == '/') ? "" : "/", ices_util_nullcheck (mount));
+            shout_get_port (stream->conn),
+            (mount && mount[0] == '/') ? "" : "/", ices_util_nullcheck (mount));
 
   return 0;
 }

<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