summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-03-11 19:27:26 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-03-11 19:27:26 +0000
commitfbea708b2e2e61af9238bc356b07a1e22ed44833 (patch)
tree59559bc3aa9de384d86a65e746c4c28c05726939 /firmware
parent3b6cc1c3c28df3dc747a5d620ed3347db12c79e1 (diff)
downloadrockbox-fbea708b2e2e61af9238bc356b07a1e22ed44833.tar.gz
rockbox-fbea708b2e2e61af9238bc356b07a1e22ed44833.tar.bz2
rockbox-fbea708b2e2e61af9238bc356b07a1e22ed44833.zip
Feature for recording: Delayed file open avoids disk spinup as long as the buffer lasts. So for short clips the internal mic can be used without disturbance.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4367 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/mpeg.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 645e60fdcd..ff545f03d0 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -288,7 +288,8 @@ static bool stop_pending;
unsigned long record_start_time; /* Value of current_tick when recording
was started */
static bool saving; /* We are saving the buffer to disk */
-static char recording_filename[MAX_PATH];
+static char recording_filename[MAX_PATH]; /* argument to thread */
+static char delayed_filename[MAX_PATH]; /* internal copy of above */
static int rec_frequency_index; /* For create_xing_header() calls */
static int rec_version_index; /* For create_xing_header() calls */
static bool disable_xing_header; /* When splitting files */
@@ -1649,11 +1650,10 @@ static void mpeg_thread(void)
}
start_recording();
-
- mpeg_file = open(recording_filename, O_WRONLY|O_CREAT);
- if(mpeg_file < 0)
- panicf("recfile: %d", mpeg_file);
+ /* delayed until buffer is saved, don't open yet */
+ strcpy(delayed_filename, recording_filename);
+ mpeg_file = -1;
break;
@@ -1783,6 +1783,14 @@ static void mpeg_thread(void)
writelen = MIN(amount_to_save,
mp3buflen - mp3buf_read);
+ if (mpeg_file < 0) /* delayed file opening */
+ {
+ mpeg_file = open(delayed_filename, O_WRONLY|O_CREAT);
+
+ if(mpeg_file < 0)
+ panicf("recfile: %d", mpeg_file);
+ }
+
if(writelen)
{
rc = write(mpeg_file, mp3buf + mp3buf_read, writelen);
@@ -1867,6 +1875,15 @@ static void mpeg_thread(void)
DEBUGF("wrl: %x\n", writelen);
+ if (mpeg_file < 0) /* delayed file opening */
+ {
+ mpeg_file = open(delayed_filename,
+ O_WRONLY|O_CREAT);
+
+ if(mpeg_file < 0)
+ panicf("recfile: %d", mpeg_file);
+ }
+
rc = write(mpeg_file, mp3buf + mp3buf_read,
writelen);