summaryrefslogtreecommitdiffstats
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)
bool radio_screen(void)
{
- char buf[128];
+ char buf[MAX_PATH];
bool done = false;
int button;
int val;
@@ -248,13 +248,13 @@ bool radio_screen(void)
case BUTTON_F3:
if(mpeg_status() == MPEG_STATUS_RECORD)
{
- mpeg_new_file(rec_create_filename());
+ mpeg_new_file(rec_create_filename(buf));
update_screen = true;
}
else
{
have_recorded = true;
- mpeg_record(rec_create_filename());
+ mpeg_record(rec_create_filename(buf));
status_set_playmode(STATUS_RECORD);
update_screen = true;
}
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 @@
#include "timefuncs.h"
#include "debug.h"
#include "misc.h"
+#include "tree.h"
+#include "string.h"
+#include "dir.h"
+#include "errno.h"
bool f2_rec_screen(void);
bool f3_rec_screen(void);
@@ -114,20 +118,22 @@ void adjust_cursor(void)
}
}
-char *rec_create_filename(void)
+char *rec_create_filename(char *buffer)
{
- static char fname[32];
- struct tm * tm;
+ int fpos;
+ struct tm *tm = get_time();
- tm = get_time();
+ if(global_settings.rec_directory)
+ getcwd(buffer, MAX_PATH);
+ else
+ strncpy(buffer, rec_base_directory, MAX_PATH);
- /* Create a filename: RYYMMDD-HHMMSS.mp3 */
- snprintf(fname, 32, "/R%02d%02d%02d-%02d%02d%02d.mp3",
+ /* Append filename to path: RYYMMDD-HH.MM.SS.mp3 */
+ fpos = strlen(buffer);
+ snprintf(&buffer[fpos], MAX_PATH-fpos, "/R%02d%02d%02d-%02d%02d%02d.mp3",
tm->tm_year%100, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
-
- DEBUGF("Filename: %s\n", fname);
- return fname;
+ return buffer;
}
bool recording_screen(void)
@@ -144,6 +150,9 @@ bool recording_screen(void)
unsigned int seconds;
unsigned int last_seconds = 0;
int hours, minutes;
+ char path_buffer[MAX_PATH];
+ int rc;
+ bool been_in_usb_mode = false;
cursor = 0;
mpeg_init_recording();
@@ -170,6 +179,25 @@ bool recording_screen(void)
lcd_getstringsize("M", &w, &h);
lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
+ /* Try to create the base directory if needed */
+ if(global_settings.rec_directory == 0)
+ {
+ rc = mkdir(rec_base_directory, 0);
+ if(rc < 0 && errno != EEXIST)
+ {
+ splash(HZ * 2, true,
+ "Can't create the %s directory. Error code %d.",
+ rec_base_directory, rc);
+ }
+ else
+ {
+ /* If we have created the directory, we want the dir browser to
+ be refreshed even if we haven't recorded anything */
+ if(errno != EEXIST)
+ have_recorded = true;
+ }
+ }
+
while(!done)
{
button = button_get_w_tmo(HZ / peak_meter_fps);
@@ -195,13 +223,13 @@ bool recording_screen(void)
if(!(mpeg_status() & MPEG_STATUS_RECORD))
{
have_recorded = true;
- mpeg_record(rec_create_filename());
+ mpeg_record(rec_create_filename(path_buffer));
status_set_playmode(STATUS_RECORD);
update_countdown = 1; /* Update immediately */
}
else
{
- mpeg_new_file(rec_create_filename());
+ mpeg_new_file(rec_create_filename(path_buffer));
update_countdown = 1; /* Update immediately */
}
last_seconds = 0;
@@ -354,8 +382,8 @@ bool recording_screen(void)
if(mpeg_status() != MPEG_STATUS_RECORD)
{
usb_screen();
- have_recorded = true; /* Refreshes the browser later on */
done = true;
+ been_in_usb_mode = true;
}
break;
}
@@ -419,7 +447,7 @@ bool recording_screen(void)
that the recorded files don't get too big. */
if (mpeg_status() && (seconds >= dseconds))
{
- mpeg_new_file(rec_create_filename());
+ mpeg_new_file(rec_create_filename(path_buffer));
update_countdown = 1;
last_seconds = 0;
}
@@ -529,7 +557,11 @@ bool recording_screen(void)
mpeg_sound_set(SOUND_AVC, global_settings.avc);
lcd_setfont(FONT_UI);
- return have_recorded;
+
+ if (have_recorded)
+ reload_directory();
+
+ return been_in_usb_mode;
}
bool 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 @@
#define RECORDING_H
bool recording_screen(void);
-char *rec_create_filename(void);
+char *rec_create_filename(char *buf);
#endif