FS#10014 - Separate tracklocking out of skip length, skip length prevented to skip tracks. This is a seperate setting now. tracks can still change during normal playback (i.e. a song ends).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20553 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2009-03-27 13:53:29 +00:00
parent e95d33b35e
commit 62f3e95945
5 changed files with 58 additions and 29 deletions

View file

@ -79,10 +79,14 @@ static void wps_state_init(void);
static void prev_track(unsigned skip_thresh) static void prev_track(unsigned skip_thresh)
{ {
if (!wps_state.id3 || (wps_state.id3->elapsed < skip_thresh*1000)) { if (!global_settings.prevent_skip
&& (wps_state.id3->elapsed < skip_thresh*1000))
{
audio_prev(); audio_prev();
return;
} }
else { else
{
if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
{ {
curr_cuesheet_skip(-1, wps_state.id3->elapsed); curr_cuesheet_skip(-1, wps_state.id3->elapsed);
@ -107,6 +111,8 @@ static void prev_track(unsigned skip_thresh)
static void next_track(void) static void next_track(void)
{ {
if (global_settings.prevent_skip)
return;
/* take care of if we're playing a cuesheet */ /* take care of if we're playing a cuesheet */
if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
{ {
@ -125,19 +131,37 @@ static void play_hop(int direction)
{ {
unsigned step = ((unsigned)global_settings.skip_length*1000); unsigned step = ((unsigned)global_settings.skip_length*1000);
unsigned long *elapsed = &(wps_state.id3->elapsed); unsigned long *elapsed = &(wps_state.id3->elapsed);
bool prevent_skip = global_settings.prevent_skip;
if (direction == 1 && wps_state.id3->length - *elapsed < step+1000) { if (direction == 1 && wps_state.id3->length - *elapsed < step+1000)
{
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
if(global_settings.beep) if (prevent_skip)
pcmbuf_beep(1000, 150, 1500*global_settings.beep); {
if(global_settings.beep)
pcmbuf_beep(1000, 150, 1500*global_settings.beep);
}
else
#endif #endif
next_track();
return; return;
} else if ((direction == -1 && *elapsed < step)) { }
*elapsed = 0; else if ((direction == -1 && *elapsed < step))
} else { {
if (!prevent_skip)
{
prev_track(3);
return;
}
else
*elapsed = 0;
}
else
{
*elapsed += step * direction; *elapsed += step * direction;
} }
if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused) { if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused)
{
#if (CONFIG_CODEC == SWCODEC) #if (CONFIG_CODEC == SWCODEC)
audio_pre_ff_rewind(); audio_pre_ff_rewind();
#else #else
@ -421,8 +445,7 @@ long gui_wps_show(void)
} }
break; break;
/* fast forward /* 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 if skip length set, next track if straight after SKIPPREV. */
case ACTION_WPS_SEEKFWD: case ACTION_WPS_SEEKFWD:
if (global_settings.party_mode) if (global_settings.party_mode)
break; break;
@ -438,18 +461,12 @@ long gui_wps_show(void)
audio_next_dir(); audio_next_dir();
} }
} }
else if (global_settings.skip_length > 0 else
&& current_tick -last_left < HZ) { ffwd_rew(ACTION_WPS_SEEKFWD);
next_track();
update_track = true;
}
else ffwd_rew(ACTION_WPS_SEEKFWD);
last_right = last_left = 0; last_right = last_left = 0;
break; break;
/* fast rewind /* 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 if skip length set, beg of track or prev track if this is
straight after SKIPPREV */
case ACTION_WPS_SEEKBACK: case ACTION_WPS_SEEKBACK:
if (global_settings.party_mode) if (global_settings.party_mode)
break; break;
@ -471,13 +488,8 @@ long gui_wps_show(void)
audio_prev_dir(); audio_prev_dir();
} }
} }
else if (global_settings.skip_length > 0 else
&& current_tick -last_right < HZ) ffwd_rew(ACTION_WPS_SEEKBACK);
{
prev_track(3+global_settings.skip_length);
update_track = true;
}
else ffwd_rew(ACTION_WPS_SEEKBACK);
last_left = last_right = 0; last_left = last_right = 0;
break; break;

View file

@ -12453,4 +12453,18 @@
*: none *: none
touchscreen: "Absolute Point" touchscreen: "Absolute Point"
</voice> </voice>
</phrase> </phrase>
<phrase>
id: LANG_PREVENT_SKIPPING
desc: in Settings -> Playback Settings
user: core
<source>
*: "Prevent Skipping"
</source>
<dest>
*: "Prevent Skipping"
</dest>
<voice>
*: "Prevent Skipping"
</voice>
</phrase>

View file

@ -176,6 +176,7 @@ MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON,
#endif #endif
MENUITEM_SETTING(skip_length, &global_settings.skip_length, NULL); MENUITEM_SETTING(skip_length, &global_settings.skip_length, NULL);
MENUITEM_SETTING(prevent_skip, &global_settings.prevent_skip, NULL);
MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0, MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
Icon_Playback_menu, Icon_Playback_menu,
@ -197,7 +198,7 @@ MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
#ifdef HAVE_HEADPHONE_DETECTION #ifdef HAVE_HEADPHONE_DETECTION
,&unplug_menu ,&unplug_menu
#endif #endif
,&skip_length ,&skip_length, &prevent_skip,
); );
static int playback_callback(int action,const struct menu_item_ex *this_item) static int playback_callback(int action,const struct menu_item_ex *this_item)

View file

@ -725,6 +725,7 @@ struct user_settings
#ifdef HAVE_SPEAKER #ifdef HAVE_SPEAKER
bool speaker_enabled; bool speaker_enabled;
#endif #endif
bool prevent_skip;
#ifdef HAVE_TOUCHSCREEN #ifdef HAVE_TOUCHSCREEN
int touch_mode; int touch_mode;

View file

@ -1467,6 +1467,7 @@ const struct settings_list settings[] = {
"touchscreen mode", "point,grid", NULL, 2, "touchscreen mode", "point,grid", NULL, 2,
ID2P(LANG_TOUCHSCREEN_POINT), ID2P(LANG_TOUCHSCREEN_GRID)), ID2P(LANG_TOUCHSCREEN_POINT), ID2P(LANG_TOUCHSCREEN_GRID)),
#endif #endif
OFFON_SETTING(0, prevent_skip, LANG_PREVENT_SKIPPING, false, "prevent_skip", NULL),
}; };
const int nb_settings = sizeof(settings)/sizeof(*settings); const int nb_settings = sizeof(settings)/sizeof(*settings);