summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-01-05 22:46:54 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-01-05 22:46:54 +0000
commit881b53ff3fab24d17e79fbbf8174446919d17217 (patch)
tree33df8be524dea125f2b0b4dd2bf62ec65c637d54 /firmware/mpeg.c
parentf993365447d8dc5bb28c76a003cecd045c3abaf7 (diff)
downloadrockbox-881b53ff3fab24d17e79fbbf8174446919d17217.tar.gz
rockbox-881b53ff3fab24d17e79fbbf8174446919d17217.zip
fixes the red builds, I hope
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4193 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r--firmware/mpeg.c102
1 files changed, 53 insertions, 49 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 1dd489a290..51d5496279 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -38,7 +38,7 @@
38#include "usb.h" 38#include "usb.h"
39#include "file.h" 39#include "file.h"
40#include "hwcompat.h" 40#include "hwcompat.h"
41#endif 41#endif /* #ifndef SIMULATOR */
42 42
43extern void bitswap(unsigned char *data, int length); 43extern void bitswap(unsigned char *data, int length);
44 44
@@ -48,13 +48,13 @@ static void start_prerecording(void);
48static void start_recording(void); 48static void start_recording(void);
49static void stop_recording(void); 49static void stop_recording(void);
50static int get_unsaved_space(void); 50static int get_unsaved_space(void);
51#endif 51#endif /* #ifdef HAVE_MAS3587F */
52 52
53#ifndef SIMULATOR 53#ifndef SIMULATOR
54static int get_unplayed_space(void); 54static int get_unplayed_space(void);
55static int get_playable_space(void); 55static int get_playable_space(void);
56static int get_unswapped_space(void); 56static int get_unswapped_space(void);
57#endif 57#endif /* #ifndef SIMULATOR */
58 58
59#define MPEG_PLAY 1 59#define MPEG_PLAY 1
60#define MPEG_STOP 2 60#define MPEG_STOP 2
@@ -79,7 +79,7 @@ static enum
79 MPEG_DECODER, 79 MPEG_DECODER,
80 MPEG_ENCODER 80 MPEG_ENCODER
81} mpeg_mode; 81} mpeg_mode;
82#endif 82#endif /* #ifdef HAVE_MAS3587F */
83 83
84extern char* playlist_peek(int steps); 84extern char* playlist_peek(int steps);
85extern bool playlist_check(int steps); 85extern bool playlist_check(int steps);
@@ -113,7 +113,7 @@ static int num_tracks_in_memory(void)
113{ 113{
114 return (tag_write_idx - tag_read_idx) & MAX_ID3_TAGS_MASK; 114 return (tag_write_idx - tag_read_idx) & MAX_ID3_TAGS_MASK;
115} 115}
116#endif 116#endif /* #ifndef SIMULATOR */
117 117
118#ifndef SIMULATOR 118#ifndef SIMULATOR
119static void debug_tags(void) 119static void debug_tags(void)
@@ -130,7 +130,7 @@ static void debug_tags(void)
130 } 130 }
131 DEBUGF("read: %d, write :%d\n", tag_read_idx, tag_write_idx); 131 DEBUGF("read: %d, write :%d\n", tag_read_idx, tag_write_idx);
132 DEBUGF("num_tracks_in_memory: %d\n", num_tracks_in_memory()); 132 DEBUGF("num_tracks_in_memory: %d\n", num_tracks_in_memory());
133#endif 133#endif /* #ifdef DEBUG_TAGS */
134} 134}
135 135
136static bool append_tag(struct id3tag *tag) 136static bool append_tag(struct id3tag *tag)
@@ -192,7 +192,7 @@ static void remove_all_tags(void)
192 192
193 debug_tags(); 193 debug_tags();
194} 194}
195#endif 195#endif /* #ifndef SIMULATOR */
196 196
197static void set_elapsed(struct mp3entry* id3) 197static void set_elapsed(struct mp3entry* id3)
198{ 198{
@@ -303,7 +303,7 @@ static int prerecord_index; /* Current index in the prerecord buffer */
303static int prerecording_max_seconds; /* Max number of seconds to store */ 303static int prerecording_max_seconds; /* Max number of seconds to store */
304static int prerecord_count; /* Number of seconds in the prerecord buffer */ 304static int prerecord_count; /* Number of seconds in the prerecord buffer */
305static int prerecord_timeout; /* The tick count of the next prerecord data store */ 305static int prerecord_timeout; /* The tick count of the next prerecord data store */
306#endif 306#endif /* #ifdef HAVE_MAS3587F */
307 307
308static int mpeg_file; 308static int mpeg_file;
309 309
@@ -311,7 +311,7 @@ static int mpeg_file;
311#ifdef HAVE_MAS3587F 311#ifdef HAVE_MAS3587F
312static bool init_recording_done; 312static bool init_recording_done;
313static bool init_playback_done; 313static bool init_playback_done;
314#endif 314#endif /* #ifdef HAVE_MAS3587F */
315static bool mpeg_stop_done; 315static bool mpeg_stop_done;
316 316
317static void recalculate_watermark(int bitrate) 317static void recalculate_watermark(int bitrate)
@@ -396,7 +396,7 @@ static void postpone_dma_tick(void)
396 396
397 TSTR |= 0x02; /* Start timer 1 */ 397 TSTR |= 0x02; /* Start timer 1 */
398} 398}
399#endif 399#endif /* #ifndef HAVE_MAS3507D */
400 400
401#ifdef DEBUG 401#ifdef DEBUG
402static void dbg_timer_start(void) 402static void dbg_timer_start(void)
@@ -417,7 +417,7 @@ static int dbg_cnt2us(unsigned int cnt)
417{ 417{
418 return (cnt * 10000) / (FREQ/800); 418 return (cnt * 10000) / (FREQ/800);
419} 419}
420#endif 420#endif /* #ifdef DEBUG */
421 421
422static int get_unplayed_space(void) 422static int get_unplayed_space(void)
423{ 423{
@@ -472,13 +472,13 @@ static int get_unsaved_space(void)
472 space += mp3buflen; 472 space += mp3buflen;
473 return space; 473 return space;
474} 474}
475#endif 475#endif /* #ifdef HAVE_MAS3587F */
476 476
477#ifdef HAVE_MAS3587F 477#ifdef HAVE_MAS3587F
478#ifdef DEBUG 478#ifdef DEBUG
479static long timing_info_index = 0; 479static long timing_info_index = 0;
480static long timing_info[1024]; 480static long timing_info[1024];
481#endif 481#endif /* #ifdef DEBUG */
482static bool inverted_pr; 482static bool inverted_pr;
483static unsigned long num_rec_bytes; 483static unsigned long num_rec_bytes;
484static unsigned long num_recorded_frames; 484static unsigned long num_recorded_frames;
@@ -530,7 +530,7 @@ static void dma_tick(void)
530#ifdef HAVE_MAS3587F 530#ifdef HAVE_MAS3587F
531 if(mpeg_mode == MPEG_DECODER) 531 if(mpeg_mode == MPEG_DECODER)
532 { 532 {
533#endif 533#endif /* #ifdef HAVE_MAS3587F */
534 if(playing && !paused) 534 if(playing && !paused)
535 { 535 {
536 /* Start DMA if it is disabled and the DEMAND pin is high */ 536 /* Start DMA if it is disabled and the DEMAND pin is high */
@@ -553,7 +553,7 @@ static void dma_tick(void)
553#ifdef DEBUG 553#ifdef DEBUG
554 timing_info[timing_info_index++] = current_tick; 554 timing_info[timing_info_index++] = current_tick;
555 TCNT2 = 0; 555 TCNT2 = 0;
556#endif 556#endif /* #ifdef DEBUG */
557 /* We read as long as EOD is high, but max 30 bytes. 557 /* We read as long as EOD is high, but max 30 bytes.
558 This code is optimized, and should probably be 558 This code is optimized, and should probably be
559 written in assembler instead. */ 559 written in assembler instead. */
@@ -610,7 +610,7 @@ static void dma_tick(void)
610#ifdef DEBUG 610#ifdef DEBUG
611 timing_info[timing_info_index++] = TCNT2 + (i << 16); 611 timing_info[timing_info_index++] = TCNT2 + (i << 16);
612 timing_info_index &= 0x3ff; 612 timing_info_index &= 0x3ff;
613#endif 613#endif /* #ifdef DEBUG */
614 614
615 num_rec_bytes += i; 615 num_rec_bytes += i;
616 616
@@ -649,7 +649,7 @@ static void dma_tick(void)
649 } 649 }
650 } 650 }
651 } 651 }
652#endif 652#endif /* #ifdef HAVE_MAS3587F */
653} 653}
654 654
655static void reset_mp3_buffer(void) 655static void reset_mp3_buffer(void)
@@ -766,7 +766,7 @@ static void demand_irq_enable(bool on)
766 766
767 set_irq_level(oldlevel); 767 set_irq_level(oldlevel);
768} 768}
769#endif 769#endif /* #ifdef HAVE_MAS3587F */
770 770
771#pragma interrupt 771#pragma interrupt
772void IMIA1(void) /* Timer 1 interrupt */ 772void IMIA1(void) /* Timer 1 interrupt */
@@ -776,7 +776,7 @@ void IMIA1(void) /* Timer 1 interrupt */
776#ifdef HAVE_MAS3587F 776#ifdef HAVE_MAS3587F
777 /* Disable interrupt */ 777 /* Disable interrupt */
778 IPRC &= ~0x000f; 778 IPRC &= ~0x000f;
779#endif 779#endif /* #ifdef HAVE_MAS3587F */
780} 780}
781 781
782#ifdef HAVE_MAS3587F 782#ifdef HAVE_MAS3587F
@@ -791,7 +791,7 @@ void IRQ3(void) /* PA15: MAS demand IRQ */
791 else 791 else
792 postpone_dma_tick(); 792 postpone_dma_tick();
793} 793}
794#endif 794#endif /* #ifdef HAVE_MAS3587F */
795 795
796static int add_track_to_tag_list(char *filename) 796static int add_track_to_tag_list(char *filename)
797{ 797{
@@ -894,7 +894,7 @@ static void stop_playing(void)
894 /* Stop the current stream */ 894 /* Stop the current stream */
895#ifdef HAVE_MAS3587F 895#ifdef HAVE_MAS3587F
896 demand_irq_enable(false); 896 demand_irq_enable(false);
897#endif 897#endif /* #ifdef HAVE_MAS3587F */
898 playing = false; 898 playing = false;
899 filling = false; 899 filling = false;
900 if(mpeg_file >= 0) 900 if(mpeg_file >= 0)
@@ -922,7 +922,7 @@ static void track_change(void)
922#ifdef HAVE_MAS3587F 922#ifdef HAVE_MAS3587F
923 /* Reset the AVC */ 923 /* Reset the AVC */
924 mpeg_sound_set(SOUND_AVC, -1); 924 mpeg_sound_set(SOUND_AVC, -1);
925#endif 925#endif /* #ifdef HAVE_MAS3587F */
926 remove_current_tag(); 926 remove_current_tag();
927 927
928 update_playlist(); 928 update_playlist();
@@ -944,7 +944,7 @@ void hexdump(unsigned char *buf, int len)
944 } 944 }
945 DEBUGF("\n"); 945 DEBUGF("\n");
946} 946}
947#endif 947#endif /* #ifdef DEBUG */
948 948
949static void start_playback_if_ready(void) 949static void start_playback_if_ready(void)
950{ 950{
@@ -977,7 +977,7 @@ static void start_playback_if_ready(void)
977 mp3_play_pause(true); 977 mp3_play_pause(true);
978#ifdef HAVE_MAS3587F 978#ifdef HAVE_MAS3587F
979 demand_irq_enable(true); 979 demand_irq_enable(true);
980#endif 980#endif /* #ifdef HAVE_MAS3587F */
981 } 981 }
982 982
983 /* Tell ourselves that we need more data */ 983 /* Tell ourselves that we need more data */
@@ -1043,7 +1043,7 @@ static unsigned long get_last_recorded_header(void)
1043 mas_readmem(MAS_BANK_D0, 0xfd1, tmp, 2); 1043 mas_readmem(MAS_BANK_D0, 0xfd1, tmp, 2);
1044 return 0xffe00000 | ((tmp[0] & 0x7c00) << 6) | (tmp[1] & 0xffff); 1044 return 0xffe00000 | ((tmp[0] & 0x7c00) << 6) | (tmp[1] & 0xffff);
1045} 1045}
1046#endif 1046#endif /* #ifdef HAVE_MAS3587F */
1047 1047
1048static void mpeg_thread(void) 1048static void mpeg_thread(void)
1049{ 1049{
@@ -1065,7 +1065,7 @@ static void mpeg_thread(void)
1065 int rc; 1065 int rc;
1066 int offset; 1066 int offset;
1067 int countdown; 1067 int countdown;
1068#endif 1068#endif /* #ifdef HAVE_MAS3587F */
1069 1069
1070 is_playing = false; 1070 is_playing = false;
1071 play_pending = false; 1071 play_pending = false;
@@ -1077,7 +1077,7 @@ static void mpeg_thread(void)
1077#ifdef HAVE_MAS3587F 1077#ifdef HAVE_MAS3587F
1078 if(mpeg_mode == MPEG_DECODER) 1078 if(mpeg_mode == MPEG_DECODER)
1079 { 1079 {
1080#endif 1080#endif /* #ifdef HAVE_MAS3587F */
1081 yield(); 1081 yield();
1082 1082
1083 /* Swap if necessary, and don't block on the queue_wait() */ 1083 /* Swap if necessary, and don't block on the queue_wait() */
@@ -1103,7 +1103,7 @@ static void mpeg_thread(void)
1103 /* Silence the A/D input, it may be on because the radio 1103 /* Silence the A/D input, it may be on because the radio
1104 may be playing */ 1104 may be playing */
1105 mas_codec_writereg(6, 0x0000); 1105 mas_codec_writereg(6, 0x0000);
1106#endif 1106#endif /* #ifdef HAVE_FMRADIO */
1107 1107
1108 /* Stop the current stream */ 1108 /* Stop the current stream */
1109 play_pending = false; 1109 play_pending = false;
@@ -1539,7 +1539,7 @@ static void mpeg_thread(void)
1539 amount_to_read = MIN(mp3buflen - mp3buf_write, amount_to_read); 1539 amount_to_read = MIN(mp3buflen - mp3buf_write, amount_to_read);
1540#if MEM == 8 1540#if MEM == 8
1541 amount_to_read = MIN(0x100000, amount_to_read); 1541 amount_to_read = MIN(0x100000, amount_to_read);
1542#endif 1542#endif /* #if MEM == 8 */
1543 1543
1544 /* Read as much mpeg data as we can fit in the buffer */ 1544 /* Read as much mpeg data as we can fit in the buffer */
1545 if(mpeg_file >= 0) 1545 if(mpeg_file >= 0)
@@ -1640,16 +1640,16 @@ static void mpeg_thread(void)
1640 1640
1641 /* Wait until the USB cable is extracted again */ 1641 /* Wait until the USB cable is extracted again */
1642 usb_wait_for_disconnect(&mpeg_queue); 1642 usb_wait_for_disconnect(&mpeg_queue);
1643#endif 1643#endif /* #ifndef SIMULATOR */
1644 break; 1644 break;
1645#endif /* USB_NONE */ 1645#endif /* #ifndef USB_NONE */
1646 1646
1647#ifdef HAVE_MAS3587F 1647#ifdef HAVE_MAS3587F
1648 case MPEG_INIT_RECORDING: 1648 case MPEG_INIT_RECORDING:
1649 init_recording(); 1649 init_recording();
1650 init_recording_done = true; 1650 init_recording_done = true;
1651 break; 1651 break;
1652#endif 1652#endif /* #ifdef HAVE_MAS3587F */
1653 } 1653 }
1654#ifdef HAVE_MAS3587F 1654#ifdef HAVE_MAS3587F
1655 } 1655 }
@@ -1809,7 +1809,7 @@ static void mpeg_thread(void)
1809 timing_info[i*2+1] >> 16); 1809 timing_info[i*2+1] >> 16);
1810 } 1810 }
1811 } 1811 }
1812#endif 1812#endif /* #ifdef DEBUG1 */
1813 1813
1814 if(prerecording) 1814 if(prerecording)
1815 { 1815 {
@@ -2026,14 +2026,14 @@ static void mpeg_thread(void)
2026 break; 2026 break;
2027 } 2027 }
2028 } 2028 }
2029#endif 2029#endif /* #ifdef HAVE_MAS3587F */
2030 } 2030 }
2031} 2031}
2032#endif /* SIMULATOR */ 2032#endif /* SIMULATOR */
2033 2033
2034#ifdef SIMULATOR 2034#ifdef SIMULATOR
2035static struct mp3entry taginfo; 2035static struct mp3entry taginfo;
2036#endif 2036#endif /* #ifdef SIMULATOR */
2037 2037
2038struct mp3entry* mpeg_current_track() 2038struct mp3entry* mpeg_current_track()
2039{ 2039{
@@ -2044,7 +2044,7 @@ struct mp3entry* mpeg_current_track()
2044 return &(id3tags[tag_read_idx]->id3); 2044 return &(id3tags[tag_read_idx]->id3);
2045 else 2045 else
2046 return NULL; 2046 return NULL;
2047#endif 2047#endif /* #ifdef SIMULATOR */
2048} 2048}
2049 2049
2050bool mpeg_has_changed_track(void) 2050bool mpeg_has_changed_track(void)
@@ -2463,7 +2463,7 @@ void mpeg_play(int offset)
2463 is_playing = true; 2463 is_playing = true;
2464 2464
2465 queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset); 2465 queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset);
2466#endif 2466#endif /* #ifdef SIMULATOR */
2467 2467
2468 mpeg_errno = 0; 2468 mpeg_errno = 0;
2469} 2469}
@@ -2478,7 +2478,7 @@ void mpeg_stop(void)
2478#else 2478#else
2479 is_playing = false; 2479 is_playing = false;
2480 playing = false; 2480 playing = false;
2481#endif 2481#endif /* #ifndef SIMULATOR */
2482 2482
2483} 2483}
2484 2484
@@ -2490,7 +2490,7 @@ void mpeg_pause(void)
2490 is_playing = true; 2490 is_playing = true;
2491 playing = false; 2491 playing = false;
2492 paused = true; 2492 paused = true;
2493#endif 2493#endif /* #ifndef SIMULATOR */
2494} 2494}
2495 2495
2496void mpeg_resume(void) 2496void mpeg_resume(void)
@@ -2501,7 +2501,7 @@ void mpeg_resume(void)
2501 is_playing = true; 2501 is_playing = true;
2502 playing = true; 2502 playing = true;
2503 paused = false; 2503 paused = false;
2504#endif 2504#endif /* #ifndef SIMULATOR */
2505} 2505}
2506 2506
2507void mpeg_next(void) 2507void mpeg_next(void)
@@ -2529,7 +2529,7 @@ void mpeg_next(void)
2529 playing = true; 2529 playing = true;
2530 break; 2530 break;
2531 } while(1); 2531 } while(1);
2532#endif 2532#endif /* #ifndef SIMULATOR */
2533} 2533}
2534 2534
2535void mpeg_prev(void) 2535void mpeg_prev(void)
@@ -2556,7 +2556,7 @@ void mpeg_prev(void)
2556 playing = true; 2556 playing = true;
2557 break; 2557 break;
2558 } while(1); 2558 } while(1);
2559#endif 2559#endif /* #ifndef SIMULATOR */
2560} 2560}
2561 2561
2562void mpeg_ff_rewind(int newtime) 2562void mpeg_ff_rewind(int newtime)
@@ -2565,14 +2565,14 @@ void mpeg_ff_rewind(int newtime)
2565 queue_post(&mpeg_queue, MPEG_FF_REWIND, (void *)newtime); 2565 queue_post(&mpeg_queue, MPEG_FF_REWIND, (void *)newtime);
2566#else 2566#else
2567 (void)newtime; 2567 (void)newtime;
2568#endif 2568#endif /* #ifndef SIMULATOR */
2569} 2569}
2570 2570
2571void mpeg_flush_and_reload_tracks(void) 2571void mpeg_flush_and_reload_tracks(void)
2572{ 2572{
2573#ifndef SIMULATOR 2573#ifndef SIMULATOR
2574 queue_post(&mpeg_queue, MPEG_FLUSH_RELOAD, NULL); 2574 queue_post(&mpeg_queue, MPEG_FLUSH_RELOAD, NULL);
2575#endif 2575#endif /* #ifndef SIMULATOR*/
2576} 2576}
2577 2577
2578int mpeg_status(void) 2578int mpeg_status(void)
@@ -2591,7 +2591,7 @@ int mpeg_status(void)
2591 2591
2592 if(is_prerecording) 2592 if(is_prerecording)
2593 ret |= MPEG_STATUS_PRERECORD; 2593 ret |= MPEG_STATUS_PRERECORD;
2594#endif 2594#endif /* #ifdef HAVE_MAS3587F */
2595 2595
2596 if(mpeg_errno) 2596 if(mpeg_errno)
2597 ret |= MPEG_STATUS_ERROR; 2597 ret |= MPEG_STATUS_ERROR;
@@ -2629,15 +2629,19 @@ static void mpeg_thread(void)
2629 sleep(HZ); 2629 sleep(HZ);
2630 } 2630 }
2631} 2631}
2632#endif 2632#endif /* #ifdef SIMULATOR */
2633 2633
2634void mpeg_init(void) 2634void mpeg_init(void)
2635{ 2635{
2636 mpeg_errno = 0; 2636 mpeg_errno = 0;
2637 2637
2638 create_thread(mpeg_thread, mpeg_stack,
2639 sizeof(mpeg_stack), mpeg_thread_name);
2640#ifndef SIMULATOR
2638 mp3buflen = mp3end - mp3buf; 2641 mp3buflen = mp3end - mp3buf;
2639
2640 queue_init(&mpeg_queue); 2642 queue_init(&mpeg_queue);
2643#endif /* #ifndef SIMULATOR */
2644
2641 create_thread(mpeg_thread, mpeg_stack, 2645 create_thread(mpeg_thread, mpeg_stack,
2642 sizeof(mpeg_stack), mpeg_thread_name); 2646 sizeof(mpeg_stack), mpeg_thread_name);
2643 2647
@@ -2649,10 +2653,10 @@ void mpeg_init(void)
2649 inverted_pr = true; 2653 inverted_pr = true;
2650 else 2654 else
2651 inverted_pr = false; 2655 inverted_pr = false;
2652#endif 2656#endif /* #ifdef HAVE_MAS3587F */
2653 2657
2654#ifdef DEBUG 2658#ifdef DEBUG
2655 dbg_timer_start(); 2659 dbg_timer_start();
2656 dbg_cnt2us(0); 2660 dbg_cnt2us(0);
2657#endif 2661#endif /* DEBUG */
2658} 2662}