diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2008-12-10 08:57:10 +0000 |
|---|---|---|
| committer | Michael Sevakis <jethead71@rockbox.org> | 2008-12-10 08:57:10 +0000 |
| commit | 8cfbd3604fac14f629244e521ad24ffa9938c790 (patch) | |
| tree | 16dc096519b8b537bb7d4b73e0c97f5f33ee752b /apps | |
| parent | 40ff47c7eea41ac893d7af5c5b97ace52a5ffade (diff) | |
| download | rockbox-8cfbd3604fac14f629244e521ad24ffa9938c790.zip rockbox-8cfbd3604fac14f629244e521ad24ffa9938c790.tar.gz rockbox-8cfbd3604fac14f629244e521ad24ffa9938c790.tar.bz2 rockbox-8cfbd3604fac14f629244e521ad24ffa9938c790.tar.xz | |
Use cookies for thread identification instead of pointers directly which gives a buffer against wrongly identifying a thread when the slot is recycled (which has been nagging me for awhile). A slot gets 255 uses before it repeats. Everything gets incompatible so a full update is required.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19377 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/buffering.c | 8 | ||||
| -rw-r--r-- | apps/codecs.h | 10 | ||||
| -rw-r--r-- | apps/codecs/mpa.c | 8 | ||||
| -rw-r--r-- | apps/codecs/spc.c | 12 | ||||
| -rw-r--r-- | apps/pcmbuf.c | 8 | ||||
| -rw-r--r-- | apps/playback.c | 16 | ||||
| -rw-r--r-- | apps/plugin.c | 6 | ||||
| -rw-r--r-- | apps/plugin.h | 26 | ||||
| -rw-r--r-- | apps/plugins/alpine_cdc.c | 2 | ||||
| -rw-r--r-- | apps/plugins/battery_bench.c | 4 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/audio_thread.c | 6 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/disk_buf.c | 8 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/disk_buf.h | 2 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/mpeg_parser.c | 2 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/stream_mgr.c | 20 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/stream_mgr.h | 2 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/stream_thread.h | 2 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/video_thread.c | 6 | ||||
| -rw-r--r-- | apps/plugins/pictureflow.c | 4 | ||||
| -rw-r--r-- | apps/plugins/test_codec.c | 4 | ||||
| -rw-r--r-- | apps/plugins/test_sampr.c | 14 | ||||
| -rw-r--r-- | apps/recorder/pcm_record.c | 20 | ||||
| -rw-r--r-- | apps/voice_thread.c | 10 |
23 files changed, 100 insertions, 100 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index dfc9006..6160869 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -184,7 +184,7 @@ enum { 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; +static unsigned int buffering_thread_id = 0; static struct event_queue buffering_queue; static struct queue_sender_list buffering_queue_sender_list; @@ -1468,13 +1468,13 @@ void buffering_init(void) conf_watermark = BUFFERING_DEFAULT_WATERMARK; queue_init(&buffering_queue, true); - buffering_thread_p = create_thread( buffering_thread, buffering_stack, + buffering_thread_id = create_thread( buffering_thread, buffering_stack, sizeof(buffering_stack), CREATE_THREAD_FROZEN, buffering_thread_name IF_PRIO(, PRIORITY_BUFFERING) IF_COP(, CPU)); queue_enable_queue_send(&buffering_queue, &buffering_queue_sender_list, - buffering_thread_p); + buffering_thread_id); } /* Initialise the buffering subsystem */ @@ -1501,7 +1501,7 @@ bool buffering_reset(char *buf, size_t buflen) high_watermark = 3*buflen / 4; #endif - thread_thaw(buffering_thread_p); + thread_thaw(buffering_thread_id); return true; } diff --git a/apps/codecs.h b/apps/codecs.h index 4194524..d765dab 100644 --- a/apps/codecs.h +++ b/apps/codecs.h @@ -82,12 +82,12 @@ #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ /* increase this every time the api struct changes */ -#define CODEC_API_VERSION 27 +#define CODEC_API_VERSION 28 /* 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 CODEC_MIN_API_VERSION 27 +#define CODEC_MIN_API_VERSION 28 /* codec return codes */ enum codec_status { @@ -164,14 +164,14 @@ struct codec_api { void (*yield)(void); #if NUM_CORES > 1 - struct thread_entry * + unsigned int (*create_thread)(void (*function)(void), void* stack, size_t stack_size, unsigned flags, const char *name IF_PRIO(, int priority) IF_COP(, unsigned int core)); - void (*thread_thaw)(struct thread_entry *thread); - void (*thread_wait)(struct thread_entry *thread); + void (*thread_thaw)(unsigned int thread_id); + void (*thread_wait)(unsigned int thread_id); void (*semaphore_init)(struct semaphore *s, int max, int start); void (*semaphore_wait)(struct semaphore *s); void (*semaphore_release)(struct semaphore *s); diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index 7732622..37a1afa 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c @@ -200,7 +200,7 @@ static void set_elapsed(struct mp3entry* id3) static int mad_synth_thread_stack[DEFAULT_STACK_SIZE/sizeof(int)/2] IBSS_ATTR; static const unsigned char * const mad_synth_thread_name = "mp3dec"; -static struct thread_entry *mad_synth_thread_p; +static unsigned int mad_synth_thread_id = 0; static void mad_synth_thread(void) @@ -249,14 +249,14 @@ static bool mad_synth_thread_create(void) ci->semaphore_init(&synth_done_sem, 1, 0); ci->semaphore_init(&synth_pending_sem, 1, 0); - mad_synth_thread_p = ci->create_thread(mad_synth_thread, + mad_synth_thread_id = ci->create_thread(mad_synth_thread, mad_synth_thread_stack, sizeof(mad_synth_thread_stack), 0, mad_synth_thread_name IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, COP)); - if (mad_synth_thread_p == NULL) + if (mad_synth_thread_id == 0) return false; return true; @@ -267,7 +267,7 @@ static void mad_synth_thread_quit(void) /*mop up COP thread*/ die=1; ci->semaphore_release(&synth_pending_sem); - ci->thread_wait(mad_synth_thread_p); + ci->thread_wait(mad_synth_thread_id); invalidate_icache(); } #else diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c index 380cfbd..14d28df 100644 --- a/apps/codecs/spc.c +++ b/apps/codecs/spc.c @@ -197,7 +197,7 @@ static int spc_emu_thread_stack[DEFAULT_STACK_SIZE/sizeof(int)] CACHEALIGN_ATTR; static const unsigned char * const spc_emu_thread_name = "spc emu"; -static struct thread_entry *emu_thread_p; +static unsigned int emu_thread_id = 0; enum { @@ -352,11 +352,11 @@ static void spc_emu_thread(void) static bool spc_emu_start(void) { - emu_thread_p = ci->create_thread(spc_emu_thread, spc_emu_thread_stack, + emu_thread_id = ci->create_thread(spc_emu_thread, spc_emu_thread_stack, sizeof(spc_emu_thread_stack), CREATE_THREAD_FROZEN, spc_emu_thread_name IF_PRIO(, PRIORITY_PLAYBACK), COP); - if (emu_thread_p == NULL) + if (emu_thread_id == 0) return false; /* Initialize audio queue as full to prevent emu thread from trying to run the @@ -368,7 +368,7 @@ static bool spc_emu_start(void) sample_queue.tail = 2; /* Start it running */ - ci->thread_thaw(emu_thread_p); + ci->thread_thaw(emu_thread_id); return true; } @@ -382,10 +382,10 @@ static inline int load_spc_buffer(uint8_t *buf, size_t size) static inline void spc_emu_quit(void) { - if (emu_thread_p != NULL) { + if (emu_thread_id != 0) { emu_thread_send_msg(SPC_EMU_QUIT, 0); /* Wait for emu thread to be killed */ - ci->thread_wait(emu_thread_p); + ci->thread_wait(emu_thread_id); invalidate_icache(); } } diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index c7db4d3..9ca5fbf 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -115,7 +115,7 @@ static bool pcmbuf_flush; static int codec_thread_priority = PRIORITY_PLAYBACK; #endif -extern struct thread_entry *codec_thread_p; +extern uintptr_t codec_thread_id; /* Helpful macros for use in conditionals this assumes some of the above * static variable names */ @@ -258,13 +258,13 @@ static void boost_codec_thread(bool boost) if (priority != codec_thread_priority) { codec_thread_priority = priority; - thread_set_priority(codec_thread_p, priority); + thread_set_priority(codec_thread_id, priority); voice_thread_set_priority(priority); } } else if (codec_thread_priority != PRIORITY_PLAYBACK) { - thread_set_priority(codec_thread_p, PRIORITY_PLAYBACK); + thread_set_priority(codec_thread_id, PRIORITY_PLAYBACK); voice_thread_set_priority(PRIORITY_PLAYBACK); codec_thread_priority = PRIORITY_PLAYBACK; } @@ -276,7 +276,7 @@ static void pcmbuf_under_watermark(void) /* Only codec thread initiates boost - voice boosts the cpu when playing a clip */ #ifndef SIMULATOR - if (thread_get_current() == codec_thread_p) + if (thread_get_current() == codec_thread_id) #endif /* SIMULATOR */ { #ifdef HAVE_PRIORITY_SCHEDULING diff --git a/apps/playback.c b/apps/playback.c index 50c4017..3aed12e 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -299,7 +299,7 @@ static struct queue_sender_list codec_queue_sender_list; static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] IBSS_ATTR; static const char codec_thread_name[] = "codec"; -struct thread_entry *codec_thread_p; /* For modifying thread priority later. */ +unsigned int codec_thread_id; /* For modifying thread priority later. */ /* PCM buffer messaging */ static struct event_queue pcmbuf_queue SHAREDBSS_ATTR; @@ -2499,7 +2499,7 @@ static void audio_thread(void) */ void audio_init(void) { - struct thread_entry *audio_thread_p; + unsigned int audio_thread_id; /* Can never do this twice */ if (audio_is_initialized) @@ -2543,22 +2543,22 @@ void audio_init(void) talk first */ talk_init(); - codec_thread_p = create_thread( + codec_thread_id = create_thread( codec_thread, codec_stack, sizeof(codec_stack), CREATE_THREAD_FROZEN, codec_thread_name IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU)); queue_enable_queue_send(&codec_queue, &codec_queue_sender_list, - codec_thread_p); + codec_thread_id); - audio_thread_p = create_thread(audio_thread, audio_stack, + audio_thread_id = create_thread(audio_thread, audio_stack, sizeof(audio_stack), CREATE_THREAD_FROZEN, audio_thread_name IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU)); queue_enable_queue_send(&audio_queue, &audio_queue_sender_list, - audio_thread_p); + audio_thread_id); #ifdef PLAYBACK_VOICE voice_thread_init(); @@ -2599,8 +2599,8 @@ void audio_init(void) #ifdef PLAYBACK_VOICE voice_thread_resume(); #endif - thread_thaw(codec_thread_p); - thread_thaw(audio_thread_p); + thread_thaw(codec_thread_id); + thread_thaw(audio_thread_id); } /* audio_init */ diff --git a/apps/plugin.c b/apps/plugin.c index de2dd3f..e55ecd4 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -146,7 +146,8 @@ static const struct plugin_api rockbox_api = { font_get_width, screen_clear_area, gui_scrollbar_draw, -#endif +#endif /* HAVE_LCD_BITMAP */ + get_codepage_name, backlight_on, backlight_off, @@ -482,6 +483,7 @@ static const struct plugin_api rockbox_api = { &statusbars, gui_syncstatusbar_draw, /* options */ + get_settings_list, find_setting, option_screen, set_option, @@ -619,8 +621,6 @@ static const struct plugin_api rockbox_api = { appsversion, /* new stuff at the end, sort into place next time the API gets incompatible */ - get_settings_list, - get_codepage_name, }; int plugin_load(const char* plugin, const void* parameter) diff --git a/apps/plugin.h b/apps/plugin.h index fd01e15..e91c866 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -7,7 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright (C) 2002 Björn Stenberg + * Copyright (C) 2002 Björn Stenberg * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -131,12 +131,12 @@ void* plugin_get_buffer(size_t *buffer_size); #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 128 +#define PLUGIN_API_VERSION 129 /* 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 127 +#define PLUGIN_MIN_API_VERSION 129 /* plugin return codes */ enum plugin_status { @@ -244,6 +244,7 @@ struct plugin_api { int min_shown, int max_shown, unsigned flags); #endif /* HAVE_LCD_BITMAP */ + const char* (*get_codepage_name)(int cp); /* backlight */ /* The backlight_* functions must be present in the API regardless whether @@ -408,13 +409,13 @@ struct plugin_api { long (*default_event_handler)(long event); long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter); struct thread_entry* threads; - struct thread_entry* (*create_thread)(void (*function)(void), void* stack, - size_t stack_size, unsigned flags, - const char *name - IF_PRIO(, int priority) - IF_COP(, unsigned int core)); + unsigned int (*create_thread)(void (*function)(void), void* stack, + size_t stack_size, unsigned flags, + const char *name + IF_PRIO(, int priority) + IF_COP(, unsigned int core)); void (*thread_exit)(void); - void (*thread_wait)(struct thread_entry *thread); + void (*thread_wait)(unsigned int thread_id); #if CONFIG_CODEC == SWCODEC void (*mutex_init)(struct mutex *m); void (*mutex_lock)(struct mutex *m); @@ -456,7 +457,7 @@ struct plugin_api { #if CONFIG_CODEC == SWCODEC void (*queue_enable_queue_send)(struct event_queue *q, struct queue_sender_list *send, - struct thread_entry *owner); + unsigned int thread_id); bool (*queue_empty)(const struct event_queue *q); void (*queue_wait)(struct event_queue *q, struct queue_event *ev); intptr_t (*queue_send)(struct event_queue *q, long id, @@ -616,6 +617,7 @@ struct plugin_api { void (*gui_syncstatusbar_draw)(struct gui_syncstatusbar * bars, bool force_redraw); /* options */ + const struct settings_list* (*get_settings_list)(int*count); const struct settings_list* (*find_setting)(const void* variable, int *id); bool (*option_screen)(const struct settings_list *setting, struct viewport parent[NB_SCREENS], @@ -771,7 +773,7 @@ struct plugin_api { char *buf, int buflen); #endif - void (*thread_thaw)(struct thread_entry *thread); + void (*thread_thaw)(unsigned int thread_id); #ifdef HAVE_SEMAPHORE_OBJECTS void (*semaphore_init)(struct semaphore *s, int max, int start); @@ -782,8 +784,6 @@ struct plugin_api { const char *appsversion; /* new stuff at the end, sort into place next time the API gets incompatible */ - const struct settings_list* (*get_settings_list)(int*count); - const char* (*get_codepage_name)(int cp); }; /* plugin header */ diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c index dfffc3b..d15e26a 100644 --- a/apps/plugins/alpine_cdc.c +++ b/apps/plugins/alpine_cdc.c @@ -206,7 +206,7 @@ struct { bool foreground; /* set as long as we're owning the UI */ bool exiting; /* signal to the thread that we want to exit */ - struct thread_entry *thread; /* worker thread id */ + unsigned int thread; /* worker thread id */ } gTread; static const struct plugin_api* rb; /* here is the global API struct pointer */ diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index b951b01..0c30eba 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -216,7 +216,7 @@ struct batt_info #define BUF_ELEMENTS (sizeof(bat)/sizeof(struct batt_info)) -static struct thread_entry *thread_id; +static unsigned int thread_id; static struct event_queue thread_q; static bool in_usb_mode; static unsigned int buf_idx; @@ -537,7 +537,7 @@ int main(void) if ((thread_id = rb->create_thread(thread, thread_stack, sizeof(thread_stack), 0, "Battery Benchmark" IF_PRIO(, PRIORITY_BACKGROUND) - IF_COP(, CPU))) == NULL) + IF_COP(, CPU))) == 0) { rb->splash(HZ, "Cannot create thread!"); return PLUGIN_ERROR; diff --git a/apps/plugins/mpegplayer/audio_thread.c b/apps/plugins/mpegplayer/audio_thread.c index 4522657..2fb46ef 100644 --- a/apps/plugins/mpegplayer/audio_thread.c +++ b/apps/plugins/mpegplayer/audio_thread.c @@ -732,7 +732,7 @@ bool audio_thread_init(void) rb->queue_enable_queue_send(audio_str.hdr.q, &audio_str_queue_send, audio_str.thread); - if (audio_str.thread == NULL) + if (audio_str.thread == 0) return false; /* Wait for thread to initialize */ @@ -744,11 +744,11 @@ bool audio_thread_init(void) /* Stops the audio thread */ void audio_thread_exit(void) { - if (audio_str.thread != NULL) + if (audio_str.thread != 0) { str_post_msg(&audio_str, STREAM_QUIT, 0); rb->thread_wait(audio_str.thread); - audio_str.thread = NULL; + audio_str.thread = 0; } #ifndef SIMULATOR diff --git a/apps/plugins/mpegplayer/disk_buf.c b/apps/plugins/mpegplayer/disk_buf.c index df5e005..c008139 100644 --- a/apps/plugins/mpegplayer/disk_buf.c +++ b/apps/plugins/mpegplayer/disk_buf.c @@ -835,7 +835,7 @@ void disk_buf_reply_msg(intptr_t retval) bool disk_buf_init(void) { - disk_buf.thread = NULL; + disk_buf.thread = 0; list_initialize(&nf_list); rb->mutex_init(&disk_buf_mtx); @@ -893,7 +893,7 @@ bool disk_buf_init(void) rb->queue_enable_queue_send(disk_buf.q, &disk_buf_queue_send, disk_buf.thread); - if (disk_buf.thread == NULL) + if (disk_buf.thread == 0) return false; /* Wait for thread to initialize */ @@ -904,10 +904,10 @@ bool disk_buf_init(void) void disk_buf_exit(void) { - if (disk_buf.thread != NULL) + if (disk_buf.thread != 0) { rb->queue_post(disk_buf.q, STREAM_QUIT, 0); rb->thread_wait(disk_buf.thread); - disk_buf.thread = NULL; + disk_buf.thread = 0; } } diff --git a/apps/plugins/mpegplayer/disk_buf.h b/apps/plugins/mpegplayer/disk_buf.h index b6399c8..e16939a 100644 --- a/apps/plugins/mpegplayer/disk_buf.h +++ b/apps/plugins/mpegplayer/disk_buf.h @@ -62,7 +62,7 @@ struct dbuf_range * playback events as well as buffering */ struct disk_buf { - struct thread_entry *thread; + unsigned int thread; struct event_queue *q; uint8_t *start; /* Start pointer */ uint8_t *end; /* End of buffer pointer less MPEG_GUARDBUF_SIZE. The diff --git a/apps/plugins/mpegplayer/mpeg_parser.c b/apps/plugins/mpegplayer/mpeg_parser.c index 54a6f23..42c388b 100644 --- a/apps/plugins/mpegplayer/mpeg_parser.c +++ b/apps/plugins/mpegplayer/mpeg_parser.c @@ -1027,7 +1027,7 @@ intptr_t parser_send_video_msg(long id, intptr_t data) { intptr_t retval = 0; - if (video_str.thread != NULL && disk_buf.in_file >= 0) + if (video_str.thread != 0 && disk_buf.in_file >= 0) { /* Hook certain messages since they involve multiple operations * behind the scenes */ diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c index 424d2fe..222ffb7 100644 --- a/apps/plugins/mpegplayer/stream_mgr.c +++ b/apps/plugins/mpegplayer/stream_mgr.c @@ -908,7 +908,7 @@ static void stream_mgr_thread(void) /* Opens a new file */ int stream_open(const char *filename) { - if (stream_mgr.thread != NULL) + if (stream_mgr.thread != 0) return stream_mgr_send_msg(STREAM_OPEN, (intptr_t)filename); return STREAM_ERROR; } @@ -916,7 +916,7 @@ int stream_open(const char *filename) /* Plays the current file starting at time 'start' */ int stream_play(void) { - if (stream_mgr.thread != NULL) + if (stream_mgr.thread != 0) return stream_mgr_send_msg(STREAM_PLAY, 0); return STREAM_ERROR; } @@ -924,7 +924,7 @@ int stream_play(void) /* Pauses playback if playing */ int stream_pause(void) { - if (stream_mgr.thread != NULL) + if (stream_mgr.thread != 0) return stream_mgr_send_msg(STREAM_PAUSE, false); return STREAM_ERROR; } @@ -932,7 +932,7 @@ int stream_pause(void) /* Resumes playback if paused */ int stream_resume(void) { - if (stream_mgr.thread != NULL) + if (stream_mgr.thread != 0) return stream_mgr_send_msg(STREAM_PAUSE, true); return STREAM_ERROR; } @@ -940,7 +940,7 @@ int stream_resume(void) /* Stops playback if not stopped */ int stream_stop(void) { - if (stream_mgr.thread != NULL) + if (stream_mgr.thread != 0) return stream_mgr_send_msg(STREAM_STOP, 0); return STREAM_ERROR; } @@ -950,7 +950,7 @@ int stream_seek(uint32_t time, int whence) { int ret; - if (stream_mgr.thread == NULL) + if (stream_mgr.thread == 0) return STREAM_ERROR; stream_mgr_lock(); @@ -968,7 +968,7 @@ int stream_seek(uint32_t time, int whence) /* Closes the current file */ int stream_close(void) { - if (stream_mgr.thread != NULL) + if (stream_mgr.thread != 0) return stream_mgr_send_msg(STREAM_CLOSE, 0); return STREAM_ERROR; } @@ -1018,7 +1018,7 @@ int stream_init(void) rb->queue_enable_queue_send(stream_mgr.q, &stream_mgr_queue_send, stream_mgr.thread); - if (stream_mgr.thread == NULL) + if (stream_mgr.thread == 0) { rb->splash(HZ, "Could not create stream manager thread!"); return STREAM_ERROR; @@ -1073,11 +1073,11 @@ void stream_exit(void) disk_buf_exit(); pcm_output_exit(); - if (stream_mgr.thread != NULL) + if (stream_mgr.thread != 0) { stream_mgr_post_msg(STREAM_QUIT, 0); rb->thread_wait(stream_mgr.thread); - stream_mgr.thread = NULL; + stream_mgr.thread = 0; } #ifndef HAVE_LCD_COLOR diff --git a/apps/plugins/mpegplayer/stream_mgr.h b/apps/plugins/mpegplayer/stream_mgr.h index e3ea920..a00b39f 100644 --- a/apps/plugins/mpegplayer/stream_mgr.h +++ b/apps/plugins/mpegplayer/stream_mgr.h @@ -27,7 +27,7 @@ * coordination with assistance from the parser */ struct stream_mgr { - struct thread_entry *thread; /* Playback control thread */ + unsigned int thread; /* Playback control thread */ struct event_queue *q; /* event queue for control thread */ const char *filename; /* Current filename */ uint32_t resume_time; /* The stream tick where playback was diff --git a/apps/plugins/mpegplayer/stream_thread.h b/apps/plugins/mpegplayer/stream_thread.h index d6e42d2..30bf46e 100644 --- a/apps/plugins/mpegplayer/stream_thread.h +++ b/apps/plugins/mpegplayer/stream_thread.h @@ -45,7 +45,7 @@ struct stream_hdr struct stream { struct stream_hdr hdr; /* Base stream data */ - struct thread_entry *thread; /* Stream's thread */ + unsigned int thread; /* Stream's thread */ uint8_t* curr_packet; /* Current stream packet beginning */ uint8_t* curr_packet_end; /* Current stream packet end */ struct list_item l; /* List of streams - either reserve pool diff --git a/apps/plugins/mpegplayer/video_thread.c b/apps/plugins/mpegplayer/video_thread.c index 100904b..8b84686 100644 --- a/apps/plugins/mpegplayer/video_thread.c +++ b/apps/plugins/mpegplayer/video_thread.c @@ -1009,7 +1009,7 @@ bool video_thread_init(void) rb->queue_enable_queue_send(video_str.hdr.q, &video_str_queue_send, video_str.thread); - if (video_str.thread == NULL) + if (video_str.thread == 0) return false; /* Wait for thread to initialize */ @@ -1022,11 +1022,11 @@ bool video_thread_init(void) /* Terminates the video thread */ void video_thread_exit(void) { - if (video_str.thread != NULL) + if (video_str.thread != 0) { str_post_msg(&video_str, STREAM_QUIT, 0); rb->thread_wait(video_str.thread); IF_COP(invalidate_icache()); - video_str.thread = NULL; + video_str.thread = 0; } } diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index 29e8a74..232c3f6 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c @@ -218,7 +218,7 @@ struct mutex slide_cache_stack_lock; static int empty_slide_hid; -struct thread_entry *thread_id; +unsigned int thread_id; struct event_queue thread_q; static char tmp_path_name[MAX_PATH]; @@ -831,7 +831,7 @@ bool create_pf_thread(void) IF_PRIO(, PRIORITY_BACKGROUND) IF_COP(, CPU) ) - ) == NULL) { + ) == 0) { return false; } thread_is_running = true; diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index b1f5aff..17effd8 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c @@ -525,7 +525,7 @@ static enum plugin_status test_track(const char* filename) long ticks; unsigned long speed; unsigned long duration; - struct thread_entry* codecthread_id; + unsigned int codecthread_id; const char* ch; /* Display filename (excluding any path)*/ @@ -590,7 +590,7 @@ static enum plugin_status test_track(const char* filename) if ((codecthread_id = rb->create_thread(codec_thread, codec_stack, codec_stack_size, 0, "testcodec" - IF_PRIO(,PRIORITY_PLAYBACK) IF_COP(, CPU))) == NULL) + IF_PRIO(,PRIORITY_PLAYBACK) IF_COP(, CPU))) == 0) { log_text("Cannot create codec thread!",true); goto exit; diff --git a/apps/plugins/test_sampr.c b/apps/plugins/test_sampr.c index 77f9b8a..1131a7a 100644 --- a/apps/plugins/test_sampr.c +++ b/apps/plugins/test_sampr.c @@ -39,7 +39,7 @@ static unsigned long hw_sampr IDATA_ATTR = HW_SAMPR_DEFAULT; static int gen_thread_stack[DEFAULT_STACK_SIZE/sizeof(int)] IBSS_ATTR; static bool gen_quit IBSS_ATTR; -static struct thread_entry *gen_thread_p; +static unsigned int gen_thread_id; #define OUTPUT_CHUNK_COUNT (1 << 1) #define OUTPUT_CHUNK_MASK (OUTPUT_CHUNK_COUNT-1) @@ -233,11 +233,11 @@ static void play_tone(bool volume_set) output_clear(); update_gen_step(); - gen_thread_p = rb->create_thread(gen_thread_func, gen_thread_stack, - sizeof(gen_thread_stack), 0, - "test_sampr generator" - IF_PRIO(, PRIORITY_PLAYBACK) - IF_COP(, CPU)); + gen_thread_id = rb->create_thread(gen_thread_func, gen_thread_stack, + sizeof(gen_thread_stack), 0, + "test_sampr generator" + IF_PRIO(, PRIORITY_PLAYBACK) + IF_COP(, CPU)); rb->pcm_play_data(get_more, NULL, 0); @@ -260,7 +260,7 @@ static void play_tone(bool volume_set) gen_quit = true; - rb->thread_wait(gen_thread_p); + rb->thread_wait(gen_thread_id); rb->pcm_play_stop(); diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c index dbbc690..9ceb68c 100644 --- a/apps/recorder/pcm_record.c +++ b/apps/recorder/pcm_record.c @@ -37,7 +37,7 @@ /***************************************************************************/ -extern struct thread_entry *codec_thread_p; +extern uintptr_t codec_thread_id; /** General recording state **/ static bool is_recording; /* We are recording */ @@ -220,7 +220,7 @@ static struct event_queue pcmrec_queue SHAREDBSS_ATTR; static struct queue_sender_list pcmrec_queue_send SHAREDBSS_ATTR; static long pcmrec_stack[3*DEFAULT_STACK_SIZE/sizeof(long)]; static const char pcmrec_thread_name[] = "pcmrec"; -static struct thread_entry *pcmrec_thread_p; +static unsigned int pcmrec_thread_id = 0; static void pcmrec_thread(void); @@ -365,12 +365,12 @@ unsigned long pcm_rec_sample_rate(void) void pcm_rec_init(void) { queue_init(&pcmrec_queue, true); - pcmrec_thread_p = + pcmrec_thread_id = create_thread(pcmrec_thread, pcmrec_stack, sizeof(pcmrec_stack), 0, pcmrec_thread_name IF_PRIO(, PRIORITY_RECORDING) IF_COP(, CPU)); queue_enable_queue_send(&pcmrec_queue, &pcmrec_queue_send, - pcmrec_thread_p); + pcmrec_thread_id); } /* pcm_rec_init */ /** audio_* group **/ @@ -878,10 +878,10 @@ static void pcmrec_flush(unsigned flush_num) priority until finished */ logf("pcmrec: boost (%s)", num >= flood_watermark ? "num" : "time"); - prio_pcmrec = thread_set_priority(NULL, - thread_get_priority(NULL) - 4); - prio_codec = thread_set_priority(codec_thread_p, - thread_get_priority(codec_thread_p) - 4); + prio_pcmrec = thread_set_priority(THREAD_ID_CURRENT, + thread_get_priority(THREAD_ID_CURRENT) - 4); + prio_codec = thread_set_priority(codec_thread_id, + thread_get_priority(codec_thread_id) - 4); } #endif @@ -931,8 +931,8 @@ static void pcmrec_flush(unsigned flush_num) { /* return to original priorities */ logf("pcmrec: unboost priority"); - thread_set_priority(NULL, prio_pcmrec); - thread_set_priority(codec_thread_p, prio_codec); + thread_set_priority(THREAD_ID_CURRENT, prio_pcmrec); + thread_set_priority(codec_thread_id, prio_codec); } last_flush_tick = current_tick; /* save tick when we left */ diff --git a/apps/voice_thread.c b/apps/voice_thread.c index 084c387..86e80ce 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c @@ -54,7 +54,7 @@ #define VOICE_SAMPLE_DEPTH 16 /* Sample depth in bits */ /* Voice thread variables */ -static struct thread_entry *voice_thread_p = NULL; +static unsigned int voice_thread_id = 0; static long voice_stack[0x7c0/sizeof(long)] IBSS_ATTR_VOICE_STACK; static const char voice_thread_name[] = "voice"; @@ -434,25 +434,25 @@ void voice_thread_init(void) queue_init(&voice_queue, false); mutex_init(&voice_mutex); - voice_thread_p = create_thread(voice_thread, voice_stack, + voice_thread_id = create_thread(voice_thread, voice_stack, sizeof(voice_stack), CREATE_THREAD_FROZEN, voice_thread_name IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU)); queue_enable_queue_send(&voice_queue, &voice_queue_sender_list, - voice_thread_p); + voice_thread_id); } /* voice_thread_init */ /* Unfreeze the voice thread */ void voice_thread_resume(void) { logf("Thawing voice thread"); - thread_thaw(voice_thread_p); + thread_thaw(voice_thread_id); } #ifdef HAVE_PRIORITY_SCHEDULING /* Set the voice thread priority */ void voice_thread_set_priority(int priority) { - thread_set_priority(voice_thread_p, priority); + thread_set_priority(voice_thread_id, priority); } #endif |