summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-04-25 19:53:34 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-04-25 19:53:34 +0000
commit205ec3279d32a152f6046ecc6ad66c39f097fa4d (patch)
treefa8bb607ebae23a0b43428ea6850797af83b57a0
parent2a2b8d8a8234633779dca0fff5e7ce23ad4c48ed (diff)
downloadrockbox-205ec3279d32a152f6046ecc6ad66c39f097fa4d.tar.gz
rockbox-205ec3279d32a152f6046ecc6ad66c39f097fa4d.zip
Make recording complain about every little file I/O problem (error on close() failure and fsync() failure). Why? I guess we will find out the disk is full about 1/2 sector sooner on average when the file APIs actually detect this correctly. :/
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13262 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/aiff_enc.c5
-rw-r--r--apps/codecs/mp3_enc.c4
-rw-r--r--apps/codecs/wav_enc.c5
-rw-r--r--apps/codecs/wavpack_enc.c5
-rw-r--r--firmware/export/pcm_record.h10
-rw-r--r--firmware/pcm_record.c14
6 files changed, 21 insertions, 22 deletions
diff --git a/apps/codecs/aiff_enc.c b/apps/codecs/aiff_enc.c
index 2292bcc275..51c4344702 100644
--- a/apps/codecs/aiff_enc.c
+++ b/apps/codecs/aiff_enc.c
@@ -181,13 +181,12 @@ static bool on_end_file(struct enc_file_event_data *data)
181 hdr.ssnd_size = htobe32(data_size + 8); 181 hdr.ssnd_size = htobe32(data_size + 8);
182 182
183 if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || 183 if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 ||
184 ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr)) 184 ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr) ||
185 ci->close(data->rec_file) != 0)
185 { 186 {
186 return false; 187 return false;
187 } 188 }
188 189
189 ci->fsync(data->rec_file);
190 ci->close(data->rec_file);
191 data->rec_file = -1; 190 data->rec_file = -1;
192 191
193 return true; 192 return true;
diff --git a/apps/codecs/mp3_enc.c b/apps/codecs/mp3_enc.c
index daa6cfefa6..08cbb18f03 100644
--- a/apps/codecs/mp3_enc.c
+++ b/apps/codecs/mp3_enc.c
@@ -2329,11 +2329,9 @@ static bool on_start_file(struct enc_file_event_data *data)
2329 2329
2330static bool on_end_file(struct enc_file_event_data *data) 2330static bool on_end_file(struct enc_file_event_data *data)
2331{ 2331{
2332 if (!is_file_data_ok(data)) 2332 if (!is_file_data_ok(data) || ci->close(data->rec_file) != 0)
2333 return false; 2333 return false;
2334 2334
2335 ci->fsync(data->rec_file);
2336 ci->close(data->rec_file);
2337 data->rec_file = -1; 2335 data->rec_file = -1;
2338 2336
2339 return true; 2337 return true;
diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c
index ff77f137d2..a11aaa07d6 100644
--- a/apps/codecs/wav_enc.c
+++ b/apps/codecs/wav_enc.c
@@ -169,13 +169,12 @@ static bool on_end_file(struct enc_file_event_data *data)
169 hdr.data_size = htole32(data_size); 169 hdr.data_size = htole32(data_size);
170 170
171 if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || 171 if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 ||
172 ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr)) 172 ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr) ||
173 ci->close(data->rec_file) != 0)
173 { 174 {
174 return false; 175 return false;
175 } 176 }
176 177
177 ci->fsync(data->rec_file);
178 ci->close(data->rec_file);
179 data->rec_file = -1; 178 data->rec_file = -1;
180 179
181 return true; 180 return true;
diff --git a/apps/codecs/wavpack_enc.c b/apps/codecs/wavpack_enc.c
index 7b6484d6cf..744b98721c 100644
--- a/apps/codecs/wavpack_enc.c
+++ b/apps/codecs/wavpack_enc.c
@@ -294,13 +294,12 @@ static bool on_end_file(struct enc_file_event_data *data)
294 ci->write(data->rec_file, &h.wpmdh, sizeof (h.wpmdh)) 294 ci->write(data->rec_file, &h.wpmdh, sizeof (h.wpmdh))
295 != sizeof (h.wpmdh) || 295 != sizeof (h.wpmdh) ||
296 ci->write(data->rec_file, &h.rhdr, sizeof (h.rhdr)) 296 ci->write(data->rec_file, &h.rhdr, sizeof (h.rhdr))
297 != sizeof (h.rhdr)) 297 != sizeof (h.rhdr) ||
298 ci->close(data->rec_file) != 0 )
298 { 299 {
299 return false; 300 return false;
300 } 301 }
301 302
302 ci->fsync(data->rec_file);
303 ci->close(data->rec_file);
304 data->rec_file = -1; 303 data->rec_file = -1;
305 304
306 return true; 305 return true;
diff --git a/firmware/export/pcm_record.h b/firmware/export/pcm_record.h
index 865a37fc70..8075b00ffc 100644
--- a/firmware/export/pcm_record.h
+++ b/firmware/export/pcm_record.h
@@ -45,15 +45,17 @@
45#define PCMREC_E_ENCODER 0x80002000 45#define PCMREC_E_ENCODER 0x80002000
46/* filename queue has desynced from stream markers */ 46/* filename queue has desynced from stream markers */
47#define PCMREC_E_FNQ_DESYNC 0x80004000 47#define PCMREC_E_FNQ_DESYNC 0x80004000
48/* I/O error has occurred */
49#define PCMREC_E_IO 0x80008000
48#ifdef PCMREC_PARANOID 50#ifdef PCMREC_PARANOID
49/* encoder has written past end of allotted space */ 51/* encoder has written past end of allotted space */
50#define PCMREC_E_CHUNK_OVF 0x80008000 52#define PCMREC_E_CHUNK_OVF 0x80010000
51/* chunk header incorrect */ 53/* chunk header incorrect */
52#define PCMREC_E_BAD_CHUNK 0x80010000 54#define PCMREC_E_BAD_CHUNK 0x80020000
53/* encoder read position changed outside of recording control */ 55/* encoder read position changed outside of recording control */
54#define PCMREC_E_ENC_RD_INDEX_TRASHED 0x80020000 56#define PCMREC_E_ENC_RD_INDEX_TRASHED 0x80040000
55/* encoder write position changed outside of recording control */ 57/* encoder write position changed outside of recording control */
56#define PCMREC_E_ENC_WR_INDEX_TRASHED 0x80040000 58#define PCMREC_E_ENC_WR_INDEX_TRASHED 0x80080000
57#endif /* PCMREC_PARANOID */ 59#endif /* PCMREC_PARANOID */
58 60
59/** 61/**
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c
index e0bb664af1..c27f80400d 100644
--- a/firmware/pcm_record.c
+++ b/firmware/pcm_record.c
@@ -653,7 +653,9 @@ static void pcmrec_close_file(int *fd_p)
653 if (*fd_p < 0) 653 if (*fd_p < 0)
654 return; /* preserve error */ 654 return; /* preserve error */
655 655
656 close(*fd_p); 656 if (close(*fd_p) != 0)
657 errors |= PCMREC_E_IO;
658
657 *fd_p = -1; 659 *fd_p = -1;
658} /* pcmrec_close_file */ 660} /* pcmrec_close_file */
659 661
@@ -1042,8 +1044,8 @@ static void pcmrec_flush(unsigned flush_num)
1042 } /* end while */ 1044 } /* end while */
1043 1045
1044 /* sync file */ 1046 /* sync file */
1045 if (rec_fdata.rec_file >= 0) 1047 if (rec_fdata.rec_file >= 0 && fsync(rec_fdata.rec_file) != 0)
1046 fsync(rec_fdata.rec_file); 1048 errors |= PCMREC_E_IO;
1047 1049
1048 cpu_boost(false); 1050 cpu_boost(false);
1049 1051
@@ -1239,13 +1241,13 @@ static void pcmrec_init(void)
1239{ 1241{
1240 unsigned char *buffer; 1242 unsigned char *buffer;
1241 1243
1242 pcmrec_close_file(&rec_fdata.rec_file);
1243 rec_fdata.rec_file = -1;
1244
1245 /* warings and errors */ 1244 /* warings and errors */
1246 warnings = 1245 warnings =
1247 errors = 0; 1246 errors = 0;
1248 1247
1248 pcmrec_close_file(&rec_fdata.rec_file);
1249 rec_fdata.rec_file = -1;
1250
1249 /* pcm FIFO */ 1251 /* pcm FIFO */
1250 dma_lock = true; 1252 dma_lock = true;
1251 SET_PCM_POS(pcm_rd_pos, 0); 1253 SET_PCM_POS(pcm_rd_pos, 0);