summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/playback.c16
-rw-r--r--apps/plugin.h6
-rw-r--r--apps/plugins/battery_bench.c2
-rw-r--r--apps/plugins/blackjack.c5
-rw-r--r--apps/plugins/chessclock.c3
-rw-r--r--apps/plugins/chip8.c2
-rw-r--r--apps/plugins/jpeg.c2
-rw-r--r--apps/plugins/lib/mem_function_wrappers.h44
-rw-r--r--apps/plugins/lib/playback_control.c10
-rw-r--r--apps/plugins/mazezam.c3
-rw-r--r--apps/plugins/metronome.c5
-rw-r--r--apps/plugins/mp3_encoder.c3
-rw-r--r--apps/plugins/properties.c4
-rw-r--r--apps/plugins/rockpaint.c3
-rw-r--r--apps/plugins/video.c2
-rw-r--r--apps/plugins/xobox.c5
-rw-r--r--apps/talk.c4
-rw-r--r--firmware/export/mp3_playback.h2
-rw-r--r--firmware/mp3_playback.c6
-rw-r--r--firmware/mpeg.c2
-rwxr-xr-xtools/configure5
21 files changed, 105 insertions, 29 deletions
diff --git a/apps/playback.c b/apps/playback.c
index ca88b5f5e3..329e8b856b 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -332,7 +332,7 @@ static struct mutex mutex_codecthread NOCACHEBSS_ATTR;
static volatile bool voice_thread_start = false; /* Triggers voice playback (A/V) */
static volatile bool voice_is_playing NOCACHEBSS_ATTR = false; /* Is voice currently playing? (V) */
static volatile bool voice_codec_loaded NOCACHEBSS_ATTR = false; /* Is voice codec loaded (V/A-) */
-static char *voicebuf = NULL;
+static unsigned char *voicebuf = NULL;
static size_t voice_remaining = 0;
#ifdef IRAM_STEAL
@@ -340,12 +340,12 @@ static size_t voice_remaining = 0;
static bool voice_iram_stolen = false;
#endif
-static void (*voice_getmore)(unsigned char** start, int* size) = NULL;
+static void (*voice_getmore)(unsigned char** start, size_t* size) = NULL;
struct voice_info {
- void (*callback)(unsigned char **start, int *size);
- int size;
- char *buf;
+ void (*callback)(unsigned char **start, size_t* size);
+ size_t size;
+ unsigned char *buf;
};
static void voice_thread(void);
static void voice_stop(void);
@@ -355,12 +355,12 @@ static void voice_stop(void);
/* --- External interfaces --- */
void mp3_play_data(const unsigned char* start, int size,
- void (*get_more)(unsigned char** start, int* size))
+ void (*get_more)(unsigned char** start, size_t* size))
{
#ifdef PLAYBACK_VOICE
static struct voice_info voice_clip;
voice_clip.callback = get_more;
- voice_clip.buf = (char *)start;
+ voice_clip.buf = (unsigned char*)start;
voice_clip.size = size;
LOGFQUEUE("mp3 > voice Q_VOICE_STOP");
queue_post(&voice_queue, Q_VOICE_STOP, 0);
@@ -1238,7 +1238,7 @@ voice_play_clip:
if (voice_remaining == 0 || voicebuf == NULL)
{
if (voice_getmore)
- voice_getmore((unsigned char **)&voicebuf, (int *)&voice_remaining);
+ voice_getmore((unsigned char **)&voicebuf, &voice_remaining);
/* If this clip is done */
if (voice_remaining == 0)
diff --git a/apps/plugin.h b/apps/plugin.h
index bc6adffab2..11bb80de66 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -114,12 +114,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 57
+#define PLUGIN_API_VERSION 58
/* 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 56
+#define PLUGIN_MIN_API_VERSION 58
/* plugin return codes */
enum plugin_status {
@@ -417,7 +417,7 @@ struct plugin_api {
int (*sound_min)(int setting);
int (*sound_max)(int setting);
#ifndef SIMULATOR
- void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size));
+ void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, size_t* size));
void (*mp3_play_pause)(bool play);
void (*mp3_play_stop)(void);
bool (*mp3_is_playing)(void);
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 13ce172f67..fef3f36db2 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -20,6 +20,7 @@
#ifndef SIMULATOR /* not for the simulator */
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
#define BATTERY_LOG "/battery_bench.txt"
@@ -98,6 +99,7 @@ PLUGIN_HEADER
/****************************** Plugin Entry Point ****************************/
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
int main(void);
bool exit_tsr(bool);
void thread(void);
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c
index f987eeb3b5..07af984a80 100644
--- a/apps/plugins/blackjack.c
+++ b/apps/plugins/blackjack.c
@@ -20,6 +20,7 @@
#include "plugin.h"
#include "card_deck.h"
#include "card_back.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -213,6 +214,8 @@ extern const fb_data card_back[];
/* global rockbox api */
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
/* dealer and player card positions */
unsigned int dealer_x, dealer_y, player_x, player_y;
@@ -1399,7 +1402,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
(void)parameter;
rb = api;
-
+
#if LCD_DEPTH > 1
rb->lcd_set_backdrop(NULL);
#endif
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c
index f1482df990..3dfb0fef6c 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -17,6 +17,7 @@
*
****************************************************************************/
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -153,6 +154,7 @@ PLUGIN_HEADER
it's nice not to have to pass the api pointer in all function calls
in the plugin */
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
#define MAX_PLAYERS 10
static struct {
@@ -192,7 +194,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
(void)parameter;
rb=api;
-
rb->memset(&settings, 0, sizeof(settings));
/* now go ahead and have fun! */
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c
index c38a5fd0bb..f76379e5f4 100644
--- a/apps/plugins/chip8.c
+++ b/apps/plugins/chip8.c
@@ -1062,7 +1062,7 @@ static unsigned char beep[]={255,
111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85};
/* callback to request more mp3 data */
-void callback(unsigned char** start, int* size)
+void callback(unsigned char** start, size_t* size)
{
*start = beep; /* give it the same frame again */
*size = sizeof(beep);
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c
index ff6df6d4e3..cd364f4d51 100644
--- a/apps/plugins/jpeg.c
+++ b/apps/plugins/jpeg.c
@@ -27,6 +27,7 @@
#include "plugin.h"
#include "playback_control.h"
#include "oldmenuapi.h"
+#include "mem_function_wrappers.h"
#ifdef HAVE_LCD_BITMAP
#include "gray.h"
@@ -186,6 +187,7 @@ PLUGIN_HEADER
/******************************* Globals ***********************************/
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
/* for portability of below JPEG code */
#define MEMSET(p,v,c) rb->memset(p,v,c)
diff --git a/apps/plugins/lib/mem_function_wrappers.h b/apps/plugins/lib/mem_function_wrappers.h
new file mode 100644
index 0000000000..ec3872c4c1
--- /dev/null
+++ b/apps/plugins/lib/mem_function_wrappers.h
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 Nils Wallménius
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __MEM_FUNCTION_WRAPPERS_H__
+#define __MEM_FUNCTION_WRAPPERS_H__
+
+/* Use this macro in plugins where gcc tries to optimize by calling
+ * these functions directly */
+
+#define MEM_FUNCTION_WRAPPERS(api) \
+ void *memcpy(void *dest, const void *src, size_t n) \
+ { \
+ return (api)->memcpy(dest, src, n); \
+ } \
+ void *memset(void *dest, int c, size_t n) \
+ { \
+ return (api)->memset(dest, c, n); \
+ } \
+ void *memmove(void *dest, const void *src, size_t n) \
+ { \
+ return (api)->memmove(dest, src, n); \
+ } \
+ int memcmp(const void *s1, const void *s2, size_t n) \
+ { \
+ return (api)->memcmp(s1, s2, n); \
+ }
+
+#endif /* __MEM_FUNCTION_WRAPPERS_H__ */
+
diff --git a/apps/plugins/lib/playback_control.c b/apps/plugins/lib/playback_control.c
index 34401e1d4f..177f26a417 100644
--- a/apps/plugins/lib/playback_control.c
+++ b/apps/plugins/lib/playback_control.c
@@ -65,10 +65,12 @@ static bool volume(void)
static bool shuffle(void)
{
- struct opt_items names[] = {
- { "No", -1 },
- { "Yes", -1 }
- };
+ struct opt_items names[2];
+ names[0].string = "No";
+ names[0].voice_id = -1;
+ names[1].string = "Yes";
+ names[1].voice_id = -1;
+
return api->set_option("Shuffle", &api->global_settings->playlist_shuffle,
BOOL, names, 2,NULL);
}
diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c
index 607348e91c..ee93d10024 100644
--- a/apps/plugins/mazezam.c
+++ b/apps/plugins/mazezam.c
@@ -20,12 +20,15 @@
****************************************************************************/
#include "plugin.h"
#include "configfile.h"
+#include "mem_function_wrappers.h"
/* Include standard plugin macro */
PLUGIN_HEADER
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
#if CONFIG_KEYPAD == RECORDER_PAD
#define MAZEZAM_UP BUTTON_UP
#define MAZEZAM_DOWN BUTTON_DOWN
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c
index 19a37a580a..daf3294b75 100644
--- a/apps/plugins/metronome.c
+++ b/apps/plugins/metronome.c
@@ -18,6 +18,7 @@
****************************************************************************/
#include "plugin.h"
#include "pluginlib_actions.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -70,6 +71,8 @@ static const struct button_mapping iriver_syncaction[] =
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
static int bpm = 120;
static int period = 0;
static int minitick = 0;
@@ -159,7 +162,7 @@ static unsigned char sound[] = {
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85};
-void callback(unsigned char** start, int* size){
+void callback(unsigned char** start, size_t* size){
(void)start; /* unused parameter, avoid warning */
*size = NULL; /* end of data */
sound_active = false;
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index 70372933e0..d1ef2e0a7c 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -12,12 +12,15 @@
* Library General Public License for more details. */
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
PLUGIN_IRAM_DECLARE
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
#define SAMP_PER_FRAME 1152
#define SAMPL2 576
#define SBLIMIT 32
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index ee7ff86cb7..2e2e057b64 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -17,11 +17,14 @@
*
****************************************************************************/
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
bool its_a_dir = false;
char str_filename[MAX_PATH];
@@ -247,7 +250,6 @@ char * get_props(int selected_item, void* data, char *buffer)
enum plugin_status plugin_start(struct plugin_api* api, void* file)
{
rb = api;
-
struct gui_synclist properties_lists;
int button;
bool prev_show_statusbar;
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index da8f8052cb..29296ac1b6 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -30,6 +30,7 @@
#include "errno.h"
#include "lib/bmp.h"
#include "lib/rgb_hsv.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -224,6 +225,8 @@ int errno;
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
static int drawcolor=0; /* Current color (in palette) */
static int bgdrawcolor=9; /* Current background color (in palette) */
bool isbg = false; /* gruik ugly hack alert */
diff --git a/apps/plugins/video.c b/apps/plugins/video.c
index f049974023..b56a9d0612 100644
--- a/apps/plugins/video.c
+++ b/apps/plugins/video.c
@@ -423,7 +423,7 @@ void timer4_isr(void)
/* ISR function to get more mp3 data */
-void GetMoreMp3(unsigned char** start, int* size)
+void GetMoreMp3(unsigned char** start, size_t* size)
{
int available;
int advance;
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c
index 33ef4d04e9..0d1bdc4f72 100644
--- a/apps/plugins/xobox.c
+++ b/apps/plugins/xobox.c
@@ -19,6 +19,7 @@
****************************************************************************/
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -204,6 +205,9 @@ static int difficulty = 75; /* Percentage of screen that needs to be filled
* in order to win the game */
static struct plugin_api *rb;
+
+MEM_FUNCTION_WRAPPERS(rb);
+
static bool quit = false;
static unsigned int board[BOARD_H][BOARD_W];
@@ -295,7 +299,6 @@ static inline void emptyStack (void)
/*********************** END OF STACK STUFF *********************/
-
/* calculate the new x coordinate of the ball according to angle and speed */
static inline int get_newx (int x, int len, int deg)
{
diff --git a/apps/talk.c b/apps/talk.c
index 1f1eefd51d..1610fa95ec 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -132,7 +132,7 @@ static int talk_menu_disable; /* if non-zero, temporarily disable voice UI (not
/***************** Private prototypes *****************/
static void load_voicefile(void);
-static void mp3_callback(unsigned char** start, int* size);
+static void mp3_callback(unsigned char** start, size_t* size);
static int shutup(void);
static int queue_clip(unsigned char* buf, long size, bool enqueue);
static int open_voicefile(void);
@@ -262,7 +262,7 @@ load_err:
/* called in ISR context if mp3 data got consumed */
-static void mp3_callback(unsigned char** start, int* size)
+static void mp3_callback(unsigned char** start, size_t* size)
{
queue[queue_read].len -= sent; /* we completed this */
queue[queue_read].buf += sent;
diff --git a/firmware/export/mp3_playback.h b/firmware/export/mp3_playback.h
index 772eafe971..d766608aec 100644
--- a/firmware/export/mp3_playback.h
+++ b/firmware/export/mp3_playback.h
@@ -39,7 +39,7 @@ void demand_irq_enable(bool on);
/* new functions, exported to plugin API */
void mp3_play_init(void);
void mp3_play_data(const unsigned char* start, int size,
- void (*get_more)(unsigned char** start, int* size) /* callback fn */
+ void (*get_more)(unsigned char** start, size_t* size) /* callback fn */
);
void mp3_play_pause(bool play);
bool mp3_pause_done(void);
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index 68fa96d619..c5c747ac2c 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -61,7 +61,7 @@ static long playstart_tick;
static long cumulative_ticks;
/* the registered callback function to ask for more mp3 data */
-static void (*callback_for_more)(unsigned char**, int*);
+static void (*callback_for_more)(unsigned char**, size_t*);
#endif /* #ifndef SIMULATOR */
/* list of tracks in memory */
@@ -167,7 +167,7 @@ void DEI3(void) __attribute__((interrupt_handler));
void DEI3(void)
{
unsigned char* start;
- int size = 0;
+ size_t size = 0;
if (callback_for_more != NULL)
{
@@ -502,7 +502,7 @@ void mp3_play_init(void)
}
void mp3_play_data(const unsigned char* start, int size,
- void (*get_more)(unsigned char** start, int* size) /* callback fn */
+ void (*get_more)(unsigned char** start, size_t* size) /* callback fn */
)
{
/* init DMA */
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index a66a4d0f01..0299d4d557 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -810,7 +810,7 @@ static void reset_mp3_buffer(void)
}
/* DMA transfer end interrupt callback */
-static void transfer_end(unsigned char** ppbuf, int* psize)
+static void transfer_end(unsigned char** ppbuf, size_t* psize)
{
if(playing && !paused)
{
diff --git a/tools/configure b/tools/configure
index 1a84a487ee..d73409d44b 100755
--- a/tools/configure
+++ b/tools/configure
@@ -1470,6 +1470,11 @@ if test "$CC" = "sh-elf-gcc"; then
fi
fi
+if test "$CC" = "m68k-elf-gcc"; then
+ # convert -O to -Os to get smaller binaries!
+ GCCOPTS=`echo $GCCOPTS | sed 's/ -O / -Os /'`
+fi
+
if test "$1" = "--ccache"; then
echo "Enable ccache for building"
ccache="ccache"