1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jörg Hohensohn 2004-03-11 19:27:26 +00:00
parent 3b6cc1c3c2
commit fbea708b2e

View file

@ -288,7 +288,8 @@ static bool stop_pending;
unsigned long record_start_time; /* Value of current_tick when recording unsigned long record_start_time; /* Value of current_tick when recording
was started */ was started */
static bool saving; /* We are saving the buffer to disk */ 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_frequency_index; /* For create_xing_header() calls */
static int rec_version_index; /* For create_xing_header() calls */ static int rec_version_index; /* For create_xing_header() calls */
static bool disable_xing_header; /* When splitting files */ static bool disable_xing_header; /* When splitting files */
@ -1649,11 +1650,10 @@ static void mpeg_thread(void)
} }
start_recording(); start_recording();
mpeg_file = open(recording_filename, O_WRONLY|O_CREAT);
if(mpeg_file < 0) /* delayed until buffer is saved, don't open yet */
panicf("recfile: %d", mpeg_file); strcpy(delayed_filename, recording_filename);
mpeg_file = -1;
break; break;
@ -1783,6 +1783,14 @@ static void mpeg_thread(void)
writelen = MIN(amount_to_save, writelen = MIN(amount_to_save,
mp3buflen - mp3buf_read); 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) if(writelen)
{ {
rc = write(mpeg_file, mp3buf + mp3buf_read, writelen); rc = write(mpeg_file, mp3buf + mp3buf_read, writelen);
@ -1867,6 +1875,15 @@ static void mpeg_thread(void)
DEBUGF("wrl: %x\n", writelen); 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, rc = write(mpeg_file, mp3buf + mp3buf_read,
writelen); writelen);