summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/mpegplayer.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/mpegplayer.c')
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c35
1 files changed, 17 insertions, 18 deletions
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
189{ 189{
190 struct thread_entry *thread; /* Stream's thread */ 190 struct thread_entry *thread; /* Stream's thread */
191 int status; /* Current stream status */ 191 int status; /* Current stream status */
192 struct event ev; /* Event sent to steam */ 192 struct queue_event ev; /* Event sent to steam */
193 int have_msg; /* 1=event pending */ 193 int have_msg; /* 1=event pending */
194 int replied; /* 1=replied to last event */ 194 int replied; /* 1=replied to last event */
195 int reply; /* reply value */ 195 int reply; /* reply value */
196 struct mutex msg_lock; /* serialization for event senders */ 196 struct spinlock msg_lock; /* serialization for event senders */
197 uint8_t* curr_packet; /* Current stream packet beginning */ 197 uint8_t* curr_packet; /* Current stream packet beginning */
198 uint8_t* curr_packet_end; /* Current stream packet end */ 198 uint8_t* curr_packet_end; /* Current stream packet end */
199 199
@@ -256,7 +256,7 @@ static void str_wait_msg(Stream *str)
256 256
257/* Returns a message waiting or blocks until one is available - removes the 257/* Returns a message waiting or blocks until one is available - removes the
258 event */ 258 event */
259static void str_get_msg(Stream *str, struct event *ev) 259static void str_get_msg(Stream *str, struct queue_event *ev)
260{ 260{
261 str_wait_msg(str); 261 str_wait_msg(str);
262 ev->id = str->ev.id; 262 ev->id = str->ev.id;
@@ -266,7 +266,7 @@ static void str_get_msg(Stream *str, struct event *ev)
266 266
267/* Peeks at the current message without blocking, returns the data but 267/* Peeks at the current message without blocking, returns the data but
268 does not remove the event */ 268 does not remove the event */
269static bool str_look_msg(Stream *str, struct event *ev) 269static bool str_look_msg(Stream *str, struct queue_event *ev)
270{ 270{
271 if (!str_have_msg(str)) 271 if (!str_have_msg(str))
272 return false; 272 return false;
@@ -345,9 +345,9 @@ static size_t file_remaining IBSS_ATTR;
345 345
346#if NUM_CORES > 1 346#if NUM_CORES > 1
347/* Some stream variables are shared between cores */ 347/* Some stream variables are shared between cores */
348struct mutex stream_lock IBSS_ATTR; 348struct spinlock stream_lock IBSS_ATTR;
349static inline void init_stream_lock(void) 349static inline void init_stream_lock(void)
350 { rb->spinlock_init(&stream_lock); } 350 { rb->spinlock_init(&stream_lock, SPINLOCK_TASK_SWITCH); }
351static inline void lock_stream(void) 351static inline void lock_stream(void)
352 { rb->spinlock_lock(&stream_lock); } 352 { rb->spinlock_lock(&stream_lock); }
353static inline void unlock_stream(void) 353static inline void unlock_stream(void)
@@ -1050,7 +1050,7 @@ static int button_loop(void)
1050 1050
1051 if (str_have_msg(&audio_str)) 1051 if (str_have_msg(&audio_str))
1052 { 1052 {
1053 struct event ev; 1053 struct queue_event ev;
1054 str_get_msg(&audio_str, &ev); 1054 str_get_msg(&audio_str, &ev);
1055 1055
1056 if (ev.id == STREAM_QUIT) 1056 if (ev.id == STREAM_QUIT)
@@ -1375,7 +1375,7 @@ static void audio_thread(void)
1375 { 1375 {
1376 if (str_have_msg(&audio_str)) 1376 if (str_have_msg(&audio_str))
1377 { 1377 {
1378 struct event ev; 1378 struct queue_event ev;
1379 str_look_msg(&audio_str, &ev); 1379 str_look_msg(&audio_str, &ev);
1380 1380
1381 if (ev.id == STREAM_QUIT) 1381 if (ev.id == STREAM_QUIT)
@@ -1498,7 +1498,7 @@ static uint32_t video_stack[VIDEO_STACKSIZE / sizeof(uint32_t)] IBSS_ATTR;
1498 1498
1499static void video_thread(void) 1499static void video_thread(void)
1500{ 1500{
1501 struct event ev; 1501 struct queue_event ev;
1502 const mpeg2_info_t * info; 1502 const mpeg2_info_t * info;
1503 mpeg2_state_t state; 1503 mpeg2_state_t state;
1504 char str[80]; 1504 char str[80];
@@ -1929,9 +1929,8 @@ void display_thumb(int in_file)
1929 video_str.status = STREAM_PLAYING; 1929 video_str.status = STREAM_PLAYING;
1930 1930
1931 if ((video_str.thread = rb->create_thread(video_thread, 1931 if ((video_str.thread = rb->create_thread(video_thread,
1932 (uint8_t*)video_stack,VIDEO_STACKSIZE,"mpgvideo" 1932 (uint8_t*)video_stack,VIDEO_STACKSIZE, 0,"mpgvideo"
1933 IF_PRIO(,PRIORITY_PLAYBACK) 1933 IF_PRIO(,PRIORITY_PLAYBACK) IF_COP(, COP))) == NULL)
1934 IF_COP(, COP, true))) == NULL)
1935 { 1934 {
1936 rb->splash(HZ, "Cannot create video thread!"); 1935 rb->splash(HZ, "Cannot create video thread!");
1937 } 1936 }
@@ -2354,8 +2353,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2354 initialize_stream( &video_str, disk_buf_start, disk_buf_len, 0xe0 ); 2353 initialize_stream( &video_str, disk_buf_start, disk_buf_len, 0xe0 );
2355 initialize_stream( &audio_str, disk_buf_start, disk_buf_len, 0xc0 ); 2354 initialize_stream( &audio_str, disk_buf_start, disk_buf_len, 0xc0 );
2356 2355
2357 rb->spinlock_init(&audio_str.msg_lock); 2356 rb->spinlock_init(&audio_str.msg_lock IF_COP(, SPINLOCK_TASK_SWITCH));
2358 rb->spinlock_init(&video_str.msg_lock); 2357 rb->spinlock_init(&video_str.msg_lock IF_COP(, SPINLOCK_TASK_SWITCH));
2359 2358
2360 audio_str.status = STREAM_BUFFERING; 2359 audio_str.status = STREAM_BUFFERING;
2361 video_str.status = STREAM_PLAYING; 2360 video_str.status = STREAM_PLAYING;
@@ -2372,14 +2371,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2372 2371
2373 /* We put the video thread on the second processor for multi-core targets. */ 2372 /* We put the video thread on the second processor for multi-core targets. */
2374 if ((video_str.thread = rb->create_thread(video_thread, 2373 if ((video_str.thread = rb->create_thread(video_thread,
2375 (uint8_t*)video_stack,VIDEO_STACKSIZE,"mpgvideo" IF_PRIO(,PRIORITY_PLAYBACK) 2374 (uint8_t*)video_stack, VIDEO_STACKSIZE, 0,
2376 IF_COP(, COP, true))) == NULL) 2375 "mpgvideo" IF_PRIO(,PRIORITY_PLAYBACK) IF_COP(, COP))) == NULL)
2377 { 2376 {
2378 rb->splash(HZ, "Cannot create video thread!"); 2377 rb->splash(HZ, "Cannot create video thread!");
2379 } 2378 }
2380 else if ((audio_str.thread = rb->create_thread(audio_thread, 2379 else if ((audio_str.thread = rb->create_thread(audio_thread,
2381 (uint8_t*)audio_stack,AUDIO_STACKSIZE,"mpgaudio" IF_PRIO(,PRIORITY_PLAYBACK) 2380 (uint8_t*)audio_stack,AUDIO_STACKSIZE, 0,"mpgaudio"
2382 IF_COP(, CPU, false))) == NULL) 2381 IF_PRIO(,PRIORITY_PLAYBACK) IF_COP(, CPU))) == NULL)
2383 { 2382 {
2384 rb->splash(HZ, "Cannot create audio thread!"); 2383 rb->splash(HZ, "Cannot create audio thread!");
2385 } 2384 }