1
0
Fork 0
forked from len0rd/rockbox

Added Benjamin Metzlers bookmarking feature (patch #669440)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4227 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2004-01-14 00:13:04 +00:00
parent 50b6358272
commit a108ec2ebd
17 changed files with 1545 additions and 42 deletions

1105
apps/bookmark.c Normal file

File diff suppressed because it is too large Load diff

33
apps/bookmark.h Normal file
View file

@ -0,0 +1,33 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2003 by Benjamin Metzler
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef __BOOKMARK_H__
#define __BOOKMARK_H__
#include <stdbool.h>
bool bookmark_menu(void);
bool bookmark_autobookmark(void);
bool bookmark_create_menu(void);
bool bookmark_mrb_load(void);
bool bookmark_autoload(char* file);
bool bookmark_load(char* file, bool autoload);
void bookmark_play(char* resume_file, int index, int offset, int seed);
#endif /* __BOOKMARK_H__ */

View file

@ -1848,6 +1848,128 @@ desc: in settings_menu, option to turn display+buttos by 180 degreed
eng: "Upside Down"
new:
#Auto bookmark prompts
id: LANG_BOOKMARK_AUTOLOAD_QUERY
desc: prompt for user to decide to create a bookmark
eng: "Load Last Bookmark?"
new:
id: LANG_AUTO_BOOKMARK_QUERY
desc: prompt for user to decide to create an bookmark
eng: "Create a Bookmark?"
new:
# Bookmark Select Menu Text
id: LANG_BOOKMARK_SELECT_LIST_BOOKMARKS
desc: From the auto-load screen, allows user to list all bookmarks
eng: "Down = List"
new:
id: LANG_BOOKMARK_SELECT_EXIT
desc: From the bookmark list screen, allows user to exit
eng: "OFF = Exit"
new:
id: LANG_BOOKMARK_SELECT_BOOKMARK_TEXT
desc: Used on the bookmark select window to label bookmark number
eng: "Bookmark"
new:
id: LANG_BOOKMARK_SELECT_INDEX_TEXT
desc: Used on the bookmark select window to label index number
eng: "Index"
new:
id: LANG_BOOKMARK_SELECT_TIME_TEXT
desc: Used on the bookmark select window to label elapsed time
eng: "Time"
new:
id: LANG_BOOKMARK_SELECT_PLAY
desc: Used on the bookmark select window to indicated the play option
eng: "PLAY = Select"
new:
id: LANG_BOOKMARK_SELECT_DELETE
desc: Used on the bookmark select window to indicated the bookmark delete option
eng: "ON+Play = Delete"
new:
# Bookmark creation/failure text
id: LANG_BOOKMARK_CREATE_SUCCESS
desc: Indicates bookmark was successfully created
eng: "Bookmark Created"
new:
id: LANG_BOOKMARK_CREATE_FAILURE
desc: Indicates bookmark was not created
eng: "Bookmark Failed!"
new:
# Bookmark creation/failure text
id: LANG_BOOKMARK_LOAD_EMPTY
desc: Indicates bookmark was empty
eng: "Bookmark Empty"
new:
# Bookmark Settings Text
id: LANG_BOOKMARK_SETTINGS
desc: in general settings
eng: "Bookmarking"
new:
id: LANG_BOOKMARK_SETTINGS_AUTOLOAD
desc: prompt for user to decide to create a bookmark
eng: "Load Last Bookmark"
new:
id: LANG_BOOKMARK_SETTINGS_AUTOCREATE
desc: prompt for user to decide to create an bookmark
eng: "Bookmark on Stop"
new:
id: LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS
desc: Configuration option to maintain a list of recent bookmarks
eng: "Maintain a List of Recent Bookmarks?"
new:
id: LANG_BOOKMARK_SETTINGS_RECENT_ONLY_YES
desc: Save in recent bookmarks only
eng: "Yes - Recent only"
new:
id: LANG_BOOKMARK_SETTINGS_RECENT_ONLY_ASK
desc: Save in recent bookmarks only
eng: "Ask - Recent only"
new:
id: LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY
desc: Save only on bookmark for each playlist in recent bookmarks
eng: "Unique only"
new:
# Main Bookmarks Menu
id: LANG_BOOKMARK_MENU
desc: Text on main menu to get to bookmark commands
eng: "Bookmarks"
new:
id: LANG_BOOKMARK_MENU_CREATE
desc: Used off of the bookmark menu to create a bookmark
eng: "Create Bookmark"
new:
id: LANG_BOOKMARK_MENU_LIST
desc: Used off of the bookmark menu to list available bookmarks for the currently playing directory or M3U
eng: "List Bookmarks"
new:
id: LANG_BOOKMARK_MENU_RECENT_BOOKMARKS
desc: Text for the menu text to access the most recent bookmarks list
eng: "Recent Bookmarks"
new:
id: LANG_RECORD_PRERECORD
desc: in recording and radio screen
eng: "Prerecording"

View file

@ -40,6 +40,7 @@
#include "status.h"
#include "fat.h"
#include "sleeptimer.h"
#include "bookmark.h"
#include "wps.h"
#include "buffer.h"
#include "screens.h"
@ -269,7 +270,10 @@ bool main_menu(void)
int i = 0;
/* main menu */
struct menu_items items[14];
struct menu_items items[15];
items[i].desc = str(LANG_BOOKMARK_MENU);
items[i++].function = bookmark_menu;
items[i].desc = str(LANG_SOUND_SETTINGS);
items[i++].function = sound_menu;

View file

@ -172,6 +172,10 @@ static void empty_playlist(bool resume)
playlist.first_index = 0;
playlist.amount = 0;
playlist.last_insert_pos = -1;
playlist.seed = 0;
playlist.shuffle_modified = false;
playlist.deleted = false;
playlist.num_inserted_tracks = 0;
playlist.shuffle_flush = false;
if (!resume)
@ -412,6 +416,7 @@ static int add_track_to_playlist(char *filename, int position, bool queue,
playlist.indices[insert_position] = flags | seek_pos;
playlist.amount++;
playlist.num_inserted_tracks++;
return insert_position;
}
@ -528,16 +533,24 @@ static int add_directory_to_playlist(char *dirname, int *position, bool queue,
static int remove_track_from_playlist(int position, bool write)
{
int i;
bool inserted;
if (playlist.amount <= 0)
return -1;
inserted = playlist.indices[position] & PLAYLIST_INSERT_TYPE_MASK;
/* shift indices now that track has been removed */
for (i=position; i<playlist.amount; i++)
playlist.indices[i] = playlist.indices[i+1];
playlist.amount--;
if (inserted)
playlist.num_inserted_tracks--;
else
playlist.deleted = true;
/* update stored indices if needed */
if (position < playlist.index)
playlist.index--;
@ -622,6 +635,10 @@ static int randomise_playlist(unsigned int seed, bool start_current, bool write)
/* indices have been moved so last insert position is no longer valid */
playlist.last_insert_pos = -1;
playlist.seed = seed;
if (playlist.num_inserted_tracks > 0 || playlist.deleted)
playlist.shuffle_modified = true;
if (write)
{
/* Don't write to disk immediately. Instead, save in settings and
@ -652,6 +669,8 @@ static int sort_playlist(bool start_current, bool write)
/* indices have been moved so last insert position is no longer valid */
playlist.last_insert_pos = -1;
if (!playlist.num_inserted_tracks && !playlist.deleted)
playlist.shuffle_modified = false;
if (write && playlist.control_fd >= 0)
{
/* Don't write to disk immediately. Instead, save in settings and
@ -1898,9 +1917,26 @@ int playlist_next(int steps)
return index;
}
bool playlist_modified(void)
{
if ((mpeg_status() & MPEG_STATUS_PLAY))
{
if (playlist.shuffle_modified ||
playlist.deleted ||
playlist.num_inserted_tracks > 0)
return true;
}
return false;
}
int playlist_get_seed(void)
{
return playlist.seed;
}
/* Get resume info for current playing song. If return value is -1 then
settings shouldn't be saved. */
int playlist_get_resume_info(short *resume_index)
int playlist_get_resume_info(int *resume_index)
{
*resume_index = playlist.index;
@ -1924,6 +1960,16 @@ int playlist_get_first_index(void)
return playlist.first_index;
}
char *playlist_get_name(char *buf, int buf_size)
{
snprintf(buf, buf_size, "%s", playlist.filename);
if (!buf[0])
return NULL;
return buf;
}
/* returns number of tracks in playlist (includes queued/inserted tracks) */
int playlist_amount(void)
{
@ -1937,12 +1983,12 @@ char *playlist_name(char *buf, int buf_size)
snprintf(buf, buf_size, "%s", playlist.filename+playlist.dirlen);
if (0 == buf[0])
if (!buf[0])
return NULL;
/* Remove extension */
sep = strrchr(buf, '.');
if (NULL != sep)
if (sep)
*sep = 0;
return buf;
@ -2043,8 +2089,7 @@ int playlist_save(char *filename)
if (fprintf(fd, "%s\n", tmp_buf) < 0)
{
splash(HZ*2, true,
str(LANG_PLAYLIST_CONTROL_UPDATE_ERROR));
splash(HZ*2, true, str(LANG_PLAYLIST_CONTROL_UPDATE_ERROR));
result = -1;
break;
}

View file

@ -39,11 +39,16 @@ struct playlist_info
char *buffer; /* buffer for in-ram playlists */
int buffer_size; /* size of buffer */
int buffer_end_pos; /* last position where buffer was written */
short index; /* index of current playing track */
short first_index; /* index of first song in playlist */
int index; /* index of current playing track */
int first_index; /* index of first song in playlist */
int amount; /* number of tracks in the index */
int last_insert_pos; /* last position we inserted a track */
bool shuffle_flush; /* Does shuffle value need to be flushed? */
int seed; /* shuffle seed */
bool shuffle_modified; /* has playlist been shuffled with
inserted tracks? */
bool deleted; /* have any tracks been deleted? */
int num_inserted_tracks; /* number of tracks inserted */
bool shuffle_flush; /* does shuffle value need to be flushed? */
struct mutex control_mutex; /* mutex for control file access */
};
@ -75,13 +80,16 @@ int playlist_start(int start_index, int offset);
bool playlist_check(int steps);
char *playlist_peek(int steps);
int playlist_next(int steps);
int playlist_get_resume_info(short *resume_index);
int playlist_get_resume_info(int *resume_index);
int playlist_get_display_index(void);
int playlist_get_first_index(void);
int playlist_amount(void);
char *playlist_name(char *buf, int buf_size);
int playlist_get_track_info(int index, struct playlist_track_info* info);
int playlist_save(char *filename);
int playlist_get_seed(void);
char *playlist_get_name(char *buf, int buf_size);
bool playlist_modified(void);
enum {
PLAYLIST_PREPEND = -1,

View file

@ -80,7 +80,7 @@ struct playlist_viewer_info {
int char_width; /* Width (in pixels) of a character */
int num_tracks; /* Number of tracks in playlist */
short current_playing_track;/* Index of current playing track */
int current_playing_track; /* Index of current playing track */
int num_loaded; /* Number of track entries loaded in viewer */
int first_index; /* Index of first loaded track */
@ -643,7 +643,7 @@ bool playlist_viewer(void)
while (!exit)
{
short track;
int track;
/* Timeout so we can determine if play status has changed */
button = button_get_w_tmo(HZ/2);

View file

@ -68,6 +68,7 @@ unsigned char bitmap_icons_6x8[LastIcon][6] =
{ 0x2a, 0x7f, 0x41, 0x41, 0x7f, 0x2a }, /* UCL flash file: chip */
{ 0x70, 0x70, 0x7f, 0x7f, 0x70, 0x70 }, /* Chip8 game: joystick */
{ 0x5d, 0x7f, 0x5d, 0x7f, 0x5d, 0x7f }, /* Video file: film strip */
{ 0xff, 0x81, 0xaf, 0xaa, 0x8c, 0xf8 }, /* Bookmark file */
};
unsigned char bitmap_icons_7x8[][7] =

View file

@ -30,6 +30,7 @@ enum icons_6x8 {
Selected, Cursor, Wps, Mod_Ajz,
Font, Language, Text, Config,
Plugin, Flashfile, Chip8, Video,
Bookmark,
LastIcon
};

View file

@ -56,6 +56,7 @@
#include "language.h"
#include "wps-display.h"
#include "powermgmt.h"
#include "bookmark.h"
#include "sprintf.h"
#include "keyboard.h"
#include "version.h"
@ -143,7 +144,7 @@ Rest of config block, only saved to disk:
caption backlight (bit 1)
car adapter mode (bit 2)
line_in (Player only) (bit 3)
0xAF [available/unused]
0xAF <most-recent-bookmarks, auto-bookmark, autoload>
0xB0 peak meter clip hold timeout (bit 0-4), peak meter performance (bit 7)
0xB1 peak meter release step size, peak_meter_dbfs (bit 7)
0xB2 peak meter min either in -db or in percent
@ -419,6 +420,9 @@ int settings_save( void )
((global_settings.caption_backlight & 1) << 1) |
((global_settings.car_adapter_mode & 1) << 2) |
((global_settings.line_in & 1) << 3));
config_block[0xaf] = ((global_settings.usemrb << 5) |
(global_settings.autocreatebookmark << 2) |
(global_settings.autoloadbookmark));
config_block[0xb0] = (unsigned char)global_settings.peak_meter_clip_hold |
(global_settings.peak_meter_performance ? 0x80 : 0);
config_block[0xb1] = global_settings.peak_meter_release |
@ -771,6 +775,9 @@ void settings_load(void)
if (config_block[0xa9] != 0xff)
global_settings.jump_scroll_delay = config_block[0xa9];
#endif
global_settings.usemrb = (config_block[0xaf] >> 5) & 3;
global_settings.autocreatebookmark = (config_block[0xaf] >> 2) & 7;
global_settings.autoloadbookmark = (config_block[0xaf]) & 3;
}
settings_apply();
@ -1128,6 +1135,21 @@ bool settings_load_config(char* file)
set_cfg_option(&global_settings.recursive_dir_insert, value,
options, 3);
}
else if (!strcasecmp(name, "autoload bookmarks"))
{
static char* options[] = {"off", "on", "ask"};
set_cfg_option(&global_settings.autoloadbookmark, value, options, 3);
}
else if (!strcasecmp(name, "autocreate bookmarks"))
{
static char* options[] = {"off", "on", "ask","recent only - yes","recent only - ask"};
set_cfg_option(&global_settings.autocreatebookmark, value, options, 5);
}
else if (!strcasecmp(name, "use most-recent-bookmarks"))
{
static char* options[] = {"off", "on", "unique only"};
set_cfg_option(&global_settings.usemrb, value, options, 3);
}
}
close(fd);
@ -1143,6 +1165,7 @@ bool settings_save_config(void)
int fd, i, value;
char filename[MAX_PATH];
char* boolopt[] = {"off","on"};
char* triopt[] = {"off","on","ask"};
/* find unused filename */
for (i=0; ; i++) {
@ -1431,11 +1454,27 @@ bool settings_save_config(void)
#endif
fprintf(fd, "#\r\n# Bookmarking\r\n#\r\n");
{
fprintf(fd, "autoload bookmarks: %s\r\n",
triopt[global_settings.autoloadbookmark]);
}
{
static char* options[] = {"off", "on", "ask","recent only - on", "recent only - ask"};
fprintf(fd, "autocreate bookmarks: %s\r\n",
options[global_settings.autocreatebookmark]);
}
{
static char* options[] = {"off", "on", "unique only"};
fprintf(fd, "UseMRB: %s\r\n", options[global_settings.usemrb]);
}
fprintf(fd, "#\r\n# Playlists\r\n#\r\n");
{
static char* options[] = {"off", "on", "ask"};
fprintf(fd, "recursive directory insert: %s\r\n",
options[global_settings.recursive_dir_insert]);
triopt[global_settings.recursive_dir_insert]);
}
close(fd);
@ -1528,6 +1567,9 @@ void settings_reset(void) {
global_settings.lang_file[0] = 0;
global_settings.runtime = 0;
global_settings.topruntime = 0;
global_settings.autocreatebookmark = BOOKMARK_NO;
global_settings.autoloadbookmark = BOOKMARK_NO;
global_settings.usemrb = BOOKMARK_NO;
global_settings.fade_on_stop = true;
global_settings.caption_backlight = false;
global_settings.car_adapter_mode = false;

View file

@ -38,6 +38,12 @@
#define RESUME_ASK_ONCE 2
#define RESUME_ON 3
#define BOOKMARK_NO 0
#define BOOKMARK_YES 1
#define BOOKMARK_ASK 2
#define BOOKMARK_UNIQUE_ONLY 2
#define BOOKMARK_RECENT_ONLY_YES 3
#define BOOKMARK_RECENT_ONLY_ASK 4
#define FF_REWIND_1000 0
#define FF_REWIND_2000 1
#define FF_REWIND_3000 2
@ -109,8 +115,8 @@ struct user_settings
/* resume settings */
int resume; /* resume option: 0=off, 1=ask, 2=on */
short resume_index; /* index in playlist (-1 for no active resume) */
short resume_first_index; /* index of first track in playlist */
int resume_index; /* index in playlist (-1 for no active resume) */
int resume_first_index; /* index of first track in playlist */
int resume_offset; /* byte offset in mp3 file */
int resume_seed; /* shuffle seed (-1=no resume shuffle 0=sorted
>0=shuffled) */
@ -161,6 +167,11 @@ struct user_settings
int bidir_limit; /* bidir scroll length limit */
int scroll_delay; /* delay (in 1/10s) before starting scroll */
int scroll_step; /* pixels to advance per update */
/* auto bookmark settings */
int autoloadbookmark; /* auto load option: 0=off, 1=ask, 2=on */
int autocreatebookmark; /* auto create option: 0=off, 1=ask, 2=on */
int usemrb; /* use MRB list: 0=No, 1=Yes*/
#ifdef HAVE_LCD_CHARCELLS
int jump_scroll; /* Fast jump when scrolling */
int jump_scroll_delay; /* Delay between jump scroll screens */
@ -205,6 +216,7 @@ bool set_option(char* string, void* variable, enum optiontype type,
bool set_int(char* string, char* unit, int* variable,
void (*function)(int), int step, int min, int max );
bool set_time(char* string, int timedate[]);
int read_line(int fd, char* buffer, int buffer_size);
void set_file(char* filename, char* setting, int maxlen);
#ifdef HAVE_MAS3587F

View file

@ -438,6 +438,40 @@ static bool resume(void)
names, 4, NULL );
}
static bool autocreatebookmark(void)
{
char* names[] = { str(LANG_SET_BOOL_NO),
str(LANG_SET_BOOL_YES),
str(LANG_RESUME_SETTING_ASK),
str(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_YES),
str(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_ASK) };
return set_option( str(LANG_BOOKMARK_SETTINGS_AUTOCREATE),
&global_settings.autocreatebookmark, INT,
names, 5, NULL );
}
static bool autoloadbookmark(void)
{
char* names[] = { str(LANG_SET_BOOL_NO),
str(LANG_SET_BOOL_YES),
str(LANG_RESUME_SETTING_ASK) };
return set_option( str(LANG_BOOKMARK_SETTINGS_AUTOLOAD),
&global_settings.autoloadbookmark, INT,
names, 3, NULL );
}
static bool useMRB(void)
{
char* names[] = { str(LANG_SET_BOOL_NO),
str(LANG_SET_BOOL_YES),
str(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY)};
return set_option( str(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS),
&global_settings.usemrb, INT,
names, 3, NULL );
}
static bool backlight_on_when_charging(void)
{
bool result = set_bool(str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
@ -789,6 +823,23 @@ static bool playback_settings_menu(void)
return result;
}
static bool bookmark_settings_menu(void)
{
int m;
bool result;
struct menu_items items[] = {
{ str(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark},
{ str(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark},
{ str(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB},
};
m=menu_init( items, sizeof items / sizeof(struct menu_items) );
result = menu_run(m);
menu_exit(m);
return result;
}
static bool reset_settings(void)
{
bool done=false;
@ -966,6 +1017,7 @@ bool settings_menu(void)
{ str(LANG_CUSTOM_FONT), font_browse },
#endif
{ str(LANG_SYSTEM), system_settings_menu },
{ str(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu },
{ str(LANG_SAVE_SETTINGS), settings_save_config },
};

View file

@ -49,6 +49,7 @@
#include "language.h"
#include "screens.h"
#include "keyboard.h"
#include "bookmark.h"
#include "onplay.h"
#include "buffer.h"
#include "plugin.h"
@ -83,6 +84,9 @@ static struct
{ ".fnt", TREE_ATTR_FONT,Font },
{ ".ch8", TREE_ATTR_CH8, Chip8 },
{ ".rvf", TREE_ATTR_RVF, Video },
{ ".bmark",TREE_ATTR_BMARK,Bookmark },
#else
{ ".bmark", TREE_ATTR_BMARK, -1 },
#endif
#ifndef SIMULATOR
#ifdef HAVE_LCD_BITMAP
@ -118,6 +122,7 @@ static int boot_size = 0;
static int boot_cluster;
static bool boot_changed = false;
static bool start_wps = false;
static bool dirbrowse(char *root, int *dirfilter);
void browse_root(void)
@ -646,9 +651,7 @@ static void start_resume(bool ask_once)
playlist_start(global_settings.resume_index,
global_settings.resume_offset);
status_set_playmode(STATUS_PLAY);
status_draw(true);
wps_show();
start_wps = true;
}
else
return;
@ -930,6 +933,7 @@ static bool dirbrowse(char *root, int *dirfilter)
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_OFF:
bookmark_autobookmark();
mpeg_stop();
status_set_playmode(STATUS_STOP);
status_draw(false);
@ -988,6 +992,12 @@ static bool dirbrowse(char *root, int *dirfilter)
lcd_stop_scroll();
switch ( file->attr & TREE_ATTR_MASK ) {
case TREE_ATTR_M3U:
if (bookmark_autoload(buf))
{
restore = true;
break;
}
if (playlist_create(currdir, file->name) != -1)
{
if (global_settings.playlist_shuffle)
@ -999,6 +1009,12 @@ static bool dirbrowse(char *root, int *dirfilter)
break;
case TREE_ATTR_MPA:
if (bookmark_autoload(currdir))
{
restore = true;
break;
}
if (playlist_create(currdir, NULL) != -1)
{
start_index =
@ -1051,6 +1067,12 @@ static bool dirbrowse(char *root, int *dirfilter)
restore = true;
break;
case TREE_ATTR_BMARK:
bookmark_load(buf, false);
restore = true;
reload_dir = true;
break;
case TREE_ATTR_TXT:
plugin_load("/.rockbox/rocks/viewer.rock",buf);
restore = true;
@ -1122,15 +1144,7 @@ static bool dirbrowse(char *root, int *dirfilter)
settings_save();
}
status_set_playmode(STATUS_PLAY);
status_draw(false);
lcd_stop_scroll();
if ( wps_show() == SYS_USB_CONNECTED ) {
reload_root = true;
}
#ifdef HAVE_LCD_BITMAP
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#endif
start_wps = true;
}
else if (*dirfilter > NUM_FILTER_MODES)
exit_func = true;
@ -1238,13 +1252,7 @@ static bool dirbrowse(char *root, int *dirfilter)
{
if (mpeg_status() & MPEG_STATUS_PLAY)
{
lcd_stop_scroll();
if (wps_show() == SYS_USB_CONNECTED)
reload_root = true;
#ifdef HAVE_LCD_BITMAP
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#endif
restore = true;
start_wps=true;
}
else
{
@ -1293,6 +1301,18 @@ static bool dirbrowse(char *root, int *dirfilter)
if ( button )
ata_spin();
if (start_wps)
{
lcd_stop_scroll();
if (wps_show() == SYS_USB_CONNECTED)
reload_root = true;
#ifdef HAVE_LCD_BITMAP
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#endif
restore = true;
start_wps=false;
}
/* do we need to rescan dir? */
if (reload_dir || reload_root ||
lastfilter != *dirfilter ||
@ -1313,6 +1333,7 @@ static bool dirbrowse(char *root, int *dirfilter)
lastfilter = *dirfilter;
lastsortcase = global_settings.sort_case;
restore = true;
while (button_get(false)); /* clear button queue */
}
if (exit_func)
@ -1507,3 +1528,51 @@ void tree_init(void)
name_buffer = buffer_alloc(name_buffer_size);
dircache = buffer_alloc(max_files_in_dir * sizeof(struct entry));
}
void bookmark_play(char *resume_file, int index, int offset, int seed)
{
int len=strlen(resume_file);
if (!strcasecmp(&resume_file[len-4], ".m3u"))
{
char* slash;
// check that the file exists
int fd = open(resume_file, O_RDONLY);
if(fd<0)
return;
close(fd);
slash = strrchr(resume_file,'/');
if (slash)
{
char* cp;
*slash=0;
cp=resume_file;
if (!cp[0])
cp="/";
if (playlist_create(cp, slash+1) != -1)
{
if (global_settings.playlist_shuffle)
playlist_shuffle(seed, -1);
playlist_start(index,offset);
}
*slash='/';
}
}
else
{
lastdir[0]='\0';
if (playlist_create(resume_file, NULL) != -1)
{
resume_directory(resume_file);
if (global_settings.playlist_shuffle)
playlist_shuffle(seed, -1);
playlist_start(index,offset);
}
}
status_set_playmode(STATUS_PLAY);
start_wps=true;
}

View file

@ -39,6 +39,7 @@ struct entry {
#define TREE_ATTR_UCL 0x0A00 /* rockbox flash image */
#define TREE_ATTR_CH8 0x0B00 /* chip-8 game */
#define TREE_ATTR_RVF 0x0C00 /* rockbox video file */
#define TREE_ATTR_BMARK 0x0D00 /* book mark file */
#define TREE_ATTR_MASK 0xFFC0 /* which bits tree.c uses (above) */
void tree_init(void);

View file

@ -45,6 +45,7 @@
#include "peakmeter.h"
#endif
#include "lang.h"
#include "bookmark.h"
#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
/* 3% of 30min file == 54s step size */
@ -943,7 +944,7 @@ int wps_show(void)
case BUTTON_RC_STOP:
#endif
#ifdef BUTTON_OFF
case BUTTON_OFF:
case BUTTON_OFF | BUTTON_REL:
#else
case BUTTON_STOP | BUTTON_REL:
if ( lastbutton != BUTTON_STOP )
@ -985,6 +986,7 @@ int wps_show(void)
fade(0);
lcd_stop_scroll();
bookmark_autobookmark();
mpeg_stop();
status_set_playmode(STATUS_STOP);

View file

@ -102,7 +102,7 @@ FIRMSRCS = $(LCDSRSC) id3.c mp3data.c usb.c mpeg.c mp3_playback.c \
APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \
playlist.c wps.c wps-display.c settings.c status.c \
screens.c peakmeter.c sleeptimer.c keyboard.c onplay.c\
misc.c plugin.c playlist_viewer.c
misc.c plugin.c playlist_viewer.c bookmark.c
MENUS = settings_menu.c sound_menu.c playlist_menu.c
@ -204,6 +204,9 @@ $(OBJDIR)/playlist.o: $(APPDIR)/playlist.c
$(OBJDIR)/playlist_viewer.o: $(APPDIR)/playlist_viewer.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/bookmark.o: $(APPDIR)/bookmark.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/plugin.o: $(APPDIR)/plugin.c plugin-win32.h
$(CC) $(APPCFLAGS) -c $< -o $@

View file

@ -102,7 +102,7 @@ FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\
APPS = main.c tree.c menu.c credits.c main_menu.c language.c\
playlist.c wps.c wps-display.c settings.c status.c icons.c\
screens.c peakmeter.c sleeptimer.c keyboard.c onplay.c\
misc.c plugin.c playlist_viewer.c
misc.c plugin.c playlist_viewer.c bookmark.c
MENUS = settings_menu.c sound_menu.c playlist_menu.c
@ -202,6 +202,9 @@ $(OBJDIR)/playlist.o: $(APPDIR)/playlist.c
$(OBJDIR)/playlist_viewer.o: $(APPDIR)/playlist_viewer.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/bookmark.o: $(APPDIR)/bookmark.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/build.lang: $(APPDIR)/lang/$(LANGUAGE).lang
perl $(TOOLSDIR)/uplang $(APPDIR)/lang/english.lang $< > $@