Public feed #726475

Mine

public text v1 · immutable
Raw Edit
·published 2007-10-05 07:25 UTC
rendered paste body
Index: apps/action.h
===================================================================
--- apps/action.h	(revision 14986)
+++ apps/action.h	(working copy)
@@ -100,6 +100,7 @@
     ACTION_WPS_BROWSE,
     ACTION_WPS_PLAY,
     ACTION_WPS_SEEKBACK,
+    ACTION_WPS_STUDY_MODE,
     ACTION_WPS_SEEKFWD,
     ACTION_WPS_STOPSEEK,
     ACTION_WPS_SKIPNEXT,
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang	(revision 14986)
+++ apps/lang/english.lang	(working copy)
@@ -11341,3 +11341,31 @@
     *: "Central Eurpean"
   </voice>
 </phrase>
+ <phrase>
+   id: LANG_STUDY_MODE
+   desc: study mode setting
+   user:
+   <source>
+     *: "Study Mode"
+   </source>
+   <dest>
+     *: "Study Mode"
+   </dest>
+   <voice>
+     *: "Study Mode"
+   </voice>
+ </phrase>
+ <phrase>
+   id: LANG_STUDY_HOP_STEP
+   desc: playback settings menu
+   user:
+   <source>
+     *: "Study Increment"
+   </source>
+   <dest>
+     *: "Study Increment"
+   </dest>
+   <voice>
+     *: "Study Increment"
+   </voice>
+ </phrase>
\ No newline at end of file
Index: apps/gui/gwps-common.c
===================================================================
--- apps/gui/gwps-common.c	(revision 14986)
+++ apps/gui/gwps-common.c	(working copy)
@@ -56,6 +56,7 @@
 #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1))
 #include "backdrop.h"
 #endif
+#include "pcmbuf.h"
 
 #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ 
                                 /* 3% of 30min file == 54s step size */
@@ -142,6 +143,39 @@
     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)
 {
     static const uint16_t ff_rew_steps[] = {
Index: apps/gui/gwps-common.h
===================================================================
--- apps/gui/gwps-common.h	(revision 14986)
+++ apps/gui/gwps-common.h	(working copy)
@@ -27,6 +27,7 @@
 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);
 
Index: apps/gui/gwps.c
===================================================================
--- apps/gui/gwps.c	(revision 14986)
+++ apps/gui/gwps.c	(working copy)
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include "config.h"
 
+#include "talk.h"
 #include "system.h"
 #include "file.h"
 #include "lcd.h"
@@ -92,8 +93,54 @@
 }
 #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)
 {
+short loop =0;
     long button = 0;
     bool restore = false;
     long restoretimer = 0; /* timer to delay screen redraw temporarily */
@@ -331,11 +378,13 @@
             }
                 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)
                     {
@@ -346,15 +395,40 @@
                         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;
+            case ACTION_WPS_STUDY_MODE:
+if(loop !=1)
+{
+loop =1;
+                talk_id(LANG_STUDY_MODE, true);
+                if(global_settings.study_mode)
+                {
+                    global_settings.study_mode =false;
+                    talk_id(LANG_OFF, true);
+                }
+                else
+                {
+                    global_settings.study_mode =true;
+                    talk_id(LANG_ON, true);
+                }
+}
+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)
                     {
@@ -371,8 +445,14 @@
                         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 */
@@ -400,34 +480,13 @@
                 /* ...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;
@@ -452,18 +511,9 @@
                 /* ...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 */
@@ -480,7 +530,9 @@
                 else
 #endif
                 {
-                    audio_next_dir();
+                    if(global_settings.study_mode)
+                        next_track();
+                    else audio_next_dir();
                 }
                 break;
             case ACTION_WPS_ABSETA_PREVDIR:
@@ -492,7 +544,9 @@
                 else
 #endif
                 {
-                    audio_prev_dir();
+                    if(global_settings.study_mode)
+                        prev_track(3);
+                    else audio_prev_dir();
                 }
                 break;
             /* menu key functions */
Index: apps/settings.h
===================================================================
--- apps/settings.h	(revision 14986)
+++ apps/settings.h	(working copy)
@@ -452,6 +452,8 @@
     bool play_selected; /* Plays selected file even in shuffle mode */
     int ff_rewind_min_step; /* FF/Rewind minimum step size */
     int ff_rewind_accel; /* FF/Rewind acceleration (in seconds per doubling) */
+    bool study_mode; /* study mode enabled */
+    int study_hop_step; /* hop step in study mode, in seconds */
 
 #ifndef HAVE_FLASH_STORAGE
     int disk_spindown; /* time until disk spindown, in seconds (0=off) */
Index: apps/menus/playback_menu.c
===================================================================
--- apps/menus/playback_menu.c	(revision 14986)
+++ apps/menus/playback_menu.c	(working copy)
@@ -60,8 +60,11 @@
 
 MENUITEM_SETTING(ff_rewind_accel, &global_settings.ff_rewind_accel, NULL);
 MENUITEM_SETTING(ff_rewind_min_step, &global_settings.ff_rewind_min_step, NULL);
+MENUITEM_SETTING(study_mode, &global_settings.study_mode, NULL);
+MENUITEM_SETTING(study_hop_step, &global_settings.study_hop_step, NULL);
 MAKE_MENU(ff_rewind_settings_menu, ID2P(LANG_WIND_MENU), 0, Icon_NOICON,
-          &ff_rewind_min_step, &ff_rewind_accel);
+          &ff_rewind_min_step, &ff_rewind_accel,
+          &study_mode, &study_hop_step);
 #ifndef HAVE_FLASH_STORAGE
 #if CONFIG_CODEC == SWCODEC
 int buffermargin_callback(int action,const struct menu_item_ex *this_item)
