From eca9f7fd6023a2b7acde89692812d1ecbd8964e6 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 10 Dec 2006 14:21:31 +0000 Subject: Place all recording functionality on pcmrec thread to serialize all recording operations. Button mash problems should be ruled out of pcm_record.c. Add additional lightweight checks by default and display any warnings that occurred during recording in first line of recording screen when they occur by blinking back and forth from warning display to normal line (Warning: ). Warnings are cleared when beginning a new recording so write the number down if you see it and file a report. Add heavier checks when PCMREC_PARANOID is defined in the player config header (encoders and pcm_record must be aware of the define since it changes the chunk header format). These checks are mainly concerned with things that may cause skipping but also add unwanted overhead for normal operation. Best used with logf enabled. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11705 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/audio.h | 17 +++++++++-------- firmware/export/enc_base.h | 8 ++++++++ firmware/export/pcm_record.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-) (limited to 'firmware/export') diff --git a/firmware/export/audio.h b/firmware/export/audio.h index 3edbfe155d..6a98d6f4c5 100644 --- a/firmware/export/audio.h +++ b/firmware/export/audio.h @@ -39,16 +39,17 @@ #define audio_play(x) sim_audio_play(x) #endif -#define AUDIO_STATUS_PLAY 1 -#define AUDIO_STATUS_PAUSE 2 -#define AUDIO_STATUS_RECORD 4 -#define AUDIO_STATUS_PRERECORD 8 -#define AUDIO_STATUS_ERROR 16 +#define AUDIO_STATUS_PLAY 0x0001 +#define AUDIO_STATUS_PAUSE 0x0002 +#define AUDIO_STATUS_RECORD 0x0004 +#define AUDIO_STATUS_PRERECORD 0x0008 +#define AUDIO_STATUS_ERROR 0x0010 +#define AUDIO_STATUS_WARNING 0x0020 -#define AUDIOERR_DISK_FULL 1 +#define AUDIOERR_DISK_FULL 1 -#define AUDIO_GAIN_LINEIN 0 -#define AUDIO_GAIN_MIC 1 +#define AUDIO_GAIN_LINEIN 0 +#define AUDIO_GAIN_MIC 1 struct audio_debug diff --git a/firmware/export/enc_base.h b/firmware/export/enc_base.h index 1be796ec8f..8d1e6fa11e 100644 --- a/firmware/export/enc_base.h +++ b/firmware/export/enc_base.h @@ -152,10 +152,18 @@ struct encoder_config #define CHUNKF_ERROR 0x80000000 /* An error has occured (passed to/ from encoder). Use the sign bit to check (long)flags < 0. */ +#define CHUNKF_ALLFLAGS 0x80000033 /* Header at the beginning of every encoder chunk */ +#ifdef PCMREC_PARANOID +#define ENC_CHUNK_MAGIC H_TO_BE32(('P' << 24) | ('T' << 16) | ('Y' << 8) | 'R') +#endif struct enc_chunk_hdr { +#ifdef PCMREC_PARANOID + unsigned long id; /* overflow detection - 'PTYR' - acronym for + "PTYR Tells You Right" ;) */ +#endif unsigned long flags; /* in/out: flags used by encoder and file writing */ size_t enc_size; /* out: amount of encoder data written to diff --git a/firmware/export/pcm_record.h b/firmware/export/pcm_record.h index f6dddb3424..865a37fc70 100644 --- a/firmware/export/pcm_record.h +++ b/firmware/export/pcm_record.h @@ -25,6 +25,37 @@ #define DMA_REC_ERROR_SPDIF (-2) #endif +/** Warnings **/ +/* pcm (dma) buffer has overflowed */ +#define PCMREC_W_PCM_BUFFER_OVF 0x00000001 +/* encoder output buffer has overflowed */ +#define PCMREC_W_ENC_BUFFER_OVF 0x00000002 +#ifdef PCMREC_PARANOID +/* dma write position alignment incorrect */ +#define PCMREC_W_DMA_WR_POS_ALIGN 0x00000004 +/* pcm read position changed at some point not under control of recording */ +#define PCMREC_W_PCM_RD_POS_TRASHED 0x00000008 +/* dma write position changed at some point not under control of recording */ +#define PCMREC_W_DMA_WR_POS_TRASHED 0x00000010 +#endif /* PCMREC_PARANOID */ +/** Errors **/ +/* failed to load encoder */ +#define PCMREC_E_LOAD_ENCODER 0x80001000 +/* error originating in encoder */ +#define PCMREC_E_ENCODER 0x80002000 +/* filename queue has desynced from stream markers */ +#define PCMREC_E_FNQ_DESYNC 0x80004000 +#ifdef PCMREC_PARANOID +/* encoder has written past end of allotted space */ +#define PCMREC_E_CHUNK_OVF 0x80008000 +/* chunk header incorrect */ +#define PCMREC_E_BAD_CHUNK 0x80010000 +/* encoder read position changed outside of recording control */ +#define PCMREC_E_ENC_RD_INDEX_TRASHED 0x80020000 +/* encoder write position changed outside of recording control */ +#define PCMREC_E_ENC_WR_INDEX_TRASHED 0x80040000 +#endif /* PCMREC_PARANOID */ + /** * RAW pcm data recording * These calls are nescessary only when using the raw pcm apis directly. @@ -54,6 +85,7 @@ void pcm_rec_error_clear(void); /* pcm_rec_status is deprecated for general use. audio_status merges the results for consistency with the hardware codec version */ unsigned long pcm_rec_status(void); +unsigned long pcm_rec_get_warnings(void); void pcm_rec_init(void); int pcm_rec_current_bitrate(void); int pcm_rec_encoder_afmt(void); /* AFMT_* value, AFMT_UNKNOWN if none */ -- cgit v1.2.3