forked from len0rd/rockbox
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
This commit is contained in:
parent
40ff47c7ee
commit
8cfbd3604f
32 changed files with 329 additions and 234 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue