Index: apps/buffering.c =================================================================== --- apps/buffering.c (revision 29827) +++ apps/buffering.c (working copy) @@ -858,6 +858,23 @@ } } +/** -- buffer thread helpers -- **/ +static void shrink_buffer_inner(struct memory_handle *h) +{ + if (h == NULL) + return; + + shrink_buffer_inner(h->next); + + shrink_handle(h); +} + +static void shrink_buffer(void) +{ + logf("shrink_buffer()"); + shrink_buffer_inner(first_handle); +} + #ifdef HAVE_ALBUMART /* Given a file descriptor to a bitmap file, write the bitmap data to the buffer, with a struct bitmap and the actual data immediately following. @@ -1223,7 +1240,7 @@ if (h->fd >= 0) lseek(h->fd, h->offset, SEEK_SET); - if (h->next && ringbuf_sub(next, h->data) <= h->filesize - newpos) { + if (ringbuf_sub(next, h->data) <= h->filesize - newpos) { /* There isn't enough space to rebuffer all of the track from its new offset, so we ask the user to free some */ DEBUGF("%s(): space is needed\n", __func__); @@ -1232,9 +1249,10 @@ } /* Now we do the rebuffer */ + shrink_buffer(); queue_reply(&buffering_queue, 0); buffer_handle(handle_id, 0); -} +} /* Backend to bufseek and bufadvance */ static int seek_handle(struct memory_handle *h, size_t newpos) @@ -1600,23 +1618,6 @@ } #endif -/** -- buffer thread helpers -- **/ -static void shrink_buffer_inner(struct memory_handle *h) -{ - if (h == NULL) - return; - - shrink_buffer_inner(h->next); - - shrink_handle(h); -} - -static void shrink_buffer(void) -{ - logf("shrink_buffer()"); - shrink_buffer_inner(first_handle); -} - static void NORETURN_ATTR buffering_thread(void) { bool filling = false;