diff options
author | Brandon Low <lostlogic@rockbox.org> | 2006-01-21 23:43:57 +0000 |
---|---|---|
committer | Brandon Low <lostlogic@rockbox.org> | 2006-01-21 23:43:57 +0000 |
commit | 8d5a6609a33f3269bc80975b81e0e859a056d952 (patch) | |
tree | 9bef78c29941956fc6473f58e1657624c150f2d5 /apps/abrepeat.h | |
parent | 0a9179cb0a4bda8191fcfcb45404ea361fcacdc5 (diff) | |
download | rockbox-8d5a6609a33f3269bc80975b81e0e859a056d952.tar.gz rockbox-8d5a6609a33f3269bc80975b81e0e859a056d952.zip |
AB-repeat mode for software codecs. Accessible through menu as a repeat mode, with buttom mappings much like those on other rockbox targets for now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8409 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/abrepeat.h')
-rw-r--r-- | apps/abrepeat.h | 80 |
1 files changed, 74 insertions, 6 deletions
diff --git a/apps/abrepeat.h b/apps/abrepeat.h index 113a1f5ee6..143e57b371 100644 --- a/apps/abrepeat.h +++ b/apps/abrepeat.h | |||
@@ -20,27 +20,95 @@ | |||
20 | #define _ABREPEAT_H_ | 20 | #define _ABREPEAT_H_ |
21 | 21 | ||
22 | #include "system.h" | 22 | #include "system.h" |
23 | #include <stdbool.h> | ||
24 | 23 | ||
25 | #ifdef AB_REPEAT_ENABLE | 24 | #ifdef AB_REPEAT_ENABLE |
25 | #include "audio.h" | ||
26 | #include "kernel.h" | ||
27 | #include <stdbool.h> | ||
26 | 28 | ||
27 | #define AB_MARKER_NONE 0 | 29 | #define AB_MARKER_NONE 0 |
28 | 30 | ||
31 | #if (AB_REPEAT_ENABLE == 1) | ||
32 | #include "settings.h" | ||
33 | #endif | ||
34 | |||
29 | void ab_repeat_init(void); | 35 | void ab_repeat_init(void); |
30 | bool ab_repeat_mode_enabled(void); // test if a/b repeat is enabled | ||
31 | bool ab_A_marker_set(void); | ||
32 | bool ab_B_marker_set(void); | ||
33 | unsigned int ab_get_A_marker(void); | 36 | unsigned int ab_get_A_marker(void); |
34 | unsigned int ab_get_B_marker(void); | 37 | unsigned int ab_get_B_marker(void); |
35 | bool ab_reached_B_marker(unsigned int song_position); | ||
36 | bool ab_before_A_marker(unsigned int song_position); | 38 | bool ab_before_A_marker(unsigned int song_position); |
37 | bool ab_after_A_marker(unsigned int song_position); | 39 | bool ab_after_A_marker(unsigned int song_position); |
38 | void ab_jump_to_A_marker(void); | 40 | void ab_jump_to_A_marker(void); |
39 | void ab_reset_markers(void); | 41 | void ab_reset_markers(void); |
40 | void ab_set_A_marker(unsigned int song_position); | 42 | void ab_set_A_marker(unsigned int song_position); |
41 | void ab_set_B_marker(unsigned int song_position); | 43 | void ab_set_B_marker(unsigned int song_position); |
44 | #if (CONFIG_CODEC == SWCODEC) | ||
45 | void ab_end_of_track_report(void); | ||
46 | #endif | ||
42 | #ifdef HAVE_LCD_BITMAP | 47 | #ifdef HAVE_LCD_BITMAP |
43 | void ab_draw_markers(int capacity, int x, int y, int w, int h); | 48 | #include "screen_access.h" |
49 | void ab_draw_markers(struct screen * screen, int capacity, | ||
50 | int x, int y, int h); | ||
51 | #endif | ||
52 | |||
53 | /* These functions really need to be inlined for speed */ | ||
54 | extern unsigned int ab_A_marker; | ||
55 | extern unsigned int ab_B_marker; | ||
56 | |||
57 | static inline bool ab_A_marker_set(void) | ||
58 | { | ||
59 | return ab_A_marker != AB_MARKER_NONE; | ||
60 | } | ||
61 | |||
62 | static inline bool ab_B_marker_set(void) | ||
63 | { | ||
64 | return ab_B_marker != AB_MARKER_NONE; | ||
65 | } | ||
66 | |||
67 | static inline bool ab_repeat_mode_enabled(void) | ||
68 | { | ||
69 | #if (AB_REPEAT_ENABLE == 2) | ||
70 | return ab_A_marker_set() || ab_B_marker_set(); | ||
71 | #else | ||
72 | return global_settings.repeat_mode == REPEAT_AB; | ||
73 | #endif | ||
74 | } | ||
75 | |||
76 | static inline bool ab_reached_B_marker(unsigned int song_position) | ||
77 | { | ||
78 | /* following is the size of the window in which we'll detect that the B marker | ||
79 | was hit; it must be larger than the frequency (in milliseconds) at which this | ||
80 | function is called otherwise detection of the B marker will be unreliable */ | ||
81 | #if (CONFIG_CODEC == SWCODEC) | ||
82 | /* On swcodec, the worst case seems to be 9600kHz with 1024 samples between | ||
83 | * calls, meaning ~9 calls per second, look within 1/5 of a second */ | ||
84 | #define B_MARKER_DETECT_WINDOW 200 | ||
85 | #else | ||
86 | /* we assume that this function will be called on each system tick and derive | ||
87 | the window size from this with a generous margin of error (note: the number | ||
88 | of ticks per second is given by HZ) */ | ||
89 | #define B_MARKER_DETECT_WINDOW ((1000/HZ)*10) | ||
90 | #endif | ||
91 | if (ab_B_marker != AB_MARKER_NONE) | ||
92 | { | ||
93 | if ( (song_position >= ab_B_marker) | ||
94 | && (song_position <= (ab_B_marker+B_MARKER_DETECT_WINDOW)) ) | ||
95 | return true; | ||
96 | } | ||
97 | return false; | ||
98 | } | ||
99 | |||
100 | #if (CONFIG_CODEC == SWCODEC) | ||
101 | static inline void ab_position_report(unsigned long position) | ||
102 | { | ||
103 | if (ab_repeat_mode_enabled()) | ||
104 | { | ||
105 | if ( !(audio_status() & AUDIO_STATUS_PAUSE) && | ||
106 | ab_reached_B_marker(position) ) | ||
107 | { | ||
108 | ab_jump_to_A_marker(); | ||
109 | } | ||
110 | } | ||
111 | } | ||
44 | #endif | 112 | #endif |
45 | 113 | ||
46 | #endif | 114 | #endif |