Index: apps/bookmark.c =================================================================== --- apps/bookmark.c (revision 25504) +++ apps/bookmark.c (working copy) @@ -42,6 +42,7 @@ #include "plugin.h" #include "file.h" #include "filefuncs.h" +#include "dsp.h" #define MAX_BOOKMARKS 10 #define MAX_BOOKMARK_SIZE 350 @@ -64,6 +65,10 @@ /* bookmark flags */ #define F_BMFILES 0x01 +/* flags for optional bookmark tokens */ +#define F_PIT_RAT 0x10 +#define F_TIM_STR 0x20 + /* bookmark values */ static struct { int resume_index; @@ -72,6 +77,9 @@ long resume_time; int repeat_mode; bool shuffle; + /* optional values */ + int pitch_ratio; + int timestretch; } bm; static bool add_bookmark(const char* bookmark_file_name, const char* bookmark, @@ -332,16 +340,25 @@ if(NULL == file) return NULL; + /* the flags for optional bookmark tokens go here */ +#define BMARK_OPTS (F_PIT_RAT | F_TIM_STR) + /* create the bookmark */ snprintf(global_bookmark, sizeof(global_bookmark), - "%d;%ld;%d;%d;%ld;%d;%d;%s;%s", + /* new optional bookmark token descriptors should be inserted + just before the "%s;%s" in this line... */ + "bmark;%d;%d;%ld;%d;%ld;%d;%d;%d;%d;%s;%s", + BMARK_OPTS, resume_index, id3->offset, playlist_get_seed(NULL), - 0, id3->elapsed, global_settings.repeat_mode, global_settings.playlist_shuffle, + /* ...and their values should go here */ + sound_get_pitch(), + dsp_get_timestretch(), + /* more mandatory tokens */ playlist_get_name(NULL, global_temp_buffer, sizeof(global_temp_buffer)), file+1); @@ -888,12 +905,18 @@ /* ------------------------------------------------------------------------*/ static bool play_bookmark(const char* bookmark) { - const int flags = F_BMFILES; + const int flags = F_BMFILES | F_PIT_RAT | F_TIM_STR; + /* update values to current setting in case bookmark doesn't have info */ + bm.pitch_ratio = sound_get_pitch(); + bm.timestretch = dsp_get_timestretch(); + if (parse_bookmark(bookmark, flags)) { global_settings.repeat_mode = bm.repeat_mode; global_settings.playlist_shuffle = bm.shuffle; + sound_set_pitch(bm.pitch_ratio); + dsp_set_timestretch(bm.timestretch); return bookmark_play(global_temp_buffer, bm.resume_index, bm.resume_offset, bm.resume_seed, global_filename); } @@ -933,18 +956,39 @@ const char* end; #define FLAG(a) (flags & a) +#define INFLAG(a) ((in_flags & a) && FLAG(a)) #define GET_INT_TOKEN(var) s = long_token(s, (long *)&var) #define GET_BOOL_TOKEN(var) var = (atoi(s)!=0); s = skip_token(s) + /* if new format bookmark, extract the optional content flags, + otherwise treat as an original format bookmark */ + int in_flags = 0; + bool new_format = (strstr(s, "bmark") == s); + if (new_format) + { + s = skip_token(s); + GET_INT_TOKEN(in_flags); + } + + /* extract all original bookmark tokens */ GET_INT_TOKEN(bm.resume_index); GET_INT_TOKEN(bm.resume_offset); GET_INT_TOKEN(bm.resume_seed); - /* skip deprecated token */ - s = skip_token(s); + if (!new_format) /* skip deprecated token */ + s = skip_token(s); GET_INT_TOKEN(bm.resume_time); GET_INT_TOKEN(bm.repeat_mode); GET_BOOL_TOKEN(bm.shuffle); + /* extract all optional bookmark tokens */ + if (in_flags) + { + if (INFLAG(F_PIT_RAT)) + GET_INT_TOKEN(bm.pitch_ratio); + if (INFLAG(F_TIM_STR)) + GET_INT_TOKEN(bm.timestretch); + } + if (*s == 0) { return false;