summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/cuesheet.c37
-rw-r--r--apps/cuesheet.h2
-rw-r--r--apps/gui/gwps-common.c6
-rw-r--r--apps/metadata.c2
-rw-r--r--apps/playback.c6
5 files changed, 29 insertions, 24 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/ */
46static bool cuesheet_handler(const char *filename) 48static 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
71bool look_for_cuesheet_file(const char *trackpath) 73bool 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
90static char *skip_whitespace(char* buf) 102static 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);
diff --git a/apps/cuesheet.h b/apps/cuesheet.h
index 51e38605ca..3fe9c1f453 100644
--- a/apps/cuesheet.h
+++ b/apps/cuesheet.h
@@ -58,7 +58,7 @@ bool cuesheet_is_enabled(void);
58void cuesheet_init(void); 58void cuesheet_init(void);
59 59
60/* looks if there is a cuesheet file that has a name matching "trackpath" */ 60/* looks if there is a cuesheet file that has a name matching "trackpath" */
61bool look_for_cuesheet_file(const char *trackpath); 61bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path);
62 62
63/* parse cuesheet "file" and store the information in "cue" */ 63/* parse cuesheet "file" and store the information in "cue" */
64bool parse_cuesheet(char *file, struct cuesheet *cue); 64bool parse_cuesheet(char *file, struct cuesheet *cue);
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 5524c1490e..b25168f252 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -389,11 +389,9 @@ bool update(struct gui_wps *gwps)
389 /* We need to parse the new cuesheet */ 389 /* We need to parse the new cuesheet */
390 390
391 char cuepath[MAX_PATH]; 391 char cuepath[MAX_PATH];
392 strncpy(cuepath, gwps->state->id3->path, MAX_PATH);
393 char *dot = strrchr(cuepath, '.');
394 strcpy(dot, ".cue");
395 392
396 if (parse_cuesheet(cuepath, curr_cue)) 393 if (look_for_cuesheet_file(gwps->state->id3->path, cuepath) &&
394 parse_cuesheet(cuepath, curr_cue))
397 { 395 {
398 gwps->state->id3->cuesheet_type = 1; 396 gwps->state->id3->cuesheet_type = 1;
399 strcpy(curr_cue->audio_filename, gwps->state->id3->path); 397 strcpy(curr_cue->audio_filename, gwps->state->id3->path);
diff --git a/apps/metadata.c b/apps/metadata.c
index 54bb40413e..430bd3cbe5 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -2369,7 +2369,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
2369 /* We have successfully read the metadata from the file */ 2369 /* We have successfully read the metadata from the file */
2370 2370
2371#ifndef __PCTOOL__ 2371#ifndef __PCTOOL__
2372 if (cuesheet_is_enabled() && look_for_cuesheet_file(trackname)) 2372 if (cuesheet_is_enabled() && look_for_cuesheet_file(trackname, NULL))
2373 { 2373 {
2374 track->id3.cuesheet_type = 1; 2374 track->id3.cuesheet_type = 1;
2375 } 2375 }
diff --git a/apps/playback.c b/apps/playback.c
index abc2e9ef30..25dec7a9ff 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -2762,13 +2762,11 @@ static bool audio_load_track(int offset, bool start_play, bool rebuffer)
2762 if (cuesheet_is_enabled() && tracks[track_widx].id3.cuesheet_type == 1) 2762 if (cuesheet_is_enabled() && tracks[track_widx].id3.cuesheet_type == 1)
2763 { 2763 {
2764 char cuepath[MAX_PATH]; 2764 char cuepath[MAX_PATH];
2765 strncpy(cuepath, trackname, MAX_PATH);
2766 char *dot = strrchr(cuepath, '.');
2767 strcpy(dot, ".cue");
2768 2765
2769 struct cuesheet *cue = start_play ? curr_cue : temp_cue; 2766 struct cuesheet *cue = start_play ? curr_cue : temp_cue;
2770 2767
2771 if (parse_cuesheet(cuepath, cue)) 2768 if (look_for_cuesheet_file(trackname, cuepath) &&
2769 parse_cuesheet(cuepath, cue))
2772 { 2770 {
2773 strcpy((cue)->audio_filename, trackname); 2771 strcpy((cue)->audio_filename, trackname);
2774 if (start_play) 2772 if (start_play)