diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2007-04-25 19:53:34 +0000 |
|---|---|---|
| committer | Michael Sevakis <jethead71@rockbox.org> | 2007-04-25 19:53:34 +0000 |
| commit | 205ec3279d32a152f6046ecc6ad66c39f097fa4d (patch) | |
| tree | fa8bb607ebae23a0b43428ea6850797af83b57a0 | |
| parent | 2a2b8d8a8234633779dca0fff5e7ce23ad4c48ed (diff) | |
| download | rockbox-205ec3279d32a152f6046ecc6ad66c39f097fa4d.zip rockbox-205ec3279d32a152f6046ecc6ad66c39f097fa4d.tar.gz rockbox-205ec3279d32a152f6046ecc6ad66c39f097fa4d.tar.bz2 rockbox-205ec3279d32a152f6046ecc6ad66c39f097fa4d.tar.xz | |
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.c | 5 | ||||
| -rw-r--r-- | apps/codecs/mp3_enc.c | 4 | ||||
| -rw-r--r-- | apps/codecs/wav_enc.c | 5 | ||||
| -rw-r--r-- | apps/codecs/wavpack_enc.c | 5 | ||||
| -rw-r--r-- | firmware/export/pcm_record.h | 10 | ||||
| -rw-r--r-- | firmware/pcm_record.c | 14 |
6 files changed, 21 insertions, 22 deletions
diff --git a/apps/codecs/aiff_enc.c b/apps/codecs/aiff_enc.c index 2292bcc..51c4344 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) hdr.ssnd_size = htobe32(data_size + 8); if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || - ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr)) + ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr) || + ci->close(data->rec_file) != 0) { return false; } - ci->fsync(data->rec_file); - ci->close(data->rec_file); data->rec_file = -1; return true; diff --git a/apps/codecs/mp3_enc.c b/apps/codecs/mp3_enc.c index daa6cfe..08cbb18 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) static bool on_end_file(struct enc_file_event_data *data) { - if (!is_file_data_ok(data)) + if (!is_file_data_ok(data) || ci->close(data->rec_file) != 0) return false; - ci->fsync(data->rec_file); - ci->close(data->rec_file); data->rec_file = -1; return true; diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c index ff77f13..a11aaa0 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) hdr.data_size = htole32(data_size); if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || - ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr)) + ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr) || + ci->close(data->rec_file) != 0) { return false; } - ci->fsync(data->rec_file); - ci->close(data->rec_file); data->rec_file = -1; return true; diff --git a/apps/codecs/wavpack_enc.c b/apps/codecs/wavpack_enc.c index 7b6484d..744b987 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) ci->write(data->rec_file, &h.wpmdh, sizeof (h.wpmdh)) != sizeof (h.wpmdh) || ci->write(data->rec_file, &h.rhdr, sizeof (h.rhdr)) - != sizeof (h.rhdr)) + != sizeof (h.rhdr) || + ci->close(data->rec_file) != 0 ) { return false; } - ci->fsync(data->rec_file); - ci->close(data->rec_file); data->rec_file = -1; return true; diff --git a/firmware/export/pcm_record.h b/firmware/export/pcm_record.h index 865a37f..8075b00 100644 --- a/firmware/export/pcm_record.h +++ b/firmware/export/pcm_record.h @@ -45,15 +45,17 @@ #define PCMREC_E_ENCODER 0x80002000 /* filename queue has desynced from stream markers */ #define PCMREC_E_FNQ_DESYNC 0x80004000 +/* I/O error has occurred */ +#define PCMREC_E_IO 0x80008000 #ifdef PCMREC_PARANOID /* encoder has written past end of allotted space */ -#define PCMREC_E_CHUNK_OVF 0x80008000 +#define PCMREC_E_CHUNK_OVF 0x80010000 /* chunk header incorrect */ -#define PCMREC_E_BAD_CHUNK 0x80010000 +#define PCMREC_E_BAD_CHUNK 0x80020000 /* encoder read position changed outside of recording control */ -#define PCMREC_E_ENC_RD_INDEX_TRASHED 0x80020000 +#define PCMREC_E_ENC_RD_INDEX_TRASHED 0x80040000 /* encoder write position changed outside of recording control */ -#define PCMREC_E_ENC_WR_INDEX_TRASHED 0x80040000 +#define PCMREC_E_ENC_WR_INDEX_TRASHED 0x80080000 #endif /* PCMREC_PARANOID */ /** diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c index e0bb664..c27f804 100644 --- a/firmware/pcm_record.c +++ b/firmware/pcm_record.c @@ -653,7 +653,9 @@ static void pcmrec_close_file(int *fd_p) if (*fd_p < 0) return; /* preserve error */ - close(*fd_p); + if (close(*fd_p) != 0) + errors |= PCMREC_E_IO; + *fd_p = -1; } /* pcmrec_close_file */ @@ -1042,8 +1044,8 @@ static void pcmrec_flush(unsigned flush_num) } /* end while */ /* sync file */ - if (rec_fdata.rec_file >= 0) - fsync(rec_fdata.rec_file); + if (rec_fdata.rec_file >= 0 && fsync(rec_fdata.rec_file) != 0) + errors |= PCMREC_E_IO; cpu_boost(false); @@ -1239,13 +1241,13 @@ static void pcmrec_init(void) { unsigned char *buffer; - pcmrec_close_file(&rec_fdata.rec_file); - rec_fdata.rec_file = -1; - /* warings and errors */ warnings = errors = 0; + pcmrec_close_file(&rec_fdata.rec_file); + rec_fdata.rec_file = -1; + /* pcm FIFO */ dma_lock = true; SET_PCM_POS(pcm_rd_pos, 0); |