mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Do the ridx > widx check where it should be done. A small rebuffering request must completely succeed before buffer can later shrink a handle or else it must reset the handle.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29491 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
64647f3403
commit
05e180a130
1 changed files with 13 additions and 9 deletions
|
@ -808,11 +808,7 @@ static void shrink_handle(struct memory_handle *h)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* only move the handle struct */
|
/* only move the handle struct */
|
||||||
size_t rd = ringbuf_sub(h->ridx, h->data);
|
delta = ringbuf_sub(h->ridx, h->data);
|
||||||
size_t wr = ringbuf_sub(h->widx, h->data);
|
|
||||||
|
|
||||||
/* ridx could be ahead of widx on a mini rebuffer */
|
|
||||||
delta = MIN(rd, wr);
|
|
||||||
if (!move_handle(&h, &delta, 0, true))
|
if (!move_handle(&h, &delta, 0, true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1154,11 +1150,19 @@ static void rebuffer_handle(int handle_id, size_t newpos)
|
||||||
h->ridx = ringbuf_add(h->data, amount);
|
h->ridx = ringbuf_add(h->data, amount);
|
||||||
|
|
||||||
if (buffer_handle(handle_id, amount + 1)) {
|
if (buffer_handle(handle_id, amount + 1)) {
|
||||||
queue_reply(&buffering_queue, 0);
|
size_t rd = ringbuf_sub(h->ridx, h->data);
|
||||||
buffer_handle(handle_id, 0); /* Ok, try the rest */
|
size_t wr = ringbuf_sub(h->widx, h->data);
|
||||||
return;
|
if (wr >= rd) {
|
||||||
|
/* It really did succeed */
|
||||||
|
queue_reply(&buffering_queue, 0);
|
||||||
|
buffer_handle(handle_id, 0); /* Ok, try the rest */
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Data collision - must reset */
|
/* Data collision or other file error - must reset */
|
||||||
|
|
||||||
|
if (newpos > h->filesize)
|
||||||
|
newpos = h->filesize; /* file truncation happened above */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset the handle to its new position */
|
/* Reset the handle to its new position */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue