Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: roadmap to blind Rockboxing (need an audio amateur/speaker)

Re: roadmap to blind Rockboxing (need an audio amateur/speaker)

From: James DuRant <jamesdurant_at_sc.rr.com>
Date: Thu, 26 Feb 2004 20:16:20 -0600

Hi, I don't know how to post this to patches, but I've been using this
patch since september and loving it. It's from the original talkbox,
but zagor edited for me to compile a while back and also added a HUGE
function. Currently, when "Play thumbnails when hovering over a
directory" is set, the directory read is whatever is under the cursor
when the earlier directory is read. Hardeeps added a "Hover Delay"
which only plays the directory name after stopping over the directory.
It adds alot to the feature and was wondering if anyone could
incorporate this feature when adding it to CVS. Thanks so much, James

Here's what hardeep sent me:
I've attached a patch that delays playing the thumbnail for ~1.5s from
the last time the cursor was scrolled when in hover mode. I only did
minimal testing on it so I'm sure there are some cases where it doesn't
work properly.


Index: rockbox/apps/playlist.c
===================================================================
RCS file: /cvsroot/rockbox/apps/playlist.c,v
retrieving revision 1.81
diff -u -r1.81 playlist.c
--- rockbox/apps/playlist.c 11 Aug 2003 16:32:56 -0000 1.81
+++ rockbox/apps/playlist.c 20 Sep 2003 18:29:09 -0000
_at__at_ -471,6 +471,9 _at__at_
         {
             int insert_pos;

+ if (!strcmp(files[i].name, THUMBNAIL_NAME))
+ continue;
+
             snprintf(buf, sizeof(buf), "%s/%s", dirname, files[i].name);

             insert_pos = add_track_to_playlist(buf, *position, queue, -1);
Index: rockbox/apps/screens.c
===================================================================
RCS file: /cvsroot/rockbox/apps/screens.c,v
retrieving revision 1.33
diff -u -r1.33 screens.c
--- rockbox/apps/screens.c 20 Jul 2003 00:12:21 -0000 1.33
+++ rockbox/apps/screens.c 20 Sep 2003 18:29:09 -0000
_at__at_ -37,6 +37,13 _at__at_
#include "powermgmt.h"
#include "adc.h"

+#ifdef HAVE_RECORDER_KEYPAD
+#include "recording.h"
+#include "tree.h"
+#endif
+
+static bool confirm_record_thumbnail(void);
+
#ifdef HAVE_LCD_BITMAP
#define BMPHEIGHT_usb_logo 32
#define BMPWIDTH_usb_logo 100
_at__at_ -431,6 +438,16 _at__at_

         lcd_clear_display();

+
+#ifdef HAVE_MAS3587F
+
+ if (strcmp(getcwd(NULL, -1), "/") != 0) {
+ lcd_putsxy(8, 0, "Record Thumbnail");
+ lcd_bitmap(bitmap_icons_7x8[Icon_UpArrow],
+ LCD_WIDTH/2 - 3, LCD_HEIGHT/2 - h*2, 7, 8, true);
+ }
+#endif
+
         /* Shuffle mode */
         lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE));
         lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE));
_at__at_ -507,6 +524,20 _at__at_
                 used = true;
                 break;

+#ifdef HAVE_MAS3587F
+ case BUTTON_UP:
+ case BUTTON_F2 | BUTTON_UP:
+ if (strcmp(getcwd(NULL, -1), "/") != 0)
+ {
+ if (confirm_record_thumbnail())
+ {
+ record_thumbnail();
+ }
+ }
+ used = true;
+ break;
+#endif
+
             case BUTTON_DOWN:
             case BUTTON_F2 | BUTTON_DOWN:
                 global_settings.dirfilter++;
_at__at_ -631,6 +662,44 _at__at_

     return false;
}
+
+static bool confirm_record_thumbnail(void)
+{
+ bool yesno;
+ bool done;
+
+ if (strcmp(getcwd(NULL, -1), "/") == 0)
+ return false;
+
+ lcd_clear_display();
+
+ lcd_putsxy(0, LCD_HEIGHT/2 - 30, "Record Thumbnail");
+ lcd_putsxy(0, LCD_HEIGHT/2 - 20, "in directory?:");
+ lcd_putsxy(0, LCD_HEIGHT/2 - 5, getcwd(NULL, -1));
+ lcd_putsxy(4, LCD_HEIGHT/2 + 10, "PLAY - Confirm");
+ lcd_putsxy(5, LCD_HEIGHT/2 + 20, " F2 - Cancel");
+ lcd_update();
+
+ done=false;
+ yesno=false;
+
+ while(!done) {
+ switch (button_get(true)) {
+ case BUTTON_PLAY:
+ yesno=true;
+ done = true;
+ break;
+
+ case BUTTON_F2:
+ yesno=false;
+ done = true;
+ break;
+ }
+ }
+
+ return yesno;
+}
+
#endif

