summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-02-22 01:40:57 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-02-22 01:40:57 +0000
commit94dea1e020806011f7596dbee508fb117954bdcc (patch)
tree6f296aed6ef4ba03081edc1fb9c3ccf867cb8026 /firmware
parent6e3eb8489bd79f9922195d4ab7c98f1e7b0ffe84 (diff)
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
Diffstat (limited to 'firmware')
-rw-r--r--firmware/mpeg.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 6fe60c99c9..e9d0943115 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -485,6 +485,7 @@ 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];
#endif
static int mpeg_file;
@@ -1576,7 +1577,7 @@ static void mpeg_thread(void)
{
/* We need to load more data before starting */
filling = true;
- queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
+ queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
play_pending = true;
}
else if (unswapped_space_left > unplayed_space_left)
@@ -1805,10 +1806,13 @@ static void mpeg_thread(void)
reset_mp3_buffer();
start_recording();
demand_irq_enable(true);
- mpeg_file = open((char *)ev.data,
- O_WRONLY | O_TRUNC | O_CREAT);
+ mpeg_file = creat(recording_filename, O_WRONLY);
+
if(mpeg_file < 0)
panicf("recfile: %d", mpeg_file);
+
+ close(mpeg_file);
+ mpeg_file = -1;
break;
case MPEG_STOP:
@@ -1870,8 +1874,16 @@ static void mpeg_thread(void)
mp3buflen - mp3buf_read);
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,
writelen);
+
+ close(mpeg_file);
+ mpeg_file = -1;
DEBUGF("rc: %x\n", rc);
mp3buf_read += amount_to_save;
@@ -2137,8 +2149,11 @@ static void init_playback(void)
void mpeg_record(char *filename)
{
+ strncpy(recording_filename, filename, MAX_PATH - 1);
+ recording_filename[MAX_PATH - 1] = 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)