From a9b2fb5ee3114fe835f6515b6aeae7454f66d821 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Tue, 16 Oct 2007 01:25:17 +0000 Subject: Finally full multicore support for PortalPlayer 502x targets with an eye towards the possibility of other types. All SVN targets the low-lag code to speed up blocking operations. Most files are modified here simple due to a name change to actually support a real event object and a param change to create_thread. Add some use of new features but just sit on things for a bit and leave full integration for later. Work will continue on to address size on sensitive targets and simplify things if possible. Any PP target having problems with SWP can easily be changed to sw corelocks with one #define change in config.h though only PP5020 has shown an issue and seems to work without any difficulties. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15134 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/mpegplayer/mpegplayer.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'apps/plugins/mpegplayer/mpegplayer.c') diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index ea10411f3f..12282a3322 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -189,11 +189,11 @@ typedef struct { struct thread_entry *thread; /* Stream's thread */ int status; /* Current stream status */ - struct event ev; /* Event sent to steam */ + struct queue_event ev; /* Event sent to steam */ int have_msg; /* 1=event pending */ int replied; /* 1=replied to last event */ int reply; /* reply value */ - struct mutex msg_lock; /* serialization for event senders */ + struct spinlock msg_lock; /* serialization for event senders */ uint8_t* curr_packet; /* Current stream packet beginning */ uint8_t* curr_packet_end; /* Current stream packet end */ @@ -256,7 +256,7 @@ static void str_wait_msg(Stream *str) /* Returns a message waiting or blocks until one is available - removes the event */ -static void str_get_msg(Stream *str, struct event *ev) +static void str_get_msg(Stream *str, struct queue_event *ev) { str_wait_msg(str); ev->id = str->ev.id; @@ -266,7 +266,7 @@ static void str_get_msg(Stream *str, struct event *ev) /* Peeks at the current message without blocking, returns the data but does not remove the event */ -static bool str_look_msg(Stream *str, struct event *ev) +static bool str_look_msg(Stream *str, struct queue_event *ev) { if (!str_have_msg(str)) return false; @@ -345,9 +345,9 @@ static size_t file_remaining IBSS_ATTR; #if NUM_CORES > 1 /* Some stream variables are shared between cores */ -struct mutex stream_lock IBSS_ATTR; +struct spinlock stream_lock IBSS_ATTR; static inline void init_stream_lock(void) - { rb->spinlock_init(&stream_lock); } + { rb->spinlock_init(&stream_lock, SPINLOCK_TASK_SWITCH); } static inline void lock_stream(void) { rb->spinlock_lock(&stream_lock); } static inline void unlock_stream(void) @@ -1050,7 +1050,7 @@ static int button_loop(void) if (str_have_msg(&audio_str)) { - struct event ev; + struct queue_event ev; str_get_msg(&audio_str, &ev); if (ev.id == STREAM_QUIT) @@ -1375,7 +1375,7 @@ static void audio_thread(void) { if (str_have_msg(&audio_str)) { - struct event ev; + struct queue_event ev; str_look_msg(&audio_str, &ev); if (ev.id == STREAM_QUIT) @@ -1498,7 +1498,7 @@ static uint32_t video_stack[VIDEO_STACKSIZE / sizeof(uint32_t)] IBSS_ATTR; static void video_thread(void) { - struct event ev; + struct queue_event ev; const mpeg2_info_t * info; mpeg2_state_t state; char str[80]; @@ -1929,9 +1929,8 @@ void display_thumb(int in_file) video_str.status = STREAM_PLAYING; if ((video_str.thread = rb->create_thread(video_thread, - (uint8_t*)video_stack,VIDEO_STACKSIZE,"mpgvideo" - IF_PRIO(,PRIORITY_PLAYBACK) - IF_COP(, COP, true))) == NULL) + (uint8_t*)video_stack,VIDEO_STACKSIZE, 0,"mpgvideo" + IF_PRIO(,PRIORITY_PLAYBACK) IF_COP(, COP))) == NULL) { rb->splash(HZ, "Cannot create video thread!"); } @@ -2354,8 +2353,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); - rb->spinlock_init(&video_str.msg_lock); + rb->spinlock_init(&audio_str.msg_lock IF_COP(, SPINLOCK_TASK_SWITCH)); + rb->spinlock_init(&video_str.msg_lock IF_COP(, SPINLOCK_TASK_SWITCH)); audio_str.status = STREAM_BUFFERING; video_str.status = STREAM_PLAYING; @@ -2372,14 +2371,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) /* We put the video thread on the second processor for multi-core targets. */ if ((video_str.thread = rb->create_thread(video_thread, - (uint8_t*)video_stack,VIDEO_STACKSIZE,"mpgvideo" IF_PRIO(,PRIORITY_PLAYBACK) - IF_COP(, COP, true))) == NULL) + (uint8_t*)video_stack, VIDEO_STACKSIZE, 0, + "mpgvideo" IF_PRIO(,PRIORITY_PLAYBACK) IF_COP(, COP))) == NULL) { rb->splash(HZ, "Cannot create video thread!"); } else if ((audio_str.thread = rb->create_thread(audio_thread, - (uint8_t*)audio_stack,AUDIO_STACKSIZE,"mpgaudio" IF_PRIO(,PRIORITY_PLAYBACK) - IF_COP(, CPU, false))) == NULL) + (uint8_t*)audio_stack,AUDIO_STACKSIZE, 0,"mpgaudio" + IF_PRIO(,PRIORITY_PLAYBACK) IF_COP(, CPU))) == NULL) { rb->splash(HZ, "Cannot create audio thread!"); } -- cgit v1.2.3