#ifdef HAVE_LCD_BITMAP
_at__at_ -802,4 +871,3 _at__at_
             sleep(ticks);
     }
}
-
Index: rockbox/apps/settings.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.c,v
retrieving revision 1.170
diff -u -r1.170 settings.c
--- rockbox/apps/settings.c 4 Sep 2003 22:49:33 -0000 1.170
+++ rockbox/apps/settings.c 20 Sep 2003 18:29:10 -0000
_at__at_ -131,8 +131,9 _at__at_
0xA9 (char)jump scroll delay (only for player)
0xAA Max number of files in playlist (1000-20000)
0xAC Max number of files in dir (50-10000)
-0xAE fade on pause/unpause/stop setting (bit 0)
- caption backlight (bit 1)
+0xAE fade on pause/unpause/stop setting (bit 0),
+ caption backlight (bit 1), play thumbnails (bit 2),
+ thumbnail mode (bit 3)
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
_at__at_ -402,7 +403,9 _at__at_
         (global_settings.max_files_in_dir >> 8) & 0xff;
     config_block[0xae] = (unsigned char)
         ((global_settings.fade_on_stop & 1) |
- ((global_settings.caption_backlight & 1) << 1));
+ ((global_settings.caption_backlight & 1) << 1) |
+ ((global_settings.play_thumbnails & 1) << 2) |
+ ((global_settings.thumbnail_mode & 1) << 3));
     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 |
_at__at_ -684,6 +687,8 _at__at_
         if (config_block[0xae] != 0xff) {
             global_settings.fade_on_stop = config_block[0xae] & 1;
             global_settings.caption_backlight = (config_block[0xae] >>
1) & 1;
+ global_settings.play_thumbnails = (config_block[0xae] >> 2)
& 1;
+ global_settings.thumbnail_mode = (config_block[0xae] >> 3) & 1;
         }

         if(config_block[0xb0] != 0xff) {
_at__at_ -1075,6 +1080,13 _at__at_
             set_cfg_option(&global_settings.recursive_dir_insert, value,
                 options, 3);
         }
+ else if (!strcasecmp(name, "play thumbnails"))
+ set_cfg_bool(&global_settings.play_thumbnails, value);
+ else if (!strcasecmp(name, "thumbnail mode")) {
+ static char* options[] = {"enter","hover"};
+ set_cfg_option(&global_settings.thumbnail_mode, value,
+ options, 2);
+ }
     }

     close(fd);
_at__at_ -1372,6 +1384,18 _at__at_
                 options[global_settings.recursive_dir_insert]);
     }

+ {
+ static char* options[] = {"off", "on"};
+ fprintf(fd, "play thumbnails: %s\r\n",
+ options[global_settings.play_thumbnails]);
+ }
+
+ {
+ static char* options[] = {"enter", "hover"};
+ fprintf(fd, "thumbnail mode: %s\r\n",
+ options[global_settings.thumbnail_mode]);
+ }
+
     close(fd);

     lcd_clear_display();
_at__at_ -1460,6 +1484,8 _at__at_
     global_settings.max_files_in_playlist = 10000;
     global_settings.show_icons = true;
     global_settings.recursive_dir_insert = RECURSE_OFF;
+ global_settings.play_thumbnails = 0;
+ global_settings.thumbnail_mode = 0;
}

bool set_bool(char* string, bool* variable )
Index: rockbox/apps/settings.h
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.h,v
retrieving revision 1.88
diff -u -r1.88 settings.h
--- rockbox/apps/settings.h 15 Jul 2003 02:34:10 -0000 1.88
+++ rockbox/apps/settings.h 20 Sep 2003 18:29:10 -0000
_at__at_ -168,6 +168,11 _at__at_
     int max_files_in_playlist; /* Max entries in playlist */
     bool show_icons; /* 0=hide 1=show */
     int recursive_dir_insert; /* should directories be inserted
recursively */
+ bool play_thumbnails; /* Enable/disable playing of directory name
+ thumbnails */
+ int thumbnail_mode; /* When to play directory thumbnails:
+ 0=when entering a directory
+ 1=when cursor is over a directory */
};

enum optiontype { INT, BOOL };
Index: rockbox/apps/settings_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings_menu.c,v
retrieving revision 1.120
diff -u -r1.120 settings_menu.c
--- rockbox/apps/settings_menu.c 21 Jul 2003 00:33:07 -0000 1.120
+++ rockbox/apps/settings_menu.c 20 Sep 2003 18:29:10 -0000
_at__at_ -695,6 +695,20 _at__at_
}
#endif

