Fix bufread implementation. This fixes problems with codecs that use it.
authorNicolas Pennequin <nicolas@nicolas-laptop.(none)>
Thu, 11 Oct 2007 13:05:25 +0000 (11 15:05 +0200)
committerlearman <learman@a1c6a512-1295-4272-9138-f99709370657>
Thu, 25 Oct 2007 19:18:20 +0000 (25 19:18 +0000)
Some codecs (like MPC or AAC) use codec_filebuf_callback(), which uses
bufseek, instead of codec_request_buffer_callback(), which uses bufgetdata.

apps/buffering.c

index 576118f..6e7d6ce 100644 (file)
@@ -828,10 +828,12 @@ ssize_t bufread(int handle_id, size_t size, char *dest)
     if (!h)
         return -1;
 
-    if (h->available < size && h->filerem > 0) /* Data isn't ready */
+    if (h->available - RINGBUF_SUB(h->ridx, h->data) < size && h->filerem > 0)
+        /* Data isn't ready */
         return -2;
 
-    if (h->available == 0 && h->filerem == 0) /* File is finished reading */
+    if (h->available - RINGBUF_SUB(h->ridx, h->data) == 0 && h->filerem == 0)
+        /* File is finished reading */
         return 0;
 
     buffered_data = MIN(size, h->available - RINGBUF_SUB(h->ridx, h->data));