summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-01-21 14:58:40 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-01-21 14:58:40 +0000
commitef7293f0bc336beb30f3a5f2eafad4a447f60ac5 (patch)
tree68b02b0278b25a10a261d8813bbf5be39e1a51b6 /apps
parent33acdef9db5ffa2c6f93dc07d0400c7a72a0f25e (diff)
downloadrockbox-ef7293f0bc336beb30f3a5f2eafad4a447f60ac5.tar.gz
rockbox-ef7293f0bc336beb30f3a5f2eafad4a447f60ac5.zip
New feature: NOw you can store the recorded files in either /recordings (the directory will be created automatically) or in the current directory.
New feature: A "Create directory" menu option (untested in the simulator). Bug fix: The ON+Play menu could do nasty things if you pressed ON+Play in an empty dir. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4268 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang15
-rw-r--r--apps/main_menu.c5
-rw-r--r--apps/recorder/radio.c6
-rw-r--r--apps/recorder/recording.c60
-rw-r--r--apps/recorder/recording.h2
-rw-r--r--apps/settings.c28
-rw-r--r--apps/settings.h5
-rw-r--r--apps/sound_menu.c15
-rw-r--r--apps/tree.c27
-rw-r--r--apps/tree.h1
10 files changed, 138 insertions, 26 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 847c5b985a..5815ec2169 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -2030,3 +2030,18 @@ id: LANG_MANAGE_MENU
2030desc: in the system sub menu 2030desc: in the system sub menu
2031eng: "Manage Settings" 2031eng: "Manage Settings"
2032new: 2032new:
2033
2034id: LANG_RECORD_DIRECTORY
2035desc: in recording settings_menu
2036eng: "Directory"
2037new:
2038
2039id: LANG_RECORD_CURRENT_DIR
2040desc: in recording directory options
2041eng: "Current dir"
2042new:
2043
2044id: LANG_CREATE_DIR
2045desc: in main menu
2046eng: "Create directory"
2047new:
diff --git a/apps/main_menu.c b/apps/main_menu.c
index 23af8d7817..b6d73ab6f2 100644
--- a/apps/main_menu.c
+++ b/apps/main_menu.c
@@ -304,7 +304,7 @@ bool main_menu(void)
304 int i = 0; 304 int i = 0;
305 305
306 /* main menu */ 306 /* main menu */
307 struct menu_items items[8]; 307 struct menu_items items[9];
308 308
309 items[i].desc = str(LANG_BOOKMARK_MENU); 309 items[i].desc = str(LANG_BOOKMARK_MENU);
310 items[i++].function = bookmark_menu; 310 items[i++].function = bookmark_menu;
@@ -336,6 +336,9 @@ bool main_menu(void)
336 items[i].desc = str(LANG_INFO); 336 items[i].desc = str(LANG_INFO);
337 items[i++].function = info_menu; 337 items[i++].function = info_menu;
338 338
339 items[i].desc = str(LANG_CREATE_DIR);
340 items[i++].function = create_dir;
341
339 m=menu_init( items, i ); 342 m=menu_init( items, i );
340#ifdef HAVE_LCD_CHARCELLS 343#ifdef HAVE_LCD_CHARCELLS
341 status_set_param(true); 344 status_set_param(true);
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 0cc85335b0..65b8beb164 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -117,7 +117,7 @@ static int find_preset(int freq)
117 117
118bool radio_screen(void) 118bool radio_screen(void)
119{ 119{
120 char buf[128]; 120 char buf[MAX_PATH];
121 bool done = false; 121 bool done = false;
122 int button; 122 int button;
123 int val; 123 int val;
@@ -248,13 +248,13 @@ bool radio_screen(void)
248 case BUTTON_F3: 248 case BUTTON_F3:
249 if(mpeg_status() == MPEG_STATUS_RECORD) 249 if(mpeg_status() == MPEG_STATUS_RECORD)
250 { 250 {
251 mpeg_new_file(rec_create_filename()); 251 mpeg_new_file(rec_create_filename(buf));
252 update_screen = true; 252 update_screen = true;
253 } 253 }
254 else 254 else
255 { 255 {
256 have_recorded = true; 256 have_recorded = true;
257 mpeg_record(rec_create_filename()); 257 mpeg_record(rec_create_filename(buf));
258 status_set_playmode(STATUS_RECORD); 258 status_set_playmode(STATUS_RECORD);
259 update_screen = true; 259 update_screen = true;
260 } 260 }
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index b98a4579f7..c7d4b803d2 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -42,6 +42,10 @@
42#include "timefuncs.h" 42#include "timefuncs.h"
43#include "debug.h" 43#include "debug.h"
44#include "misc.h" 44#include "misc.h"
45#include "tree.h"
46#include "string.h"
47#include "dir.h"
48#include "errno.h"
45 49
46bool f2_rec_screen(void); 50bool f2_rec_screen(void);
47bool f3_rec_screen(void); 51bool f3_rec_screen(void);
@@ -114,20 +118,22 @@ void adjust_cursor(void)
114 } 118 }
115} 119}
116 120
117char *rec_create_filename(void) 121char *rec_create_filename(char *buffer)
118{ 122{
119 static char fname[32]; 123 int fpos;
120 struct tm * tm; 124 struct tm *tm = get_time();
121 125
122 tm = get_time(); 126 if(global_settings.rec_directory)
127 getcwd(buffer, MAX_PATH);
128 else
129 strncpy(buffer, rec_base_directory, MAX_PATH);
123 130
124 /* Create a filename: RYYMMDD-HHMMSS.mp3 */ 131 /* Append filename to path: RYYMMDD-HH.MM.SS.mp3 */
125 snprintf(fname, 32, "/R%02d%02d%02d-%02d%02d%02d.mp3", 132 fpos = strlen(buffer);
133 snprintf(&buffer[fpos], MAX_PATH-fpos, "/R%02d%02d%02d-%02d%02d%02d.mp3",
126 tm->tm_year%100, tm->tm_mon+1, tm->tm_mday, 134 tm->tm_year%100, tm->tm_mon+1, tm->tm_mday,
127 tm->tm_hour, tm->tm_min, tm->tm_sec); 135 tm->tm_hour, tm->tm_min, tm->tm_sec);
128 136 return buffer;
129 DEBUGF("Filename: %s\n", fname);
130 return fname;
131} 137}
132 138
133bool recording_screen(void) 139bool recording_screen(void)
@@ -144,6 +150,9 @@ bool recording_screen(void)
144 unsigned int seconds; 150 unsigned int seconds;
145 unsigned int last_seconds = 0; 151 unsigned int last_seconds = 0;
146 int hours, minutes; 152 int hours, minutes;
153 char path_buffer[MAX_PATH];
154 int rc;
155 bool been_in_usb_mode = false;
147 156
148 cursor = 0; 157 cursor = 0;
149 mpeg_init_recording(); 158 mpeg_init_recording();
@@ -170,6 +179,25 @@ bool recording_screen(void)
170 lcd_getstringsize("M", &w, &h); 179 lcd_getstringsize("M", &w, &h);
171 lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8); 180 lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
172 181
182 /* Try to create the base directory if needed */
183 if(global_settings.rec_directory == 0)
184 {
185 rc = mkdir(rec_base_directory, 0);
186 if(rc < 0 && errno != EEXIST)
187 {
188 splash(HZ * 2, true,
189 "Can't create the %s directory. Error code %d.",
190 rec_base_directory, rc);
191 }
192 else
193 {
194 /* If we have created the directory, we want the dir browser to
195 be refreshed even if we haven't recorded anything */
196 if(errno != EEXIST)
197 have_recorded = true;
198 }
199 }
200
173 while(!done) 201 while(!done)
174 { 202 {
175 button = button_get_w_tmo(HZ / peak_meter_fps); 203 button = button_get_w_tmo(HZ / peak_meter_fps);
@@ -195,13 +223,13 @@ bool recording_screen(void)
195 if(!(mpeg_status() & MPEG_STATUS_RECORD)) 223 if(!(mpeg_status() & MPEG_STATUS_RECORD))
196 { 224 {
197 have_recorded = true; 225 have_recorded = true;
198 mpeg_record(rec_create_filename()); 226 mpeg_record(rec_create_filename(path_buffer));
199 status_set_playmode(STATUS_RECORD); 227 status_set_playmode(STATUS_RECORD);
200 update_countdown = 1; /* Update immediately */ 228 update_countdown = 1; /* Update immediately */
201 } 229 }
202 else 230 else
203 { 231 {
204 mpeg_new_file(rec_create_filename()); 232 mpeg_new_file(rec_create_filename(path_buffer));
205 update_countdown = 1; /* Update immediately */ 233 update_countdown = 1; /* Update immediately */
206 } 234 }
207 last_seconds = 0; 235 last_seconds = 0;
@@ -354,8 +382,8 @@ bool recording_screen(void)
354 if(mpeg_status() != MPEG_STATUS_RECORD) 382 if(mpeg_status() != MPEG_STATUS_RECORD)
355 { 383 {
356 usb_screen(); 384 usb_screen();
357 have_recorded = true; /* Refreshes the browser later on */
358 done = true; 385 done = true;
386 been_in_usb_mode = true;
359 } 387 }
360 break; 388 break;
361 } 389 }
@@ -419,7 +447,7 @@ bool recording_screen(void)
419 that the recorded files don't get too big. */ 447 that the recorded files don't get too big. */
420 if (mpeg_status() && (seconds >= dseconds)) 448 if (mpeg_status() && (seconds >= dseconds))
421 { 449 {
422 mpeg_new_file(rec_create_filename()); 450 mpeg_new_file(rec_create_filename(path_buffer));
423 update_countdown = 1; 451 update_countdown = 1;
424 last_seconds = 0; 452 last_seconds = 0;
425 } 453 }
@@ -529,7 +557,11 @@ bool recording_screen(void)
529 mpeg_sound_set(SOUND_AVC, global_settings.avc); 557 mpeg_sound_set(SOUND_AVC, global_settings.avc);
530 558
531 lcd_setfont(FONT_UI); 559 lcd_setfont(FONT_UI);
532 return have_recorded; 560
561 if (have_recorded)
562 reload_directory();
563
564 return been_in_usb_mode;
533} 565}
534 566
535bool f2_rec_screen(void) 567bool f2_rec_screen(void)
diff --git a/apps/recorder/recording.h b/apps/recorder/recording.h
index 08edbbcfb4..174621b3b7 100644
--- a/apps/recorder/recording.h
+++ b/apps/recorder/recording.h
@@ -20,6 +20,6 @@
20#define RECORDING_H 20#define RECORDING_H
21 21
22bool recording_screen(void); 22bool recording_screen(void);
23char *rec_create_filename(void); 23char *rec_create_filename(char *buf);
24 24
25#endif 25#endif
diff --git a/apps/settings.c b/apps/settings.c
index abb2b79dca..bfc943bef0 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -65,8 +65,10 @@ void dac_line_in(bool enable);
65#endif 65#endif
66struct user_settings global_settings; 66struct user_settings global_settings;
67char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */ 67char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */
68char rec_base_directory[] = REC_BASE_DIR;
68 69
69#define CONFIG_BLOCK_VERSION 8 70
71#define CONFIG_BLOCK_VERSION 9
70#define CONFIG_BLOCK_SIZE 512 72#define CONFIG_BLOCK_SIZE 512
71#define RTC_BLOCK_SIZE 44 73#define RTC_BLOCK_SIZE 44
72 74
@@ -156,7 +158,7 @@ Rest of config block, only saved to disk:
1560xB8 (char[20]) WPS file 1580xB8 (char[20]) WPS file
1570xCC (char[20]) Lang file 1590xCC (char[20]) Lang file
1580xE0 (char[20]) Font file 1600xE0 (char[20]) Font file
1590xF4 Prerecording time (bit 0-4) 1610xF4 Prerecording time (bit 0-4), Recording directory option (bit 5-6)
1600xF5-0xFF <unused> 1620xF5-0xFF <unused>
161 163
162*************************************/ 164*************************************/
@@ -439,7 +441,8 @@ int settings_save( void )
439 strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME); 441 strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME);
440 strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME); 442 strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME);
441 443
442 config_block[0xf4]=(unsigned char)global_settings.rec_prerecord_time; 444 config_block[0xf4]=((unsigned char)global_settings.rec_prerecord_time |
445 ((unsigned char)global_settings.rec_directory << 5));
443 446
444 if(save_config_buffer()) 447 if(save_config_buffer())
445 { 448 {
@@ -681,7 +684,7 @@ void settings_load(void)
681 } 684 }
682 685
683 if (config_block[0x1d] != 0xFF) 686 if (config_block[0x1d] != 0xFF)
684 memcpy(&global_settings.resume_seed,&config_block[0x1d], 4); 687 memcpy(&global_settings.resume_seed, &config_block[0x1d], 4);
685 688
686 if (config_block[0x21] != 0xFF) 689 if (config_block[0x21] != 0xFF)
687 { 690 {
@@ -766,8 +769,10 @@ void settings_load(void)
766 strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME); 769 strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME);
767 strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME); 770 strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME);
768 771
769 if (config_block[0xf4] != 0xff) 772 if (config_block[0xf4] != 0xff) {
770 global_settings.rec_prerecord_time = config_block[0xf4]; 773 global_settings.rec_prerecord_time = config_block[0xf4] & 0x1f;
774 global_settings.rec_directory = (config_block[0xf4] >> 5) & 3;
775 }
771 776
772#ifdef HAVE_LCD_CHARCELLS 777#ifdef HAVE_LCD_CHARCELLS
773 if (config_block[0xa8] != 0xff) 778 if (config_block[0xa8] != 0xff)
@@ -1101,6 +1106,10 @@ bool settings_load_config(char* file)
1101 else if (!strcasecmp(name, "prerecording time")) { 1106 else if (!strcasecmp(name, "prerecording time")) {
1102 set_cfg_int(&global_settings.rec_prerecord_time, value, 0, 30); 1107 set_cfg_int(&global_settings.rec_prerecord_time, value, 0, 30);
1103 } 1108 }
1109 else if (!strcasecmp(name, "rec directory")) {
1110 static char* options[] = {rec_base_directory, "current"};
1111 set_cfg_option(&global_settings.rec_directory, value, options, 2);
1112 }
1104#endif 1113#endif
1105 else if (!strcasecmp(name, "idle poweroff")) { 1114 else if (!strcasecmp(name, "idle poweroff")) {
1106 static char* options[] = {"off","1","2","3","4","5","6","7","8", 1115 static char* options[] = {"off","1","2","3","4","5","6","7","8",
@@ -1454,6 +1463,12 @@ bool settings_save_config(void)
1454 fprintf(fd, "prerecording time: %d\r\n", 1463 fprintf(fd, "prerecording time: %d\r\n",
1455 global_settings.rec_prerecord_time); 1464 global_settings.rec_prerecord_time);
1456 1465
1466 {
1467 static char* options[] = {rec_base_directory, "current"};
1468 fprintf(fd, "rec directory: %s\r\n",
1469 options[global_settings.rec_directory]);
1470 }
1471
1457#endif 1472#endif
1458 1473
1459 fprintf(fd, "#\r\n# Bookmarking\r\n#\r\n"); 1474 fprintf(fd, "#\r\n# Bookmarking\r\n#\r\n");
@@ -1513,6 +1528,7 @@ void settings_reset(void) {
1513 global_settings.rec_right_gain = 2; /* 0dB */ 1528 global_settings.rec_right_gain = 2; /* 0dB */
1514 global_settings.rec_editable = false; 1529 global_settings.rec_editable = false;
1515 global_settings.rec_prerecord_time = 0; 1530 global_settings.rec_prerecord_time = 0;
1531 global_settings.rec_directory = 0; /* rec_base_directory */
1516 global_settings.resume = RESUME_ASK; 1532 global_settings.resume = RESUME_ASK;
1517 global_settings.contrast = lcd_default_contrast(); 1533 global_settings.contrast = lcd_default_contrast();
1518 global_settings.invert = DEFAULT_INVERT_SETTING; 1534 global_settings.invert = DEFAULT_INVERT_SETTING;
diff --git a/apps/settings.h b/apps/settings.h
index 49fa83b359..436b5204d5 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -28,6 +28,7 @@
28#define FONT_DIR "/fonts" 28#define FONT_DIR "/fonts"
29#define LANG_DIR "/langs" 29#define LANG_DIR "/langs"
30#define PLUGIN_DIR ROCKBOX_DIR"/rocks" 30#define PLUGIN_DIR ROCKBOX_DIR"/rocks"
31#define REC_BASE_DIR "/recordings"
31 32
32#define MAX_FILENAME 20 33#define MAX_FILENAME 20
33 34
@@ -95,6 +96,7 @@ struct user_settings
95 13= 24:00 */ 96 13= 24:00 */
96 97
97 int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */ 98 int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */
99 int rec_directory; /* 0=base dir, 1=current dir */
98 100
99 /* device settings */ 101 /* device settings */
100 102
@@ -230,6 +232,9 @@ extern struct user_settings global_settings;
230extern char rockboxdir[]; 232extern char rockboxdir[];
231extern long lasttime; 233extern long lasttime;
232 234
235/* Recording base directory */
236extern char rec_base_directory[];
237
233/* system defines */ 238/* system defines */
234 239
235#ifdef HAVE_LCD_CHARCELLS 240#ifdef HAVE_LCD_CHARCELLS
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index 11a5581ecb..01bbe09bd1 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -255,6 +255,17 @@ static bool recprerecord(void)
255 names, 31, NULL ); 255 names, 31, NULL );
256} 256}
257 257
258static bool recdirectory(void)
259{
260 char *names[] = {
261 rec_base_directory, str(LANG_RECORD_CURRENT_DIR)
262 };
263
264 return set_option(str(LANG_RECORD_DIRECTORY),
265 &global_settings.rec_directory, INT,
266 names, 2, NULL );
267}
268
258#endif /* HAVE_MAS3587F */ 269#endif /* HAVE_MAS3587F */
259 270
260static void set_chanconf(int val) 271static void set_chanconf(int val)
@@ -308,7 +319,7 @@ bool recording_menu(bool no_source)
308{ 319{
309 int m; 320 int m;
310 int i = 0; 321 int i = 0;
311 struct menu_items menu[7]; 322 struct menu_items menu[8];
312 bool result; 323 bool result;
313 324
314 menu[i].desc = str(LANG_RECORDING_QUALITY); 325 menu[i].desc = str(LANG_RECORDING_QUALITY);
@@ -327,6 +338,8 @@ bool recording_menu(bool no_source)
327 menu[i++].function = rectimesplit; 338 menu[i++].function = rectimesplit;
328 menu[i].desc = str(LANG_RECORD_PRERECORD_TIME); 339 menu[i].desc = str(LANG_RECORD_PRERECORD_TIME);
329 menu[i++].function = recprerecord; 340 menu[i++].function = recprerecord;
341 menu[i].desc = str(LANG_RECORD_DIRECTORY);
342 menu[i++].function = recdirectory;
330 343
331 m=menu_init( menu, i ); 344 m=menu_init( menu, i );
332 result = menu_run(m); 345 result = menu_run(m);
diff --git a/apps/tree.c b/apps/tree.c
index 9e1a22f567..aedeeb1dfd 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -772,6 +772,9 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
772 { 772 {
773 int onplay_result; 773 int onplay_result;
774 774
775 if(!numentries)
776 break;
777
775 if (currdir[1]) 778 if (currdir[1])
776 snprintf(buf, sizeof buf, "%s/%s", 779 snprintf(buf, sizeof buf, "%s/%s",
777 currdir, dircache[dircursor+dirstart].name); 780 currdir, dircache[dircursor+dirstart].name);
@@ -1499,6 +1502,30 @@ bool create_playlist(void)
1499 return true; 1502 return true;
1500} 1503}
1501 1504
1505bool create_dir(void)
1506{
1507 char dirname[MAX_PATH];
1508 int rc;
1509 int pathlen;
1510
1511 memset(dirname, 0, sizeof dirname);
1512
1513 snprintf(dirname, sizeof dirname, "%s/",
1514 currdir[1] ? currdir : "");
1515
1516 pathlen = strlen(dirname);
1517 rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen);
1518 if(rc < 0)
1519 return false;
1520
1521 rc = mkdir(dirname, 0);
1522 if(rc < 0) {
1523 splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED));
1524 }
1525
1526 return true;
1527}
1528
1502bool rockbox_browse(char *root, int dirfilter) 1529bool rockbox_browse(char *root, int dirfilter)
1503{ 1530{
1504 bool rc; 1531 bool rc;
diff --git a/apps/tree.h b/apps/tree.h
index c7b678eb82..45297361f5 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -47,6 +47,7 @@ void browse_root(void);
47void set_current_file(char *path); 47void set_current_file(char *path);
48bool rockbox_browse(char *root, int dirfilter); 48bool rockbox_browse(char *root, int dirfilter);
49bool create_playlist(void); 49bool create_playlist(void);
50bool create_dir(void);
50void resume_directory(char *dir); 51void resume_directory(char *dir);
51char *getcwd(char *buf, int size); 52char *getcwd(char *buf, int size);
52void reload_directory(void); 53void reload_directory(void);