summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-12-10 08:57:10 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-12-10 08:57:10 +0000
commit8cfbd3604fac14f629244e521ad24ffa9938c790 (patch)
tree16dc096519b8b537bb7d4b73e0c97f5f33ee752b /apps/plugins
parent40ff47c7eea41ac893d7af5c5b97ace52a5ffade (diff)
downloadrockbox-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/plugins')
-rw-r--r--apps/plugins/alpine_cdc.c2
-rw-r--r--apps/plugins/battery_bench.c4
-rw-r--r--apps/plugins/mpegplayer/audio_thread.c6
-rw-r--r--apps/plugins/mpegplayer/disk_buf.c8
-rw-r--r--apps/plugins/mpegplayer/disk_buf.h2
-rw-r--r--apps/plugins/mpegplayer/mpeg_parser.c2
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.c20
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.h2
-rw-r--r--apps/plugins/mpegplayer/stream_thread.h2
-rw-r--r--apps/plugins/mpegplayer/video_thread.c6
-rw-r--r--apps/plugins/pictureflow.c4
-rw-r--r--apps/plugins/test_codec.c4
-rw-r--r--apps/plugins/test_sampr.c14
13 files changed, 38 insertions, 38 deletions
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();