mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Prefix the error constants with ERR_
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15359 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
75eff7af5e
commit
d400e23e38
3 changed files with 27 additions and 27 deletions
|
@ -803,11 +803,11 @@ management functions for all the actual handle management work.
|
||||||
int bufopen(const char *file, size_t offset, enum data_type type)
|
int bufopen(const char *file, size_t offset, enum data_type type)
|
||||||
{
|
{
|
||||||
if (!can_add_handle())
|
if (!can_add_handle())
|
||||||
return BUFFER_FULL;
|
return ERR_BUFFER_FULL;
|
||||||
|
|
||||||
int fd = open(file, O_RDONLY);
|
int fd = open(file, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return FILE_ERROR;
|
return ERR_FILE_ERROR;
|
||||||
|
|
||||||
size_t size = filesize(fd);
|
size_t size = filesize(fd);
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ int bufopen(const char *file, size_t offset, enum data_type type)
|
||||||
{
|
{
|
||||||
DEBUGF("bufopen: failed to add handle\n");
|
DEBUGF("bufopen: failed to add handle\n");
|
||||||
close(fd);
|
close(fd);
|
||||||
return BUFFER_FULL;
|
return ERR_BUFFER_FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(h->path, file, MAX_PATH);
|
strncpy(h->path, file, MAX_PATH);
|
||||||
|
@ -854,12 +854,12 @@ int bufopen(const char *file, size_t offset, enum data_type type)
|
||||||
int bufalloc(const void *src, size_t size, enum data_type type)
|
int bufalloc(const void *src, size_t size, enum data_type type)
|
||||||
{
|
{
|
||||||
if (!can_add_handle())
|
if (!can_add_handle())
|
||||||
return BUFFER_FULL;
|
return ERR_BUFFER_FULL;
|
||||||
|
|
||||||
struct memory_handle *h = add_handle(size, false, true);
|
struct memory_handle *h = add_handle(size, false, true);
|
||||||
|
|
||||||
if (!h)
|
if (!h)
|
||||||
return BUFFER_FULL;
|
return ERR_BUFFER_FULL;
|
||||||
|
|
||||||
if (src) {
|
if (src) {
|
||||||
if (type == TYPE_ID3 && size == sizeof(struct mp3entry)) {
|
if (type == TYPE_ID3 && size == sizeof(struct mp3entry)) {
|
||||||
|
@ -907,11 +907,11 @@ int bufseek(int handle_id, size_t newpos)
|
||||||
{
|
{
|
||||||
struct memory_handle *h = find_handle(handle_id);
|
struct memory_handle *h = find_handle(handle_id);
|
||||||
if (!h)
|
if (!h)
|
||||||
return HANDLE_NOT_FOUND;
|
return ERR_HANDLE_NOT_FOUND;
|
||||||
|
|
||||||
if (newpos > h->filesize) {
|
if (newpos > h->filesize) {
|
||||||
/* access beyond the end of the file */
|
/* access beyond the end of the file */
|
||||||
return INVALID_VALUE;
|
return ERR_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
else if (newpos < h->offset || h->offset + h->available < newpos) {
|
else if (newpos < h->offset || h->offset + h->available < newpos) {
|
||||||
/* access before or after buffered data. A rebuffer is needed. */
|
/* access before or after buffered data. A rebuffer is needed. */
|
||||||
|
@ -929,7 +929,7 @@ int bufadvance(int handle_id, off_t offset)
|
||||||
{
|
{
|
||||||
const struct memory_handle *h = find_handle(handle_id);
|
const struct memory_handle *h = find_handle(handle_id);
|
||||||
if (!h)
|
if (!h)
|
||||||
return HANDLE_NOT_FOUND;
|
return ERR_HANDLE_NOT_FOUND;
|
||||||
|
|
||||||
size_t newpos = h->offset + RINGBUF_SUB(h->ridx, h->data) + offset;
|
size_t newpos = h->offset + RINGBUF_SUB(h->ridx, h->data) + offset;
|
||||||
return bufseek(handle_id, newpos);
|
return bufseek(handle_id, newpos);
|
||||||
|
@ -941,18 +941,18 @@ ssize_t bufread(int handle_id, size_t size, void *dest)
|
||||||
{
|
{
|
||||||
const struct memory_handle *h = find_handle(handle_id);
|
const struct memory_handle *h = find_handle(handle_id);
|
||||||
if (!h)
|
if (!h)
|
||||||
return HANDLE_NOT_FOUND;
|
return ERR_HANDLE_NOT_FOUND;
|
||||||
|
|
||||||
size_t ret;
|
size_t ret;
|
||||||
size_t copy_n = RINGBUF_SUB(h->widx, h->ridx);
|
size_t copy_n = RINGBUF_SUB(h->widx, h->ridx);
|
||||||
|
|
||||||
if (size == 0 && h->filerem > 0 && copy_n == 0)
|
if (size == 0 && h->filerem > 0 && copy_n == 0)
|
||||||
/* Data isn't ready */
|
/* Data isn't ready */
|
||||||
return DATA_NOT_READY;
|
return ERR_DATA_NOT_READY;
|
||||||
|
|
||||||
if (copy_n < size && h->filerem > 0)
|
if (copy_n < size && h->filerem > 0)
|
||||||
/* Data isn't ready */
|
/* Data isn't ready */
|
||||||
return DATA_NOT_READY;
|
return ERR_DATA_NOT_READY;
|
||||||
|
|
||||||
if (copy_n == 0 && h->filerem == 0)
|
if (copy_n == 0 && h->filerem == 0)
|
||||||
/* File is finished reading */
|
/* File is finished reading */
|
||||||
|
@ -984,18 +984,18 @@ ssize_t bufgetdata(int handle_id, size_t size, void **data)
|
||||||
{
|
{
|
||||||
const struct memory_handle *h = find_handle(handle_id);
|
const struct memory_handle *h = find_handle(handle_id);
|
||||||
if (!h)
|
if (!h)
|
||||||
return HANDLE_NOT_FOUND;
|
return ERR_HANDLE_NOT_FOUND;
|
||||||
|
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
size_t copy_n = RINGBUF_SUB(h->widx, h->ridx);
|
size_t copy_n = RINGBUF_SUB(h->widx, h->ridx);
|
||||||
|
|
||||||
if (size == 0 && h->filerem > 0 && copy_n == 0)
|
if (size == 0 && h->filerem > 0 && copy_n == 0)
|
||||||
/* Data isn't ready */
|
/* Data isn't ready */
|
||||||
return DATA_NOT_READY;
|
return ERR_DATA_NOT_READY;
|
||||||
|
|
||||||
if (copy_n < size && h->filerem > 0)
|
if (copy_n < size && h->filerem > 0)
|
||||||
/* Data isn't ready */
|
/* Data isn't ready */
|
||||||
return DATA_NOT_READY;
|
return ERR_DATA_NOT_READY;
|
||||||
|
|
||||||
if (copy_n == 0 && h->filerem == 0)
|
if (copy_n == 0 && h->filerem == 0)
|
||||||
/* File is finished reading */
|
/* File is finished reading */
|
||||||
|
@ -1040,7 +1040,7 @@ ssize_t buf_get_offset(int handle_id, void *ptr)
|
||||||
{
|
{
|
||||||
const struct memory_handle *h = find_handle(handle_id);
|
const struct memory_handle *h = find_handle(handle_id);
|
||||||
if (!h)
|
if (!h)
|
||||||
return HANDLE_NOT_FOUND;
|
return ERR_HANDLE_NOT_FOUND;
|
||||||
|
|
||||||
return (size_t)ptr - (size_t)&buffer[h->ridx];
|
return (size_t)ptr - (size_t)&buffer[h->ridx];
|
||||||
}
|
}
|
||||||
|
@ -1049,7 +1049,7 @@ ssize_t buf_handle_offset(int handle_id)
|
||||||
{
|
{
|
||||||
const struct memory_handle *h = find_handle(handle_id);
|
const struct memory_handle *h = find_handle(handle_id);
|
||||||
if (!h)
|
if (!h)
|
||||||
return HANDLE_NOT_FOUND;
|
return ERR_HANDLE_NOT_FOUND;
|
||||||
return h->offset;
|
return h->offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,11 @@ enum data_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Error return values */
|
/* Error return values */
|
||||||
#define HANDLE_NOT_FOUND -1
|
#define ERR_HANDLE_NOT_FOUND -1
|
||||||
#define BUFFER_FULL -2
|
#define ERR_BUFFER_FULL -2
|
||||||
#define INVALID_VALUE -3
|
#define ERR_INVALID_VALUE -3
|
||||||
#define FILE_ERROR -4
|
#define ERR_FILE_ERROR -4
|
||||||
#define DATA_NOT_READY -5
|
#define ERR_DATA_NOT_READY -5
|
||||||
|
|
||||||
|
|
||||||
/* Initialise the buffering subsystem */
|
/* Initialise the buffering subsystem */
|
||||||
|
|
|
@ -366,11 +366,11 @@ static void *bufgetcodec(struct track_info *track)
|
||||||
void *ptr;
|
void *ptr;
|
||||||
ssize_t ret = bufgetdata(track->codec_hid, track->codecsize, &ptr);
|
ssize_t ret = bufgetdata(track->codec_hid, track->codecsize, &ptr);
|
||||||
|
|
||||||
if (ret == DATA_NOT_READY) {
|
if (ret == ERR_DATA_NOT_READY) {
|
||||||
buf_request_buffer_handle(track->codec_hid);
|
buf_request_buffer_handle(track->codec_hid);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ret == DATA_NOT_READY) {
|
while (ret == ERR_DATA_NOT_READY) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
ret = bufgetdata(track->codec_hid, track->codecsize, &ptr);
|
ret = bufgetdata(track->codec_hid, track->codecsize, &ptr);
|
||||||
}
|
}
|
||||||
|
@ -1516,13 +1516,13 @@ static size_t codec_filebuf_callback(void *ptr, size_t size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
if (copy_n == DATA_NOT_READY)
|
if (copy_n == ERR_DATA_NOT_READY)
|
||||||
{
|
{
|
||||||
buf_request_buffer_handle(CUR_TI->audio_hid);
|
buf_request_buffer_handle(CUR_TI->audio_hid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let the disk buffer catch fill until enough data is available */
|
/* Let the disk buffer catch fill until enough data is available */
|
||||||
while (copy_n == DATA_NOT_READY)
|
while (copy_n == ERR_DATA_NOT_READY)
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
|
@ -1561,13 +1561,13 @@ static void* codec_request_buffer_callback(size_t *realsize, size_t reqsize)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == DATA_NOT_READY)
|
if (ret == ERR_DATA_NOT_READY)
|
||||||
{
|
{
|
||||||
buf_request_buffer_handle(CUR_TI->audio_hid);
|
buf_request_buffer_handle(CUR_TI->audio_hid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let the disk buffer catch fill until enough data is available */
|
/* Let the disk buffer catch fill until enough data is available */
|
||||||
while (ret == DATA_NOT_READY)
|
while (ret == ERR_DATA_NOT_READY)
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue