buffering: remove bufgettail/bufcuttail

These operations can only be used in limited circumstances and have
exactly one user. bufgettail especially seems of dubious value; how
often do you need to read N bytes from the end of a file without
changing the file position?

strip_tags() was the only function using them, to strip off ID3v1
and APE tags off the end of buffered tracks. This would save only
32-192 bytes per track -- if the container format uses APE/ID3v1.
It hardly seems worth the effort.

Change-Id: I8fc3c1408517eda6126e75e76d76daea904b50eb
This commit is contained in:
Aidan MacDonald 2022-03-26 21:54:23 +00:00 committed by Solomon Peachy
parent 931d616071
commit 9e93796407
6 changed files with 1 additions and 119 deletions

View file

@ -1436,62 +1436,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
============================