summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs.c2
-rw-r--r--apps/codecs.h6
-rw-r--r--apps/debug_menu.c56
-rw-r--r--apps/pcmbuf.c42
-rw-r--r--apps/playback.c45
-rw-r--r--apps/playlist.c4
-rw-r--r--apps/plugin.c129
-rw-r--r--apps/plugin.h156
-rw-r--r--apps/plugins/alpine_cdc.c5
-rw-r--r--apps/plugins/battery_bench.c7
-rw-r--r--apps/tagcache.c9
11 files changed, 265 insertions, 196 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index addb8b5..b4b8c98 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -123,7 +123,7 @@ struct codec_api ci = {
&current_tick,
default_event_handler,
default_event_handler_ex,
- create_thread,
+ create_thread_on_core,
remove_thread,
reset_poweroff_timer,
#ifndef SIMULATOR
diff --git a/apps/codecs.h b/apps/codecs.h
index dde376d..96804a8 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -196,8 +196,10 @@ struct codec_api {
long* current_tick;
long (*default_event_handler)(long event);
long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter);
- int (*create_thread)(void (*function)(void), void* stack, int stack_size, const char *name);
- void (*remove_thread)(int threadnum);
+ struct thread_entry* (*create_thread)(unsigned int core, void (*function)(void),
+ void* stack, int stack_size, const char *name
+ IF_PRIO(, int priority));
+ void (*remove_thread)(struct thread_entry *thread);
void (*reset_poweroff_timer)(void);
#ifndef SIMULATOR
int (*system_memory_guard)(int newmode);
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 60f405a..bda5a5c 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -80,13 +80,27 @@ extern char ata_device;
extern int ata_io_address;
extern struct core_entry cores[NUM_CORES];
+char thread_status_char(int status)
+{
+ switch (status)
+ {
+ case STATE_RUNNING : return 'R';
+ case STATE_BLOCKED : return 'B';
+ case STATE_SLEEPING : return 'S';
+ case STATE_BLOCKED_W_TMO: return 'T';
+ }
+
+ return '?';
+}
#ifdef HAVE_LCD_BITMAP
/* Test code!!! */
bool dbg_os(void)
{
+ struct thread_entry *thread;
char buf[32];
int i;
int usage;
+ int status;
#if NUM_CORES > 1
unsigned int core;
int line;
@@ -98,24 +112,54 @@ bool dbg_os(void)
while(1)
{
+#if 0 /* Enable to simulate UI lag. */
+ int _x;
+ for (_x = 0; _x < 1000000L; _x++) ;
+#endif
#if NUM_CORES > 1
lcd_puts(0, 0, "Core and stack usage:");
line = 0;
for(core = 0; core < NUM_CORES; core++)
{
- for(i = 0; i < num_threads[core]; i++)
+ for(i = 0; i < MAXTHREADS; i++)
{
- usage = thread_stack_usage_on_core(core, i);
- snprintf(buf, 32, "(%d) %s: %d%%", core, thread_name[core][i], usage);
+ thread = &cores[core].threads[i];
+ if (thread->name == NULL)
+ continue;
+
+ usage = thread_stack_usage(thread);
+ status = thread_get_status(thread);
+
+ snprintf(buf, 32, "(%d) %c%c %d %s: %d%%", core,
+ (status == STATE_RUNNING) ? '*' : ' ',
+ thread_status_char(status),
+ cores[CURRENT_CORE].threads[i].priority,
+ cores[core].threads[i].name, usage);
lcd_puts(0, ++line, buf);
}
}
#else
lcd_puts(0, 0, "Stack usage:");
- for(i = 0; i < cores[CURRENT_CORE].num_threads;i++)
+ for(i = 0; i < MAXTHREADS; i++)
{
- usage = thread_stack_usage(i);
- snprintf(buf, 32, "%s: %d%%", cores[CURRENT_CORE].threads[i].name, usage);
+ thread = &cores[CURRENT_CORE].threads[i];
+ if (thread->name == NULL)
+ continue;
+
+ usage = thread_stack_usage(thread);
+ status = thread_get_status(thread);
+# ifdef HAVE_PRIORITY_SCHEDULING
+ snprintf(buf, 32, "%c%c %d %s: %d%%",
+ (status == STATE_RUNNING) ? '*' : ' ',
+ thread_status_char(status),
+ cores[CURRENT_CORE].threads[i].priority,
+ cores[CURRENT_CORE].threads[i].name, usage);
+# else
+ snprintf(buf, 32, "%c%c %s: %d%%",
+ (status == STATE_RUNNING) ? '*' : ' ',
+ (status == STATE_BLOCKED) ? 'B' : ' ',
+ cores[CURRENT_CORE].threads[i].name, usage);
+# endif
lcd_puts(0, 1+i, buf);
}
#endif
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index b18d411..f8fd2af 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -35,9 +35,10 @@
#include "settings.h"
#include "audio.h"
#include "dsp.h"
+#include "thread.h"
-/* 1.5s low mark */
-#define PCMBUF_WATERMARK (NATIVE_FREQUENCY * 6)
+/* Keep watermark high for iPods at least (2s) */
+#define PCMBUF_WATERMARK (NATIVE_FREQUENCY * 8)
/* Structure we can use to queue pcm chunks in memory to be played
* by the driver code. */
@@ -94,6 +95,8 @@ static size_t pcmbuf_mix_sample IDATA_ATTR;
static bool low_latency_mode = false;
static bool pcmbuf_flush;
+extern struct thread_entry *codec_thread_p;
+
/* Helpful macros for use in conditionals this assumes some of the above
* static variable names */
#define NEED_FLUSH(position) \
@@ -109,14 +112,37 @@ static bool pcmbuf_flush_fillpos(void);
void pcmbuf_boost(bool state)
{
static bool boost_state = false;
-
+#ifdef HAVE_PRIORITY_SCHEDULING
+ static bool priority_modified = false;
+#endif
+
if (crossfade_init || crossfade_active)
return;
- if (state != boost_state) {
+ if (state != boost_state)
+ {
cpu_boost(state);
boost_state = state;
}
+
+#ifdef HAVE_PRIORITY_SCHEDULING
+ if (state && LOW_DATA(2) && pcm_is_playing())
+ {
+ if (!priority_modified)
+ {
+ /* Buffer is critically low so override UI priority. */
+ priority_modified = true;
+ thread_set_priority(codec_thread_p, PRIORITY_REALTIME);
+ }
+ }
+ else if (priority_modified)
+ {
+ /* Set back the original priority. */
+ thread_set_priority(codec_thread_p, PRIORITY_PLAYBACK);
+ priority_modified = false;
+ }
+
+#endif
}
#endif
@@ -244,7 +270,9 @@ static void pcmbuf_under_watermark(void)
pcmbuf_boost(true);
/* Disable crossfade if < .5s of audio */
if (LOW_DATA(2))
+ {
crossfade_active = false;
+ }
}
void pcmbuf_set_event_handler(void (*event_handler)(void))
@@ -270,8 +298,8 @@ bool pcmbuf_is_lowdata(void)
crossfade_init || crossfade_active)
return false;
- /* 0.5 seconds of buffer is low data */
- return LOW_DATA(2);
+ /* 1 seconds of buffer is low data */
+ return LOW_DATA(4);
}
/* Amount of bytes left in the buffer. */
@@ -443,7 +471,7 @@ static bool pcmbuf_flush_fillpos(void)
pcmbuf_play_start();
}
/* Let approximately one chunk of data playback */
- sleep(PCMBUF_TARGET_CHUNK/(NATIVE_FREQUENCY * 4) / 5);
+ sleep(HZ*PCMBUF_TARGET_CHUNK/(NATIVE_FREQUENCY*4));
}
pcmbuf_add_chunk();
return true;
diff --git a/apps/playback.c b/apps/playback.c
index 352c99b..33667cc 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -176,7 +176,7 @@ static char *voicebuf;
static size_t voice_remaining;
static bool voice_is_playing;
static void (*voice_getmore)(unsigned char** start, int* size);
-static int voice_thread_num = -1;
+static struct thread_entry *voice_thread_p = NULL;
/* Is file buffer currently being refilled? */
static volatile bool filling IDATA_ATTR;
@@ -267,6 +267,8 @@ static struct event_queue codec_queue;
static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]
IBSS_ATTR;
static const char codec_thread_name[] = "codec";
+/* For modifying thread priority later. */
+struct thread_entry *codec_thread_p;
/* Voice thread */
static struct event_queue voice_queue;
@@ -628,13 +630,13 @@ void audio_preinit(void)
mutex_init(&mutex_codecthread);
- queue_init(&audio_queue);
- queue_init(&codec_queue);
- /* clear, not init to create a private queue */
- queue_clear(&codec_callback_queue);
+ queue_init(&audio_queue, true);
+ queue_init(&codec_queue, true);
+ /* create a private queue */
+ queue_init(&codec_callback_queue, false);
create_thread(audio_thread, audio_stack, sizeof(audio_stack),
- audio_thread_name);
+ audio_thread_name IF_PRIO(, PRIORITY_BUFFERING));
}
void audio_init(void)
@@ -648,14 +650,14 @@ void voice_init(void)
if (!filebuf)
return; /* Audio buffers not yet set up */
- if (voice_thread_num >= 0)
+ if (voice_thread_p)
{
logf("Terminating voice codec");
- remove_thread(voice_thread_num);
+ remove_thread(voice_thread_p);
if (current_codec == CODEC_IDX_VOICE)
mutex_unlock(&mutex_codecthread);
queue_delete(&voice_queue);
- voice_thread_num = -1;
+ voice_thread_p = NULL;
voice_codec_loaded = false;
}
@@ -663,9 +665,10 @@ void voice_init(void)
return;
logf("Starting voice codec");
- queue_init(&voice_queue);
- voice_thread_num = create_thread(voice_thread, voice_stack,
- sizeof(voice_stack), voice_thread_name);
+ queue_init(&voice_queue, true);
+ voice_thread_p = create_thread(voice_thread, voice_stack,
+ sizeof(voice_stack), voice_thread_name
+ IF_PRIO(, PRIORITY_PLAYBACK));
while (!voice_codec_loaded)
yield();
@@ -1740,7 +1743,7 @@ static void codec_thread(void)
#endif
#ifndef SIMULATOR
- case SYS_USB_CONNECTED:
+ case SYS_USB_CONNECTED:
LOGFQUEUE("codec < SYS_USB_CONNECTED");
queue_clear(&codec_queue);
usb_acknowledge(SYS_USB_CONNECTED_ACK);
@@ -1982,13 +1985,15 @@ static bool audio_yield_codecs(void)
{
yield();
- if (!queue_empty(&audio_queue)) return true;
+ if (!queue_empty(&audio_queue))
+ return true;
while ((pcmbuf_is_crossfade_active() || pcmbuf_is_lowdata())
&& !ci.stop_codec && playing && !audio_filebuf_is_lowdata())
{
sleep(1);
- if (!queue_empty(&audio_queue)) return true;
+ if (!queue_empty(&audio_queue))
+ return true;
}
return false;
@@ -3178,8 +3183,9 @@ static void audio_playback_init(void)
id3_voice.frequency = 11200;
id3_voice.length = 1000000L;
- create_thread(codec_thread, codec_stack, sizeof(codec_stack),
- codec_thread_name);
+ codec_thread_p = create_thread(codec_thread, codec_stack,
+ sizeof(codec_stack),
+ codec_thread_name IF_PRIO(, PRIORITY_PLAYBACK));
while (1)
{
@@ -3213,7 +3219,8 @@ static void audio_thread(void)
/* At first initialize audio system in background. */
audio_playback_init();
- while (1) {
+ while (1)
+ {
if (filling)
{
queue_wait_w_tmo(&audio_queue, &ev, 0);
@@ -3221,7 +3228,7 @@ static void audio_thread(void)
ev.id = Q_AUDIO_FILL_BUFFER;
}
else
- queue_wait_w_tmo(&audio_queue, &ev, HZ);
+ queue_wait_w_tmo(&audio_queue, &ev, HZ/2);
switch (ev.id) {
case Q_AUDIO_FILL_BUFFER:
diff --git a/apps/playlist.c b/apps/playlist.c
index a75e32a..4ab98ab 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -1777,8 +1777,8 @@ void playlist_init(void)
memset(playlist->filenames, 0,
playlist->max_playlist_size * sizeof(int));
create_thread(playlist_thread, playlist_stack, sizeof(playlist_stack),
- playlist_thread_name);
- queue_init(&playlist_queue);
+ playlist_thread_name IF_PRIO(, PRIORITY_BACKGROUND));
+ queue_init(&playlist_queue, true);
#endif
}
diff --git a/apps/plugin.c b/apps/plugin.c
index 6e2a8bc..9ffb980 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -108,6 +108,7 @@ static const struct plugin_api rockbox_api = {
PREFIX(lcd_icon),
lcd_double_height,
#else
+ lcd_setmargins,
lcd_set_drawmode,
lcd_get_drawmode,
lcd_setfont,
@@ -132,6 +133,9 @@ static const struct plugin_api rockbox_api = {
lcd_bitmap_transparent_part,
lcd_bitmap_transparent,
#endif
+ bidi_l2v,
+ font_get_bits,
+ font_load,
lcd_putsxy,
lcd_puts_style,
lcd_puts_scroll_style,
@@ -178,6 +182,45 @@ static const struct plugin_api rockbox_api = {
remote_backlight_on,
remote_backlight_off,
#endif
+#if NB_SCREENS == 2
+ {&screens[SCREEN_MAIN], &screens[SCREEN_REMOTE]},
+#else
+ {&screens[SCREEN_MAIN]},
+#endif
+#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
+ lcd_remote_set_foreground,
+ lcd_remote_get_foreground,
+ lcd_remote_set_background,
+ lcd_remote_get_background,
+ lcd_remote_bitmap_part,
+ lcd_remote_bitmap,
+#endif
+
+#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
+ lcd_yuv_blit,
+#endif
+ /* list */
+ gui_synclist_init,
+ gui_synclist_set_nb_items,
+ gui_synclist_set_icon_callback,
+ gui_synclist_get_nb_items,
+ gui_synclist_get_sel_pos,
+ gui_synclist_draw,
+ gui_synclist_select_item,
+ gui_synclist_select_next,
+ gui_synclist_select_previous,
+ gui_synclist_select_next_page,
+ gui_synclist_select_previous_page,
+ gui_synclist_add_item,
+ gui_synclist_del_item,
+ gui_synclist_limit_scroll,
+ gui_synclist_flash,
+#ifdef HAVE_LCD_BITMAP
+ gui_synclist_scroll_right,
+ gui_synclist_scroll_left,
+#endif
+ gui_synclist_do_button,
+
/* button */
button_get,
button_get_w_tmo,
@@ -205,12 +248,14 @@ static const struct plugin_api rockbox_api = {
ata_sleep,
ata_disk_is_active,
#endif
+ reload_directory,
/* dir */
PREFIX(opendir),
PREFIX(closedir),
PREFIX(readdir),
PREFIX(mkdir),
+ PREFIX(rmdir),
/* kernel/ system */
PREFIX(sleep),
@@ -253,6 +298,7 @@ static const struct plugin_api rockbox_api = {
/* strings and memory */
snprintf,
+ vsnprintf,
strcpy,
strncpy,
strlen,
@@ -268,6 +314,7 @@ static const struct plugin_api rockbox_api = {
atoi,
strchr,
strcat,
+ memchr,
memcmp,
strcasestr,
/* unicode stuff */
@@ -277,9 +324,12 @@ static const struct plugin_api rockbox_api = {
utf16BEdecode,
utf8encode,
utf8length,
+ utf8seek,
/* sound */
sound_set,
+ set_sound,
+
sound_min,
sound_max,
#ifndef SIMULATOR
@@ -334,6 +384,9 @@ static const struct plugin_api rockbox_api = {
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
mas_codec_writereg,
mas_codec_readreg,
+ i2c_begin,
+ i2c_end,
+ i2c_write,
#endif
#endif /* !SIMULATOR && CONFIG_CODEC != SWCODEC */
@@ -352,7 +405,15 @@ static const struct plugin_api rockbox_api = {
menu_insert,
menu_set_cursor,
set_option,
+ set_int,
+ set_bool,
+ /* action handling */
+ get_custom_action,
+ get_action,
+ action_signalscreenchange,
+ action_userabort,
+
/* power */
battery_level,
battery_level_safe,
@@ -405,74 +466,6 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time
the API gets incompatible */
- set_sound,
-#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)) && !defined(SIMULATOR)
- i2c_begin,
- i2c_end,
- i2c_write,
-#endif
-
- vsnprintf,
- memchr,
- /* list */
- gui_synclist_init,
- gui_synclist_set_nb_items,
- gui_synclist_set_icon_callback,
- gui_synclist_get_nb_items,
- gui_synclist_get_sel_pos,
- gui_synclist_draw,
- gui_synclist_select_item,
- gui_synclist_select_next,
- gui_synclist_select_previous,
- gui_synclist_select_next_page,
- gui_synclist_select_previous_page,
- gui_synclist_add_item,
- gui_synclist_del_item,
- gui_synclist_limit_scroll,
- gui_synclist_flash,
-#ifdef HAVE_LCD_BITMAP
- gui_synclist_scroll_right,
- gui_synclist_scroll_left,
-#endif
- gui_synclist_do_button,
-
-#ifdef HAVE_LCD_BITMAP
- lcd_setmargins,
-#endif
- utf8seek,
-
- set_int,
- reload_directory,
- set_bool,
-#if NB_SCREENS == 2
- {&screens[SCREEN_MAIN], &screens[SCREEN_REMOTE]},
-#else
- {&screens[SCREEN_MAIN]},
-#endif
-#ifdef HAVE_LCD_BITMAP
- bidi_l2v,
- font_get_bits,
- font_load,
-#endif
-#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
- lcd_remote_set_foreground,
- lcd_remote_get_foreground,
- lcd_remote_set_background,
- lcd_remote_get_background,
- lcd_remote_bitmap_part,
- lcd_remote_bitmap,
-#endif
-
-#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
- lcd_yuv_blit,
-#endif
-
- PREFIX(rmdir),
- /* action handling */
- get_custom_action,
- get_action,
- action_signalscreenchange,
- action_userabort,
};
int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 9b3cec5..b89dfd0 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -105,12 +105,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 29
+#define PLUGIN_API_VERSION 30
/* 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 14
+#define PLUGIN_MIN_API_VERSION 30
/* plugin return codes */
enum plugin_status {
@@ -143,6 +143,7 @@ struct plugin_api {
void (*PREFIX(lcd_icon))(int icon, bool enable);
void (*lcd_double_height)(bool on);
#else
+ void (*lcd_setmargins)(int x, int y);
void (*lcd_set_drawmode)(int mode);
int (*lcd_get_drawmode)(void);
void (*lcd_setfont)(int font);
@@ -174,6 +175,9 @@ struct plugin_api {
void (*lcd_bitmap_transparent)(const fb_data *src, int x, int y,
int width, int height);
#endif
+ unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
+ const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
+ struct font* (*font_load)(const char *path);
void (*lcd_putsxy)(int x, int y, const unsigned char *string);
void (*lcd_puts_style)(int x, int y, const unsigned char *str, int style);
void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
@@ -229,7 +233,50 @@ struct plugin_api {
void (*remote_backlight_on)(void);
void (*remote_backlight_off)(void);
#endif
+ struct screen* screens[NB_SCREENS];
+#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
+ void (*lcd_remote_set_foreground)(unsigned foreground);
+ unsigned (*lcd_remote_get_foreground)(void);
+ void (*lcd_remote_set_background)(unsigned foreground);
+ unsigned (*lcd_remote_get_background)(void);
+ void (*lcd_remote_bitmap_part)(const fb_remote_data *src, int src_x, int src_y,
+ int stride, int x, int y, int width, int height);
+ void (*lcd_remote_bitmap)(const fb_remote_data *src, int x, int y, int width,
+ int height);
+#endif
+#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
+ void (*lcd_yuv_blit)(unsigned char * const src[3],
+ int src_x, int src_y, int stride,
+ int x, int y, int width, int height);
+#endif
+ /* list */
+ void (*gui_synclist_init)(struct gui_synclist * lists,
+ list_get_name callback_get_item_name,void * data,
+ bool scroll_all,int selected_size);
+ void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items);
+ void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, list_get_icon icon_callback);
+ int (*gui_synclist_get_nb_items)(struct gui_synclist * lists);
+ int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists);
+ void (*gui_synclist_draw)(struct gui_synclist * lists);
+ void (*gui_synclist_select_item)(struct gui_synclist * lists,
+ int item_number);
+ void (*gui_synclist_select_next)(struct gui_synclist * lists);
+ void (*gui_synclist_select_previous)(struct gui_synclist * lists);
+ void (*gui_synclist_select_next_page)(struct gui_synclist * lists,
+ enum screen_type screen);
+ void (*gui_synclist_select_previous_page)(struct gui_synclist * lists,
+ enum screen_type screen);
+ void (*gui_synclist_add_item)(struct gui_synclist * lists);
+ void (*gui_synclist_del_item)(struct gui_synclist * lists);
+ void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
+ void (*gui_synclist_flash)(struct gui_synclist * lists);
+#ifdef HAVE_LCD_BITMAP
+ void (*gui_synclist_scroll_right)(struct gui_synclist * lists);
+ void (*gui_synclist_scroll_left)(struct gui_synclist * lists);
+#endif
+ unsigned (*gui_synclist_do_button)(struct gui_synclist * lists, unsigned button);
+
/* button */
long (*button_get)(bool block);
long (*button_get_w_tmo)(int ticks);
@@ -257,12 +304,14 @@ struct plugin_api {
void (*ata_sleep)(void);
bool (*ata_disk_is_active)(void);
#endif
+ void (*reload_directory)(void);
/* dir */
DIR* (*PREFIX(opendir))(const char* name);
int (*PREFIX(closedir))(DIR* dir);
struct dirent* (*PREFIX(readdir))(DIR* dir);
int (*PREFIX(mkdir))(const char *name, int mode);
+ int (*PREFIX(rmdir))(const char *name);
/* kernel/ system */
void (*PREFIX(sleep))(int ticks);
@@ -270,8 +319,10 @@ struct plugin_api {
long* current_tick;
long (*default_event_handler)(long event);
long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter);
- int (*create_thread)(void (*function)(void), void* stack, int stack_size, const char *name);
- void (*remove_thread)(int threadnum);
+ struct thread_entry* (*create_thread)(void (*function)(void), void* stack,
+ int stack_size, const char *name
+ IF_PRIO(, int priority));
+ void (*remove_thread)(struct thread_entry *thread);
void (*reset_poweroff_timer)(void);
#ifndef SIMULATOR
int (*system_memory_guard)(int newmode);
@@ -285,7 +336,7 @@ struct plugin_api {
void (*timer_unregister)(void);
bool (*timer_set_period)(long count);
#endif
- void (*queue_init)(struct event_queue *q);
+ void (*queue_init)(struct event_queue *q, bool register_queue);
void (*queue_delete)(struct event_queue *q);
void (*queue_post)(struct event_queue *q, long id, void *data);
void (*queue_wait_w_tmo)(struct event_queue *q, struct event *ev,
@@ -308,6 +359,7 @@ struct plugin_api {
/* strings and memory */
int (*snprintf)(char *buf, size_t size, const char *fmt, ...);
+ int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap);
char* (*strcpy)(char *dst, const char *src);
char* (*strncpy)(char *dst, const char *src, size_t length);
size_t (*strlen)(const char *str);
@@ -323,6 +375,7 @@ struct plugin_api {
int (*atoi)(const char *str);
char *(*strchr)(const char *s, int c);
char *(*strcat)(char *s1, const char *s2);
+ void *(*memchr)(const void *s1, int c, size_t n);
int (*memcmp)(const void *s1, const void *s2, size_t n);
char *(*strcasestr) (const char* phaystack, const char* pneedle);
/* unicode stuff */
@@ -332,9 +385,12 @@ struct plugin_api {
unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8);
unsigned long (*utf8length)(const unsigned char *utf8);
+ int (*utf8seek)(const unsigned char* utf8, int offset);
/* sound */
void (*sound_set)(int setting, int value);
+ bool (*set_sound)(const unsigned char * string,
+ int* variable, int setting);
int (*sound_min)(int setting);
int (*sound_max)(int setting);
#ifndef SIMULATOR
@@ -390,6 +446,9 @@ struct plugin_api {
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
int (*mas_codec_writereg)(int reg, unsigned int val);
int (*mas_codec_readreg)(int reg);
+ void (*i2c_begin)(void);
+ void (*i2c_end)(void);
+ int (*i2c_write)(int address, unsigned char* buf, int count );
#endif
#endif
@@ -413,7 +472,17 @@ struct plugin_api {
bool (*set_option)(const char* string, void* variable,
enum optiontype type, const struct opt_items* options,
int numoptions, void (*function)(int));
+ bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
+ int* variable, void (*function)(int), int step, int min,
+ int max, void (*formatter)(char*, int, int, const char*) );
+ bool (*set_bool)(const char* string, bool* variable );
+ /* action handling */
+ int (*get_custom_action)(int context,int timeout,
+ const struct button_mapping* (*get_context_map)(int));
+ int (*get_action)(int context, int timeout);
+ void (*action_signalscreenchange)(void);
+ bool (*action_userabort)(int timeout);
/* power */
int (*battery_level)(void);
@@ -476,83 +545,6 @@ struct plugin_api {
/* new stuff at the end, sort into place next time
the API gets incompatible */
- bool (*set_sound)(const unsigned char * string,
- int* variable, int setting);
-#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)) && !defined(SIMULATOR)
- void (*i2c_begin)(void);
- void (*i2c_end)(void);
- int (*i2c_write)(int address, unsigned char* buf, int count );
-#endif
-
- int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap);
- void *(*memchr)(const void *s1, int c, size_t n);
-
- /* list */
- void (*gui_synclist_init)(struct gui_synclist * lists,
- list_get_name callback_get_item_name,void * data,
- bool scroll_all,int selected_size);
- void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items);
- void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, list_get_icon icon_callback);
- int (*gui_synclist_get_nb_items)(struct gui_synclist * lists);
- int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists);
- void (*gui_synclist_draw)(struct gui_synclist * lists);
- void (*gui_synclist_select_item)(struct gui_synclist * lists,
- int item_number);
- void (*gui_synclist_select_next)(struct gui_synclist * lists);
- void (*gui_synclist_select_previous)(struct gui_synclist * lists);
- void (*gui_synclist_select_next_page)(struct gui_synclist * lists,
- enum screen_type screen);
- void (*gui_synclist_select_previous_page)(struct gui_synclist * lists,
- enum screen_type screen);
- void (*gui_synclist_add_item)(struct gui_synclist * lists);
- void (*gui_synclist_del_item)(struct gui_synclist * lists);
- void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
- void (*gui_synclist_flash)(struct gui_synclist * lists);
-#ifdef HAVE_LCD_BITMAP
- void (*gui_synclist_scroll_right)(struct gui_synclist * lists);
- void (*gui_synclist_scroll_left)(struct gui_synclist * lists);
-#endif
- unsigned (*gui_synclist_do_button)(struct gui_synclist * lists, unsigned button);
-
-#ifdef HAVE_LCD_BITMAP
- void (*lcd_setmargins)(int x, int y);
-#endif
- int (*utf8seek)(const unsigned char* utf8, int offset);
-
- bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
- int* variable, void (*function)(int), int step, int min,
- int max, void (*formatter)(char*, int, int, const char*) );
- void (*reload_directory)(void);
- bool (*set_bool)(const char* string, bool* variable );
- struct screen* screens[NB_SCREENS];
-#ifdef HAVE_LCD_BITMAP
- unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
- const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
- struct font* (*font_load)(const char *path);
-#endif
-#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
- void (*lcd_remote_set_foreground)(unsigned foreground);
- unsigned (*lcd_remote_get_foreground)(void);
- void (*lcd_remote_set_background)(unsigned foreground);
- unsigned (*lcd_remote_get_background)(void);
- void (*lcd_remote_bitmap_part)(const fb_remote_data *src, int src_x, int src_y,
- int stride, int x, int y, int width, int height);
- void (*lcd_remote_bitmap)(const fb_remote_data *src, int x, int y, int width,
- int height);
-#endif
-#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
- void (*lcd_yuv_blit)(unsigned char * const src[3],
- int src_x, int src_y, int stride,
- int x, int y, int width, int height);
-#endif
-
- int (*PREFIX(rmdir))(const char *name);
- /* action handling */
- int (*get_custom_action)(int context,int timeout,
- const struct button_mapping* (*get_context_map)(int));
- int (*get_action)(int context, int timeout);
- void (*action_signalscreenchange)(void);
- bool (*action_userabort)(int timeout);
};
/* plugin header */
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c
index a482664..134bb3d 100644
--- a/apps/plugins/alpine_cdc.c
+++ b/apps/plugins/alpine_cdc.c
@@ -202,7 +202,7 @@ struct
/* communication to the worker thread */
struct
{
- int id; /* ID of the thread */
+ struct thread_entry *id; /* Pointer of the thread */
bool foreground; /* set as long as we're owning the UI */
bool exiting; /* signal to the thread that we want to exit */
bool ended; /* response from the thread, that is has exited */
@@ -1169,7 +1169,8 @@ int main(void* parameter)
rb->memset(&gTread, 0, sizeof(gTread));
gTread.foreground = true;
- gTread.id = rb->create_thread(thread, stack, stacksize, "CDC");
+ gTread.id = rb->create_thread(thread, stack, stacksize, "CDC"
+ IF_PRIO(, PRIORITY_BACKGROUND));
#ifdef DEBUG
do
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 9400bd2..3c56f84 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -102,7 +102,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
struct
{
- int id;
+ struct thread_entry *id;
bool ended;
} s_thread;
@@ -454,10 +454,11 @@ int main(void)
rb->close(fd);
}
- rb->queue_init(&thread_q); /* put the thread's queue in the bcast list */
+ rb->queue_init(&thread_q, true); /* put the thread's queue in the bcast list */
rb->memset(&s_thread, 0, sizeof(s_thread)); /* zero the struct */
if((s_thread.id = rb->create_thread(thread, thread_stack,
- sizeof(thread_stack), "Battery Benchmark"))<0)
+ sizeof(thread_stack), "Battery Benchmark"
+ IF_PRIO(, PRIORITY_BACKGROUND))) == NULL)
{
rb->splash(HZ,true,"Cannot create thread!");
return PLUGIN_ERROR;
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 2ed80a8..f478598 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -54,6 +54,7 @@
*/
#include <stdio.h>
+#include "config.h"
#include "thread.h"
#include "kernel.h"
#include "system.h"
@@ -1062,7 +1063,6 @@ static bool get_next(struct tagcache_search *tcs)
if (tagcache_is_numeric_tag(tcs->type))
{
- logf("r:%d", tcs->position);
snprintf(buf, sizeof(buf), "%d", tcs->position);
tcs->result_seek = tcs->position;
tcs->result = buf;
@@ -3455,7 +3455,6 @@ static void tagcache_thread(void)
sleep(HZ);
stat.ready = check_all_headers();
-
while (1)
{
queue_wait_w_tmo(&tagcache_queue, &ev, HZ);
@@ -3503,6 +3502,7 @@ static void tagcache_thread(void)
logf("tagcache check done");
+
check_done = true;
break ;
@@ -3612,9 +3612,10 @@ void tagcache_init(void)
current_serial = 0;
write_lock = read_lock = 0;
- queue_init(&tagcache_queue);
+ queue_init(&tagcache_queue, true);
create_thread(tagcache_thread, tagcache_stack,
- sizeof(tagcache_stack), tagcache_thread_name);
+ sizeof(tagcache_stack), tagcache_thread_name
+ IF_PRIO(, PRIORITY_BACKGROUND));
}
bool tagcache_is_initialized(void)