From 73f9863b1be9f31c8c18813b512c3504a7adfebc Mon Sep 17 00:00:00 2001 From: Steve Bavin Date: Wed, 26 Mar 2008 08:57:25 +0000 Subject: More consts that require no functional change. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16814 a1c6a512-1295-4272-9138-f99709370657 --- apps/buffering.c | 74 ++++++++++++++++++++++++++------------------------- apps/buffering.h | 34 +++++++++++------------ apps/plugin.h | 32 +++++++++++----------- firmware/export/id3.h | 4 +-- firmware/id3.c | 4 +-- 5 files changed, 75 insertions(+), 73 deletions(-) diff --git a/apps/buffering.c b/apps/buffering.c index 0cb428c947..d49669777b 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -182,7 +182,7 @@ enum { }; /* Buffering thread */ -void buffering_thread(void); +static void buffering_thread(void); static long buffering_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]; static const char buffering_thread_name[] = "buffering"; static struct thread_entry *buffering_thread_p; @@ -190,7 +190,7 @@ static struct event_queue buffering_queue; static struct queue_sender_list buffering_queue_sender_list; -static void call_buffering_callbacks(enum callback_event ev, int value); +static void call_buffering_callbacks(const enum callback_event ev, const int value); /* @@ -407,7 +407,7 @@ static struct memory_handle *find_handle(const int handle_id) found in the linked list for adjustment. This function has no side effects if NULL is returned. */ static bool move_handle(struct memory_handle **h, size_t *delta, - const size_t data_size, bool can_wrap) + const size_t data_size, const bool can_wrap) { struct memory_handle *dest; const struct memory_handle *src; @@ -492,7 +492,7 @@ static bool move_handle(struct memory_handle **h, size_t *delta, if (overlap > 0) { size_t first_part = size_to_move - overlap; memmove(dest, src, first_part); - memmove(buffer, (char *)src + first_part, overlap); + memmove(buffer, (const char *)src + first_part, overlap); } else { memmove(dest, src, size_to_move); } @@ -559,7 +559,7 @@ static inline bool buffer_is_low(void) /* Buffer data for the given handle. Return whether or not the buffering should continue explicitly. */ -static bool buffer_handle(int handle_id) +static bool buffer_handle(const int handle_id) { logf("buffer_handle(%d)", handle_id); struct memory_handle *h = find_handle(handle_id); @@ -667,7 +667,7 @@ static bool buffer_handle(int handle_id) /* Reset writing position and data buffer of a handle to its current offset. Use this after having set the new offset to use. */ -static void reset_handle(int handle_id) +static void reset_handle(const int handle_id) { logf("reset_handle(%d)", handle_id); @@ -687,7 +687,7 @@ static void reset_handle(int handle_id) } /* Seek to a nonbuffered part of a handle by rebuffering the data. */ -static void rebuffer_handle(int handle_id, size_t newpos) +static void rebuffer_handle(const int handle_id, const size_t newpos) { struct memory_handle *h = find_handle(handle_id); if (!h) @@ -725,7 +725,7 @@ static void rebuffer_handle(int handle_id, size_t newpos) h->ridx = h->data; } -static bool close_handle(int handle_id) +static bool close_handle(const int handle_id) { struct memory_handle *h = find_handle(handle_id); @@ -774,7 +774,7 @@ static void shrink_handle(struct memory_handle *h) /* when moving an mp3entry we need to readjust its pointers. */ adjust_mp3entry((struct mp3entry *)&buffer[h->data], (void *)&buffer[h->data], - (void *)&buffer[olddata]); + (const void *)&buffer[olddata]); } else if (h->type == TYPE_BITMAP) { /* adjust the bitmap's pointer */ struct bitmap *bmp = (struct bitmap *)&buffer[h->data]; @@ -873,7 +873,7 @@ management functions for all the actual handle management work. return value: <0 if the file cannot be opened, or one file already queued to be opened, otherwise the handle for the file in the buffer */ -int bufopen(const char *file, size_t offset, enum data_type type) +int bufopen(const char *file, size_t offset, const enum data_type type) { int fd = open(file, O_RDONLY); if (fd < 0) @@ -955,7 +955,7 @@ int bufopen(const char *file, size_t offset, enum data_type type) requested amount of data can entirely fit in the buffer without wrapping. Return value is the handle id for success or <0 for failure. */ -int bufalloc(const void *src, size_t size, enum data_type type) +int bufalloc(const void *src, const size_t size, const enum data_type type) { struct memory_handle *h = add_handle(size, false, true); @@ -966,7 +966,7 @@ int bufalloc(const void *src, size_t size, enum data_type type) if (type == TYPE_ID3 && size == sizeof(struct mp3entry)) { /* specially take care of struct mp3entry */ copy_mp3entry((struct mp3entry *)&buffer[buf_widx], - (struct mp3entry *)src); + (const struct mp3entry *)src); } else { memcpy(&buffer[buf_widx], src, size); } @@ -990,7 +990,7 @@ int bufalloc(const void *src, size_t size, enum data_type type) } /* Close the handle. Return true for success and false for failure */ -bool bufclose(int handle_id) +bool bufclose(const int handle_id) { logf("bufclose(%d)", handle_id); @@ -1004,7 +1004,7 @@ bool bufclose(int handle_id) -1 if the handle wasn't found -2 if the new requested position was beyond the end of the file */ -int bufseek(int handle_id, size_t newpos) +int bufseek(const int handle_id, const size_t newpos) { struct memory_handle *h = find_handle(handle_id); if (!h) @@ -1026,7 +1026,7 @@ int bufseek(int handle_id, size_t newpos) /* Advance the reading index in a handle (relatively to its current position). Return 0 for success and < 0 for failure */ -int bufadvance(int handle_id, off_t offset) +int bufadvance(const int handle_id, const off_t offset) { const struct memory_handle *h = find_handle(handle_id); if (!h) @@ -1094,7 +1094,7 @@ static struct memory_handle *prep_bufdata(const int handle_id, size_t *size, Return the number of bytes copied or < 0 for failure (handle not found). The caller is blocked until the requested amount of data is available. */ -ssize_t bufread(int handle_id, size_t size, void *dest) +ssize_t bufread(const int handle_id, size_t size, void *dest) { const struct memory_handle *h; @@ -1126,7 +1126,7 @@ ssize_t bufread(int handle_id, size_t size, void *dest) The guard buffer may be used to provide the requested size. This means it's unsafe to request more than the size of the guard buffer. */ -ssize_t bufgetdata(int handle_id, size_t size, void **data) +ssize_t bufgetdata(const int handle_id, size_t size, void **data) { const struct memory_handle *h; @@ -1141,7 +1141,7 @@ ssize_t bufgetdata(int handle_id, size_t size, void **data) size_t copy_n = h->ridx + size - buffer_len; /* prep_bufdata ensures size <= buffer_len - h->ridx + GUARD_BUFSIZE, so copy_n <= GUARD_BUFSIZE */ - memcpy(guard_buffer, (unsigned char *)buffer, copy_n); + memcpy(guard_buffer, (const unsigned char *)buffer, copy_n); } if (data) @@ -1150,7 +1150,7 @@ ssize_t bufgetdata(int handle_id, size_t size, void **data) return size; } -ssize_t bufgettail(int handle_id, size_t size, void **data) +ssize_t bufgettail(const int handle_id, const size_t size, void **data) { size_t tidx; @@ -1173,14 +1173,14 @@ ssize_t bufgettail(int handle_id, size_t size, void **data) if (tidx + size > buffer_len) { size_t copy_n = tidx + size - buffer_len; - memcpy(guard_buffer, (unsigned char *)buffer, copy_n); + memcpy(guard_buffer, (const unsigned char *)buffer, copy_n); } *data = &buffer[tidx]; return size; } -ssize_t bufcuttail(int handle_id, size_t size) +ssize_t bufcuttail(const int handle_id, size_t size) { struct memory_handle *h; @@ -1198,9 +1198,9 @@ ssize_t bufcuttail(int handle_id, size_t size) h->available -= size; h->filesize -= size; h->widx = RINGBUF_SUB(h->widx, size); - if (h == cur_handle) { + if (h == cur_handle) buf_widx = h->widx; - } + return size; } @@ -1223,7 +1223,7 @@ management functions for all the actual handle management work. */ /* Get a handle offset from a pointer */ -ssize_t buf_get_offset(int handle_id, void *ptr) +ssize_t buf_get_offset(const int handle_id, void *ptr) { const struct memory_handle *h = find_handle(handle_id); if (!h) @@ -1232,7 +1232,7 @@ ssize_t buf_get_offset(int handle_id, void *ptr) return (size_t)ptr - (size_t)&buffer[h->ridx]; } -ssize_t buf_handle_offset(int handle_id) +ssize_t buf_handle_offset(const int handle_id) { const struct memory_handle *h = find_handle(handle_id); if (!h) @@ -1240,13 +1240,13 @@ ssize_t buf_handle_offset(int handle_id) return h->offset; } -void buf_request_buffer_handle(int handle_id) +void buf_request_buffer_handle(const int handle_id) { LOGFQUEUE("buffering >| Q_START_FILL %d",handle_id); queue_send(&buffering_queue, Q_START_FILL, handle_id); } -void buf_set_base_handle(int handle_id) +void buf_set_base_handle(const int handle_id) { LOGFQUEUE("buffering > Q_BASE_HANDLE %d", handle_id); queue_post(&buffering_queue, Q_BASE_HANDLE, handle_id); @@ -1258,13 +1258,13 @@ size_t buf_used(void) return BUF_USED; } -void buf_set_watermark(size_t bytes) +void buf_set_watermark(const size_t bytes) { LOGFQUEUE("buffering > Q_SET_WATERMARK %ld", (long)bytes); queue_post(&buffering_queue, Q_SET_WATERMARK, bytes); } -bool register_buffering_callback(buffering_callback func) +bool register_buffering_callback(const buffering_callback func) { int i; if (buffer_callback_count >= MAX_BUF_CALLBACKS) @@ -1283,7 +1283,7 @@ bool register_buffering_callback(buffering_callback func) return false; } -void unregister_buffering_callback(buffering_callback func) +void unregister_buffering_callback(const buffering_callback func) { int i; for (i = 0; i < MAX_BUF_CALLBACKS; i++) @@ -1297,7 +1297,7 @@ void unregister_buffering_callback(buffering_callback func) return; } -static void call_buffering_callbacks(enum callback_event ev, int value) +static void call_buffering_callbacks(const enum callback_event ev, const int value) { logf("call_buffering_callbacks()"); int i; @@ -1310,8 +1310,8 @@ static void call_buffering_callbacks(enum callback_event ev, int value) } } -static void shrink_buffer_inner(struct memory_handle *h) { - +static void shrink_buffer_inner(struct memory_handle *h) +{ if (h == NULL) return; @@ -1320,7 +1320,8 @@ static void shrink_buffer_inner(struct memory_handle *h) { shrink_handle(h); } -static void shrink_buffer(void) { +static void shrink_buffer(void) +{ logf("shrink_buffer()"); shrink_buffer_inner(first_handle); } @@ -1444,7 +1445,8 @@ void buffering_thread(void) } } -void buffering_init(void) { +void buffering_init(void) +{ mutex_init(&llist_mutex); #ifdef HAVE_PRIORITY_SCHEDULING /* This behavior not safe atm */ @@ -1464,7 +1466,7 @@ void buffering_init(void) { } /* Initialise the buffering subsystem */ -bool buffering_reset(char *buf, size_t buflen) +bool buffering_reset(char *buf, const size_t buflen) { if (!buf || !buflen) return false; diff --git a/apps/buffering.h b/apps/buffering.h index bc61ec5e6d..abe8f608c6 100644 --- a/apps/buffering.h +++ b/apps/buffering.h @@ -56,7 +56,7 @@ enum callback_event { void buffering_init(void); /* Reset the buffering system */ -bool buffering_reset(char *buf, size_t buflen); +bool buffering_reset(char *buf, const size_t buflen); /*************************************************************************** @@ -80,15 +80,15 @@ bool buffering_reset(char *buf, size_t buflen); #define BUF_MAX_HANDLES 256 -int bufopen(const char *file, size_t offset, enum data_type type); -int bufalloc(const void *src, size_t size, enum data_type type); -bool bufclose(int handle_id); -int bufseek(int handle_id, size_t newpos); -int bufadvance(int handle_id, off_t offset); -ssize_t bufread(int handle_id, size_t size, void *dest); -ssize_t bufgetdata(int handle_id, size_t size, void **data); -ssize_t bufgettail(int handle_id, size_t size, void **data); -ssize_t bufcuttail(int handle_id, size_t size); +int bufopen(const char *file, size_t offset, const enum data_type type); +int bufalloc(const void *src, const size_t size, const enum data_type type); +bool bufclose(const int handle_id); +int bufseek(const int handle_id, const size_t newpos); +int bufadvance(const int handle_id, const off_t offset); +ssize_t bufread(const int handle_id, size_t size, void *dest); +ssize_t bufgetdata(const int handle_id, size_t size, void **data); +ssize_t bufgettail(const int handle_id, const size_t size, void **data); +ssize_t bufcuttail(const int handle_id, size_t size); /*************************************************************************** @@ -102,10 +102,10 @@ ssize_t bufcuttail(int handle_id, size_t size); * buf_used: Total amount of buffer space used (including allocated space) ****************************************************************************/ -ssize_t buf_get_offset(int handle_id, void *ptr); -ssize_t buf_handle_offset(int handle_id); -void buf_request_buffer_handle(int handle_id); -void buf_set_base_handle(int handle_id); +ssize_t buf_get_offset(const int handle_id, void *ptr); +ssize_t buf_handle_offset(const int handle_id); +void buf_request_buffer_handle(const int handle_id); +void buf_set_base_handle(const int handle_id); size_t buf_used(void); @@ -123,9 +123,9 @@ size_t buf_used(void); ****************************************************************************/ #define MAX_BUF_CALLBACKS 4 -typedef void (*buffering_callback)(enum callback_event ev, int value); -bool register_buffering_callback(buffering_callback func); -void unregister_buffering_callback(buffering_callback func); +typedef void (*buffering_callback)(const enum callback_event ev, const int value); +bool register_buffering_callback(const buffering_callback func); +void unregister_buffering_callback(const buffering_callback func); /* Settings */ enum { diff --git a/apps/plugin.h b/apps/plugin.h index 66ed5fdbb2..27fcffb69c 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -120,12 +120,12 @@ #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 103 +#define PLUGIN_API_VERSION 104 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 103 +#define PLUGIN_MIN_API_VERSION 104 /* plugin return codes */ enum plugin_status { @@ -684,20 +684,20 @@ struct plugin_api { #if (CONFIG_CODEC == SWCODEC) /* buffering API */ - int (*bufopen)(const char *file, size_t offset, enum data_type type); - int (*bufalloc)(const void *src, size_t size, enum data_type type); - bool (*bufclose)(int handle_id); - int (*bufseek)(int handle_id, size_t newpos); - int (*bufadvance)(int handle_id, off_t offset); - ssize_t (*bufread)(int handle_id, size_t size, void *dest); - ssize_t (*bufgetdata)(int handle_id, size_t size, void **data); - ssize_t (*bufgettail)(int handle_id, size_t size, void **data); - ssize_t (*bufcuttail)(int handle_id, size_t size); - - ssize_t (*buf_get_offset)(int handle_id, void *ptr); - ssize_t (*buf_handle_offset)(int handle_id); - void (*buf_request_buffer_handle)(int handle_id); - void (*buf_set_base_handle)(int handle_id); + int (*bufopen)(const char *file, size_t offset, const enum data_type type); + int (*bufalloc)(const void *src, const size_t size, const enum data_type type); + bool (*bufclose)(const int handle_id); + int (*bufseek)(const int handle_id, const size_t newpos); + int (*bufadvance)(const int handle_id, const off_t offset); + ssize_t (*bufread)(const int handle_id, size_t size, void *dest); + ssize_t (*bufgetdata)(const int handle_id, size_t size, void **data); + ssize_t (*bufgettail)(const int handle_id, const size_t size, void **data); + ssize_t (*bufcuttail)(const int handle_id, size_t size); + + ssize_t (*buf_get_offset)(const int handle_id, void *ptr); + ssize_t (*buf_handle_offset)(const int handle_id); + void (*buf_request_buffer_handle)(const int handle_id); + void (*buf_set_base_handle)(const int handle_id); size_t (*buf_used)(void); #endif diff --git a/firmware/export/id3.h b/firmware/export/id3.h index bb3b6a6fe5..0035fae19a 100644 --- a/firmware/export/id3.h +++ b/firmware/export/id3.h @@ -234,7 +234,7 @@ bool mp3info(struct mp3entry *entry, const char *filename); char* id3_get_num_genre(const unsigned int genre_num); char* id3_get_codec(const struct mp3entry* id3); int getid3v2len(int fd); -void adjust_mp3entry(struct mp3entry *entry, void *dest, void *orig); -void copy_mp3entry(struct mp3entry *dest, struct mp3entry *orig); +void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig); +void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig); #endif diff --git a/firmware/id3.c b/firmware/id3.c index f594528910..6afe2ac304 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -1231,7 +1231,7 @@ bool mp3info(struct mp3entry *entry, const char *filename) return result; } -void adjust_mp3entry(struct mp3entry *entry, void *dest, void *orig) +void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig) { long offset; if (orig > dest) @@ -1270,7 +1270,7 @@ void adjust_mp3entry(struct mp3entry *entry, void *dest, void *orig) #endif } -void copy_mp3entry(struct mp3entry *dest, struct mp3entry *orig) +void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig) { memcpy(dest, orig, sizeof(struct mp3entry)); adjust_mp3entry(dest, dest, orig); -- cgit v1.2.3