diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2007-10-22 05:57:38 +0000 |
|---|---|---|
| committer | Michael Sevakis <jethead71@rockbox.org> | 2007-10-22 05:57:38 +0000 |
| commit | 7e12bba0d26a609ce16e981f0ebd4b8e73f59a8e (patch) | |
| tree | 71673763db2a63da47e34f62e7513b2c8e987c87 /apps/plugins/mpegplayer | |
| parent | 344c41f644e9b95da55a66ea47d7b4afc6102e47 (diff) | |
| download | rockbox-7e12bba0d26a609ce16e981f0ebd4b8e73f59a8e.zip rockbox-7e12bba0d26a609ce16e981f0ebd4b8e73f59a8e.tar.gz rockbox-7e12bba0d26a609ce16e981f0ebd4b8e73f59a8e.tar.bz2 rockbox-7e12bba0d26a609ce16e981f0ebd4b8e73f59a8e.tar.xz | |
Phase in thread_wait when waiting for a thread to exit. Begin phasing out the spinlock object for general use; it will become a multicore-only object for core locking. Take care of plugins first.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15260 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mpegplayer')
| -rw-r--r-- | apps/plugins/mpegplayer/mpegplayer.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index e77031b..770abf9 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -188,7 +188,7 @@ typedef struct int have_msg; /* 1=event pending */ int replied; /* 1=replied to last event */ int reply; /* reply value */ - struct spinlock msg_lock; /* serialization for event senders */ + struct mutex msg_lock; /* serialization for event senders */ uint8_t* curr_packet; /* Current stream packet beginning */ uint8_t* curr_packet_end; /* Current stream packet end */ @@ -294,7 +294,7 @@ static intptr_t str_send_msg(Stream *str, int id, intptr_t data) #endif /* Only one thread at a time, please */ - rb->spinlock_lock(&str->msg_lock); + rb->mutex_lock(&str->msg_lock); str->ev.id = id; str->ev.data = data; @@ -316,7 +316,7 @@ static intptr_t str_send_msg(Stream *str, int id, intptr_t data) reply = str->reply; - rb->spinlock_unlock(&str->msg_lock); + rb->mutex_unlock(&str->msg_lock); return reply; } @@ -340,13 +340,13 @@ static size_t file_remaining IBSS_ATTR; #if NUM_CORES > 1 /* Some stream variables are shared between cores */ -struct spinlock stream_lock IBSS_ATTR; +struct mutex stream_lock IBSS_ATTR; static inline void init_stream_lock(void) - { rb->spinlock_init(&stream_lock, SPINLOCK_TASK_SWITCH); } + { rb->mutex_init(&stream_lock); } static inline void lock_stream(void) - { rb->spinlock_lock(&stream_lock); } + { rb->mutex_lock(&stream_lock); } static inline void unlock_stream(void) - { rb->spinlock_unlock(&stream_lock); } + { rb->mutex_unlock(&stream_lock); } #else /* No RMW issue here */ static inline void init_stream_lock(void) @@ -1937,8 +1937,7 @@ void display_thumb(int in_file) } else { - while (video_str.status != STREAM_TERMINATED) - rb->yield(); + rb->thread_wait(video_str.thread); } if ( video_str.curr_packet_end == video_str.curr_packet) @@ -2417,8 +2416,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) initialize_stream( &video_str, disk_buf_start, disk_buf_len, 0xe0 ); initialize_stream( &audio_str, disk_buf_start, disk_buf_len, 0xc0 ); - rb->spinlock_init(&audio_str.msg_lock IF_COP(, SPINLOCK_TASK_SWITCH)); - rb->spinlock_init(&video_str.msg_lock IF_COP(, SPINLOCK_TASK_SWITCH)); + rb->mutex_init(&audio_str.msg_lock); + rb->mutex_init(&video_str.msg_lock); audio_str.status = STREAM_BUFFERING; video_str.status = STREAM_PLAYING; @@ -2504,12 +2503,16 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) /* Stop the threads and wait for them to terminate */ if (video_str.thread != NULL) + { str_send_msg(&video_str, STREAM_QUIT, 0); + rb->thread_wait(video_str.thread); + } if (audio_str.thread != NULL) + { str_send_msg(&audio_str, STREAM_QUIT, 0); - - rb->sleep(HZ/10); + rb->thread_wait(audio_str.thread); + } #if NUM_CORES > 1 invalidate_icache(); |