diff options
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r-- | firmware/mpeg.c | 166 |
1 files changed, 67 insertions, 99 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index a0305760bc..b1d1facc73 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -19,6 +19,9 @@ | |||
19 | #include <stdbool.h> | 19 | #include <stdbool.h> |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include "config.h" | 21 | #include "config.h" |
22 | |||
23 | #if CONFIG_HWCODEC != MASNONE | ||
24 | |||
22 | #include "debug.h" | 25 | #include "debug.h" |
23 | #include "panic.h" | 26 | #include "panic.h" |
24 | #include "id3.h" | 27 | #include "id3.h" |
@@ -33,6 +36,7 @@ | |||
33 | #include "buffer.h" | 36 | #include "buffer.h" |
34 | #include "mp3_playback.h" | 37 | #include "mp3_playback.h" |
35 | #include "sound.h" | 38 | #include "sound.h" |
39 | #include "bitswap.h" | ||
36 | #ifndef SIMULATOR | 40 | #ifndef SIMULATOR |
37 | #include "i2c.h" | 41 | #include "i2c.h" |
38 | #include "mas.h" | 42 | #include "mas.h" |
@@ -41,9 +45,7 @@ | |||
41 | #include "usb.h" | 45 | #include "usb.h" |
42 | #include "file.h" | 46 | #include "file.h" |
43 | #include "hwcompat.h" | 47 | #include "hwcompat.h" |
44 | #endif /* #ifndef SIMULATOR */ | 48 | #endif /* !SIMULATOR */ |
45 | |||
46 | #include "bitswap.h" | ||
47 | 49 | ||
48 | #if CONFIG_HWCODEC == MAS3587F | 50 | #if CONFIG_HWCODEC == MAS3587F |
49 | static void init_recording(void); | 51 | static void init_recording(void); |
@@ -53,13 +55,13 @@ static void stop_recording(void); | |||
53 | static int get_unsaved_space(void); | 55 | static int get_unsaved_space(void); |
54 | static void pause_recording(void); | 56 | static void pause_recording(void); |
55 | static void resume_recording(void); | 57 | static void resume_recording(void); |
56 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 58 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
57 | 59 | ||
58 | #ifndef SIMULATOR | 60 | #ifndef SIMULATOR |
59 | static int get_unplayed_space(void); | 61 | static int get_unplayed_space(void); |
60 | static int get_playable_space(void); | 62 | static int get_playable_space(void); |
61 | static int get_unswapped_space(void); | 63 | static int get_unswapped_space(void); |
62 | #endif /* #ifndef SIMULATOR */ | 64 | #endif /* !SIMULATOR */ |
63 | 65 | ||
64 | #define MPEG_PLAY 1 | 66 | #define MPEG_PLAY 1 |
65 | #define MPEG_STOP 2 | 67 | #define MPEG_STOP 2 |
@@ -86,7 +88,7 @@ extern enum /* from mp3_playback.c */ | |||
86 | MPEG_DECODER, | 88 | MPEG_DECODER, |
87 | MPEG_ENCODER | 89 | MPEG_ENCODER |
88 | } mpeg_mode; | 90 | } mpeg_mode; |
89 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 91 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
90 | 92 | ||
91 | extern char* playlist_peek(int steps); | 93 | extern char* playlist_peek(int steps); |
92 | extern bool playlist_check(int steps); | 94 | extern bool playlist_check(int steps); |
@@ -121,7 +123,7 @@ static int num_tracks_in_memory(void) | |||
121 | { | 123 | { |
122 | return (track_write_idx - track_read_idx) & MAX_TRACK_ENTRIES_MASK; | 124 | return (track_write_idx - track_read_idx) & MAX_TRACK_ENTRIES_MASK; |
123 | } | 125 | } |
124 | #endif /* #ifndef SIMULATOR */ | 126 | #endif /* !SIMULATOR */ |
125 | 127 | ||
126 | #ifndef SIMULATOR | 128 | #ifndef SIMULATOR |
127 | static void debug_tags(void) | 129 | static void debug_tags(void) |
@@ -135,7 +137,7 @@ static void debug_tags(void) | |||
135 | } | 137 | } |
136 | DEBUGF("read: %d, write :%d\n", track_read_idx, track_write_idx); | 138 | DEBUGF("read: %d, write :%d\n", track_read_idx, track_write_idx); |
137 | DEBUGF("num_tracks_in_memory: %d\n", num_tracks_in_memory()); | 139 | DEBUGF("num_tracks_in_memory: %d\n", num_tracks_in_memory()); |
138 | #endif /* #ifdef DEBUG_TAGS */ | 140 | #endif /* DEBUG_TAGS */ |
139 | } | 141 | } |
140 | 142 | ||
141 | static void remove_current_tag(void) | 143 | static void remove_current_tag(void) |
@@ -172,7 +174,7 @@ static struct trackdata *get_trackdata(int offset) | |||
172 | else | 174 | else |
173 | return &trackdata[(track_read_idx + offset) & MAX_TRACK_ENTRIES_MASK]; | 175 | return &trackdata[(track_read_idx + offset) & MAX_TRACK_ENTRIES_MASK]; |
174 | } | 176 | } |
175 | #endif /* #ifndef SIMULATOR */ | 177 | #endif /* !SIMULATOR */ |
176 | 178 | ||
177 | static void set_elapsed(struct mp3entry* id3) | 179 | static void set_elapsed(struct mp3entry* id3) |
178 | { | 180 | { |
@@ -293,16 +295,14 @@ unsigned long mpeg_get_last_header(void) | |||
293 | { | 295 | { |
294 | #ifdef SIMULATOR | 296 | #ifdef SIMULATOR |
295 | return 0; | 297 | return 0; |
296 | #elif CONFIG_HWCODEC != MASNONE | 298 | #else /* !SIMULATOR */ |
297 | unsigned long tmp[2]; | 299 | unsigned long tmp[2]; |
298 | 300 | ||
299 | /* Read the frame data from the MAS and reconstruct it with the | 301 | /* Read the frame data from the MAS and reconstruct it with the |
300 | frame sync and all */ | 302 | frame sync and all */ |
301 | mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_STATUS_1, tmp, 2); | 303 | mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_STATUS_1, tmp, 2); |
302 | return 0xffe00000 | ((tmp[0] & 0x7c00) << 6) | (tmp[1] & 0xffff); | 304 | return 0xffe00000 | ((tmp[0] & 0x7c00) << 6) | (tmp[1] & 0xffff); |
303 | #else | 305 | #endif /* !SIMULATOR */ |
304 | return 0; | ||
305 | #endif | ||
306 | } | 306 | } |
307 | 307 | ||
308 | static bool paused; /* playback is paused */ | 308 | static bool paused; /* playback is paused */ |
@@ -312,7 +312,7 @@ static unsigned int mpeg_errno; | |||
312 | #ifdef SIMULATOR | 312 | #ifdef SIMULATOR |
313 | static bool is_playing = false; | 313 | static bool is_playing = false; |
314 | static bool playing = false; | 314 | static bool playing = false; |
315 | #else | 315 | #else /* !SIMULATOR */ |
316 | static int last_dma_tick = 0; | 316 | static int last_dma_tick = 0; |
317 | 317 | ||
318 | extern unsigned long mas_version_code; | 318 | extern unsigned long mas_version_code; |
@@ -370,13 +370,13 @@ static int prerecord_timeout; /* The tick count of the next prerecord data store | |||
370 | 370 | ||
371 | /* Shadow MAS registers */ | 371 | /* Shadow MAS registers */ |
372 | unsigned long shadow_encoder_control = 0; | 372 | unsigned long shadow_encoder_control = 0; |
373 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 373 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
374 | 374 | ||
375 | #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) | 375 | #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) |
376 | unsigned long shadow_io_control_main = 0; | 376 | unsigned long shadow_io_control_main = 0; |
377 | unsigned long shadow_soft_mute = 0; | 377 | unsigned long shadow_soft_mute = 0; |
378 | unsigned shadow_codec_reg0; | 378 | unsigned shadow_codec_reg0; |
379 | #endif | 379 | #endif /* (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */ |
380 | 380 | ||
381 | static int mpeg_file; | 381 | static int mpeg_file; |
382 | 382 | ||
@@ -384,7 +384,7 @@ static int mpeg_file; | |||
384 | #if CONFIG_HWCODEC == MAS3587F | 384 | #if CONFIG_HWCODEC == MAS3587F |
385 | static bool init_recording_done; | 385 | static bool init_recording_done; |
386 | static bool init_playback_done; | 386 | static bool init_playback_done; |
387 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 387 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
388 | static bool mpeg_stop_done; | 388 | static bool mpeg_stop_done; |
389 | 389 | ||
390 | static void recalculate_watermark(int bitrate) | 390 | static void recalculate_watermark(int bitrate) |
@@ -465,7 +465,7 @@ static int dbg_cnt2us(unsigned int cnt) | |||
465 | { | 465 | { |
466 | return (cnt * 10000) / (FREQ/800); | 466 | return (cnt * 10000) / (FREQ/800); |
467 | } | 467 | } |
468 | #endif /* #ifdef DEBUG */ | 468 | #endif /* DEBUG */ |
469 | 469 | ||
470 | static int get_unplayed_space(void) | 470 | static int get_unplayed_space(void) |
471 | { | 471 | { |
@@ -518,13 +518,13 @@ static int get_unsaved_space(void) | |||
518 | space += audiobuflen; | 518 | space += audiobuflen; |
519 | return space; | 519 | return space; |
520 | } | 520 | } |
521 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 521 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
522 | 522 | ||
523 | #if CONFIG_HWCODEC == MAS3587F | 523 | #if CONFIG_HWCODEC == MAS3587F |
524 | #ifdef DEBUG | 524 | #ifdef DEBUG |
525 | static long timing_info_index = 0; | 525 | static long timing_info_index = 0; |
526 | static long timing_info[1024]; | 526 | static long timing_info[1024]; |
527 | #endif /* #ifdef DEBUG */ | 527 | #endif /* DEBUG */ |
528 | static unsigned long num_rec_bytes; | 528 | static unsigned long num_rec_bytes; |
529 | static unsigned long num_recorded_frames; | 529 | static unsigned long num_recorded_frames; |
530 | 530 | ||
@@ -554,7 +554,7 @@ void rec_tick(void) | |||
554 | #ifdef DEBUG | 554 | #ifdef DEBUG |
555 | timing_info[timing_info_index++] = current_tick; | 555 | timing_info[timing_info_index++] = current_tick; |
556 | TCNT2 = 0; | 556 | TCNT2 = 0; |
557 | #endif /* #ifdef DEBUG */ | 557 | #endif /* DEBUG */ |
558 | /* Note: Although this loop is run in interrupt context, further | 558 | /* Note: Although this loop is run in interrupt context, further |
559 | * optimisation will do no good. The MAS would then deliver bad | 559 | * optimisation will do no good. The MAS would then deliver bad |
560 | * frames occasionally, as observed in extended experiments. */ | 560 | * frames occasionally, as observed in extended experiments. */ |
@@ -589,7 +589,7 @@ void rec_tick(void) | |||
589 | #ifdef DEBUG | 589 | #ifdef DEBUG |
590 | timing_info[timing_info_index++] = TCNT2 + (i << 16); | 590 | timing_info[timing_info_index++] = TCNT2 + (i << 16); |
591 | timing_info_index &= 0x3ff; | 591 | timing_info_index &= 0x3ff; |
592 | #endif /* #ifdef DEBUG */ | 592 | #endif /* DEBUG */ |
593 | 593 | ||
594 | num_rec_bytes += i; | 594 | num_rec_bytes += i; |
595 | 595 | ||
@@ -625,7 +625,7 @@ void rec_tick(void) | |||
625 | } | 625 | } |
626 | } | 626 | } |
627 | } | 627 | } |
628 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 628 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
629 | 629 | ||
630 | void playback_tick(void) | 630 | void playback_tick(void) |
631 | { | 631 | { |
@@ -878,7 +878,7 @@ static void track_change(void) | |||
878 | #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) | 878 | #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) |
879 | /* Reset the AVC */ | 879 | /* Reset the AVC */ |
880 | sound_set(SOUND_AVC, -1); | 880 | sound_set(SOUND_AVC, -1); |
881 | #endif /* #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */ | 881 | #endif /* (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */ |
882 | 882 | ||
883 | if (num_tracks_in_memory() > 0) | 883 | if (num_tracks_in_memory() > 0) |
884 | { | 884 | { |
@@ -904,7 +904,7 @@ void hexdump(const unsigned char *buf, int len) | |||
904 | } | 904 | } |
905 | DEBUGF("\n"); | 905 | DEBUGF("\n"); |
906 | } | 906 | } |
907 | #endif /* #ifdef DEBUG */ | 907 | #endif /* DEBUG */ |
908 | 908 | ||
909 | static void start_playback_if_ready(void) | 909 | static void start_playback_if_ready(void) |
910 | { | 910 | { |
@@ -943,7 +943,6 @@ static void start_playback_if_ready(void) | |||
943 | } | 943 | } |
944 | } | 944 | } |
945 | 945 | ||
946 | #if CONFIG_HWCODEC != MASNONE | ||
947 | static bool swap_one_chunk(void) | 946 | static bool swap_one_chunk(void) |
948 | { | 947 | { |
949 | int free_space_left; | 948 | int free_space_left; |
@@ -984,7 +983,6 @@ static bool swap_one_chunk(void) | |||
984 | 983 | ||
985 | return true; | 984 | return true; |
986 | } | 985 | } |
987 | #endif | ||
988 | 986 | ||
989 | #ifdef HAVE_RECORDING | 987 | #ifdef HAVE_RECORDING |
990 | const unsigned char empty_id3_header[] = | 988 | const unsigned char empty_id3_header[] = |
@@ -992,11 +990,10 @@ const unsigned char empty_id3_header[] = | |||
992 | 'I', 'D', '3', 0x03, 0x00, 0x00, | 990 | 'I', 'D', '3', 0x03, 0x00, 0x00, |
993 | 0x00, 0x00, 0x1f, 0x76 /* Size is 4096 minus 10 bytes for the header */ | 991 | 0x00, 0x00, 0x1f, 0x76 /* Size is 4096 minus 10 bytes for the header */ |
994 | }; | 992 | }; |
995 | #endif | 993 | #endif /* HAVE_RECORDING */ |
996 | 994 | ||
997 | static void mpeg_thread(void) | 995 | static void mpeg_thread(void) |
998 | { | 996 | { |
999 | #if CONFIG_HWCODEC != MASNONE | ||
1000 | static int pause_tick = 0; | 997 | static int pause_tick = 0; |
1001 | static unsigned int pause_track = 0; | 998 | static unsigned int pause_track = 0; |
1002 | struct event ev; | 999 | struct event ev; |
@@ -1013,7 +1010,7 @@ static void mpeg_thread(void) | |||
1013 | int save_endpos = 0; | 1010 | int save_endpos = 0; |
1014 | int rc; | 1011 | int rc; |
1015 | long offset; | 1012 | long offset; |
1016 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 1013 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
1017 | 1014 | ||
1018 | is_playing = false; | 1015 | is_playing = false; |
1019 | play_pending = false; | 1016 | play_pending = false; |
@@ -1025,7 +1022,7 @@ static void mpeg_thread(void) | |||
1025 | #if CONFIG_HWCODEC == MAS3587F | 1022 | #if CONFIG_HWCODEC == MAS3587F |
1026 | if(mpeg_mode == MPEG_DECODER) | 1023 | if(mpeg_mode == MPEG_DECODER) |
1027 | { | 1024 | { |
1028 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 1025 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
1029 | yield(); | 1026 | yield(); |
1030 | 1027 | ||
1031 | /* Swap if necessary, and don't block on the queue_wait() */ | 1028 | /* Swap if necessary, and don't block on the queue_wait() */ |
@@ -1056,7 +1053,7 @@ static void mpeg_thread(void) | |||
1056 | /* Silence the A/D input, it may be on because the radio | 1053 | /* Silence the A/D input, it may be on because the radio |
1057 | may be playing */ | 1054 | may be playing */ |
1058 | mas_codec_writereg(6, 0x0000); | 1055 | mas_codec_writereg(6, 0x0000); |
1059 | #endif /* #ifdef CONFIG_TUNER */ | 1056 | #endif /* CONFIG_TUNER */ |
1060 | 1057 | ||
1061 | /* Stop the current stream */ | 1058 | /* Stop the current stream */ |
1062 | play_pending = false; | 1059 | play_pending = false; |
@@ -1447,10 +1444,10 @@ static void mpeg_thread(void) | |||
1447 | amount_to_read); | 1444 | amount_to_read); |
1448 | #if MEM == 8 | 1445 | #if MEM == 8 |
1449 | amount_to_read = MIN(0x100000, amount_to_read); | 1446 | amount_to_read = MIN(0x100000, amount_to_read); |
1450 | #endif /* #if MEM == 8 */ | 1447 | #endif /* MEM == 8 */ |
1451 | #ifdef HAVE_MMC /* MMC is slow, so don't read too large chunks */ | 1448 | #ifdef HAVE_MMC /* MMC is slow, so don't read too large chunks */ |
1452 | amount_to_read = MIN(0x40000, amount_to_read); | 1449 | amount_to_read = MIN(0x40000, amount_to_read); |
1453 | #endif | 1450 | #endif /* HAVE_MMC */ |
1454 | 1451 | ||
1455 | /* Read as much mpeg data as we can fit in the buffer */ | 1452 | /* Read as much mpeg data as we can fit in the buffer */ |
1456 | if(mpeg_file >= 0) | 1453 | if(mpeg_file >= 0) |
@@ -1554,7 +1551,7 @@ static void mpeg_thread(void) | |||
1554 | is_playing = false; | 1551 | is_playing = false; |
1555 | paused = false; | 1552 | paused = false; |
1556 | stop_playing(); | 1553 | stop_playing(); |
1557 | #ifndef SIMULATOR | 1554 | #ifndef SIMULATOR //CHECKME |
1558 | 1555 | ||
1559 | /* Tell the USB thread that we are safe */ | 1556 | /* Tell the USB thread that we are safe */ |
1560 | DEBUGF("mpeg_thread got SYS_USB_CONNECTED\n"); | 1557 | DEBUGF("mpeg_thread got SYS_USB_CONNECTED\n"); |
@@ -1562,16 +1559,16 @@ static void mpeg_thread(void) | |||
1562 | 1559 | ||
1563 | /* Wait until the USB cable is extracted again */ | 1560 | /* Wait until the USB cable is extracted again */ |
1564 | usb_wait_for_disconnect(&mpeg_queue); | 1561 | usb_wait_for_disconnect(&mpeg_queue); |
1565 | #endif /* #ifndef SIMULATOR */ | 1562 | #endif /* !SIMULATOR */ |
1566 | break; | 1563 | break; |
1567 | #endif /* #ifndef USB_NONE */ | 1564 | #endif /* !USB_NONE */ |
1568 | 1565 | ||
1569 | #if CONFIG_HWCODEC == MAS3587F | 1566 | #if CONFIG_HWCODEC == MAS3587F |
1570 | case MPEG_INIT_RECORDING: | 1567 | case MPEG_INIT_RECORDING: |
1571 | init_recording(); | 1568 | init_recording(); |
1572 | init_recording_done = true; | 1569 | init_recording_done = true; |
1573 | break; | 1570 | break; |
1574 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 1571 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
1575 | 1572 | ||
1576 | case SYS_TIMEOUT: | 1573 | case SYS_TIMEOUT: |
1577 | if (playing) | 1574 | if (playing) |
@@ -1738,7 +1735,7 @@ static void mpeg_thread(void) | |||
1738 | timing_info[i*2+1] >> 16); | 1735 | timing_info[i*2+1] >> 16); |
1739 | } | 1736 | } |
1740 | } | 1737 | } |
1741 | #endif /* #ifdef DEBUG1 */ | 1738 | #endif /* DEBUG1 */ |
1742 | 1739 | ||
1743 | if (prerecording) | 1740 | if (prerecording) |
1744 | { | 1741 | { |
@@ -1911,67 +1908,42 @@ static void mpeg_thread(void) | |||
1911 | break; | 1908 | break; |
1912 | } | 1909 | } |
1913 | } | 1910 | } |
1914 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 1911 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
1915 | } | 1912 | } |
1916 | #else /* HWCODEC != NONE */ | ||
1917 | struct event ev; | ||
1918 | |||
1919 | while(1) | ||
1920 | { | ||
1921 | queue_wait(&mpeg_queue, &ev); | ||
1922 | |||
1923 | switch(ev.id) | ||
1924 | { | ||
1925 | case MPEG_STOP: | ||
1926 | mpeg_stop_done = true; | ||
1927 | break; | ||
1928 | |||
1929 | case SYS_USB_CONNECTED: | ||
1930 | /* Tell the USB thread that we are safe */ | ||
1931 | DEBUGF("mpeg_thread got SYS_USB_CONNECTED\n"); | ||
1932 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | ||
1933 | |||
1934 | /* Wait until the USB cable is extracted again */ | ||
1935 | usb_wait_for_disconnect(&mpeg_queue); | ||
1936 | break; | ||
1937 | } | ||
1938 | } | ||
1939 | #endif | ||
1940 | } | 1913 | } |
1941 | #endif /* SIMULATOR */ | 1914 | #endif /* !SIMULATOR */ |
1942 | 1915 | ||
1943 | #ifdef SIMULATOR | 1916 | #ifdef SIMULATOR |
1944 | static struct mp3entry taginfo; | 1917 | static struct mp3entry taginfo; |
1945 | #endif /* #ifdef SIMULATOR */ | 1918 | #endif /* SIMULATOR */ |
1946 | 1919 | ||
1947 | void mpeg_id3_options(bool _v1first) | 1920 | void mpeg_id3_options(bool _v1first) |
1948 | { | 1921 | { |
1949 | v1first = _v1first; | 1922 | v1first = _v1first; |
1950 | } | 1923 | } |
1951 | 1924 | ||
1952 | #ifndef IRIVER_H100 | ||
1953 | struct mp3entry* audio_current_track() | 1925 | struct mp3entry* audio_current_track() |
1954 | { | 1926 | { |
1955 | #ifdef SIMULATOR | 1927 | #ifdef SIMULATOR |
1956 | return &taginfo; | 1928 | return &taginfo; |
1957 | #else | 1929 | #else /* !SIMULATOR */ |
1958 | if(num_tracks_in_memory()) | 1930 | if(num_tracks_in_memory()) |
1959 | return &get_trackdata(0)->id3; | 1931 | return &get_trackdata(0)->id3; |
1960 | else | 1932 | else |
1961 | return NULL; | 1933 | return NULL; |
1962 | #endif /* #ifdef SIMULATOR */ | 1934 | #endif /* !SIMULATOR */ |
1963 | } | 1935 | } |
1964 | 1936 | ||
1965 | struct mp3entry* audio_next_track() | 1937 | struct mp3entry* audio_next_track() |
1966 | { | 1938 | { |
1967 | #ifdef SIMULATOR | 1939 | #ifdef SIMULATOR |
1968 | return &taginfo; | 1940 | return &taginfo; |
1969 | #else | 1941 | #else /* !SIMULATOR */ |
1970 | if(num_tracks_in_memory() > 1) | 1942 | if(num_tracks_in_memory() > 1) |
1971 | return &get_trackdata(1)->id3; | 1943 | return &get_trackdata(1)->id3; |
1972 | else | 1944 | else |
1973 | return NULL; | 1945 | return NULL; |
1974 | #endif /* #ifdef SIMULATOR */ | 1946 | #endif /* !SIMULATOR */ |
1975 | } | 1947 | } |
1976 | 1948 | ||
1977 | bool audio_has_changed_track(void) | 1949 | bool audio_has_changed_track(void) |
@@ -1983,7 +1955,6 @@ bool audio_has_changed_track(void) | |||
1983 | } | 1955 | } |
1984 | return false; | 1956 | return false; |
1985 | } | 1957 | } |
1986 | #endif | ||
1987 | 1958 | ||
1988 | #if CONFIG_HWCODEC == MAS3587F | 1959 | #if CONFIG_HWCODEC == MAS3587F |
1989 | void audio_init_playback(void) | 1960 | void audio_init_playback(void) |
@@ -2087,7 +2058,6 @@ static void init_recording(void) | |||
2087 | mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1); | 2058 | mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1); |
2088 | } while(!(val & 0x40)); | 2059 | } while(!(val & 0x40)); |
2089 | 2060 | ||
2090 | #if 1 | ||
2091 | /* We have started the recording application with monitoring OFF. | 2061 | /* We have started the recording application with monitoring OFF. |
2092 | This is because we want to record at least one frame to fill the DMA | 2062 | This is because we want to record at least one frame to fill the DMA |
2093 | buffer, because the silly MAS will not negate EOD until at least one | 2063 | buffer, because the silly MAS will not negate EOD until at least one |
@@ -2106,7 +2076,6 @@ static void init_recording(void) | |||
2106 | } while(val & 1); | 2076 | } while(val & 1); |
2107 | 2077 | ||
2108 | drain_dma_buffer(); | 2078 | drain_dma_buffer(); |
2109 | #endif | ||
2110 | mpeg_mode = MPEG_ENCODER; | 2079 | mpeg_mode = MPEG_ENCODER; |
2111 | 2080 | ||
2112 | DEBUGF("MAS Recording application started\n"); | 2081 | DEBUGF("MAS Recording application started\n"); |
@@ -2356,7 +2325,7 @@ int mpeg_get_mas_pllfreq(void) | |||
2356 | else | 2325 | else |
2357 | return 24576000; | 2326 | return 24576000; |
2358 | } | 2327 | } |
2359 | #endif | 2328 | #endif /* CONFIG_TUNER & S1A0903X01 */ |
2360 | 2329 | ||
2361 | /* try to make some kind of beep, also in recording mode */ | 2330 | /* try to make some kind of beep, also in recording mode */ |
2362 | void audio_beep(int duration) | 2331 | void audio_beep(int duration) |
@@ -2432,7 +2401,7 @@ unsigned long mpeg_num_recorded_bytes(void) | |||
2432 | return 0; | 2401 | return 0; |
2433 | } | 2402 | } |
2434 | 2403 | ||
2435 | #elif (CONFIG_HWCODEC == MASNONE) || defined(SIMULATOR) | 2404 | #elif defined(SIMULATOR) |
2436 | 2405 | ||
2437 | /* dummies coming up | 2406 | /* dummies coming up |
2438 | 2407 | ||
@@ -2508,9 +2477,8 @@ void mpeg_set_recording_options(int frequency, int quality, | |||
2508 | (void)editable; | 2477 | (void)editable; |
2509 | (void)prerecord_time; | 2478 | (void)prerecord_time; |
2510 | } | 2479 | } |
2511 | #endif | 2480 | #endif /* CONFIG_HWCODEC == MAS3587F; SIMULATOR */ |
2512 | 2481 | ||
2513 | #ifndef IRIVER_H100 | ||
2514 | void audio_play(int offset) | 2482 | void audio_play(int offset) |
2515 | { | 2483 | { |
2516 | #ifdef SIMULATOR | 2484 | #ifdef SIMULATOR |
@@ -2530,7 +2498,7 @@ void audio_play(int offset) | |||
2530 | continue; | 2498 | continue; |
2531 | } | 2499 | } |
2532 | #ifdef HAVE_MPEG_PLAY | 2500 | #ifdef HAVE_MPEG_PLAY |
2533 | real_mpeg_play(trackname); | 2501 | real_mpeg_play(trackname); |
2534 | #endif | 2502 | #endif |
2535 | playlist_next(steps); | 2503 | playlist_next(steps); |
2536 | taginfo.offset = offset; | 2504 | taginfo.offset = offset; |
@@ -2539,11 +2507,11 @@ void audio_play(int offset) | |||
2539 | playing = true; | 2507 | playing = true; |
2540 | break; | 2508 | break; |
2541 | } while(1); | 2509 | } while(1); |
2542 | #else | 2510 | #else /* !SIMULATOR */ |
2543 | is_playing = true; | 2511 | is_playing = true; |
2544 | 2512 | ||
2545 | queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset); | 2513 | queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset); |
2546 | #endif /* #ifdef SIMULATOR */ | 2514 | #endif /* !SIMULATOR */ |
2547 | 2515 | ||
2548 | mpeg_errno = 0; | 2516 | mpeg_errno = 0; |
2549 | } | 2517 | } |
@@ -2555,11 +2523,11 @@ void audio_stop(void) | |||
2555 | queue_post(&mpeg_queue, MPEG_STOP, NULL); | 2523 | queue_post(&mpeg_queue, MPEG_STOP, NULL); |
2556 | while(!mpeg_stop_done) | 2524 | while(!mpeg_stop_done) |
2557 | yield(); | 2525 | yield(); |
2558 | #else | 2526 | #else /* SIMULATOR */ |
2559 | paused = false; | 2527 | paused = false; |
2560 | is_playing = false; | 2528 | is_playing = false; |
2561 | playing = false; | 2529 | playing = false; |
2562 | #endif /* #ifndef SIMULATOR */ | 2530 | #endif /* SIMULATOR */ |
2563 | 2531 | ||
2564 | } | 2532 | } |
2565 | 2533 | ||
@@ -2567,29 +2535,29 @@ void audio_pause(void) | |||
2567 | { | 2535 | { |
2568 | #ifndef SIMULATOR | 2536 | #ifndef SIMULATOR |
2569 | queue_post(&mpeg_queue, MPEG_PAUSE, NULL); | 2537 | queue_post(&mpeg_queue, MPEG_PAUSE, NULL); |
2570 | #else | 2538 | #else /* SIMULATOR */ |
2571 | is_playing = true; | 2539 | is_playing = true; |
2572 | playing = false; | 2540 | playing = false; |
2573 | paused = true; | 2541 | paused = true; |
2574 | #endif /* #ifndef SIMULATOR */ | 2542 | #endif /* SIMULATOR */ |
2575 | } | 2543 | } |
2576 | 2544 | ||
2577 | void audio_resume(void) | 2545 | void audio_resume(void) |
2578 | { | 2546 | { |
2579 | #ifndef SIMULATOR | 2547 | #ifndef SIMULATOR |
2580 | queue_post(&mpeg_queue, MPEG_RESUME, NULL); | 2548 | queue_post(&mpeg_queue, MPEG_RESUME, NULL); |
2581 | #else | 2549 | #else /* SIMULATOR */ |
2582 | is_playing = true; | 2550 | is_playing = true; |
2583 | playing = true; | 2551 | playing = true; |
2584 | paused = false; | 2552 | paused = false; |
2585 | #endif /* #ifndef SIMULATOR */ | 2553 | #endif /* SIMULATOR */ |
2586 | } | 2554 | } |
2587 | 2555 | ||
2588 | void audio_next(void) | 2556 | void audio_next(void) |
2589 | { | 2557 | { |
2590 | #ifndef SIMULATOR | 2558 | #ifndef SIMULATOR |
2591 | queue_post(&mpeg_queue, MPEG_NEXT, NULL); | 2559 | queue_post(&mpeg_queue, MPEG_NEXT, NULL); |
2592 | #else | 2560 | #else /* SIMULATOR */ |
2593 | char* file; | 2561 | char* file; |
2594 | int steps = 1; | 2562 | int steps = 1; |
2595 | int index; | 2563 | int index; |
@@ -2610,14 +2578,14 @@ void audio_next(void) | |||
2610 | playing = true; | 2578 | playing = true; |
2611 | break; | 2579 | break; |
2612 | } while(1); | 2580 | } while(1); |
2613 | #endif /* #ifndef SIMULATOR */ | 2581 | #endif /* SIMULATOR */ |
2614 | } | 2582 | } |
2615 | 2583 | ||
2616 | void audio_prev(void) | 2584 | void audio_prev(void) |
2617 | { | 2585 | { |
2618 | #ifndef SIMULATOR | 2586 | #ifndef SIMULATOR |
2619 | queue_post(&mpeg_queue, MPEG_PREV, NULL); | 2587 | queue_post(&mpeg_queue, MPEG_PREV, NULL); |
2620 | #else | 2588 | #else /* SIMULATOR */ |
2621 | char* file; | 2589 | char* file; |
2622 | int steps = -1; | 2590 | int steps = -1; |
2623 | int index; | 2591 | int index; |
@@ -2637,23 +2605,23 @@ void audio_prev(void) | |||
2637 | playing = true; | 2605 | playing = true; |
2638 | break; | 2606 | break; |
2639 | } while(1); | 2607 | } while(1); |
2640 | #endif /* #ifndef SIMULATOR */ | 2608 | #endif /* SIMULATOR */ |
2641 | } | 2609 | } |
2642 | 2610 | ||
2643 | void audio_ff_rewind(int newtime) | 2611 | void audio_ff_rewind(int newtime) |
2644 | { | 2612 | { |
2645 | #ifndef SIMULATOR | 2613 | #ifndef SIMULATOR |
2646 | queue_post(&mpeg_queue, MPEG_FF_REWIND, (void *)newtime); | 2614 | queue_post(&mpeg_queue, MPEG_FF_REWIND, (void *)newtime); |
2647 | #else | 2615 | #else /* SIMULATOR */ |
2648 | (void)newtime; | 2616 | (void)newtime; |
2649 | #endif /* #ifndef SIMULATOR */ | 2617 | #endif /* SIMULATOR */ |
2650 | } | 2618 | } |
2651 | 2619 | ||
2652 | void audio_flush_and_reload_tracks(void) | 2620 | void audio_flush_and_reload_tracks(void) |
2653 | { | 2621 | { |
2654 | #ifndef SIMULATOR | 2622 | #ifndef SIMULATOR |
2655 | queue_post(&mpeg_queue, MPEG_FLUSH_RELOAD, NULL); | 2623 | queue_post(&mpeg_queue, MPEG_FLUSH_RELOAD, NULL); |
2656 | #endif /* #ifndef SIMULATOR*/ | 2624 | #endif /* !SIMULATOR*/ |
2657 | } | 2625 | } |
2658 | 2626 | ||
2659 | int audio_status(void) | 2627 | int audio_status(void) |
@@ -2672,7 +2640,7 @@ int audio_status(void) | |||
2672 | 2640 | ||
2673 | if(is_prerecording) | 2641 | if(is_prerecording) |
2674 | ret |= AUDIO_STATUS_PRERECORD; | 2642 | ret |= AUDIO_STATUS_PRERECORD; |
2675 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 2643 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
2676 | 2644 | ||
2677 | if(mpeg_errno) | 2645 | if(mpeg_errno) |
2678 | ret |= AUDIO_STATUS_ERROR; | 2646 | ret |= AUDIO_STATUS_ERROR; |
@@ -2710,7 +2678,7 @@ static void mpeg_thread(void) | |||
2710 | sleep(HZ); | 2678 | sleep(HZ); |
2711 | } | 2679 | } |
2712 | } | 2680 | } |
2713 | #endif /* #ifdef SIMULATOR */ | 2681 | #endif /* SIMULATOR */ |
2714 | 2682 | ||
2715 | void audio_init(void) | 2683 | void audio_init(void) |
2716 | { | 2684 | { |
@@ -2719,7 +2687,7 @@ void audio_init(void) | |||
2719 | #ifndef SIMULATOR | 2687 | #ifndef SIMULATOR |
2720 | audiobuflen = audiobufend - audiobuf; | 2688 | audiobuflen = audiobufend - audiobuf; |
2721 | queue_init(&mpeg_queue); | 2689 | queue_init(&mpeg_queue); |
2722 | #endif /* #ifndef SIMULATOR */ | 2690 | #endif /* !SIMULATOR */ |
2723 | create_thread(mpeg_thread, mpeg_stack, | 2691 | create_thread(mpeg_thread, mpeg_stack, |
2724 | sizeof(mpeg_stack), mpeg_thread_name); | 2692 | sizeof(mpeg_stack), mpeg_thread_name); |
2725 | 2693 | ||
@@ -2730,7 +2698,7 @@ void audio_init(void) | |||
2730 | and_b(~0x08, &PADRH); | 2698 | and_b(~0x08, &PADRH); |
2731 | else | 2699 | else |
2732 | or_b(0x08, &PADRH); | 2700 | or_b(0x08, &PADRH); |
2733 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 2701 | #endif /* CONFIG_HWCODEC == MAS3587F */ |
2734 | 2702 | ||
2735 | #ifdef DEBUG | 2703 | #ifdef DEBUG |
2736 | dbg_timer_start(); | 2704 | dbg_timer_start(); |
@@ -2738,4 +2706,4 @@ void audio_init(void) | |||
2738 | #endif /* DEBUG */ | 2706 | #endif /* DEBUG */ |
2739 | } | 2707 | } |
2740 | 2708 | ||
2741 | #endif /* IRIVER_H100 */ | 2709 | #endif /* CONFIG_HWCODEC != MASNONE */ |