diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2005-04-04 12:06:29 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2005-04-04 12:06:29 +0000 |
commit | 8a237a829e0f63b61536f315209a6d0ea1477e31 (patch) | |
tree | 1fe54329fe776aa7bc982a37203cb61c13244a48 /firmware/mpeg.c | |
parent | ec4e9b8d600c53add3c8bf6eb7fe1975dba141a7 (diff) | |
download | rockbox-8a237a829e0f63b61536f315209a6d0ea1477e31.tar.gz rockbox-8a237a829e0f63b61536f315209a6d0ea1477e31.zip |
More audio code restructuring, mostly renaming functions so far
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6246 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r-- | firmware/mpeg.c | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index d8de1a37b4..79265e4452 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "panic.h" | 23 | #include "panic.h" |
24 | #include "id3.h" | 24 | #include "id3.h" |
25 | #include "mpeg.h" | 25 | #include "mpeg.h" |
26 | #include "audio.h" | ||
26 | #include "ata.h" | 27 | #include "ata.h" |
27 | #include "string.h" | 28 | #include "string.h" |
28 | #include <kernel.h> | 29 | #include <kernel.h> |
@@ -220,10 +221,10 @@ static void set_elapsed(struct mp3entry* id3) | |||
220 | id3->elapsed = id3->offset / id3->bpf * id3->tpf; | 221 | id3->elapsed = id3->offset / id3->bpf * id3->tpf; |
221 | } | 222 | } |
222 | 223 | ||
223 | int mpeg_get_file_pos(void) | 224 | int audio_get_file_pos(void) |
224 | { | 225 | { |
225 | int pos = -1; | 226 | int pos = -1; |
226 | struct mp3entry *id3 = mpeg_current_track(); | 227 | struct mp3entry *id3 = audio_current_track(); |
227 | 228 | ||
228 | if (id3->vbr) | 229 | if (id3->vbr) |
229 | { | 230 | { |
@@ -402,12 +403,12 @@ static void recalculate_watermark(int bitrate) | |||
402 | } | 403 | } |
403 | } | 404 | } |
404 | 405 | ||
405 | void mpeg_set_buffer_margin(int seconds) | 406 | void audio_set_buffer_margin(int seconds) |
406 | { | 407 | { |
407 | low_watermark_margin = seconds; | 408 | low_watermark_margin = seconds; |
408 | } | 409 | } |
409 | 410 | ||
410 | void mpeg_get_debugdata(struct mpeg_debug *dbgdata) | 411 | void audio_get_debugdata(struct audio_debug *dbgdata) |
411 | { | 412 | { |
412 | dbgdata->mp3buflen = mp3buflen; | 413 | dbgdata->mp3buflen = mp3buflen; |
413 | dbgdata->mp3buf_write = mp3buf_write; | 414 | dbgdata->mp3buf_write = mp3buf_write; |
@@ -1264,7 +1265,7 @@ static void mpeg_thread(void) | |||
1264 | } | 1265 | } |
1265 | 1266 | ||
1266 | case MPEG_FF_REWIND: { | 1267 | case MPEG_FF_REWIND: { |
1267 | struct mp3entry *id3 = mpeg_current_track(); | 1268 | struct mp3entry *id3 = audio_current_track(); |
1268 | unsigned int oldtime = id3->elapsed; | 1269 | unsigned int oldtime = id3->elapsed; |
1269 | unsigned int newtime = (unsigned int)ev.data; | 1270 | unsigned int newtime = (unsigned int)ev.data; |
1270 | int curpos, newpos, diffpos; | 1271 | int curpos, newpos, diffpos; |
@@ -1272,7 +1273,7 @@ static void mpeg_thread(void) | |||
1272 | 1273 | ||
1273 | id3->elapsed = newtime; | 1274 | id3->elapsed = newtime; |
1274 | 1275 | ||
1275 | newpos = mpeg_get_file_pos(); | 1276 | newpos = audio_get_file_pos(); |
1276 | if(newpos < 0) | 1277 | if(newpos < 0) |
1277 | { | 1278 | { |
1278 | id3->elapsed = oldtime; | 1279 | id3->elapsed = oldtime; |
@@ -1808,7 +1809,7 @@ static void mpeg_thread(void) | |||
1808 | { | 1809 | { |
1809 | if(errno == ENOSPC) | 1810 | if(errno == ENOSPC) |
1810 | { | 1811 | { |
1811 | mpeg_errno = MPEGERR_DISK_FULL; | 1812 | mpeg_errno = AUDIOERR_DISK_FULL; |
1812 | demand_irq_enable(false); | 1813 | demand_irq_enable(false); |
1813 | stop_recording(); | 1814 | stop_recording(); |
1814 | queue_post(&mpeg_queue, MPEG_STOP_DONE, 0); | 1815 | queue_post(&mpeg_queue, MPEG_STOP_DONE, 0); |
@@ -1830,7 +1831,7 @@ static void mpeg_thread(void) | |||
1830 | { | 1831 | { |
1831 | if(errno == ENOSPC) | 1832 | if(errno == ENOSPC) |
1832 | { | 1833 | { |
1833 | mpeg_errno = MPEGERR_DISK_FULL; | 1834 | mpeg_errno = AUDIOERR_DISK_FULL; |
1834 | demand_irq_enable(false); | 1835 | demand_irq_enable(false); |
1835 | stop_recording(); | 1836 | stop_recording(); |
1836 | queue_post(&mpeg_queue, MPEG_STOP_DONE, 0); | 1837 | queue_post(&mpeg_queue, MPEG_STOP_DONE, 0); |
@@ -1902,7 +1903,7 @@ static void mpeg_thread(void) | |||
1902 | { | 1903 | { |
1903 | if(errno == ENOSPC) | 1904 | if(errno == ENOSPC) |
1904 | { | 1905 | { |
1905 | mpeg_errno = MPEGERR_DISK_FULL; | 1906 | mpeg_errno = AUDIOERR_DISK_FULL; |
1906 | stop_recording(); | 1907 | stop_recording(); |
1907 | queue_post(&mpeg_queue, MPEG_STOP_DONE, 0); | 1908 | queue_post(&mpeg_queue, MPEG_STOP_DONE, 0); |
1908 | break; | 1909 | break; |
@@ -2013,7 +2014,7 @@ void mpeg_id3_options(bool _v1first) | |||
2013 | v1first = _v1first; | 2014 | v1first = _v1first; |
2014 | } | 2015 | } |
2015 | 2016 | ||
2016 | struct mp3entry* mpeg_current_track() | 2017 | struct mp3entry* audio_current_track() |
2017 | { | 2018 | { |
2018 | #ifdef SIMULATOR | 2019 | #ifdef SIMULATOR |
2019 | return &taginfo; | 2020 | return &taginfo; |
@@ -2025,7 +2026,7 @@ struct mp3entry* mpeg_current_track() | |||
2025 | #endif /* #ifdef SIMULATOR */ | 2026 | #endif /* #ifdef SIMULATOR */ |
2026 | } | 2027 | } |
2027 | 2028 | ||
2028 | struct mp3entry* mpeg_next_track() | 2029 | struct mp3entry* audio_next_track() |
2029 | { | 2030 | { |
2030 | #ifdef SIMULATOR | 2031 | #ifdef SIMULATOR |
2031 | return &taginfo; | 2032 | return &taginfo; |
@@ -2037,7 +2038,7 @@ struct mp3entry* mpeg_next_track() | |||
2037 | #endif /* #ifdef SIMULATOR */ | 2038 | #endif /* #ifdef SIMULATOR */ |
2038 | } | 2039 | } |
2039 | 2040 | ||
2040 | bool mpeg_has_changed_track(void) | 2041 | bool audio_has_changed_track(void) |
2041 | { | 2042 | { |
2042 | if(last_track_counter != current_track_counter) | 2043 | if(last_track_counter != current_track_counter) |
2043 | { | 2044 | { |
@@ -2048,7 +2049,7 @@ bool mpeg_has_changed_track(void) | |||
2048 | } | 2049 | } |
2049 | 2050 | ||
2050 | #if CONFIG_HWCODEC == MAS3587F | 2051 | #if CONFIG_HWCODEC == MAS3587F |
2051 | void mpeg_init_playback(void) | 2052 | void audio_init_playback(void) |
2052 | { | 2053 | { |
2053 | init_playback_done = false; | 2054 | init_playback_done = false; |
2054 | queue_post(&mpeg_queue, MPEG_INIT_PLAYBACK, NULL); | 2055 | queue_post(&mpeg_queue, MPEG_INIT_PLAYBACK, NULL); |
@@ -2407,7 +2408,7 @@ void mpeg_set_recording_gain(int left, int right, bool use_mic) | |||
2407 | } | 2408 | } |
2408 | 2409 | ||
2409 | /* try to make some kind of beep, also in recording mode */ | 2410 | /* try to make some kind of beep, also in recording mode */ |
2410 | void mpeg_beep(int duration) | 2411 | void audio_beep(int duration) |
2411 | { | 2412 | { |
2412 | long starttick = current_tick; | 2413 | long starttick = current_tick; |
2413 | do | 2414 | do |
@@ -2495,7 +2496,7 @@ void bitswap(unsigned char *data, int length) | |||
2495 | (void)length; | 2496 | (void)length; |
2496 | } | 2497 | } |
2497 | 2498 | ||
2498 | void mpeg_init_playback(void) | 2499 | void audio_init_playback(void) |
2499 | { | 2500 | { |
2500 | /* a dummy */ | 2501 | /* a dummy */ |
2501 | } | 2502 | } |
@@ -2504,7 +2505,7 @@ unsigned long mpeg_recorded_time(void) | |||
2504 | /* a dummy */ | 2505 | /* a dummy */ |
2505 | return 0; | 2506 | return 0; |
2506 | } | 2507 | } |
2507 | void mpeg_beep(int duration) | 2508 | void audio_beep(int duration) |
2508 | { | 2509 | { |
2509 | /* a dummy */ | 2510 | /* a dummy */ |
2510 | (void)duration; | 2511 | (void)duration; |
@@ -2558,7 +2559,7 @@ void mpeg_set_recording_options(int frequency, int quality, | |||
2558 | } | 2559 | } |
2559 | #endif | 2560 | #endif |
2560 | 2561 | ||
2561 | void mpeg_play(int offset) | 2562 | void audio_play(int offset) |
2562 | { | 2563 | { |
2563 | #ifdef SIMULATOR | 2564 | #ifdef SIMULATOR |
2564 | char* trackname; | 2565 | char* trackname; |
@@ -2595,7 +2596,7 @@ void mpeg_play(int offset) | |||
2595 | mpeg_errno = 0; | 2596 | mpeg_errno = 0; |
2596 | } | 2597 | } |
2597 | 2598 | ||
2598 | void mpeg_stop(void) | 2599 | void audio_stop(void) |
2599 | { | 2600 | { |
2600 | #ifndef SIMULATOR | 2601 | #ifndef SIMULATOR |
2601 | mpeg_stop_done = false; | 2602 | mpeg_stop_done = false; |
@@ -2610,7 +2611,7 @@ void mpeg_stop(void) | |||
2610 | 2611 | ||
2611 | } | 2612 | } |
2612 | 2613 | ||
2613 | void mpeg_pause(void) | 2614 | void audio_pause(void) |
2614 | { | 2615 | { |
2615 | #ifndef SIMULATOR | 2616 | #ifndef SIMULATOR |
2616 | queue_post(&mpeg_queue, MPEG_PAUSE, NULL); | 2617 | queue_post(&mpeg_queue, MPEG_PAUSE, NULL); |
@@ -2621,7 +2622,7 @@ void mpeg_pause(void) | |||
2621 | #endif /* #ifndef SIMULATOR */ | 2622 | #endif /* #ifndef SIMULATOR */ |
2622 | } | 2623 | } |
2623 | 2624 | ||
2624 | void mpeg_resume(void) | 2625 | void audio_resume(void) |
2625 | { | 2626 | { |
2626 | #ifndef SIMULATOR | 2627 | #ifndef SIMULATOR |
2627 | queue_post(&mpeg_queue, MPEG_RESUME, NULL); | 2628 | queue_post(&mpeg_queue, MPEG_RESUME, NULL); |
@@ -2632,7 +2633,7 @@ void mpeg_resume(void) | |||
2632 | #endif /* #ifndef SIMULATOR */ | 2633 | #endif /* #ifndef SIMULATOR */ |
2633 | } | 2634 | } |
2634 | 2635 | ||
2635 | void mpeg_next(void) | 2636 | void audio_next(void) |
2636 | { | 2637 | { |
2637 | #ifndef SIMULATOR | 2638 | #ifndef SIMULATOR |
2638 | queue_post(&mpeg_queue, MPEG_NEXT, NULL); | 2639 | queue_post(&mpeg_queue, MPEG_NEXT, NULL); |
@@ -2660,7 +2661,7 @@ void mpeg_next(void) | |||
2660 | #endif /* #ifndef SIMULATOR */ | 2661 | #endif /* #ifndef SIMULATOR */ |
2661 | } | 2662 | } |
2662 | 2663 | ||
2663 | void mpeg_prev(void) | 2664 | void audio_prev(void) |
2664 | { | 2665 | { |
2665 | #ifndef SIMULATOR | 2666 | #ifndef SIMULATOR |
2666 | queue_post(&mpeg_queue, MPEG_PREV, NULL); | 2667 | queue_post(&mpeg_queue, MPEG_PREV, NULL); |
@@ -2687,7 +2688,7 @@ void mpeg_prev(void) | |||
2687 | #endif /* #ifndef SIMULATOR */ | 2688 | #endif /* #ifndef SIMULATOR */ |
2688 | } | 2689 | } |
2689 | 2690 | ||
2690 | void mpeg_ff_rewind(int newtime) | 2691 | void audio_ff_rewind(int newtime) |
2691 | { | 2692 | { |
2692 | #ifndef SIMULATOR | 2693 | #ifndef SIMULATOR |
2693 | queue_post(&mpeg_queue, MPEG_FF_REWIND, (void *)newtime); | 2694 | queue_post(&mpeg_queue, MPEG_FF_REWIND, (void *)newtime); |
@@ -2696,43 +2697,43 @@ void mpeg_ff_rewind(int newtime) | |||
2696 | #endif /* #ifndef SIMULATOR */ | 2697 | #endif /* #ifndef SIMULATOR */ |
2697 | } | 2698 | } |
2698 | 2699 | ||
2699 | void mpeg_flush_and_reload_tracks(void) | 2700 | void audio_flush_and_reload_tracks(void) |
2700 | { | 2701 | { |
2701 | #ifndef SIMULATOR | 2702 | #ifndef SIMULATOR |
2702 | queue_post(&mpeg_queue, MPEG_FLUSH_RELOAD, NULL); | 2703 | queue_post(&mpeg_queue, MPEG_FLUSH_RELOAD, NULL); |
2703 | #endif /* #ifndef SIMULATOR*/ | 2704 | #endif /* #ifndef SIMULATOR*/ |
2704 | } | 2705 | } |
2705 | 2706 | ||
2706 | int mpeg_status(void) | 2707 | int audio_status(void) |
2707 | { | 2708 | { |
2708 | int ret = 0; | 2709 | int ret = 0; |
2709 | 2710 | ||
2710 | if(is_playing) | 2711 | if(is_playing) |
2711 | ret |= MPEG_STATUS_PLAY; | 2712 | ret |= AUDIO_STATUS_PLAY; |
2712 | 2713 | ||
2713 | if(paused) | 2714 | if(paused) |
2714 | ret |= MPEG_STATUS_PAUSE; | 2715 | ret |= AUDIO_STATUS_PAUSE; |
2715 | 2716 | ||
2716 | #if CONFIG_HWCODEC == MAS3587F | 2717 | #if CONFIG_HWCODEC == MAS3587F |
2717 | if(is_recording && !is_prerecording) | 2718 | if(is_recording && !is_prerecording) |
2718 | ret |= MPEG_STATUS_RECORD; | 2719 | ret |= AUDIO_STATUS_RECORD; |
2719 | 2720 | ||
2720 | if(is_prerecording) | 2721 | if(is_prerecording) |
2721 | ret |= MPEG_STATUS_PRERECORD; | 2722 | ret |= AUDIO_STATUS_PRERECORD; |
2722 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 2723 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ |
2723 | 2724 | ||
2724 | if(mpeg_errno) | 2725 | if(mpeg_errno) |
2725 | ret |= MPEG_STATUS_ERROR; | 2726 | ret |= AUDIO_STATUS_ERROR; |
2726 | 2727 | ||
2727 | return ret; | 2728 | return ret; |
2728 | } | 2729 | } |
2729 | 2730 | ||
2730 | unsigned int mpeg_error(void) | 2731 | unsigned int audio_error(void) |
2731 | { | 2732 | { |
2732 | return mpeg_errno; | 2733 | return mpeg_errno; |
2733 | } | 2734 | } |
2734 | 2735 | ||
2735 | void mpeg_error_clear(void) | 2736 | void audio_error_clear(void) |
2736 | { | 2737 | { |
2737 | mpeg_errno = 0; | 2738 | mpeg_errno = 0; |
2738 | } | 2739 | } |
@@ -2745,21 +2746,21 @@ static void mpeg_thread(void) | |||
2745 | struct mp3entry* id3; | 2746 | struct mp3entry* id3; |
2746 | while ( 1 ) { | 2747 | while ( 1 ) { |
2747 | if (is_playing) { | 2748 | if (is_playing) { |
2748 | id3 = mpeg_current_track(); | 2749 | id3 = audio_current_track(); |
2749 | if (!paused) | 2750 | if (!paused) |
2750 | { | 2751 | { |
2751 | id3->elapsed+=1000; | 2752 | id3->elapsed+=1000; |
2752 | id3->offset+=1000; | 2753 | id3->offset+=1000; |
2753 | } | 2754 | } |
2754 | if (id3->elapsed>=id3->length) | 2755 | if (id3->elapsed>=id3->length) |
2755 | mpeg_next(); | 2756 | audio_next(); |
2756 | } | 2757 | } |
2757 | sleep(HZ); | 2758 | sleep(HZ); |
2758 | } | 2759 | } |
2759 | } | 2760 | } |
2760 | #endif /* #ifdef SIMULATOR */ | 2761 | #endif /* #ifdef SIMULATOR */ |
2761 | 2762 | ||
2762 | void mpeg_init(void) | 2763 | void audio_init(void) |
2763 | { | 2764 | { |
2764 | mpeg_errno = 0; | 2765 | mpeg_errno = 0; |
2765 | 2766 | ||