diff options
Diffstat (limited to 'apps/cuesheet.c')
-rw-r--r-- | apps/cuesheet.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/apps/cuesheet.c b/apps/cuesheet.c index 9bac3681f3..ce7714fa44 100644 --- a/apps/cuesheet.c +++ b/apps/cuesheet.c | |||
@@ -41,11 +41,13 @@ | |||
41 | #include "playback.h" | 41 | #include "playback.h" |
42 | #include "cuesheet.h" | 42 | #include "cuesheet.h" |
43 | 43 | ||
44 | #define CUE_DIR ROCKBOX_DIR "/cue" | ||
45 | |||
44 | #if CONFIG_CODEC != SWCODEC | 46 | #if CONFIG_CODEC != SWCODEC |
45 | /* special trickery because the hwcodec playback engine is in firmware/ */ | 47 | /* special trickery because the hwcodec playback engine is in firmware/ */ |
46 | static bool cuesheet_handler(const char *filename) | 48 | static bool cuesheet_handler(const char *filename) |
47 | { | 49 | { |
48 | return cuesheet_is_enabled() && look_for_cuesheet_file(filename); | 50 | return cuesheet_is_enabled() && look_for_cuesheet_file(filename, NULL); |
49 | } | 51 | } |
50 | #endif | 52 | #endif |
51 | 53 | ||
@@ -68,8 +70,9 @@ bool cuesheet_is_enabled(void) | |||
68 | return (curr_cue != NULL); | 70 | return (curr_cue != NULL); |
69 | } | 71 | } |
70 | 72 | ||
71 | bool look_for_cuesheet_file(const char *trackpath) | 73 | bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path) |
72 | { | 74 | { |
75 | DEBUGF("look for cue file\n"); | ||
73 | char cuepath[MAX_PATH]; | 76 | char cuepath[MAX_PATH]; |
74 | strncpy(cuepath, trackpath, MAX_PATH); | 77 | strncpy(cuepath, trackpath, MAX_PATH); |
75 | char *dot = strrchr(cuepath, '.'); | 78 | char *dot = strrchr(cuepath, '.'); |
@@ -78,13 +81,22 @@ bool look_for_cuesheet_file(const char *trackpath) | |||
78 | int fd = open(cuepath,O_RDONLY); | 81 | int fd = open(cuepath,O_RDONLY); |
79 | if (fd < 0) | 82 | if (fd < 0) |
80 | { | 83 | { |
81 | return false; | 84 | strcpy(cuepath, CUE_DIR); |
82 | } | 85 | strcat(cuepath, strrchr(trackpath, '/')); |
83 | else | 86 | char *dot = strrchr(cuepath, '.'); |
84 | { | 87 | strcpy(dot, ".cue"); |
85 | close(fd); | 88 | fd = open(cuepath,O_RDONLY); |
86 | return true; | 89 | if (fd < 0) |
90 | { | ||
91 | if (found_cue_path) | ||
92 | found_cue_path = NULL; | ||
93 | return false; | ||
94 | } | ||
87 | } | 95 | } |
96 | close(fd); | ||
97 | if (found_cue_path) | ||
98 | strncpy(found_cue_path, cuepath, MAX_PATH); | ||
99 | return true; | ||
88 | } | 100 | } |
89 | 101 | ||
90 | static char *skip_whitespace(char* buf) | 102 | static char *skip_whitespace(char* buf) |
@@ -122,6 +134,7 @@ bool parse_cuesheet(char *file, struct cuesheet *cue) | |||
122 | char line[MAX_PATH]; | 134 | char line[MAX_PATH]; |
123 | char *s; | 135 | char *s; |
124 | 136 | ||
137 | DEBUGF("cue parse\n"); | ||
125 | int fd = open(file,O_RDONLY); | 138 | int fd = open(file,O_RDONLY); |
126 | if (fd < 0) | 139 | if (fd < 0) |
127 | { | 140 | { |
@@ -271,9 +284,7 @@ void browse_cuesheet(struct cuesheet *cue) | |||
271 | 284 | ||
272 | if (id3 && *id3->path && strcmp(id3->path, "No file!")) | 285 | if (id3 && *id3->path && strcmp(id3->path, "No file!")) |
273 | { | 286 | { |
274 | strncpy(cuepath, id3->path, MAX_PATH); | 287 | look_for_cuesheet_file(id3->path, cuepath); |
275 | dot = strrchr(cuepath, '.'); | ||
276 | strcpy(dot, ".cue"); | ||
277 | } | 288 | } |
278 | 289 | ||
279 | if (id3 && id3->cuesheet_type && !strcmp(cue->path, cuepath)) | 290 | if (id3 && id3->cuesheet_type && !strcmp(cue->path, cuepath)) |
@@ -294,9 +305,7 @@ void browse_cuesheet(struct cuesheet *cue) | |||
294 | id3 = audio_current_track(); | 305 | id3 = audio_current_track(); |
295 | if (id3 && *id3->path && strcmp(id3->path, "No file!")) | 306 | if (id3 && *id3->path && strcmp(id3->path, "No file!")) |
296 | { | 307 | { |
297 | strncpy(cuepath, id3->path, MAX_PATH); | 308 | look_for_cuesheet_file(id3->path, cuepath); |
298 | dot = strrchr(cuepath, '.'); | ||
299 | strcpy(dot, ".cue"); | ||
300 | if (id3->cuesheet_type && !strcmp(cue->path, cuepath)) | 309 | if (id3->cuesheet_type && !strcmp(cue->path, cuepath)) |
301 | { | 310 | { |
302 | sel = gui_synclist_get_sel_pos(&lists); | 311 | sel = gui_synclist_get_sel_pos(&lists); |