forked from len0rd/rockbox
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
This commit is contained in:
parent
2a2b8d8a82
commit
205ec3279d
6 changed files with 21 additions and 22 deletions
|
|
@ -181,13 +181,12 @@ static bool on_end_file(struct enc_file_event_data *data)
|
||||||
hdr.ssnd_size = htobe32(data_size + 8);
|
hdr.ssnd_size = htobe32(data_size + 8);
|
||||||
|
|
||||||
if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 ||
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ci->fsync(data->rec_file);
|
|
||||||
ci->close(data->rec_file);
|
|
||||||
data->rec_file = -1;
|
data->rec_file = -1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -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)
|
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;
|
return false;
|
||||||
|
|
||||||
ci->fsync(data->rec_file);
|
|
||||||
ci->close(data->rec_file);
|
|
||||||
data->rec_file = -1;
|
data->rec_file = -1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -169,13 +169,12 @@ static bool on_end_file(struct enc_file_event_data *data)
|
||||||
hdr.data_size = htole32(data_size);
|
hdr.data_size = htole32(data_size);
|
||||||
|
|
||||||
if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 ||
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ci->fsync(data->rec_file);
|
|
||||||
ci->close(data->rec_file);
|
|
||||||
data->rec_file = -1;
|
data->rec_file = -1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -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))
|
ci->write(data->rec_file, &h.wpmdh, sizeof (h.wpmdh))
|
||||||
!= sizeof (h.wpmdh) ||
|
!= sizeof (h.wpmdh) ||
|
||||||
ci->write(data->rec_file, &h.rhdr, sizeof (h.rhdr))
|
ci->write(data->rec_file, &h.rhdr, sizeof (h.rhdr))
|
||||||
!= sizeof (h.rhdr))
|
!= sizeof (h.rhdr) ||
|
||||||
|
ci->close(data->rec_file) != 0 )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ci->fsync(data->rec_file);
|
|
||||||
ci->close(data->rec_file);
|
|
||||||
data->rec_file = -1;
|
data->rec_file = -1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -45,15 +45,17 @@
|
||||||
#define PCMREC_E_ENCODER 0x80002000
|
#define PCMREC_E_ENCODER 0x80002000
|
||||||
/* filename queue has desynced from stream markers */
|
/* filename queue has desynced from stream markers */
|
||||||
#define PCMREC_E_FNQ_DESYNC 0x80004000
|
#define PCMREC_E_FNQ_DESYNC 0x80004000
|
||||||
|
/* I/O error has occurred */
|
||||||
|
#define PCMREC_E_IO 0x80008000
|
||||||
#ifdef PCMREC_PARANOID
|
#ifdef PCMREC_PARANOID
|
||||||
/* encoder has written past end of allotted space */
|
/* encoder has written past end of allotted space */
|
||||||
#define PCMREC_E_CHUNK_OVF 0x80008000
|
#define PCMREC_E_CHUNK_OVF 0x80010000
|
||||||
/* chunk header incorrect */
|
/* chunk header incorrect */
|
||||||
#define PCMREC_E_BAD_CHUNK 0x80010000
|
#define PCMREC_E_BAD_CHUNK 0x80020000
|
||||||
/* encoder read position changed outside of recording control */
|
/* 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 */
|
/* 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 */
|
#endif /* PCMREC_PARANOID */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -653,7 +653,9 @@ static void pcmrec_close_file(int *fd_p)
|
||||||
if (*fd_p < 0)
|
if (*fd_p < 0)
|
||||||
return; /* preserve error */
|
return; /* preserve error */
|
||||||
|
|
||||||
close(*fd_p);
|
if (close(*fd_p) != 0)
|
||||||
|
errors |= PCMREC_E_IO;
|
||||||
|
|
||||||
*fd_p = -1;
|
*fd_p = -1;
|
||||||
} /* pcmrec_close_file */
|
} /* pcmrec_close_file */
|
||||||
|
|
||||||
|
|
@ -1042,8 +1044,8 @@ static void pcmrec_flush(unsigned flush_num)
|
||||||
} /* end while */
|
} /* end while */
|
||||||
|
|
||||||
/* sync file */
|
/* sync file */
|
||||||
if (rec_fdata.rec_file >= 0)
|
if (rec_fdata.rec_file >= 0 && fsync(rec_fdata.rec_file) != 0)
|
||||||
fsync(rec_fdata.rec_file);
|
errors |= PCMREC_E_IO;
|
||||||
|
|
||||||
cpu_boost(false);
|
cpu_boost(false);
|
||||||
|
|
||||||
|
|
@ -1239,13 +1241,13 @@ static void pcmrec_init(void)
|
||||||
{
|
{
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
|
|
||||||
pcmrec_close_file(&rec_fdata.rec_file);
|
|
||||||
rec_fdata.rec_file = -1;
|
|
||||||
|
|
||||||
/* warings and errors */
|
/* warings and errors */
|
||||||
warnings =
|
warnings =
|
||||||
errors = 0;
|
errors = 0;
|
||||||
|
|
||||||
|
pcmrec_close_file(&rec_fdata.rec_file);
|
||||||
|
rec_fdata.rec_file = -1;
|
||||||
|
|
||||||
/* pcm FIFO */
|
/* pcm FIFO */
|
||||||
dma_lock = true;
|
dma_lock = true;
|
||||||
SET_PCM_POS(pcm_rd_pos, 0);
|
SET_PCM_POS(pcm_rd_pos, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue