From ab0f7e17ef225f2db908276f903d1354b7777618 Mon Sep 17 00:00:00 2001 From: Stéphane Doyon Date: Sun, 4 May 2008 13:47:58 +0000 Subject: Accept FS#6188: study mode. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17355 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 34 +++++++++++++ apps/gui/gwps-common.h | 1 + apps/gui/gwps.c | 127 +++++++++++++++++++++++++++++++------------------ 3 files changed, 116 insertions(+), 46 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index ed4ca17b2a..bcb82df100 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -78,6 +78,7 @@ static void gui_wps_statusbar_draw(struct gui_wps *wps, bool force) #define gui_wps_statusbar_draw(wps, force) \ gui_statusbar_draw((wps)->statusbar, (force)) #endif +#include "pcmbuf.h" /* fades the volume */ void fade(bool fade_in) @@ -143,6 +144,39 @@ bool update_onvol_change(struct gui_wps * gwps) return false; } +void play_hop(int direction) +{ + if(!wps_state.id3 || !wps_state.id3->length + || global_settings.study_hop_step == 0) + return; +#define STEP ((unsigned)global_settings.study_hop_step *1000) + if(direction == 1 + && wps_state.id3->length - wps_state.id3->elapsed < STEP+1000) { +#if CONFIG_CODEC == SWCODEC + if(global_settings.beep) + pcmbuf_beep(1000, 150, 1500*global_settings.beep); +#endif + return; + } + if((direction == -1 && wps_state.id3->elapsed < STEP)) + wps_state.id3->elapsed = 0; + else + wps_state.id3->elapsed += STEP *direction; + if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused) { +#if (CONFIG_CODEC == SWCODEC) + audio_pre_ff_rewind(); +#else + audio_pause(); +#endif + } + audio_ff_rewind(wps_state.id3->elapsed); +#if (CONFIG_CODEC != SWCODEC) + if (!wps_state.paused) + audio_resume(); +#endif +#undef STEP +} + bool ffwd_rew(int button) { unsigned int step = 0; /* current ff/rewind step */ diff --git a/apps/gui/gwps-common.h b/apps/gui/gwps-common.h index 76555c1c06..23080254f2 100644 --- a/apps/gui/gwps-common.h +++ b/apps/gui/gwps-common.h @@ -27,6 +27,7 @@ void fade(bool fade_in); bool gui_wps_display(void); bool update_onvol_change(struct gui_wps * gwps); bool update(struct gui_wps *gwps); +void play_hop(int direction); bool ffwd_rew(int button); void display_keylock_text(bool locked); diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 2e72813d73..28aea4945f 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -90,6 +90,51 @@ static void gui_wps_set_margin(struct gui_wps *gwps) } #endif +static void prev_track(unsigned skip_thresh) +{ + if (!wps_state.id3 || (wps_state.id3->elapsed < skip_thresh*1000)) { + audio_prev(); + } + else { + if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) + { + curr_cuesheet_skip(-1, wps_state.id3->elapsed); + return; + } + + if (!wps_state.paused) +#if (CONFIG_CODEC == SWCODEC) + audio_pre_ff_rewind(); +#else + audio_pause(); +#endif + + audio_ff_rewind(0); + +#if (CONFIG_CODEC != SWCODEC) + if (!wps_state.paused) + audio_resume(); +#endif + } +} + +void next_track(void) +{ + /* take care of if we're playing a cuesheet */ + if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) + { + if (curr_cuesheet_skip(1, wps_state.id3->elapsed)) + { + /* if the result was false, then we really want + to skip to the next track */ + return; + } + } + + audio_next(); +} + + long gui_wps_show(void) { long button = 0; @@ -335,11 +380,13 @@ long gui_wps_show(void) } break; /* fast forward - OR next dir if this is straight after ACTION_WPS_SKIPNEXT */ + OR next dir if this is straight after ACTION_WPS_SKIPNEXT + OR in study mode, next track if straight after SKIPPREV. */ case ACTION_WPS_SEEKFWD: if (global_settings.party_mode) break; - if (current_tick -last_right < HZ) + if (!global_settings.study_mode + && current_tick -last_right < HZ) { if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) { @@ -350,15 +397,23 @@ long gui_wps_show(void) audio_next_dir(); } } + else if(global_settings.study_mode + && current_tick -last_left < HZ) { + next_track(); + update_track = true; + } else ffwd_rew(ACTION_WPS_SEEKFWD); - last_right = 0; + last_right = last_left = 0; break; /* fast rewind - OR prev dir if this is straight after ACTION_WPS_SKIPPREV */ + OR prev dir if this is straight after ACTION_WPS_SKIPPREV, + OR in study mode, beg of track or prev track if this is + straight after SKIPPREV */ case ACTION_WPS_SEEKBACK: if (global_settings.party_mode) break; - if (current_tick -last_left < HZ) + if (!global_settings.study_mode + && current_tick -last_left < HZ) { if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) { @@ -375,8 +430,14 @@ long gui_wps_show(void) audio_prev_dir(); } } + else if(global_settings.study_mode + && current_tick -last_right < HZ) + { + prev_track(3+global_settings.study_hop_step); + update_track = true; + } else ffwd_rew(ACTION_WPS_SEEKBACK); - last_left = 0; + last_left = last_right = 0; break; /* prev / restart */ @@ -404,34 +465,13 @@ long gui_wps_show(void) /* ...otherwise, do it normally */ #endif - if (!wps_state.id3 || (wps_state.id3->elapsed < 3*1000)) { - audio_prev(); - } - else { - - if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) - { - curr_cuesheet_skip(-1, wps_state.id3->elapsed); - break; - } - - if (!wps_state.paused) -#if (CONFIG_CODEC == SWCODEC) - audio_pre_ff_rewind(); -#else - audio_pause(); -#endif - - audio_ff_rewind(0); - -#if (CONFIG_CODEC != SWCODEC) - if (!wps_state.paused) - audio_resume(); -#endif - } + if(global_settings.study_mode) + play_hop(-1); + else prev_track(3); break; - /* next */ + /* next + OR in study mode, hop by predetermined amount. */ case ACTION_WPS_SKIPNEXT: if (global_settings.party_mode) break; @@ -456,18 +496,9 @@ long gui_wps_show(void) /* ...otherwise, do it normally */ #endif - /* take care of if we're playing a cuesheet */ - if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) - { - if (curr_cuesheet_skip(1, wps_state.id3->elapsed)) - { - /* if the result was false, then we really want - to skip to the next track */ - break; - } - } - - audio_next(); + if(global_settings.study_mode) + play_hop(1); + else next_track(); break; /* next / prev directories */ /* and set A-B markers if in a-b mode */ @@ -484,7 +515,9 @@ long gui_wps_show(void) else #endif { - audio_next_dir(); + if(global_settings.study_mode) + next_track(); + else audio_next_dir(); } break; case ACTION_WPS_ABSETA_PREVDIR: @@ -496,7 +529,9 @@ long gui_wps_show(void) else #endif { - audio_prev_dir(); + if(global_settings.study_mode) + prev_track(3); + else audio_prev_dir(); } break; /* menu key functions */ -- cgit v1.2.3