+
+static bool play_thumbnails(void)
+{
+ return set_bool( "Play Thumbnails", &global_settings.play_thumbnails );
+}
+
+static bool thumbnail_mode(void)
+{
+ char* names[] = { "enter", "hover"};
+
+ return set_option("Thumbnail Mode",
&global_settings.thumbnail_mode, INT,
+ names, 2, NULL );
+}
+
static bool playback_settings_menu(void)
{
     int m;
_at__at_ -790,6 +804,8 _at__at_
         { str(LANG_CASE_MENU), sort_case },
         { str(LANG_FILTER), dir_filter },
         { str(LANG_FOLLOW), browse_current },
+ { "Play Thumbnails", play_thumbnails },
+ { "Thumbnail Mode", thumbnail_mode },
     };

     m = menu_init( items, sizeof items / sizeof(struct menu_items) );
Index: rockbox/apps/tree.c
===================================================================
RCS file: /cvsroot/rockbox/apps/tree.c,v
retrieving revision 1.205
diff -u -r1.205 tree.c
--- rockbox/apps/tree.c 6 Aug 2003 17:30:40 -0000 1.205
+++ rockbox/apps/tree.c 20 Sep 2003 18:29:11 -0000
_at__at_ -151,6 +151,8 _at__at_
#define TREE_MENU BUTTON_MENU
#endif /* HAVE_RECORDER_KEYPAD */

+#define HOVER_DELAY 1.5
+
static int build_playlist(int start_index)
{
     int i;
_at__at_ -158,7 +160,8 _at__at_

     for(i = 0;i < filesindir;i++)
     {
- if(dircache[i].attr & TREE_ATTR_MPA)
+ if(dircache[i].attr & TREE_ATTR_MPA &&
+ (strcmp(dircache[i].name, THUMBNAIL_NAME) != 0))
         {
             DEBUGF("Adding %s\n", dircache[i].name);
             if (playlist_add(dircache[i].name) < 0)
_at__at_ -175,6 +178,34 _at__at_
     return start_index;
}

+static int play_dirname(int start_index)
+{
+ int fd;
+ char dirname_mp3_filename[MAX_PATH+1];
+
+ snprintf(dirname_mp3_filename, sizeof(dirname_mp3_filename),
"%s/%s/%s",
+ currdir, dircache[start_index].name, THUMBNAIL_NAME);
+
+ DEBUGF("Checking for %s\n", dirname_mp3_filename);
+
+ fd = open(dirname_mp3_filename, O_RDONLY);
+ if (fd < 0)
+ {
+ DEBUGF("Failed to find: %s\n", dirname_mp3_filename);
+ return -1;
+ }
+
+ close(fd);
+
+ DEBUGF("Found: %s\n", dirname_mp3_filename);
+
+ playlist_create(NULL, NULL);
+ playlist_insert_track(dirname_mp3_filename, 0, true);
+ playlist_start(0,0);
+
+ return 1;
+}
+
static int compare(const void* p1, const void* p2)
{
     struct entry* e1 = (struct entry*)p1;
_at__at_ -825,6 +856,9 _at__at_
     bool update_all = false; /* set this to true when the whole file list
                                 has been refreshed on screen */

+ int last_thumbnail_played=-1;
+ long last_scroll = -1;
+
#ifdef HAVE_LCD_BITMAP
     int fw, fh;
     lcd_getstringsize("A", &fw, &fh);
_at__at_ -898,6 +932,7 _at__at_
                         strcpy(lastfile, buf);

                     restore = true;
+ last_scroll = current_tick;
                 }
                 break;

_at__at_ -932,6 +967,15 _at__at_
                     snprintf(buf,sizeof(buf),"/%s",file->name);

                 if (file->attr & ATTR_DIRECTORY) {
+ if (global_settings.play_thumbnails &&
+ global_settings.thumbnail_mode == 0 &&
+ !(mpeg_status() & MPEG_STATUS_PLAY))
+ {
+ /* play_dirname */
+ DEBUGF("Playing directory thumbnail: %s", currdir);
+ play_dirname(dircursor+dirstart);
+ }
+
                     memcpy(currdir,buf,sizeof(currdir));
                     if ( dirlevel < MAX_DIR_LEVELS ) {
                         dirpos[dirlevel] = dirstart;
_at__at_ -940,6 +984,7 _at__at_
                     dirlevel++;
                     dircursor=0;
                     dirstart=0;
+ last_scroll = current_tick;
                 }
                 else {
                     int seed = current_tick;
_at__at_ -1122,6 +1167,7 _at__at_
                         }
                     }
                     need_update = true;
+ last_scroll = current_tick;
                 }
                 break;

_at__at_ -1157,6 +1203,7 _at__at_
                         }
                     }
                     need_update = true;
