summaryrefslogtreecommitdiff
path: root/apps/recorder
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/recorder
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/recorder')
-rw-r--r--apps/recorder/radio.c6
-rw-r--r--apps/recorder/recording.c60
-rw-r--r--apps/recorder/recording.h2
3 files changed, 50 insertions, 18 deletions
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