summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-06-26 21:27:17 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-06-26 21:27:17 +0000
commita61617f2b278fe3e0ea14b26980f2a98950fcdc3 (patch)
tree68e6e8c80c3c767e2932661b22dd7bf4531bb7d4 /firmware/mpeg.c
parent928e334831f87dfe3b35b50e119b0ade9980b944 (diff)
downloadrockbox-a61617f2b278fe3e0ea14b26980f2a98950fcdc3.tar.gz
rockbox-a61617f2b278fe3e0ea14b26980f2a98950fcdc3.zip
Added mpeg_next() and mpeg_prev() (Yusef Napora)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1205 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r--firmware/mpeg.c74
1 files changed, 71 insertions, 3 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 5f717d60f0..2cc5e2feb8 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -38,9 +38,12 @@
38#define MPEG_STOP 2 38#define MPEG_STOP 2
39#define MPEG_PAUSE 3 39#define MPEG_PAUSE 3
40#define MPEG_RESUME 4 40#define MPEG_RESUME 4
41#define MPEG_NEXT 5
42#define MPEG_PREV 6
41#define MPEG_NEED_DATA 100 43#define MPEG_NEED_DATA 100
42 44
43extern char* peek_next_track(int type); 45extern char* peek_next_track(int type);
46extern char* peek_prev_track(int type);
44 47
45#ifndef ARCHOS_RECORDER 48#ifndef ARCHOS_RECORDER
46static unsigned int bass_table[] = 49static unsigned int bass_table[] =
@@ -311,11 +314,16 @@ void IMIA1(void)
311 TSR1 &= ~0x01; 314 TSR1 &= ~0x01;
312} 315}
313 316
314static int new_file(void) 317/* If next_track is true, opens the next track, if false, opens prev track */
318static int new_file(bool next_track)
315{ 319{
316 char *trackname; 320 char *trackname;
317 321
318 trackname = peek_next_track(0); 322 if (next_track)
323 trackname = peek_next_track(0);
324 else
325 trackname = peek_prev_track(0);
326
319 if ( !trackname ) 327 if ( !trackname )
320 return -1; 328 return -1;
321 329
@@ -419,6 +427,56 @@ static void mpeg_thread(void)
419 start_dma(); 427 start_dma();
420 break; 428 break;
421 429
430 case MPEG_NEXT:
431 DEBUGF("MPEG_NEXT\n");
432 /* stop the current stream */
433 play_pending = false;
434 playing = false;
435 stop_dma();
436
437 reset_mp3_buffer();
438 /* Open the next file */
439 if (mpeg_file >= 0)
440 close(mpeg_file);
441 if (new_file(true) < 0) {
442 DEBUGF("Finished Playing!\n");
443 filling = false;
444 } else {
445 /* Make it read more data */
446 filling = true;
447 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
448
449 /* Tell the file loading code that we want to start playing
450 as soon as we have some data */
451 play_pending = true;
452 }
453 break;
454
455 case MPEG_PREV:
456 DEBUGF("MPEG_PREV\n");
457 /* stop the current stream */
458 play_pending = false;
459 playing = false;
460 stop_dma();
461
462 reset_mp3_buffer();
463 /* Open the next file */
464 if (mpeg_file >= 0)
465 close(mpeg_file);
466 if (new_file(false) < 0) {
467 DEBUGF("Finished Playing!\n");
468 filling = false;
469 } else {
470 /* Make it read more data */
471 filling = true;
472 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
473
474 /* Tell the file loading code that we want to start playing
475 as soon as we have some data */
476 play_pending = true;
477 }
478 break;
479
422 case MPEG_NEED_DATA: 480 case MPEG_NEED_DATA:
423 free_space_left = mp3buf_read - mp3buf_write; 481 free_space_left = mp3buf_read - mp3buf_write;
424 482
@@ -486,7 +544,7 @@ static void mpeg_thread(void)
486 boundary */ 544 boundary */
487 mp3buf_write = (mp3buf_write + 1) & 0xfffffffe; 545 mp3buf_write = (mp3buf_write + 1) & 0xfffffffe;
488 546
489 if(new_file() < 0) 547 if(new_file(1) < 0)
490 { 548 {
491 /* No more data to play */ 549 /* No more data to play */
492 DEBUGF("Finished playing\n"); 550 DEBUGF("Finished playing\n");
@@ -569,6 +627,16 @@ void mpeg_resume(void)
569 queue_post(&mpeg_queue, MPEG_RESUME, NULL); 627 queue_post(&mpeg_queue, MPEG_RESUME, NULL);
570} 628}
571 629
630void mpeg_next(void)
631{
632 queue_post(&mpeg_queue, MPEG_NEXT, NULL);
633}
634
635void mpeg_prev(void)
636{
637 queue_post(&mpeg_queue, MPEG_PREV, NULL);
638}
639
572void mpeg_volume(int percent) 640void mpeg_volume(int percent)
573{ 641{
574 int volume; 642 int volume;