Index: apps/bookmark.c =================================================================== --- apps/bookmark.c (revision 25494) +++ 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 @@ -71,6 +72,10 @@ #define F_REP_MOD 0x040 #define F_SHUFFLE 0x080 +/* flags for optional bookmark tokens */ +#define F_PIT_RAT 0x100 +#define F_TIM_STR 0x200 + static struct bookmark_values { int resume_index; @@ -80,6 +85,9 @@ long resume_time; int repeat_mode; bool shuffle; + /* optional values */ + int pitch_ratio; + int timestretch; } bm; #define CHECK_BOOKMARK(bookmark) parse_bookmark(bookmark, 0) @@ -341,9 +349,15 @@ 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;%d;%ld;%d;%d;%d;%d;%s;%s", + BMARK_OPTS, resume_index, id3->offset, playlist_get_seed(NULL), @@ -351,6 +365,10 @@ 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); @@ -898,12 +916,18 @@ static bool play_bookmark(const char* bookmark) { const int flags = F_BMFILES | F_RES_IND | F_RES_OFF | F_RES_SED | - F_REP_MOD | F_SHUFFLE; + F_REP_MOD | F_SHUFFLE | 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); } @@ -967,7 +991,18 @@ const char* end; #define FLAG(a) (flags & a) +#define INFLAG(a) (in_flags & a) + /* if new format bookmark, extract the optional content flags, + otherwise treat as an original format bookmark */ + int in_flags = 0; + if (strstr(s, "bmark") == s) + { + s = skip_token(s); + s = int_token(s, true, &in_flags); + } + + /* extract all original bookmark tokens */ s = int_token(s, FLAG(F_RES_IND), &bm.resume_index); s = int_token(s, FLAG(F_RES_OFF), &bm.resume_offset); s = int_token(s, FLAG(F_RES_SED), &bm.resume_seed); @@ -975,6 +1010,15 @@ s = long_token(s, FLAG(F_RES_TIM), &bm.resume_time); s = int_token(s, FLAG(F_REP_MOD), &bm.repeat_mode); s = bool_token(s, FLAG(F_SHUFFLE), &bm.shuffle); + + /* extract all optional bookmark tokens */ + if (in_flags) + { + if (INFLAG(F_PIT_RAT)) + s = int_token(s, FLAG(F_PIT_RAT), &bm.pitch_ratio); + if (INFLAG(F_TIM_STR)) + s = int_token(s, FLAG(F_TIM_STR), &bm.timestretch); + } if (*s == 0) {