Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

fix buffering problem in rockbox

By: a guest on Jan 21st, 2011  |  syntax: C  |  size: 1.19 KB  |  hits: 151  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. peadar@fatlenny$ diff -Nuw apps/buffering.c.0 apps/buffering.c
  2. --- apps/buffering.c.0  2011-01-11 00:01:50.000000000 +0000
  3. +++ apps/buffering.c    2011-01-22 01:50:57.000000000 +0000
  4. @@ -681,7 +681,7 @@
  5.           * If this is true, then there's a handle even though we have still
  6.          * data to buffer. This should NEVER EVER happen! (but it does :( ) */
  7.         if (h->next && (overlap
  8. -                = ringbuf_add_cross(h->widx, copy_n, next_handle)) > 0)
  9. +                = ringbuf_add_cross(h->widx, copy_n, next_handle)) >= 0)
  10.         {
  11.             /* stop buffering data for now and post-pone buffering the rest */
  12.             stop = true;
  13. @@ -689,7 +689,11 @@
  14.                     " copy_n:%lu overlap:%ld h1.filerem:%lu\n", __func__,
  15.                     h->id, h->next->id, (unsigned long)copy_n, (long)overlap,
  16.                     (unsigned long)h->filerem);
  17. -            copy_n -= overlap;
  18. +            if (overlap == (ssize_t)copy_n) {
  19. +                DEBUGF("%u: buffer_handle(%d): READ NOTHING\n", thread_get_current(), handle_id);
  20. +                return false;
  21. +            }
  22. +            copy_n -= overlap + 1;
  23.         }
  24.  
  25.         /* rc is the actual amount read */