diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2009-07-20 05:18:18 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2009-07-20 05:18:18 +0000 |
commit | 24b136f62de82d7419751b6aaeae0ad3d8497bea (patch) | |
tree | b9bcfd07ca26f3da2f0ce500fc39e0719b3cbb8a /apps/cuesheet.c | |
parent | 4c4fb82d9c112ccbcc4c94a7d85fe82d09801844 (diff) | |
download | rockbox-24b136f62de82d7419751b6aaeae0ad3d8497bea.tar.gz rockbox-24b136f62de82d7419751b6aaeae0ad3d8497bea.zip |
rework cuesheet support:
swcodec: search for a .cue during buffering (with the possibility of adding embedded cuesheets later)
hwcodec: search for a .cue when the id3 info for the current track is requested for the first time (disk should be spining so non issue)
major beenfit from this is simplofy cuesheet handling code a bit... if mp3entry.cuesheet != NULL then there is a valid cuesheet.. no need to worry about if its enabled and preloaded.
There is the possibility of putting the next/prev subtrack handling inside the playback code (as well as the id3 updating stuff (see FS#9789 for more info), but thats probably not a good idea.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21978 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/cuesheet.c')
-rw-r--r-- | apps/cuesheet.c | 54 |
1 files changed, 19 insertions, 35 deletions
diff --git a/apps/cuesheet.c b/apps/cuesheet.c index fa1d93f334..aaa2670a40 100644 --- a/apps/cuesheet.c +++ b/apps/cuesheet.c | |||
@@ -43,33 +43,6 @@ | |||
43 | 43 | ||
44 | #define CUE_DIR ROCKBOX_DIR "/cue" | 44 | #define CUE_DIR ROCKBOX_DIR "/cue" |
45 | 45 | ||
46 | struct cuesheet *curr_cue; | ||
47 | |||
48 | #if CONFIG_CODEC != SWCODEC | ||
49 | /* special trickery because the hwcodec playback engine is in firmware/ */ | ||
50 | static bool cuesheet_handler(const char *filename) | ||
51 | { | ||
52 | return cuesheet_is_enabled() && look_for_cuesheet_file(filename, NULL); | ||
53 | } | ||
54 | #endif | ||
55 | |||
56 | void cuesheet_init(void) | ||
57 | { | ||
58 | if (global_settings.cuesheet) { | ||
59 | curr_cue = (struct cuesheet *)buffer_alloc(sizeof(struct cuesheet)); | ||
60 | #if CONFIG_CODEC != SWCODEC | ||
61 | audio_set_cuesheet_callback(cuesheet_handler); | ||
62 | #endif | ||
63 | } else { | ||
64 | curr_cue = NULL; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | bool cuesheet_is_enabled(void) | ||
69 | { | ||
70 | return (curr_cue != NULL); | ||
71 | } | ||
72 | |||
73 | bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path) | 46 | bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path) |
74 | { | 47 | { |
75 | /* DEBUGF("look for cue file\n"); */ | 48 | /* DEBUGF("look for cue file\n"); */ |
@@ -134,7 +107,6 @@ bool parse_cuesheet(char *file, struct cuesheet *cue) | |||
134 | char *s; | 107 | char *s; |
135 | bool utf8 = false; | 108 | bool utf8 = false; |
136 | 109 | ||
137 | DEBUGF("cue parse\n"); | ||
138 | int fd = open_utf8(file,O_RDONLY); | 110 | int fd = open_utf8(file,O_RDONLY); |
139 | if (fd < 0) | 111 | if (fd < 0) |
140 | { | 112 | { |
@@ -293,12 +265,8 @@ void browse_cuesheet(struct cuesheet *cue) | |||
293 | gui_synclist_set_nb_items(&lists, 2*cue->track_count); | 265 | gui_synclist_set_nb_items(&lists, 2*cue->track_count); |
294 | gui_synclist_set_title(&lists, title, 0); | 266 | gui_synclist_set_title(&lists, title, 0); |
295 | 267 | ||
296 | if (id3 && *id3->path && strcmp(id3->path, "No file!")) | ||
297 | { | ||
298 | look_for_cuesheet_file(id3->path, cuepath); | ||
299 | } | ||
300 | 268 | ||
301 | if (id3 && id3->cuesheet_type && !strcmp(cue->path, cuepath)) | 269 | if (id3) |
302 | { | 270 | { |
303 | gui_synclist_select_item(&lists, | 271 | gui_synclist_select_item(&lists, |
304 | 2*cue_find_current_track(cue, id3->elapsed)); | 272 | 2*cue_find_current_track(cue, id3->elapsed)); |
@@ -317,7 +285,7 @@ void browse_cuesheet(struct cuesheet *cue) | |||
317 | if (id3 && *id3->path && strcmp(id3->path, "No file!")) | 285 | if (id3 && *id3->path && strcmp(id3->path, "No file!")) |
318 | { | 286 | { |
319 | look_for_cuesheet_file(id3->path, cuepath); | 287 | look_for_cuesheet_file(id3->path, cuepath); |
320 | if (id3->cuesheet_type && !strcmp(cue->path, cuepath)) | 288 | if (id3->cuesheet && !strcmp(cue->path, cuepath)) |
321 | { | 289 | { |
322 | sel = gui_synclist_get_sel_pos(&lists); | 290 | sel = gui_synclist_get_sel_pos(&lists); |
323 | seek(cue->tracks[sel/2].offset); | 291 | seek(cue->tracks[sel/2].offset); |
@@ -351,8 +319,9 @@ bool display_cuesheet_content(char* filename) | |||
351 | */ | 319 | */ |
352 | bool curr_cuesheet_skip(int direction, unsigned long curr_pos) | 320 | bool curr_cuesheet_skip(int direction, unsigned long curr_pos) |
353 | { | 321 | { |
322 | struct cuesheet *curr_cue = audio_current_track()->cuesheet; | ||
354 | int track = cue_find_current_track(curr_cue, curr_pos); | 323 | int track = cue_find_current_track(curr_cue, curr_pos); |
355 | 324 | ||
356 | if (direction >= 0 && track == curr_cue->track_count - 1) | 325 | if (direction >= 0 && track == curr_cue->track_count - 1) |
357 | { | 326 | { |
358 | /* we want to get out of the cuesheet */ | 327 | /* we want to get out of the cuesheet */ |
@@ -406,6 +375,7 @@ static inline void draw_veritcal_line_mark(struct screen * screen, | |||
406 | void cue_draw_markers(struct screen *screen, unsigned long tracklen, | 375 | void cue_draw_markers(struct screen *screen, unsigned long tracklen, |
407 | int x1, int x2, int y, int h) | 376 | int x1, int x2, int y, int h) |
408 | { | 377 | { |
378 | struct cuesheet *curr_cue = audio_current_track()->cuesheet; | ||
409 | int i,xi; | 379 | int i,xi; |
410 | int w = x2 - x1; | 380 | int w = x2 - x1; |
411 | for (i=1; i < curr_cue->track_count; i++) | 381 | for (i=1; i < curr_cue->track_count; i++) |
@@ -415,3 +385,17 @@ void cue_draw_markers(struct screen *screen, unsigned long tracklen, | |||
415 | } | 385 | } |
416 | } | 386 | } |
417 | #endif | 387 | #endif |
388 | |||
389 | bool cuesheet_subtrack_changed(struct mp3entry *id3) | ||
390 | { | ||
391 | struct cuesheet *cue = id3->cuesheet; | ||
392 | if (cue && (id3->elapsed < cue->curr_track->offset | ||
393 | || (cue->curr_track_idx < cue->track_count - 1 | ||
394 | && id3->elapsed >= (cue->curr_track+1)->offset))) | ||
395 | { | ||
396 | cue_find_current_track(cue, id3->elapsed); | ||
397 | cue_spoof_id3(cue, id3); | ||
398 | return true; | ||
399 | } | ||
400 | return false; | ||
401 | } | ||