diff options
author | Steve Bavin <pondlife@pondlife.me> | 2006-10-30 08:54:48 +0000 |
---|---|---|
committer | Steve Bavin <pondlife@pondlife.me> | 2006-10-30 08:54:48 +0000 |
commit | 145ec81d2f879482fbfe192dcf39350f36bda3d7 (patch) | |
tree | 3aca57766370602bf49be1a1e88eaafed9df6fd2 /apps/playback.c | |
parent | f40f0debcbada2ef635872b9c4d352b7416bf721 (diff) | |
download | rockbox-145ec81d2f879482fbfe192dcf39350f36bda3d7.tar.gz rockbox-145ec81d2f879482fbfe192dcf39350f36bda3d7.zip |
Rearrange and comment variable declarations; no functional change
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11391 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 159 |
1 files changed, 72 insertions, 87 deletions
diff --git a/apps/playback.c b/apps/playback.c index feeb61a3ff..53dd05866e 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -154,14 +154,6 @@ enum { | |||
154 | #endif | 154 | #endif |
155 | #define CODEC_IRAM_SIZE 0xc000 | 155 | #define CODEC_IRAM_SIZE 0xc000 |
156 | 156 | ||
157 | #ifdef PLAYBACK_VOICE | ||
158 | #ifdef SIMULATOR | ||
159 | static unsigned char sim_iram[CODEC_IRAM_SIZE]; | ||
160 | #undef CODEC_IRAM_ORIGIN | ||
161 | #define CODEC_IRAM_ORIGIN sim_iram | ||
162 | #endif | ||
163 | #endif | ||
164 | |||
165 | #ifndef SIMULATOR | 157 | #ifndef SIMULATOR |
166 | extern bool audio_is_initialized; | 158 | extern bool audio_is_initialized; |
167 | #else | 159 | #else |
@@ -169,87 +161,66 @@ static bool audio_is_initialized = false; | |||
169 | #endif | 161 | #endif |
170 | 162 | ||
171 | 163 | ||
164 | /* Variables are commented with the threads that use them: * | ||
165 | * A=audio, C=codec, V=voice. A suffix of - indicates that * | ||
166 | * the variable is read but not updated on that thread. */ | ||
172 | 167 | ||
173 | static struct mutex mutex_codecthread; | 168 | /* Main state control */ |
174 | static struct event_queue codec_callback_queue; | 169 | static struct event_queue codec_callback_queue; /* Queue for codec callback responses */ |
175 | 170 | static volatile bool audio_codec_loaded; /* Is codec loaded? (C/A-) */ | |
176 | static volatile bool audio_codec_loaded; | 171 | static volatile bool playing; /* Is audio playing? (A) */ |
177 | static volatile bool playing; | 172 | static volatile bool paused; /* Is audio paused? (A/C-) */ |
178 | static volatile bool paused; | 173 | static volatile bool filling IDATA_ATTR; /* Is file buffer currently being refilled? (A/C-) */ |
179 | |||
180 | /* Is file buffer currently being refilled? */ | ||
181 | static volatile bool filling IDATA_ATTR; | ||
182 | |||
183 | volatile int current_codec IDATA_ATTR; | ||
184 | extern unsigned char codecbuf[]; | ||
185 | 174 | ||
186 | /* Ring buffer where tracks and codecs are loaded. */ | 175 | /* Ring buffer where tracks and codecs are loaded */ |
187 | static char *filebuf; | 176 | static char *filebuf; /* Pointer to start of ring buffer (A/C-) */ |
177 | size_t filebuflen; /* Total size of the ring buffer FIXME: make static (A/C-)*/ | ||
178 | static volatile size_t buf_ridx IDATA_ATTR; /* Ring buffer read position (A/C) FIXME? should be (C/A-) */ | ||
179 | static volatile size_t buf_widx IDATA_ATTR; /* Ring buffer read position (A/C-) */ | ||
188 | 180 | ||
189 | /* Total size of the ring buffer. */ | ||
190 | size_t filebuflen; | ||
191 | |||
192 | /* Ring buffer read and write indexes. */ | ||
193 | static volatile size_t buf_ridx IDATA_ATTR; | ||
194 | static volatile size_t buf_widx IDATA_ATTR; | ||
195 | |||
196 | /* Ring buffer arithmetic */ | ||
197 | #define RINGBUF_ADD(p,v) ((p+v)<filebuflen ? p+v : p+v-filebuflen) | 181 | #define RINGBUF_ADD(p,v) ((p+v)<filebuflen ? p+v : p+v-filebuflen) |
198 | #define RINGBUF_SUB(p,v) ((p>=v) ? p-v : p+filebuflen-v) | 182 | #define RINGBUF_SUB(p,v) ((p>=v) ? p-v : p+filebuflen-v) |
199 | #define RINGBUF_ADD_CROSS(p1,v,p2) ((p1<p2)?(int)(p1+v)-(int)p2:(int)(p1+v-p2)-(int)filebuflen) | 183 | #define RINGBUF_ADD_CROSS(p1,v,p2) ((p1<p2)?(int)(p1+v)-(int)p2:(int)(p1+v-p2)-(int)filebuflen) |
184 | #define FILEBUFUSED RINGBUF_SUB(buf_widx, buf_ridx) /* Bytes available in the buffer */ | ||
200 | 185 | ||
201 | /* Bytes available in the buffer. */ | 186 | /* Track info buffer */ |
202 | #define FILEBUFUSED RINGBUF_SUB(buf_widx, buf_ridx) | 187 | static struct track_info tracks[MAX_TRACK]; /* Track info structure about songs in the file buffer (A/C-) */ |
203 | 188 | static volatile int track_ridx; /* Track being decoded (A/C-) */ | |
204 | /* Codec swapping pointers */ | 189 | static int track_widx; /* Track being buffered (A) */ |
205 | static unsigned char *iram_buf[2]; | 190 | static bool track_changed; /* Set to indicate track has changed (A) */ |
206 | static unsigned char *dram_buf[2]; | 191 | static struct track_info *prev_ti; /* Pointer to previous track played info (A/C-) */ |
207 | |||
208 | /* Step count to the next unbuffered track. */ | ||
209 | static int last_peek_offset; /* Audio thread */ | ||
210 | |||
211 | /* Track information (count in file buffer, read/write indexes for | ||
212 | track ring structure. */ | ||
213 | static int track_ridx; | ||
214 | static int track_widx; | ||
215 | static bool track_changed; /* Audio and codec threads */ | ||
216 | 192 | ||
217 | /* Partially loaded song's file handle to continue buffering later. */ | 193 | #define CUR_TI (&tracks[track_ridx]) /* Pointer to current track playing info (A/C-) */ |
218 | static int current_fd; | ||
219 | 194 | ||
220 | /* Track info structure about songs in the file buffer. */ | 195 | /* Audio buffering controls */ |
221 | static struct track_info tracks[MAX_TRACK]; /* Audio thread */ | 196 | static int last_peek_offset; /* Step count to the next unbuffered track (A) */ |
197 | static int current_fd; /* Partially loaded track file handle to continue buffering (A) */ | ||
222 | 198 | ||
223 | /* Pointer to track info structure about current song playing. */ | 199 | /* Scrobbler support */ |
224 | #define CUR_TI (&tracks[track_ridx]) | 200 | static unsigned long prev_track_elapsed; /* Previous track elapsed time (C/A-) */ |
225 | 201 | ||
226 | /* Pointer to track info structure about previous played song. */ | 202 | /* Track change controls */ |
227 | static struct track_info *prev_ti; /* Audio and codec threads */ | 203 | static bool automatic_skip = false; /* Was the skip being executed manual or automatic? (C/A-) */ |
204 | static bool playlist_end = false; /* Have we reached end of the current playlist? (A) */ | ||
205 | static bool dir_skip = false; /* Is a directory skip pending? (A) */ | ||
206 | static bool new_playlist = false; /* Are we starting a new playlist? (A) */ | ||
207 | static int wps_offset = 0; /* Pending track change offset, to keep WPS responsive (A) */ | ||
228 | 208 | ||
229 | /* Have we reached end of the current playlist. */ | 209 | /* Callbacks.. */ |
230 | static bool playlist_end = false; /* Audio thread */ | 210 | void (*track_changed_callback)(struct mp3entry *id3); /* ...when current track has really changed */ |
231 | 211 | void (*track_buffer_callback)(struct mp3entry *id3, bool last_track); /* ...when track has been buffered */ | |
232 | /* Was the skip being executed manual or automatic? */ | 212 | void (*track_unbuffer_callback)(struct mp3entry *id3, bool last_track); /* ...when track is being unbuffered */ |
233 | static bool automatic_skip = false; /* Audio and codec threads */ | ||
234 | static bool dir_skip = false; /* Audio thread */ | ||
235 | static bool new_playlist = false; /* Audio thread */ | ||
236 | static int wps_offset = 0; | ||
237 | |||
238 | /* Callback function to call when current track has really changed. */ | ||
239 | void (*track_changed_callback)(struct mp3entry *id3); | ||
240 | void (*track_buffer_callback)(struct mp3entry *id3, bool last_track); | ||
241 | void (*track_unbuffer_callback)(struct mp3entry *id3, bool last_track); | ||
242 | 213 | ||
243 | /* Configuration */ | 214 | /* Configuration */ |
244 | static size_t conf_watermark; | 215 | static size_t conf_watermark; /* Low water mark (A/C) FIXME */ |
245 | static size_t conf_filechunk; | 216 | static size_t conf_filechunk; /* Largest chunk the codec accepts (A/C) FIXME */ |
246 | static size_t conf_preseek; | 217 | static size_t conf_preseek; /* Codec pre-seek margin (A/C) FIXME */ |
247 | static size_t buffer_margin; | 218 | static size_t buffer_margin; /* Buffer margin aka anti-skip buffer (A/C-) */ |
248 | static bool v1first = false; | 219 | static bool v1first = false; /* ID3 data control, true if V1 then V2 (A) */ |
249 | 220 | ||
250 | /* Multiple threads */ | 221 | /* Multiple threads */ |
251 | static const char * get_codec_filename(int enc_spec); | 222 | static const char *get_codec_filename(int enc_spec); /* Returns codec filename (A-/C-/V-) */ |
252 | static void set_filebuf_watermark(int seconds); | 223 | static void set_filebuf_watermark(int seconds); /* Set low watermark (A/C) FIXME */ |
253 | 224 | ||
254 | /* Audio thread */ | 225 | /* Audio thread */ |
255 | static struct event_queue audio_queue; | 226 | static struct event_queue audio_queue; |
@@ -267,34 +238,48 @@ static struct event_queue codec_queue; | |||
267 | static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] | 238 | static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] |
268 | IBSS_ATTR; | 239 | IBSS_ATTR; |
269 | static const char codec_thread_name[] = "codec"; | 240 | static const char codec_thread_name[] = "codec"; |
270 | /* For modifying thread priority later. */ | 241 | struct thread_entry *codec_thread_p; /* For modifying thread priority later. */ |
271 | struct thread_entry *codec_thread_p; | 242 | |
243 | volatile int current_codec IDATA_ATTR; /* Current codec (normal/voice) */ | ||
272 | 244 | ||
273 | /* Voice thread */ | 245 | /* Voice thread */ |
274 | #ifdef PLAYBACK_VOICE | 246 | #ifdef PLAYBACK_VOICE |
275 | extern struct codec_api ci_voice; | ||
276 | 247 | ||
277 | /* Play time of the previous track */ | 248 | extern struct codec_api ci_voice; |
278 | unsigned long prev_track_elapsed; | ||
279 | 249 | ||
280 | static volatile bool voice_thread_start; | ||
281 | static volatile bool voice_is_playing; | ||
282 | static volatile bool voice_codec_loaded; | ||
283 | static void (*voice_getmore)(unsigned char** start, int* size); | ||
284 | static char *voicebuf; | ||
285 | static size_t voice_remaining; | ||
286 | static struct thread_entry *voice_thread_p = NULL; | 250 | static struct thread_entry *voice_thread_p = NULL; |
287 | |||
288 | static struct event_queue voice_queue; | 251 | static struct event_queue voice_queue; |
289 | static long voice_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] | 252 | static long voice_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] |
290 | IBSS_ATTR; | 253 | IBSS_ATTR; |
291 | static const char voice_thread_name[] = "voice codec"; | 254 | static const char voice_thread_name[] = "voice codec"; |
255 | |||
256 | /* Voice codec swapping control */ | ||
257 | extern unsigned char codecbuf[]; /* DRAM codec swap buffer */ | ||
258 | |||
259 | #ifdef SIMULATOR | ||
260 | static unsigned char sim_iram[CODEC_IRAM_SIZE]; /* IRAM codec swap buffer for sim*/ | ||
261 | #undef CODEC_IRAM_ORIGIN | ||
262 | #define CODEC_IRAM_ORIGIN sim_iram | ||
263 | #endif | ||
264 | |||
265 | static unsigned char *iram_buf[2]; /* Ptr to IRAM buffers for normal/voice codecs */ | ||
266 | static unsigned char *dram_buf[2]; /* Ptr to DRAM buffers for normal/voice codecs */ | ||
267 | static struct mutex mutex_codecthread; /* Mutex to control which codec (normal/voice) is running */ | ||
268 | |||
269 | /* Voice state */ | ||
270 | static volatile bool voice_thread_start; /* Set to trigger voice playback (A/V) */ | ||
271 | static volatile bool voice_is_playing; /* Is voice currently playing? (V) */ | ||
272 | static volatile bool voice_codec_loaded; /* Is voice codec loaded (V/A-) */ | ||
273 | static char *voicebuf; | ||
274 | static size_t voice_remaining; | ||
275 | |||
276 | static void (*voice_getmore)(unsigned char** start, int* size); | ||
277 | |||
292 | struct voice_info { | 278 | struct voice_info { |
293 | void (*callback)(unsigned char **start, int *size); | 279 | void (*callback)(unsigned char **start, int *size); |
294 | int size; | 280 | int size; |
295 | char *buf; | 281 | char *buf; |
296 | }; | 282 | }; |
297 | |||
298 | static void voice_thread(void); | 283 | static void voice_thread(void); |
299 | 284 | ||
300 | #endif /* PLAYBACK_VOICE */ | 285 | #endif /* PLAYBACK_VOICE */ |
@@ -1585,7 +1570,7 @@ static void codec_configure_callback(int setting, void *value) | |||
1585 | static void codec_track_changed(void) | 1570 | static void codec_track_changed(void) |
1586 | { | 1571 | { |
1587 | automatic_skip = false; | 1572 | automatic_skip = false; |
1588 | track_changed = true; | 1573 | track_changed = true; /* FIXME: should only be updated on the audio thread? */ |
1589 | LOGFQUEUE("codec > audio Q_AUDIO_TRACK_CHANGED"); | 1574 | LOGFQUEUE("codec > audio Q_AUDIO_TRACK_CHANGED"); |
1590 | queue_post(&audio_queue, Q_AUDIO_TRACK_CHANGED, 0); | 1575 | queue_post(&audio_queue, Q_AUDIO_TRACK_CHANGED, 0); |
1591 | } | 1576 | } |