summaryrefslogtreecommitdiff
path: root/apps/bookmark.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/bookmark.c')
-rw-r--r--apps/bookmark.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index f783c83992..1860d5737b 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -86,7 +86,7 @@ static void say_bookmark(const char* bookmark,
86 int bookmark_id, bool show_playlist_name); 86 int bookmark_id, bool show_playlist_name);
87static bool play_bookmark(const char* bookmark); 87static bool play_bookmark(const char* bookmark);
88static bool generate_bookmark_file_name(const char *in); 88static bool generate_bookmark_file_name(const char *in);
89static bool parse_bookmark(const char *bookmark, const bool get_filenames); 89static bool parse_bookmark(const char *bookmark, const bool get_filenames, const bool strip_dir);
90static int buffer_bookmarks(struct bookmark_list* bookmarks, int first_line); 90static int buffer_bookmarks(struct bookmark_list* bookmarks, int first_line);
91static const char* get_bookmark_info(int list_index, 91static const char* get_bookmark_info(int list_index,
92 void* data, 92 void* data,
@@ -339,7 +339,7 @@ static bool add_bookmark(const char* bookmark_file_name, const char* bookmark,
339 if (most_recent && (bookmark_count >= MAX_BOOKMARKS)) 339 if (most_recent && (bookmark_count >= MAX_BOOKMARKS))
340 break; 340 break;
341 341
342 if (!parse_bookmark(global_read_buffer, false)) 342 if (!parse_bookmark(global_read_buffer, false, false))
343 break; 343 break;
344 344
345 equal = false; 345 equal = false;
@@ -402,6 +402,10 @@ static char* create_bookmark()
402 return NULL; 402 return NULL;
403 403
404 /* create the bookmark */ 404 /* create the bookmark */
405 playlist_get_name(NULL, global_temp_buffer, sizeof(global_temp_buffer));
406 if (global_temp_buffer[strlen(global_temp_buffer) - 1] != '/')
407 file = id3->path;
408 else file++;
405 snprintf(global_bookmark, sizeof(global_bookmark), 409 snprintf(global_bookmark, sizeof(global_bookmark),
406 /* new optional bookmark token descriptors should be inserted 410 /* new optional bookmark token descriptors should be inserted
407 just before the "%s;%s" in this line... */ 411 just before the "%s;%s" in this line... */
@@ -428,12 +432,11 @@ static char* create_bookmark()
428 (long)dsp_get_timestretch(), 432 (long)dsp_get_timestretch(),
429#endif 433#endif
430 /* more mandatory tokens */ 434 /* more mandatory tokens */
431 playlist_get_name(NULL, global_temp_buffer, 435 global_temp_buffer,
432 sizeof(global_temp_buffer)), 436 file);
433 file+1);
434 437
435 /* checking to see if the bookmark is valid */ 438 /* checking to see if the bookmark is valid */
436 if (parse_bookmark(global_bookmark, false)) 439 if (parse_bookmark(global_bookmark, false, false))
437 return global_bookmark; 440 return global_bookmark;
438 else 441 else
439 return NULL; 442 return NULL;
@@ -653,7 +656,7 @@ static const char* get_bookmark_info(int list_index,
653 } 656 }
654 } 657 }
655 658
656 if (!parse_bookmark(bookmarks->items[index - bookmarks->start], true)) 659 if (!parse_bookmark(bookmarks->items[index - bookmarks->start], true, true))
657 { 660 {
658 return list_index % 2 == 0 ? (char*) str(LANG_BOOKMARK_INVALID) : " "; 661 return list_index % 2 == 0 ? (char*) str(LANG_BOOKMARK_INVALID) : " ";
659 } 662 }
@@ -930,7 +933,7 @@ static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id)
930static void say_bookmark(const char* bookmark, 933static void say_bookmark(const char* bookmark,
931 int bookmark_id, bool show_playlist_name) 934 int bookmark_id, bool show_playlist_name)
932{ 935{
933 if (!parse_bookmark(bookmark, true)) 936 if (!parse_bookmark(bookmark, true, false))
934 { 937 {
935 talk_id(LANG_BOOKMARK_INVALID, false); 938 talk_id(LANG_BOOKMARK_INVALID, false);
936 return; 939 return;
@@ -967,16 +970,10 @@ static void say_bookmark(const char* bookmark,
967 970
968#if CONFIG_CODEC == SWCODEC 971#if CONFIG_CODEC == SWCODEC
969 /* Track filename */ 972 /* Track filename */
970 if(is_dir) 973 if(!is_dir)
971 talk_file_or_spell(global_temp_buffer, global_filename, 974 global_temp_buffer[0] = 0;
972 TALK_IDARRAY(VOICE_FILE), true); 975 talk_file_or_spell(global_temp_buffer, global_filename,
973 else 976 TALK_IDARRAY(VOICE_FILE), true);
974 { /* Unfortunately if this is a playlist, we do not know in which
975 directory the file is and therefore cannot find the track's
976 .talk file. */
977 talk_id(VOICE_FILE, true);
978 talk_spell(global_filename, true);
979 }
980#endif 977#endif
981} 978}
982 979
@@ -992,7 +989,7 @@ static bool play_bookmark(const char* bookmark)
992 bm.speed = dsp_get_timestretch(); 989 bm.speed = dsp_get_timestretch();
993#endif 990#endif
994 991
995 if (parse_bookmark(bookmark, true)) 992 if (parse_bookmark(bookmark, true, true))
996 { 993 {
997 global_settings.repeat_mode = bm.repeat_mode; 994 global_settings.repeat_mode = bm.repeat_mode;
998 global_settings.playlist_shuffle = bm.shuffle; 995 global_settings.playlist_shuffle = bm.shuffle;
@@ -1042,7 +1039,7 @@ static const char* long_token(const char* s, long* dest)
1042/* the filename tokens are to be extracted. */ 1039/* the filename tokens are to be extracted. */
1043/* Returns true on successful bookmark parse. */ 1040/* Returns true on successful bookmark parse. */
1044/* ----------------------------------------------------------------------- */ 1041/* ----------------------------------------------------------------------- */
1045static bool parse_bookmark(const char *bookmark, const bool parse_filenames) 1042static bool parse_bookmark(const char *bookmark, const bool parse_filenames, const bool strip_dir)
1046{ 1043{
1047 const char* s = bookmark; 1044 const char* s = bookmark;
1048 const char* end; 1045 const char* end;
@@ -1094,6 +1091,15 @@ static bool parse_bookmark(const char *bookmark, const bool parse_filenames)
1094 if (end != NULL) 1091 if (end != NULL)
1095 { 1092 {
1096 end++; 1093 end++;
1094 if (strip_dir)
1095 {
1096 s = strrchr(end, '/');
1097 if (s)
1098 {
1099 end = s;
1100 end++;
1101 }
1102 }
1097 strlcpy(global_filename, end, MAX_PATH); 1103 strlcpy(global_filename, end, MAX_PATH);
1098 } 1104 }
1099 } 1105 }