Index: apps/settings_list.c
===================================================================
--- apps/settings_list.c	(revision 14986)
+++ apps/settings_list.c	(working copy)
@@ -650,6 +650,9 @@
         ff_rewind_min_step_getlang, NULL),        
     INT_SETTING(0, ff_rewind_accel, LANG_FFRW_ACCEL, 3, "scan accel",
         UNIT_SEC, 16, 0, -1, scanaccel_formatter, scanaccel_getlang, NULL), 
+    OFFON_SETTING(0,study_mode,LANG_STUDY_MODE,false,"Study mode", NULL),
+    INT_SETTING(0, study_hop_step, LANG_STUDY_HOP_STEP, 5, "Study hop step",
+                UNIT_SEC, 0, 250, 1, NULL, NULL, NULL), 
 #if (CONFIG_CODEC == SWCODEC) && !defined(HAVE_FLASH_STORAGE)
     STRINGCHOICE_SETTING(0, buffer_margin, LANG_MP3BUFFER_MARGIN, 0,"antiskip",
         "5s,15s,30s,1min,2min,3min,5min,10min",NULL, 8,
Index: apps/keymaps/keymap-h1x0_h3x0.c
===================================================================
--- apps/keymaps/keymap-h1x0_h3x0.c	(revision 14986)
+++ apps/keymaps/keymap-h1x0_h3x0.c	(working copy)
@@ -73,7 +73,7 @@
     { ACTION_WPS_SEEKBACK,      BUTTON_LEFT|BUTTON_REPEAT,      BUTTON_NONE },
     { ACTION_WPS_SEEKFWD,       BUTTON_RIGHT|BUTTON_REPEAT,     BUTTON_NONE },
     { ACTION_WPS_STOPSEEK,      BUTTON_LEFT|BUTTON_REL,         BUTTON_LEFT|BUTTON_REPEAT },
-    { ACTION_WPS_STOPSEEK,      BUTTON_RIGHT|BUTTON_REL,        BUTTON_RIGHT|BUTTON_REPEAT },
+    { ACTION_WPS_STUDY_MODE, BUTTON_ON | BUTTON_REPEAT , BUTTON_NONE},
     { ACTION_WPS_ABSETB_NEXTDIR,       BUTTON_ON|BUTTON_RIGHT,         BUTTON_NONE },
     { ACTION_WPS_ABSETA_PREVDIR,       BUTTON_ON|BUTTON_LEFT,          BUTTON_NONE },
     { ACTION_WPS_STOP,          BUTTON_OFF|BUTTON_REL,          BUTTON_OFF },