changeset 3138:8e26022bb814

aac: handle premature EOF on shoutcast streams more gracefully. in combination with the neon work, we no longer have a problem. (closes #57)
author William Pitcock <nenolod@atheme.org>
date Thu, 07 May 2009 11:14:36 -0500
parents 8c884237cecd
children 647edbe263bd
files src/aac/libmp4.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/aac/libmp4.c	Thu May 07 11:04:15 2009 -0500
+++ b/src/aac/libmp4.c	Thu May 07 11:14:36 2009 -0500
@@ -651,6 +651,7 @@
     gulong      samplerate = 0;
     guchar      channels = 0;
     gulong      buffervalid = 0;
+    gulong	ret = 0;
     gchar       *ttemp = NULL, *stemp = NULL;
     gchar       *temp = g_strdup(filename);
     gchar       *xmmstitle = NULL;
@@ -747,10 +748,15 @@
         {
             buffervalid -= bufferconsumed;
             memmove(streambuffer, &streambuffer[bufferconsumed], buffervalid);
-            buffervalid += aud_vfs_fread(&streambuffer[buffervalid], 1,
+            ret = aud_vfs_fread(&streambuffer[buffervalid], 1,
                          BUFFER_SIZE-buffervalid, file);
+            buffervalid += ret;
             bufferconsumed = 0;
 
+            /* XXX: buffer underrun on a shoutcast stream, well this is unpleasant. --nenolod */
+            if (ret == 0 && remote == TRUE)
+                break;
+
             ttemp = aud_vfs_get_metadata(file, "stream-name");
 
             if (ttemp != NULL)