Author: awy
Date: Fri Oct 10 08:02:57 2008
New Revision: 3095

URL: http://svn.slimdevices.com?rev=3095&root=Jive&view=rev
Log:
(bug 9517) Only call FLAC decoder when likely to have enough data for a full 
frame (or end of stream).

Modified:
    7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_flac.c
    7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c
    7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.h

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_flac.c
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_flac.c?rev=3095&root=Jive&r1=3094&r2=3095&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_flac.c 
(original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_flac.c Fri 
Oct 10 08:02:57 2008
@@ -157,6 +157,16 @@
        }
 
        if (! decode_output_can_write(2 * 4608 * sizeof(sample_t), 
self->sample_rate)) {
+               return FALSE;
+       }
+       
+       /* Because FLAC__stream_decoder_process_single() will keep calling the 
read
+        * callback, in a hard loop, until it gets a full frame, we want to 
avoid calling
+        * it unless it is likely to get a full frame. The absolute maximum 
size of a
+        * FLAC frame is too large to use that, so we pick a value that will 
work most
+        * of the time.
+        */
+       if (streambuf_would_wait_for(25000)) {
                return FALSE;
        }
 

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c?rev=3095&root=Jive&r1=3094&r2=3095&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c Fri Oct 10 
08:02:57 2008
@@ -78,7 +78,22 @@
 
        return n;
 }
-
+/* returns true if the stream is still open but cannot yet supply the 
requested bytes */
+bool_t streambuf_would_wait_for(size_t bytes) {
+       size_t n;
+       
+       if (!streambuf_streaming) {
+               return TRUE;
+       }
+
+       fifo_lock(&streambuf_fifo);
+
+       n = fifo_bytes_used(&streambuf_fifo);
+
+       fifo_unlock(&streambuf_fifo);
+
+       return n < bytes;
+}
 
 void streambuf_get_status(size_t *size, size_t *usedbytes, u32_t *bytesL, 
u32_t *bytesH) {
 

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.h
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.h?rev=3095&root=Jive&r1=3094&r2=3095&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.h (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.h Fri Oct 10 
08:02:57 2008
@@ -10,6 +10,8 @@
 extern size_t streambuf_get_freebytes(void);
 
 extern size_t streambuf_get_usedbytes(void);
+
+extern bool_t streambuf_would_wait_for(size_t bytes);
 
 extern void streambuf_get_status(size_t *size, size_t *usedbytes, u32_t 
*bytesL, u32_t *bytesH);
 

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to