diff --git a/apps/buffering.c b/apps/buffering.c index d891382d81..938cc95620 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -190,7 +190,7 @@ static struct event_queue buffering_queue; static struct queue_sender_list buffering_queue_sender_list; -static void call_buffering_callbacks(const enum callback_event ev, const int value); +static void call_buffering_callbacks(enum callback_event ev, int value); /* @@ -225,8 +225,8 @@ buf_ridx == buf_widx means the buffer is empty. only potential side effect is to allocate space for the cur_handle if it returns NULL. */ -static struct memory_handle *add_handle(const size_t data_size, const bool can_wrap, - const bool alloc_all) +static struct memory_handle *add_handle(size_t data_size, bool can_wrap, + bool alloc_all) { /* gives each handle a unique id */ static int cur_handle_id = 0; @@ -363,7 +363,7 @@ static bool rm_handle(const struct memory_handle *h) /* Return a pointer to the memory handle of given ID. NULL if the handle wasn't found */ -static struct memory_handle *find_handle(const int handle_id) +static struct memory_handle *find_handle(int handle_id) { if (handle_id < 0) return NULL; @@ -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, const bool can_wrap) + size_t data_size, bool can_wrap) { struct memory_handle *dest; const struct memory_handle *src; @@ -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(const int handle_id) +static bool buffer_handle(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(const 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(const int handle_id) +static void reset_handle(int handle_id) { logf("reset_handle(%d)", handle_id); @@ -687,7 +687,7 @@ static void reset_handle(const int handle_id) } /* Seek to a nonbuffered part of a handle by rebuffering the data. */ -static void rebuffer_handle(const int handle_id, const size_t newpos) +static void rebuffer_handle(int handle_id, size_t newpos) { struct memory_handle *h = find_handle(handle_id); if (!h) @@ -725,7 +725,7 @@ static void rebuffer_handle(const int handle_id, const size_t newpos) h->ridx = h->data; } -static bool close_handle(const int handle_id) +static bool close_handle(int handle_id) { struct memory_handle *h = find_handle(handle_id); @@ -830,7 +830,7 @@ static bool fill_buffer(void) /* Given a file descriptor to a bitmap file, write the bitmap data to the buffer, with a struct bitmap and the actual data immediately following. Return value is the total size (struct + data). */ -static int load_bitmap(const int fd) +static int load_bitmap(int fd) { int rc; struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx]; @@ -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, const size_t offset, const enum data_type type) +int bufopen(const char *file, size_t offset, enum data_type type) { size_t adjusted_offset = offset; @@ -957,7 +957,7 @@ int bufopen(const char *file, const size_t offset, const 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, const size_t size, const enum data_type type) +int bufalloc(const void *src, size_t size, enum data_type type) { struct memory_handle *h = add_handle(size, false, true); @@ -992,7 +992,7 @@ int bufalloc(const void *src, const size_t size, const enum data_type type) } /* Close the handle. Return true for success and false for failure */ -bool bufclose(const int handle_id) +bool bufclose(int handle_id) { logf("bufclose(%d)", handle_id); @@ -1006,7 +1006,7 @@ bool bufclose(const 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(const int handle_id, const size_t newpos) +int bufseek(int handle_id, size_t newpos) { struct memory_handle *h = find_handle(handle_id); if (!h) @@ -1028,7 +1028,7 @@ int bufseek(const int handle_id, const 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(const int handle_id, const off_t offset) +int bufadvance(int handle_id, off_t offset) { const struct memory_handle *h = find_handle(handle_id); if (!h) @@ -1042,8 +1042,8 @@ int bufadvance(const int handle_id, const off_t offset) * actual amount of data available for reading. This function explicitly * does not check the validity of the input handle. It does do range checks * on size and returns a valid (and explicit) amount of data for reading */ -static struct memory_handle *prep_bufdata(const int handle_id, size_t *size, - const bool guardbuf_limit) +static struct memory_handle *prep_bufdata(int handle_id, size_t *size, + bool guardbuf_limit) { struct memory_handle *h = find_handle(handle_id); if (!h) @@ -1096,7 +1096,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(const int handle_id, const size_t size, void *dest) +ssize_t bufread(int handle_id, size_t size, void *dest) { const struct memory_handle *h; size_t adjusted_size = size; @@ -1129,7 +1129,7 @@ ssize_t bufread(const int handle_id, const 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(const int handle_id, const size_t size, void **data) +ssize_t bufgetdata(int handle_id, size_t size, void **data) { const struct memory_handle *h; size_t adjusted_size = size; @@ -1154,7 +1154,7 @@ ssize_t bufgetdata(const int handle_id, const size_t size, void **data) return adjusted_size; } -ssize_t bufgettail(const int handle_id, const size_t size, void **data) +ssize_t bufgettail(int handle_id, size_t size, void **data) { size_t tidx; @@ -1184,7 +1184,7 @@ ssize_t bufgettail(const int handle_id, const size_t size, void **data) return size; } -ssize_t bufcuttail(const int handle_id, const size_t size) +ssize_t bufcuttail(int handle_id, size_t size) { struct memory_handle *h; size_t adjusted_size = size; @@ -1228,7 +1228,7 @@ management functions for all the actual handle management work. */ /* Get a handle offset from a pointer */ -ssize_t buf_get_offset(const int handle_id, void *ptr) +ssize_t buf_get_offset(int handle_id, void *ptr) { const struct memory_handle *h = find_handle(handle_id); if (!h) @@ -1237,7 +1237,7 @@ ssize_t buf_get_offset(const int handle_id, void *ptr) return (size_t)ptr - (size_t)&buffer[h->ridx]; } -ssize_t buf_handle_offset(const int handle_id) +ssize_t buf_handle_offset(int handle_id) { const struct memory_handle *h = find_handle(handle_id); if (!h) @@ -1245,13 +1245,13 @@ ssize_t buf_handle_offset(const int handle_id) return h->offset; } -void buf_request_buffer_handle(const int handle_id) +void buf_request_buffer_handle(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(const int handle_id) +void buf_set_base_handle(int handle_id) { LOGFQUEUE("buffering > Q_BASE_HANDLE %d", handle_id); queue_post(&buffering_queue, Q_BASE_HANDLE, handle_id); @@ -1263,13 +1263,13 @@ size_t buf_used(void) return BUF_USED; } -void buf_set_watermark(const size_t bytes) +void buf_set_watermark(size_t bytes) { LOGFQUEUE("buffering > Q_SET_WATERMARK %ld", (long)bytes); queue_post(&buffering_queue, Q_SET_WATERMARK, bytes); } -bool register_buffering_callback(const buffering_callback func) +bool register_buffering_callback(buffering_callback func) { int i; if (buffer_callback_count >= MAX_BUF_CALLBACKS) @@ -1288,7 +1288,7 @@ bool register_buffering_callback(const buffering_callback func) return false; } -void unregister_buffering_callback(const buffering_callback func) +void unregister_buffering_callback(buffering_callback func) { int i; for (i = 0; i < MAX_BUF_CALLBACKS; i++) @@ -1302,7 +1302,7 @@ void unregister_buffering_callback(const buffering_callback func) return; } -static void call_buffering_callbacks(const enum callback_event ev, const int value) +static void call_buffering_callbacks(enum callback_event ev, int value) { logf("call_buffering_callbacks()"); int i; @@ -1471,7 +1471,7 @@ void buffering_init(void) } /* Initialise the buffering subsystem */ -bool buffering_reset(char *buf, const size_t buflen) +bool buffering_reset(char *buf, size_t buflen) { if (!buf || !buflen) return false; diff --git a/apps/buffering.h b/apps/buffering.h index abe8f608c6..bc61ec5e6d 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, const size_t buflen); +bool buffering_reset(char *buf, size_t buflen); /*************************************************************************** @@ -80,15 +80,15 @@ bool buffering_reset(char *buf, const size_t buflen); #define BUF_MAX_HANDLES 256 -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); +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); /*************************************************************************** @@ -102,10 +102,10 @@ ssize_t bufcuttail(const int handle_id, size_t size); * buf_used: Total amount of buffer space used (including allocated space) ****************************************************************************/ -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); +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); size_t buf_used(void); @@ -123,9 +123,9 @@ size_t buf_used(void); ****************************************************************************/ #define MAX_BUF_CALLBACKS 4 -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); +typedef void (*buffering_callback)(enum callback_event ev, int value); +bool register_buffering_callback(buffering_callback func); +void unregister_buffering_callback(buffering_callback func); /* Settings */ enum { diff --git a/apps/codecs.h b/apps/codecs.h index 85b73a4953..fb5675fd84 100644 --- a/apps/codecs.h +++ b/apps/codecs.h @@ -126,28 +126,28 @@ struct codec_api { void* (*get_codec_memory)(size_t *size); /* Insert PCM data into audio buffer for playback. Playback will start automatically. */ - bool (*pcmbuf_insert)(const void *ch1, const void *ch2, const int count); + bool (*pcmbuf_insert)(const void *ch1, const void *ch2, int count); /* Set song position in WPS (value in ms). */ - void (*set_elapsed)(const unsigned int value); + void (*set_elapsed)(unsigned int value); /* Read next amount bytes from file buffer to . Will return number of bytes read or 0 if end of file. */ - size_t (*read_filebuf)(void *ptr, const size_t size); + size_t (*read_filebuf)(void *ptr, size_t size); /* Request pointer to file buffer which can be used to read amount of data. tells the buffer system how much data it should try to allocate. If is 0, end of file is reached. */ - void* (*request_buffer)(size_t *realsize, const size_t reqsize); + void* (*request_buffer)(size_t *realsize, size_t reqsize); /* Advance file buffer position by amount of bytes. */ - void (*advance_buffer)(const size_t amount); + void (*advance_buffer)(size_t amount); /* Advance file buffer to a pointer location inside file buffer. */ void (*advance_buffer_loc)(void *ptr); /* Seek file buffer to position beginning of file. */ - bool (*seek_buffer)(const size_t newpos); + bool (*seek_buffer)(size_t newpos); /* Codec should call this function when it has done the seeking. */ void (*seek_complete)(void); /* Calculate mp3 seek position from given time data in ms. */ - off_t (*mp3_get_filepos)(const int newtime); + off_t (*mp3_get_filepos)(int newtime); /* Request file change from file buffer. Returns true is next track is available and changed. If return value is false, codec should exit immediately with PLUGIN_OK status. */ @@ -155,12 +155,12 @@ struct codec_api { /* Free the buffer area of the current codec after its loaded */ void (*discard_codec)(void); - void (*set_offset)(const size_t value); + void (*set_offset)(size_t value); /* Configure different codec buffer parameters. */ - void (*configure)(const int setting, const intptr_t value); + void (*configure)(int setting, intptr_t value); /* kernel/ system */ - void (*PREFIX(sleep))(const int ticks); + void (*PREFIX(sleep))(int ticks); void (*yield)(void); #if NUM_CORES > 1 diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index b9587d08dd..8f16c90523 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -82,7 +82,7 @@ static char *fadebuf IDATA_ATTR; static char *voicebuf IDATA_ATTR; static void (*pcmbuf_event_handler)(void) IDATA_ATTR; -static void (*position_callback)(const size_t size) IDATA_ATTR; +static void (*position_callback)(size_t size) IDATA_ATTR; /* Crossfade related state */ static bool crossfade_enabled; @@ -188,7 +188,7 @@ static void pcmbuf_callback(unsigned char** start, size_t* size) } } -void pcmbuf_set_position_callback(void (*callback)(const size_t size)) +void pcmbuf_set_position_callback(void (*callback)(size_t size)) { position_callback = callback; } @@ -938,7 +938,7 @@ void pcmbuf_write_complete(int count) } #if 0 -bool pcmbuf_insert_buffer(char *buf, const int count) +bool pcmbuf_insert_buffer(char *buf, int count) { size_t length = (size_t)(unsigned int)count << 2; diff --git a/apps/pcmbuf.h b/apps/pcmbuf.h index 9263285a6b..06362452c0 100644 --- a/apps/pcmbuf.h +++ b/apps/pcmbuf.h @@ -63,7 +63,7 @@ bool pcmbuf_is_lowdata(void); void pcmbuf_play_start(void); bool pcmbuf_crossfade_init(bool manual_skip); void pcmbuf_set_event_handler(void (*callback)(void)); -void pcmbuf_set_position_callback(void (*callback)(const size_t size)); +void pcmbuf_set_position_callback(void (*callback)(size_t size)); size_t pcmbuf_free(void); unsigned int pcmbuf_get_latency(void); void pcmbuf_set_low_latency(bool state); diff --git a/apps/playback.c b/apps/playback.c index de58e8b40d..880c9acf7e 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -249,7 +249,7 @@ static size_t buffer_margin = 0; /* Buffer margin aka anti-skip buffer (A/C-) * /* Multiple threads */ /* Set the watermark to trigger buffer fill (A/C) FIXME */ -static void set_filebuf_watermark(const int seconds, const size_t max); +static void set_filebuf_watermark(int seconds, size_t max); /* Audio thread */ static struct event_queue audio_queue NOCACHEBSS_ATTR; @@ -277,7 +277,7 @@ static struct event_queue pcmbuf_queue NOCACHEBSS_ATTR; /* Function to be called by pcm buffer callbacks. * Permissible Context(s): Audio interrupt */ -static void pcmbuf_callback_queue_post(const long id, intptr_t data) +static void pcmbuf_callback_queue_post(long id, intptr_t data) { /* No lock since we're already in audio interrupt context */ queue_post(&pcmbuf_queue, id, data); @@ -313,7 +313,7 @@ static void pcmbuf_queue_clear(void) /* --- Helper functions --- */ -static struct mp3entry *bufgetid3(const int handle_id) +static struct mp3entry *bufgetid3(int handle_id) { if (handle_id < 0) return NULL; @@ -384,7 +384,7 @@ void audio_hard_stop(void) #endif } -bool audio_restore_playback(const int type) +bool audio_restore_playback(int type) { switch (type) { @@ -401,7 +401,7 @@ bool audio_restore_playback(const int type) } } -unsigned char *audio_get_buffer(const bool talk_buf, size_t *buffer_size) +unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size) { unsigned char *buf, *end; @@ -621,7 +621,7 @@ bool audio_has_changed_track(void) return false; } -void audio_play(const long offset) +void audio_play(long offset) { logf("audio_play"); @@ -710,7 +710,7 @@ void audio_pre_ff_rewind(void) queue_post(&audio_queue, Q_AUDIO_PRE_FF_REWIND, 0); } -void audio_ff_rewind(const long newpos) +void audio_ff_rewind(long newpos) { LOGFQUEUE("audio > audio Q_AUDIO_FF_REWIND"); queue_post(&audio_queue, Q_AUDIO_FF_REWIND, newpos); @@ -753,7 +753,7 @@ int audio_get_file_pos(void) } #ifndef HAVE_FLASH_STORAGE -void audio_set_buffer_margin(const int setting) +void audio_set_buffer_margin(int setting) { static const int lookup[] = {5, 15, 30, 60, 120, 180, 300, 600}; buffer_margin = lookup[setting]; @@ -763,7 +763,7 @@ void audio_set_buffer_margin(const int setting) #endif /* Take necessary steps to enable or disable the crossfade setting */ -void audio_set_crossfade(const int enable) +void audio_set_crossfade(int enable) { size_t offset; bool was_playing; @@ -805,7 +805,7 @@ void audio_set_crossfade(const int enable) /* --- Routines called from multiple threads --- */ -static void set_filebuf_watermark(const int seconds, const size_t max) +static void set_filebuf_watermark(int seconds, size_t max) { size_t bytes; @@ -817,7 +817,7 @@ static void set_filebuf_watermark(const int seconds, const size_t max) buf_set_watermark(bytes); } -const char *get_codec_filename(const int cod_spec) +const char *get_codec_filename(int cod_spec) { const char *fname; @@ -838,11 +838,10 @@ const char *get_codec_filename(const int cod_spec) afmt, fname ? fname : ""); #else /* !HAVE_RECORDING */ /* Always decoder */ - int afmt = cod_spec; - if ((unsigned)afmt >= AFMT_NUM_CODECS) - afmt = AFMT_UNKNOWN; - fname = audio_formats[afmt].codec_root_fn; - logf("Codec: %d - %s", afmt, fname ? fname : ""); + if ((unsigned)cod_spec >= AFMT_NUM_CODECS) + cod_spec = AFMT_UNKNOWN; + fname = audio_formats[cod_spec].codec_root_fn; + logf("Codec: %d - %s", cod_spec, fname ? fname : ""); #endif /* HAVE_RECORDING */ return fname; @@ -850,14 +849,13 @@ const char *get_codec_filename(const int cod_spec) /* --- Codec thread --- */ static bool codec_pcmbuf_insert_callback( - const void *ch1, const void *ch2, const int count) + const void *ch1, const void *ch2, int count) { const char *src[2] = { ch1, ch2 }; - int remaining = count; - while (remaining > 0) + while (count > 0) { - int out_count = dsp_output_count(ci.dsp, remaining); + int out_count = dsp_output_count(ci.dsp, count); int inp_count; char *dest; @@ -881,8 +879,8 @@ static bool codec_pcmbuf_insert_callback( return true; /* Input size has grown, no error, just don't write more than length */ - if (inp_count > remaining) - inp_count = remaining; + if (inp_count > count) + inp_count = count; out_count = dsp_process(ci.dsp, dest, src, inp_count); @@ -891,7 +889,7 @@ static bool codec_pcmbuf_insert_callback( pcmbuf_write_complete(out_count); - remaining -= inp_count; + count -= inp_count; } return true; @@ -907,8 +905,8 @@ static void* codec_get_memory_callback(size_t *size) "elapsed" value of the previous (to the codec, but current to the user/PCM/WPS) track, so that the progressbar reaches the end. During that transition, the WPS will display prevtrack_id3. */ -static void codec_pcmbuf_position_callback(const size_t size) ICODE_ATTR; -static void codec_pcmbuf_position_callback(const size_t size) +static void codec_pcmbuf_position_callback(size_t size) ICODE_ATTR; +static void codec_pcmbuf_position_callback(size_t size) { /* This is called from an ISR, so be quick */ unsigned int time = size * 1000 / 4 / NATIVE_FREQUENCY + @@ -923,7 +921,7 @@ static void codec_pcmbuf_position_callback(const size_t size) prevtrack_id3.elapsed = time; } -static void codec_set_elapsed_callback(const unsigned int value) +static void codec_set_elapsed_callback(unsigned int value) { unsigned int latency; if (ci.seek_time) @@ -943,7 +941,7 @@ static void codec_set_elapsed_callback(const unsigned int value) } } -static void codec_set_offset_callback(const size_t value) +static void codec_set_offset_callback(size_t value) { unsigned int latency; @@ -957,14 +955,14 @@ static void codec_set_offset_callback(const size_t value) curtrack_id3.offset = value - latency; } -static void codec_advance_buffer_counters(const size_t amount) +static void codec_advance_buffer_counters(size_t amount) { bufadvance(CUR_TI->audio_hid, amount); ci.curpos += amount; } /* copy up-to size bytes into ptr and return the actual size copied */ -static size_t codec_filebuf_callback(void *ptr, const size_t size) +static size_t codec_filebuf_callback(void *ptr, size_t size) { ssize_t copy_n; @@ -984,7 +982,7 @@ static size_t codec_filebuf_callback(void *ptr, const size_t size) return copy_n; } /* codec_filebuf_callback */ -static void* codec_request_buffer_callback(size_t *realsize, const size_t reqsize) +static void* codec_request_buffer_callback(size_t *realsize, size_t reqsize) { size_t copy_n = reqsize; ssize_t ret; @@ -1023,7 +1021,7 @@ static int get_codec_base_type(int type) return type; } -static void codec_advance_buffer_callback(const size_t amount) +static void codec_advance_buffer_callback(size_t amount) { codec_advance_buffer_counters(amount); codec_set_offset_callback(ci.curpos); @@ -1090,7 +1088,7 @@ static int codec_get_file_pos(void) return pos; } -static off_t codec_mp3_get_filepos_callback(const int newtime) +static off_t codec_mp3_get_filepos_callback(int newtime) { off_t newpos; @@ -1116,7 +1114,7 @@ static void codec_seek_complete_callback(void) ci.seek_time = 0; } -static bool codec_seek_buffer_callback(const size_t newpos) +static bool codec_seek_buffer_callback(size_t newpos) { logf("codec_seek_buffer_callback"); @@ -1130,7 +1128,7 @@ static bool codec_seek_buffer_callback(const size_t newpos) } } -static void codec_configure_callback(const int setting, const intptr_t value) +static void codec_configure_callback(int setting, intptr_t value) { switch (setting) { case CODEC_SET_FILEBUF_WATERMARK: @@ -1180,7 +1178,7 @@ static inline void codec_crossfade_track_change(void) codec_track_changed(); } -static void codec_track_skip_done(const bool was_manual) +static void codec_track_skip_done(bool was_manual) { /* Manual track change (always crossfade or flush audio). */ if (was_manual) @@ -1487,7 +1485,7 @@ static void audio_update_trackinfo(void) ci.taginfo_ready = &CUR_TI->taginfo_ready; } -static void buffering_audio_callback(const enum callback_event ev, const int value) +static void buffering_audio_callback(enum callback_event ev, int value) { (void)value; logf("buffering_audio_callback"); @@ -1551,7 +1549,7 @@ static bool audio_release_tracks(void) return true; } -static bool audio_loadcodec(const bool start_play) +static bool audio_loadcodec(bool start_play) { int prev_track; char codec_path[MAX_PATH]; /* Full path to codec */ @@ -1669,7 +1667,7 @@ static void audio_set_elapsed(struct mp3entry* id3) /* Load one track by making the appropriate bufopen calls. Return true if everything required was loaded correctly, false if not. */ -static bool audio_load_track(const int offset, const bool start_play) +static bool audio_load_track(int offset, bool start_play) { const char *trackname; char msgbuf[80]; @@ -1716,9 +1714,8 @@ static bool audio_load_track(const int offset, const bool start_play) tracks[track_widx].filesize = filesize(fd); - int adjusted_offset = offset; - if ((unsigned)adjusted_offset > tracks[track_widx].filesize) - adjusted_offset = 0; + if ((unsigned)offset > tracks[track_widx].filesize) + offset = 0; /* Set default values */ if (start_play) @@ -1830,17 +1827,17 @@ static bool audio_load_track(const int offset, const bool start_play) case AFMT_MPA_L1: case AFMT_MPA_L2: case AFMT_MPA_L3: - if (adjusted_offset > 0) { - file_offset = adjusted_offset; - track_id3->offset = adjusted_offset; + if (offset > 0) { + file_offset = offset; + track_id3->offset = offset; audio_set_elapsed(track_id3); } break; case AFMT_WAVPACK: if (offset > 0) { - file_offset = adjusted_offset; - track_id3->offset = adjusted_offset; + file_offset = offset; + track_id3->offset = offset; track_id3->elapsed = track_id3->length / 2; } break; @@ -1853,8 +1850,8 @@ static bool audio_load_track(const int offset, const bool start_play) case AFMT_AAC: case AFMT_MPC: case AFMT_APE: - if (adjusted_offset > 0) - track_id3->offset = adjusted_offset; + if (offset > 0) + track_id3->offset = offset; break; case AFMT_NSF: @@ -1893,7 +1890,7 @@ static bool audio_load_track(const int offset, const bool start_play) return true; } -static void audio_fill_file_buffer(const bool start_play, const size_t offset) +static void audio_fill_file_buffer(bool start_play, size_t offset) { struct queue_event ev; bool had_next_track = audio_next_track() != NULL; @@ -2195,7 +2192,7 @@ static void audio_stop_playback(void) memset(&curtrack_id3, 0, sizeof(struct mp3entry)); } -static void audio_play_start(const size_t offset) +static void audio_play_start(size_t offset) { int i; @@ -2288,7 +2285,7 @@ static void audio_new_playlist(void) } /* Called on manual track skip */ -static void audio_initiate_track_change(const long direction) +static void audio_initiate_track_change(long direction) { logf("audio_initiate_track_change(%ld)", direction); @@ -2300,7 +2297,7 @@ static void audio_initiate_track_change(const long direction) } /* Called on manual dir skip */ -static void audio_initiate_dir_change(const long direction) +static void audio_initiate_dir_change(long direction) { playlist_end = false; dir_skip = true; diff --git a/apps/playback.h b/apps/playback.h index b65c572145..9951cc2a0d 100644 --- a/apps/playback.h +++ b/apps/playback.h @@ -38,13 +38,13 @@ #define MAX_TRACK_MASK (MAX_TRACK-1) /* Functions */ -const char *get_codec_filename(const int cod_spec); +const char *get_codec_filename(int cod_spec); void voice_wait(void); void audio_wait_for_init(void); int audio_track_count(void); long audio_filebufused(void); void audio_pre_ff_rewind(void); -void audio_set_crossfade(const int type); +void audio_set_crossfade(int type); void audio_hard_stop(void); /* Stops audio from serving playback */ @@ -53,7 +53,7 @@ enum AUDIO_WANT_PLAYBACK = 0, AUDIO_WANT_VOICE, }; -bool audio_restore_playback(const int type); /* Restores the audio buffer to handle the requested playback */ +bool audio_restore_playback(int type); /* Restores the audio buffer to handle the requested playback */ #ifdef HAVE_ALBUMART int audio_current_aa_hid(void); diff --git a/apps/plugin.h b/apps/plugin.h index 148c84a58e..1753272952 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -521,13 +521,13 @@ struct plugin_api { int (*playlist_amount)(void); int (*playlist_resume)(void); int (*playlist_start)(int start_index, int offset); - void (*PREFIX(audio_play))(const long offset); + void (*PREFIX(audio_play))(long offset); void (*audio_stop)(void); void (*audio_pause)(void); void (*audio_resume)(void); void (*audio_next)(void); void (*audio_prev)(void); - void (*audio_ff_rewind)(const long newtime); + void (*audio_ff_rewind)(long newtime); struct mp3entry* (*audio_next_track)(void); int (*audio_status)(void); bool (*audio_has_changed_track)(void); @@ -570,15 +570,15 @@ struct plugin_api { bool (*option_screen)(struct settings_list *setting, bool use_temp_var, unsigned char* option_title); bool (*set_option)(const char* string, const void* variable, - const enum optiontype type, const struct opt_items* options, - const int numoptions, void (*function)(int)); + enum optiontype type, const struct opt_items* options, + int numoptions, void (*function)(int)); bool (*set_bool_options)(const char* string, const bool* variable, - const char* yes_str, const int yes_voice, - const char* no_str, const int no_voice, + const char* yes_str, int yes_voice, + const char* no_str, int no_voice, void (*function)(bool)); - bool (*set_int)(const unsigned char* string, const char* unit, const int voice_unit, - const int* variable, void (*function)(int), const int step, - const int min, const int max, + bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit, + const int* variable, void (*function)(int), int step, + int min, int max, void (*formatter)(char*, size_t, int, const char*) ); bool (*set_bool)(const char* string, const bool* variable ); @@ -684,20 +684,20 @@ struct plugin_api { #if (CONFIG_CODEC == SWCODEC) /* buffering API */ - 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); + 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)(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); + 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); size_t (*buf_used)(void); #endif diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 7390318152..f33d83fb15 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c @@ -197,7 +197,7 @@ static void* get_codec_memory(size_t *size) } /* Null output */ -static bool pcmbuf_insert_null(const void *ch1, const void *ch2, const int count) +static bool pcmbuf_insert_null(const void *ch1, const void *ch2, int count) { /* Always successful - just discard data */ (void)ch1; @@ -310,7 +310,7 @@ static bool pcmbuf_insert_wav(const void *ch1, const void *ch2, int count) /* Set song position in WPS (value in ms). */ -static void set_elapsed(const unsigned int value) +static void set_elapsed(unsigned int value) { elapsed = value; } @@ -318,7 +318,7 @@ static void set_elapsed(const unsigned int value) /* Read next amount bytes from file buffer to . Will return number of bytes read or 0 if end of file. */ -static size_t read_filebuf(void *ptr, const size_t size) +static size_t read_filebuf(void *ptr, size_t size) { if (ci.curpos > (off_t)track.filesize) { @@ -336,7 +336,7 @@ static size_t read_filebuf(void *ptr, const size_t size) amount of data. tells the buffer system how much data it should try to allocate. If is 0, end of file is reached. */ -static void* request_buffer(size_t *realsize, const size_t reqsize) +static void* request_buffer(size_t *realsize, size_t reqsize) { *realsize = MIN(track.filesize-ci.curpos,reqsize); @@ -345,7 +345,7 @@ static void* request_buffer(size_t *realsize, const size_t reqsize) /* Advance file buffer position by amount of bytes. */ -static void advance_buffer(const size_t amount) +static void advance_buffer(size_t amount) { ci.curpos += amount; } @@ -359,7 +359,7 @@ static void advance_buffer_loc(void *ptr) /* Seek file buffer to position beginning of file. */ -static bool seek_buffer(const size_t newpos) +static bool seek_buffer(size_t newpos) { ci.curpos = newpos; return true; @@ -374,7 +374,7 @@ static void seek_complete(void) /* Calculate mp3 seek position from given time data in ms. */ -static off_t mp3_get_filepos(const int newtime) +static off_t mp3_get_filepos(int newtime) { /* We don't ask the codec to seek, so no need to implement this. */ (void)newtime; @@ -399,7 +399,7 @@ static void discard_codec(void) } -static void set_offset(const size_t value) +static void set_offset(size_t value) { /* ??? */ (void)value; diff --git a/apps/settings.c b/apps/settings.c index 6e1aa3eaec..56d59f419f 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -114,7 +114,7 @@ long lasttime = 0; #define NVRAM_FILE ROCKBOX_DIR "/nvram.bin" static char nvram_buffer[NVRAM_BLOCK_SIZE]; -static bool read_nvram_data(char* buf, const int max_len) +static bool read_nvram_data(char* buf, int max_len) { unsigned crc32 = 0xffffffff; int var_count = 0, i = 0, buf_pos = 0; @@ -164,7 +164,7 @@ static bool read_nvram_data(char* buf, const int max_len) } return true; } -static bool write_nvram_data(char* buf, const int max_len) +static bool write_nvram_data(char* buf, int max_len) { unsigned crc32 = 0xffffffff; int i = 0, buf_pos = 0; @@ -222,7 +222,7 @@ static bool write_nvram_data(char* buf, const int max_len) /* * load settings from disk or RTC RAM */ -void settings_load(const int which) +void settings_load(int which) { DEBUGF( "reload_all_settings()\n" ); if (which&SETTINGS_RTC) @@ -234,7 +234,7 @@ void settings_load(const int which) } } -static bool cfg_string_to_int(const int setting_id, int* out, const char* str) +static bool cfg_string_to_int(int setting_id, int* out, const char* str) { const char* start = settings[setting_id].cfg_vals; char* end = NULL; @@ -265,7 +265,7 @@ static bool cfg_string_to_int(const int setting_id, int* out, const char* str) return false; } -bool settings_load_config(const char* file, const bool apply) +bool settings_load_config(const char* file, bool apply) { int fd; char line[128]; @@ -363,7 +363,7 @@ bool settings_load_config(const char* file, const bool apply) /** Writing to a config file and saving settings **/ -bool cfg_int_to_string(const int setting_id, const int val, char* buf, const int buf_len) +bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len) { int flags = settings[setting_id].flags; const char* start = settings[setting_id].cfg_vals; @@ -420,7 +420,7 @@ bool cfg_int_to_string(const int setting_id, const int val, char* buf, const int } -static bool is_changed(const int setting_id) +static bool is_changed(int setting_id) { const struct settings_list *setting = &settings[setting_id]; switch (setting->flags&F_T_MASK) @@ -454,7 +454,7 @@ static bool is_changed(const int setting_id) return true; } -static bool settings_write_config(const char* filename, const int options) +static bool settings_write_config(const char* filename, int options) { int i; int fd; @@ -609,7 +609,7 @@ int settings_save(void) return 0; } -bool settings_save_config(const int options) +bool settings_save_config(int options) { char filename[MAX_PATH]; char *folder; @@ -719,7 +719,7 @@ void sound_settings_apply(void) #endif } -void settings_apply(const bool read_disk) +void settings_apply(bool read_disk) { char buf[64]; #if CONFIG_CODEC == SWCODEC @@ -1009,8 +1009,8 @@ bool set_bool(const char* string, const bool* variable ) bool set_bool_options(const char* string, const bool* variable, - const char* yes_str, const int yes_voice, - const char* no_str, const int no_voice, + const char* yes_str, int yes_voice, + const char* no_str, int no_voice, void (*function)(bool)) { struct opt_items names[] = { @@ -1026,12 +1026,12 @@ bool set_bool_options(const char* string, const bool* variable, bool set_int(const unsigned char* string, const char* unit, - const int voice_unit, + int voice_unit, const int* variable, void (*function)(int), - const int step, - const int min, - const int max, + int step, + int min, + int max, void (*formatter)(char*, size_t, int, const char*) ) { return set_int_ex(string, unit, voice_unit, variable, function, @@ -1040,12 +1040,12 @@ bool set_int(const unsigned char* string, bool set_int_ex(const unsigned char* string, const char* unit, - const int voice_unit, + int voice_unit, const int* variable, void (*function)(int), - const int step, - const int min, - const int max, + int step, + int min, + int max, void (*formatter)(char*, size_t, int, const char*), int32_t (*get_talk_id)(int, int)) { @@ -1076,9 +1076,9 @@ static int32_t set_option_get_talk_id(int value, int unit) (void)unit; return set_option_options[value].voice_id; } -bool set_option(const char* string, const void* variable, const enum optiontype type, +bool set_option(const char* string, const void* variable, enum optiontype type, const struct opt_items* options, - const int numoptions, void (*function)(int)) + int numoptions, void (*function)(int)) { int temp; struct settings_list item; @@ -1108,7 +1108,7 @@ bool set_option(const char* string, const void* variable, const enum optiontype } -void set_file(const char* filename, char* setting, const int maxlen) +void set_file(const char* filename, char* setting, int maxlen) { char* fptr = strrchr(filename,'/'); int len; diff --git a/apps/settings.h b/apps/settings.h index 3523bca0dd..d3fd0683b7 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -195,8 +195,8 @@ extern unsigned char vp_dummy[VIRT_SIZE]; #define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */ #define SETTINGS_HD 2 /* only the settings from the disk sector */ #define SETTINGS_ALL 3 /* both */ -void settings_load(const int which); -bool settings_load_config(const char* file, const bool apply); +void settings_load(int which); +bool settings_load_config(const char* file, bool apply); void status_save(void); int settings_save(void); @@ -213,40 +213,40 @@ enum { SETTINGS_SAVE_EQPRESET, #endif }; -bool settings_save_config(const int options); +bool settings_save_config(int options); void settings_reset(void); void sound_settings_apply(void); -void settings_apply(const bool read_disk); +void settings_apply(bool read_disk); void settings_apply_pm_range(void); void settings_display(void); enum optiontype { INT, BOOL }; const struct settings_list* find_setting(const void* variable, int *id); -bool cfg_int_to_string(const int setting_id, const int val, char* buf, const int buf_len); +bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len); bool set_bool_options(const char* string, const bool* variable, - const char* yes_str, const int yes_voice, - const char* no_str, const int no_voice, + const char* yes_str, int yes_voice, + const char* no_str, int no_voice, void (*function)(bool)); bool set_bool(const char* string, const bool* variable); -bool set_int(const unsigned char* string, const char* unit, const int voice_unit, +bool set_int(const unsigned char* string, const char* unit, int voice_unit, const int* variable, - void (*function)(int), const int step, const int min, const int max, + void (*function)(int), int step, int min, int max, void (*formatter)(char*, size_t, int, const char*) ); /* use this one if you need to create a lang from the value (i.e with TALK_ID()) */ -bool set_int_ex(const unsigned char* string, const char* unit, const int voice_unit, +bool set_int_ex(const unsigned char* string, const char* unit, int voice_unit, const int* variable, - void (*function)(int), const int step, const int min, const int max, + void (*function)(int), int step, int min, int max, void (*formatter)(char*, size_t, int, const char*), int32_t (*get_talk_id)(int, int)); -void set_file(const char* filename, char* setting, const int maxlen); +void set_file(const char* filename, char* setting, int maxlen); -bool set_option(const char* string, const void* variable, const enum optiontype type, - const struct opt_items* options, const int numoptions, void (*function)(int)); +bool set_option(const char* string, const void* variable, enum optiontype type, + const struct opt_items* options, int numoptions, void (*function)(int)); diff --git a/firmware/export/audio.h b/firmware/export/audio.h index 49ff4c168a..5cd0d0fc9e 100644 --- a/firmware/export/audio.h +++ b/firmware/export/audio.h @@ -77,21 +77,21 @@ struct audio_debug }; void audio_init(void); -void audio_play(const long offset); +void audio_play(long offset); void audio_stop(void); void audio_pause(void); void audio_resume(void); void audio_next(void); void audio_prev(void); int audio_status(void); -void audio_ff_rewind(const long newtime); +void audio_ff_rewind(long newtime); void audio_flush_and_reload_tracks(void); struct mp3entry* audio_current_track(void); struct mp3entry* audio_next_track(void); bool audio_has_changed_track(void); void audio_get_debugdata(struct audio_debug *dbgdata); #ifndef HAVE_FLASH_STORAGE -void audio_set_buffer_margin(const int seconds); +void audio_set_buffer_margin(int seconds); #endif unsigned int audio_error(void); void audio_error_clear(void); @@ -100,7 +100,7 @@ void audio_beep(int duration); void audio_init_playback(void); /* Required call when audio buffer is required for some other purpose */ -unsigned char *audio_get_buffer(const bool talk_buf, size_t *buffer_size); +unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size); /* only implemented in playback.c, but called from firmware */ /* channel modes */ @@ -196,7 +196,7 @@ unsigned long audio_recorded_time(void); unsigned long audio_num_recorded_bytes(void); #if CONFIG_CODEC == SWCODEC -/* SWCODEC recoring functions */ +/* SWCODEC recording functions */ /* playback.c */ bool audio_load_encoder(int afmt); void audio_remove_encoder(void); diff --git a/firmware/export/id3.h b/firmware/export/id3.h index 0035fae19a..8b2d02ea30 100644 --- a/firmware/export/id3.h +++ b/firmware/export/id3.h @@ -231,7 +231,7 @@ enum { bool get_mp3_metadata(int fd, struct mp3entry *entry, const char *filename); bool mp3info(struct mp3entry *entry, const char *filename); -char* id3_get_num_genre(const unsigned int genre_num); +char* id3_get_num_genre(unsigned int genre_num); char* id3_get_codec(const struct mp3entry* id3); int getid3v2len(int fd); void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig); diff --git a/firmware/id3.c b/firmware/id3.c index 6afe2ac304..d63acbb8aa 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -185,7 +185,7 @@ static const char* const genres[] = { "Synthpop" }; -char* id3_get_num_genre(const unsigned int genre_num) +char* id3_get_num_genre(unsigned int genre_num) { if (genre_num < sizeof(genres)/sizeof(char*)) return (char*)genres[genre_num]; diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 78824cfe36..de3b347f77 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -210,7 +210,7 @@ unsigned shadow_codec_reg0; #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ #ifdef HAVE_RECORDING -const unsigned char empty_id3_header[] = +static const unsigned char empty_id3_header[] = { 'I', 'D', '3', 0x03, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x76 /* Size is 4096 minus 10 bytes for the header */ @@ -533,7 +533,7 @@ static void recalculate_watermark(int bitrate) } #ifndef HAVE_FLASH_STORAGE -void audio_set_buffer_margin(const int seconds) +void audio_set_buffer_margin(int seconds) { low_watermark_margin = seconds; } @@ -2627,7 +2627,7 @@ void audio_set_recording_options(struct audio_recording_options *options) #endif /* SIMULATOR */ #endif /* CONFIG_CODEC == MAS3587F */ -void audio_play(const long offset) +void audio_play(long offset) { #ifdef SIMULATOR char* trackname; @@ -2768,7 +2768,7 @@ void audio_prev(void) #endif /* SIMULATOR */ } -void audio_ff_rewind(const long newtime) +void audio_ff_rewind(long newtime) { #ifndef SIMULATOR queue_post(&mpeg_queue, MPEG_FF_REWIND, newtime); diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 81f3697802..c40d10082c 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -33,7 +33,7 @@ extern char having_new_lcd; #if CONFIG_CODEC != SWCODEC -void audio_set_buffer_margin(const int seconds) +void audio_set_buffer_margin(int seconds) { (void)seconds; }