+ last_scroll = current_tick;
                 }
                 break;

_at__at_ -1173,6 +1220,7 _at__at_
                 {
                     /* start scroll */
                     restore = true;
+ last_scroll = current_tick;
                 }
                 else
                 {
_at__at_ -1219,6 +1267,22 _at__at_
                 break;

             case BUTTON_NONE:
+ if (file->attr & ATTR_DIRECTORY) {
+ /* play directory thumbnail */
+ if (global_settings.play_thumbnails &&
+ global_settings.thumbnail_mode == 1 &&
+ last_thumbnail_played != dircursor+dirstart &&
+ !(mpeg_status() & MPEG_STATUS_PLAY) &&
+ last_scroll > 0 &&
+
TIME_AFTER(current_tick,(last_scroll+HZ*HOVER_DELAY)))
+ {
+ DEBUGF("Playing directory thumbnail: %s", currdir);
+ play_dirname(dircursor+dirstart);
+ last_thumbnail_played = dircursor+dirstart;
+ last_scroll = -1;
+ }
+ }
+
                 status_draw(false);
                 break;
         }
Index: rockbox/apps/tree.h
===================================================================
RCS file: /cvsroot/rockbox/apps/tree.h,v
retrieving revision 1.8
diff -u -r1.8 tree.h
--- rockbox/apps/tree.h 27 Jul 2003 22:08:42 -0000 1.8
+++ rockbox/apps/tree.h 20 Sep 2003 18:29:11 -0000
_at__at_ -39,6 +39,8 _at__at_
#define TREE_ATTR_UCL 0x4000 /* rockbox flash image */
#define TREE_ATTR_MASK 0xffd0 /* which bits tree.c uses (above + DIR) */

+#define THUMBNAIL_NAME ".dirname.mp3"
+
void tree_init(void);
void browse_root(void);
void set_current_file(char *path);
Index: rockbox/apps/recorder/recording.c
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/recording.c,v
retrieving revision 1.35
diff -u -r1.35 recording.c
--- rockbox/apps/recorder/recording.c 20 Sep 2003 18:02:05 -0000 1.35
+++ rockbox/apps/recorder/recording.c 20 Sep 2003 18:29:11 -0000
_at__at_ -41,6 +41,7 _at__at_
#include "timefuncs.h"
#include "debug.h"
#include "misc.h"
+#include "tree.h"

bool f2_rec_screen(void);
bool f3_rec_screen(void);
_at__at_ -55,6 +56,9 _at__at_
extern unsigned long record_start_frame; /* Frame number where
                                             recording started */

+static bool use_alt_filename;
+static char alt_filename[MAX_PATH+1];
+
#define SOURCE_MIC 0
#define SOURCE_LINE 1
#define SOURCE_SPDIF 2
_at__at_ -216,7 +220,16 _at__at_
                 if(!mpeg_status())
                 {
                     have_recorded = true;
- mpeg_record(create_filename());
+
+ if (!use_alt_filename)
+ {
+ mpeg_record(create_filename());
+ }
+ else
+ {
+ mpeg_record(alt_filename);
+ }
+
                     status_set_playmode(STATUS_RECORD);
                     update_countdown = 1; /* Update immediately */
                     last_seconds = 0;
_at__at_ -713,4 +726,26 _at__at_
     lcd_setfont(FONT_UI);

     return false;
+}
+
+bool record_thumbnail(void)
+{
+ int fd;
+
+ use_alt_filename = true;
+ snprintf(alt_filename, sizeof(alt_filename), "%s/%s",
+ getcwd(NULL, -1), THUMBNAIL_NAME);
+
+ fd = open(alt_filename, O_RDONLY);
+
+ if (fd >= 0)
+ {
+ close(fd);
+ remove(alt_filename);
+ }
+
+ recording_screen();
+ use_alt_filename = false;
+
+ return true;
}
Index: rockbox/apps/recorder/recording.h
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/recording.h,v
retrieving revision 1.1
diff -u -r1.1 recording.h
--- rockbox/apps/recorder/recording.h 10 Nov 2002 16:42:31 -0000 1.1
+++ rockbox/apps/recorder/recording.h 20 Sep 2003 18:29:11 -0000
_at__at_ -20,5 +20,6 _at__at_
#define RECORDING_H

bool recording_screen(void);
+bool record_thumbnail(void);

#endif




_______________________________________________
http://cool.haxx.se/mailman/listinfo/rockbox
Received on 2004-02-27

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy