mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Reapply "buffering: remove bufgettail/bufcuttail"
This reverts commit 2bd88936f7
. Strip tags functionlity will be moved to codec.
Change-Id: Iff28ff7a29da09632ceed30a7959cc1ee8bf3cc8
This commit is contained in:
parent
e7110c0beb
commit
78903e9d38
5 changed files with 2 additions and 107 deletions
|
@ -1440,62 +1440,6 @@ ssize_t bufgetdata(int handle_id, size_t size, void **data)
|
|||
return size;
|
||||
}
|
||||
|
||||
ssize_t bufgettail(int handle_id, size_t size, void **data)
|
||||
{
|
||||
if (thread_self() != buffering_thread_id)
|
||||
return ERR_WRONG_THREAD; /* only from buffering thread */
|
||||
|
||||
/* We don't support tail requests of > guardbuf_size, for simplicity */
|
||||
if (size > GUARD_BUFSIZE)
|
||||
return ERR_INVALID_VALUE;
|
||||
|
||||
const struct memory_handle *h = find_handle(handle_id);
|
||||
if (!h)
|
||||
return ERR_HANDLE_NOT_FOUND;
|
||||
|
||||
if (h->end >= h->filesize) {
|
||||
size_t tidx = ringbuf_sub_empty(h->widx, size);
|
||||
|
||||
if (tidx + size > buffer_len) {
|
||||
size_t copy_n = tidx + size - buffer_len;
|
||||
memcpy(guard_buffer, ringbuf_ptr(0), copy_n);
|
||||
}
|
||||
|
||||
*data = ringbuf_ptr(tidx);
|
||||
}
|
||||
else {
|
||||
size = ERR_HANDLE_NOT_DONE;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
ssize_t bufcuttail(int handle_id, size_t size)
|
||||
{
|
||||
if (thread_self() != buffering_thread_id)
|
||||
return ERR_WRONG_THREAD; /* only from buffering thread */
|
||||
|
||||
struct memory_handle *h = find_handle(handle_id);
|
||||
if (!h)
|
||||
return ERR_HANDLE_NOT_FOUND;
|
||||
|
||||
if (h->end >= h->filesize) {
|
||||
/* Cannot trim to before read position */
|
||||
size_t available = h->end - MAX(h->start, h->pos);
|
||||
if (available < size)
|
||||
size = available;
|
||||
|
||||
h->widx = ringbuf_sub_empty(h->widx, size);
|
||||
h->filesize -= size;
|
||||
h->end -= size;
|
||||
} else {
|
||||
size = ERR_HANDLE_NOT_DONE;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SECONDARY EXPORTED FUNCTIONS
|
||||
============================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue