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: Please help compile TALKBOX to current CVS
From: Hardeep Sidhu (hardeeps_at_pobox.com)
Date: 2003-08-18


James DuRant wrote:

>Hey everybody, I know this may be asking a lot, but I was wondering if
>anyone would help me with TALKBOX. I cannot the .diff to patch to the
>source (7 out of 10 hunks succeed). It is a very small .diff and
>probably wouldn't take much (for those who know how to program) to
>modify the .diff to compile. The current .diff was made to compile for
>the 2.0 release, but since then has not been updated. I really enjoy
>using Talkbox features while driving, and if anyone could take a look at
>it then it would help a lot. You can download the .diff file from
>here....
>http://pages.sbcglobal.net/gsudindranath/
>
>

The attached patch contains the following changes to Danan's 5/15/2003
talkbox patch:
- Updates to latest CVS
- Save settings in config block
- No longer disable repeat mode but, instead, make use of playlist queue
functionality to play thumbnail only once
- Skip the thumbnail when playing/inserting a directory
- Removed get_currdir() function and changed to use existing getcwd()

Danan - Please have a look at the changes and see if you agree with
them. Also, this is a pretty cool feature that people are using so I'd
recommend posting it on SF for inclusion into the mainline.

-Hardeep

Index: rockbox/apps/playlist.c
===================================================================
RCS file: /cvsroot/rockbox/apps/playlist.c,v
retrieving revision 1.80
diff -u -r1.80 playlist.c
--- rockbox/apps/playlist.c 8 Jul 2003 06:31:23 -0000 1.80
+++ rockbox/apps/playlist.c 10 Aug 2003 17:43:54 -0000
@@ -471,6 +471,9 @@
         {
             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 10 Aug 2003 17:43:55 -0000
@@ -37,6 +37,13 @@
 #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
@@ -431,6 +438,16 @@
 
         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));
@@ -507,6 +524,20 @@
                 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++;
@@ -631,6 +662,44 @@
 
     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
@@ -802,4 +871,3 @@
             sleep(ticks);
     }
 }
-
Index: rockbox/apps/settings.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.c,v
retrieving revision 1.168
diff -u -r1.168 settings.c
--- rockbox/apps/settings.c 9 Aug 2003 08:52:50 -0000 1.168
+++ rockbox/apps/settings.c 10 Aug 2003 17:43:56 -0000
@@ -131,8 +131,9 @@
 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
@@ -402,7 +403,9 @@
         (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 |
@@ -682,6 +685,8 @@
         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) {
@@ -1073,6 +1078,13 @@
             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);
@@ -1370,6 +1382,18 @@
                 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();
@@ -1458,6 +1482,8 @@
     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 10 Aug 2003 17:43:56 -0000
@@ -168,6 +168,11 @@
     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 10 Aug 2003 17:43:56 -0000
@@ -695,6 +695,20 @@
 }
 #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;
@@ -790,6 +804,8 @@
         { 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 10 Aug 2003 17:43:57 -0000
@@ -158,7 +158,8 @@
 
     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)
@@ -175,6 +176,34 @@
     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;
@@ -825,6 +854,8 @@
     bool update_all = false; /* set this to true when the whole file list
                                 has been refreshed on screen */
 
+ int last_thumbnail_played=-1;
+
 #ifdef HAVE_LCD_BITMAP
     int fw, fh;
     lcd_getstringsize("A", &fw, &fh);
@@ -853,6 +884,20 @@
 
         bool restore = false;
 
+ 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))
+ {
+ DEBUGF("Playing directory thumbnail: %s", currdir);
+ play_dirname(dircursor+dirstart);
+ last_thumbnail_played = dircursor+dirstart;
+ }
+ }
+
         button = button_get_w_tmo(HZ/5);
 
 #ifndef SIMULATOR
@@ -932,6 +977,16 @@
                     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;
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 10 Aug 2003 17:43:57 -0000
@@ -39,6 +39,8 @@
 #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.33
diff -u -r1.33 recording.c
--- rockbox/apps/recorder/recording.c 22 Jul 2003 18:34:23 -0000 1.33
+++ rockbox/apps/recorder/recording.c 10 Aug 2003 17:43:57 -0000
@@ -40,6 +40,7 @@
 #include "timefuncs.h"
 #include "debug.h"
 #include "misc.h"
+#include "tree.h"
 
 bool f2_rec_screen(void);
 bool f3_rec_screen(void);
@@ -54,6 +55,9 @@
 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
@@ -215,7 +219,16 @@
                 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;
@@ -712,4 +725,26 @@
     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 10 Aug 2003 17:43:57 -0000
@@ -20,5 +20,6 @@
 #define RECORDING_H
 
 bool recording_screen(void);
+bool record_thumbnail(void);
 
 #endif



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa