forked from len0rd/rockbox
Safer recording, now closes the file after each successful buffer save
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3321 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6e3eb8489b
commit
94dea1e020
1 changed files with 19 additions and 4 deletions
|
|
@ -485,6 +485,7 @@ 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];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int mpeg_file;
|
static int mpeg_file;
|
||||||
|
|
@ -1805,10 +1806,13 @@ static void mpeg_thread(void)
|
||||||
reset_mp3_buffer();
|
reset_mp3_buffer();
|
||||||
start_recording();
|
start_recording();
|
||||||
demand_irq_enable(true);
|
demand_irq_enable(true);
|
||||||
mpeg_file = open((char *)ev.data,
|
mpeg_file = creat(recording_filename, O_WRONLY);
|
||||||
O_WRONLY | O_TRUNC | O_CREAT);
|
|
||||||
if(mpeg_file < 0)
|
if(mpeg_file < 0)
|
||||||
panicf("recfile: %d", mpeg_file);
|
panicf("recfile: %d", mpeg_file);
|
||||||
|
|
||||||
|
close(mpeg_file);
|
||||||
|
mpeg_file = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MPEG_STOP:
|
case MPEG_STOP:
|
||||||
|
|
@ -1870,8 +1874,16 @@ static void mpeg_thread(void)
|
||||||
mp3buflen - mp3buf_read);
|
mp3buflen - mp3buf_read);
|
||||||
|
|
||||||
DEBUGF("wrl: %x\n", writelen);
|
DEBUGF("wrl: %x\n", writelen);
|
||||||
|
mpeg_file = open(recording_filename,
|
||||||
|
O_WRONLY| O_APPEND);
|
||||||
|
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);
|
||||||
|
|
||||||
|
close(mpeg_file);
|
||||||
|
mpeg_file = -1;
|
||||||
DEBUGF("rc: %x\n", rc);
|
DEBUGF("rc: %x\n", rc);
|
||||||
|
|
||||||
mp3buf_read += amount_to_save;
|
mp3buf_read += amount_to_save;
|
||||||
|
|
@ -2137,8 +2149,11 @@ static void init_playback(void)
|
||||||
|
|
||||||
void mpeg_record(char *filename)
|
void mpeg_record(char *filename)
|
||||||
{
|
{
|
||||||
|
strncpy(recording_filename, filename, MAX_PATH - 1);
|
||||||
|
recording_filename[MAX_PATH - 1] = 0;
|
||||||
|
|
||||||
num_rec_bytes = 0;
|
num_rec_bytes = 0;
|
||||||
queue_post(&mpeg_queue, MPEG_RECORD, (void*)filename);
|
queue_post(&mpeg_queue, MPEG_RECORD, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void start_recording(void)
|
static void start_recording(void)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue