diff --git a/src/AudioGeneratorMP3.cpp b/src/AudioGeneratorMP3.cpp index d839cd0..63108ac 100644 --- a/src/AudioGeneratorMP3.cpp +++ b/src/AudioGeneratorMP3.cpp @@ -394,11 +394,11 @@ bool AudioGeneratorMP3::begin(AudioFileSource *source, AudioOutput *output) { // and to determine if there's enough stack space to allocate some blocks there // instead of precious heap. -#undef stack +#undef stackenter extern "C" { #ifdef ESP32 //TODO - add ESP32 checks - void stack(const char *s, const char *t, int i) { + void stackenter(const char *s, const char *t, int i) { } int stackfree() { return 8192; @@ -407,7 +407,7 @@ extern "C" { #include extern cont_t g_cont; - void stack(const char *s, const char *t, int i) { + void stackenter(const char *s, const char *t, int i) { (void) t; (void) i; register uint32_t *sp asm("a1"); @@ -436,7 +436,7 @@ extern "C" { return freestack; } #else - void stack(const char *s, const char *t, int i) { + void stackenter(const char *s, const char *t, int i) { (void) s; (void) t; (void) i; diff --git a/src/libmad/bit.c b/src/libmad/bit.c index 02e1b17..ec019a8 100644 --- a/src/libmad/bit.c +++ b/src/libmad/bit.c @@ -86,7 +86,7 @@ static const unsigned int crc_table[256] PROGMEM = { DESCRIPTION: initialize bit pointer struct */ void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); bitptr->byte = byte; bitptr->cache = 0; bitptr->left = CHAR_BIT; @@ -98,7 +98,7 @@ void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte) { */ unsigned int mad_bit_length(struct mad_bitptr const *begin, struct mad_bitptr const *end) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); return begin->left + CHAR_BIT * (end->byte - (begin->byte + 1)) + (CHAR_BIT - end->left); } @@ -108,7 +108,7 @@ unsigned int mad_bit_length(struct mad_bitptr const *begin, DESCRIPTION: return pointer to next unprocessed byte */ unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); return bitptr->left == CHAR_BIT ? bitptr->byte : bitptr->byte + 1; } @@ -117,7 +117,7 @@ unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr) { DESCRIPTION: advance bit pointer */ void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); bitptr->byte += len / CHAR_BIT; bitptr->left -= len % CHAR_BIT; @@ -183,7 +183,7 @@ unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) { void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, unsigned long value) { unsigned char *ptr; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); ptr = (unsigned char *) bitptr->byte; @@ -198,7 +198,7 @@ void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, unsigned short init) { unsigned int crc; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); for (crc = init; len >= 32; len -= 32) { unsigned long data; diff --git a/src/libmad/config.h b/src/libmad/config.h index 0538b78..219c12b 100644 --- a/src/libmad/config.h +++ b/src/libmad/config.h @@ -5,7 +5,7 @@ /* #undef DEBUG */ // Uncomment to show heap and stack space on entry -#define stack(a,b,c) +#define stackenter(a,b,c) // Helper function to see if we can allocate one chunk on the stack # ifdef __cplusplus diff --git a/src/libmad/decoder.c b/src/libmad/decoder.c index 87611ac..0d8134c 100644 --- a/src/libmad/decoder.c +++ b/src/libmad/decoder.c @@ -326,7 +326,7 @@ int run_sync(struct mad_decoder *decoder) { struct mad_frame *frame; struct mad_synth *synth; int result = 0; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); if (decoder->input_func == 0) { return 0; diff --git a/src/libmad/frame.c b/src/libmad/frame.c index bcc5368..a7bb316 100644 --- a/src/libmad/frame.c +++ b/src/libmad/frame.c @@ -98,7 +98,7 @@ void mad_header_init(struct mad_header *header) { DESCRIPTION: initialize frame struct */ void mad_frame_init(struct mad_frame *frame) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); mad_header_init(&frame->header); frame->options = 0; diff --git a/src/libmad/layer3.c b/src/libmad/layer3.c index 2323f78..8376e9f 100644 --- a/src/libmad/layer3.c +++ b/src/libmad/layer3.c @@ -537,7 +537,7 @@ enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, unsigned int *priv_bitlen) { unsigned int ngr, gr, ch, i; enum mad_error result = MAD_ERROR_NONE; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); *data_bitlen = 0; *priv_bitlen = lsf ? ((nch == 1) ? 1 : 2) : ((nch == 1) ? 5 : 3); @@ -635,7 +635,7 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, struct mad_bitptr start; unsigned int scalefac_compress, index, slen[4], part, n, i; unsigned int const *nsfb; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); start = *ptr; @@ -745,7 +745,7 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, struct channel const *gr0ch, unsigned int scfsi) { struct mad_bitptr start; unsigned int slen1, slen2, sfbi; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); start = *ptr; @@ -849,7 +849,7 @@ void III_exponents(struct channel const *channel, unsigned int const *sfbwidth, signed int exponents[39]) { signed int gain; unsigned int scalefac_multiplier, sfbi; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); gain = (signed int) channel->global_gain - 210; scalefac_multiplier = (channel->flags & scalefac_scale) ? 2 : 1; @@ -919,7 +919,7 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp) { signed int frac; struct fixedfloat power; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); frac = exp % 4; /* assumes sign(frac) == sign(exp) */ exp /= 4; @@ -979,7 +979,7 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], mad_fixed_t const *sfbound; register unsigned long bitcache; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); bits_left = (signed) channel->part2_3_length - (signed) part2_length; if (bits_left < 0) { return MAD_ERROR_BADPART3LEN; @@ -1334,7 +1334,7 @@ enum mad_error III_reorder(mad_fixed_t xr[576], struct channel const *channel, // if (!tmp) return MAD_ERROR_NOMEM; // } - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); /* this is probably wrong for 8000 Hz mixed blocks */ @@ -1388,7 +1388,7 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], unsigned int const *sfbwidth) { short modes[39]; unsigned int sfbi, l, n, i; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); if (granule->ch[0].block_type != granule->ch[1].block_type || @@ -1605,7 +1605,7 @@ static void III_aliasreduce(mad_fixed_t xr[576], int lines) { mad_fixed_t const *bound; int i; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); bound = &xr[lines]; for (xr += 18; xr < bound; xr += 18) { @@ -1711,7 +1711,7 @@ static inline void sdctII(mad_fixed_t const x[18], mad_fixed_t X[18]) { mad_fixed_t tmp[9]; int i; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); /* scale[i] = 2 * cos(PI * (2 * i + 1) / (2 * 18)) */ static mad_fixed_t const scale[9] PROGMEM = { @@ -1760,7 +1760,7 @@ static inline void dctIV(mad_fixed_t const y[18], mad_fixed_t X[18]) { mad_fixed_t tmp[18]; int i; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); /* scale[i] = 2 * cos(PI * (2 * i + 1) / (4 * 18)) */ static mad_fixed_t const scale[18] PROGMEM = { @@ -1805,7 +1805,7 @@ static inline void imdct36(mad_fixed_t const x[18], mad_fixed_t y[36]) { mad_fixed_t tmp[18]; int i; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); /* DCT-IV */ @@ -2129,7 +2129,7 @@ static void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36], unsigned int block_type) { unsigned int i; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); /* IMDCT */ @@ -2232,7 +2232,7 @@ void III_imdct_s(mad_fixed_t const X[18], mad_fixed_t z[36]) { // MAD_F_MLA may produce non-32b aligned reads, so copy from progmem to stack and work from there... mad_fixed_t imdct_s_lcl[6][6]; memcpy_P(imdct_s_lcl, imdct_s, sizeof(imdct_s)); - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); /* IMDCT */ @@ -2308,7 +2308,7 @@ static void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18], mad_fixed_t sample[18][32], unsigned int sb) { unsigned int i; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); # if defined(ASO_INTERLEAVE2) { @@ -2394,7 +2394,7 @@ void III_overlap_z(mad_fixed_t overlap[18], static void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) { unsigned int i; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); # if 1 || defined(ASO_INTERLEAVE1) || defined(ASO_INTERLEAVE2) { @@ -2439,7 +2439,7 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, xr[0] = frame->xr_raw; //xr_raw; xr[1] = frame->xr_raw + 576; //xr_raw + 576; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); { unsigned int sfreq; @@ -2623,7 +2623,7 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) { struct sideinfo si; enum mad_error error; int result = 0; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); nch = MAD_NCHANNELS(header); si_len = (header->flags & MAD_FLAG_LSF_EXT) ? diff --git a/src/libmad/stream.c b/src/libmad/stream.c index 6193202..c9d43b9 100644 --- a/src/libmad/stream.c +++ b/src/libmad/stream.c @@ -36,7 +36,7 @@ DESCRIPTION: initialize stream struct */ void mad_stream_init(struct mad_stream *stream) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); stream->buffer = 0; stream->bufend = 0; stream->skiplen = 0; @@ -62,7 +62,7 @@ void mad_stream_init(struct mad_stream *stream) { DESCRIPTION: deallocate any dynamic memory associated with stream */ void mad_stream_finish(struct mad_stream *stream) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); (void) stream; mad_bit_finish(&stream->anc_ptr); @@ -75,7 +75,7 @@ void mad_stream_finish(struct mad_stream *stream) { */ void mad_stream_buffer(struct mad_stream *stream, unsigned char const *buffer, unsigned long length) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); stream->buffer = buffer; stream->bufend = buffer + length; @@ -92,7 +92,7 @@ void mad_stream_buffer(struct mad_stream *stream, DESCRIPTION: arrange to skip bytes before the next frame */ void mad_stream_skip(struct mad_stream *stream, unsigned long length) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); stream->skiplen += length; } @@ -102,7 +102,7 @@ void mad_stream_skip(struct mad_stream *stream, unsigned long length) { */ int mad_stream_sync(struct mad_stream *stream) { register unsigned char const *ptr, *end; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); ptr = mad_bit_nextbyte(&stream->ptr); end = stream->bufend; @@ -126,7 +126,7 @@ int mad_stream_sync(struct mad_stream *stream) { DESCRIPTION: return a string description of the current error condition */ char const *mad_stream_errorstr(struct mad_stream const *stream) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); switch (stream->error) { case MAD_ERROR_NONE: return PSTR("no error"); diff --git a/src/libmad/synth.c b/src/libmad/synth.c index 6e1f16a..833d77a 100644 --- a/src/libmad/synth.c +++ b/src/libmad/synth.c @@ -53,7 +53,7 @@ static int16_t scale(mad_fixed_t sample) { DESCRIPTION: initialize synth struct */ void mad_synth_init(struct mad_synth *synth) { - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); mad_synth_mute(synth); synth->phase = 0; @@ -69,7 +69,7 @@ void mad_synth_init(struct mad_synth *synth) { */ void mad_synth_mute(struct mad_synth *synth) { unsigned int ch, s, v; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); for (ch = 0; ch < 2; ++ch) { for (s = 0; s < 16; ++s) { @@ -164,7 +164,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, mad_fixed_t t160, t161, t162, t163, t164, t165, t166, t167; mad_fixed_t t168, t169, t170, t171, t172, t173, t174, t175; mad_fixed_t t176; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); /* costab[i] = cos(PI / (2 * 32) * i) */ # if defined(OPT_DCTO) @@ -584,7 +584,7 @@ enum mad_flow synth_full(struct mad_synth *synth, struct mad_frame const *frame, register mad_fixed_t const(*Dptr)[32], *ptr; register mad_fixed64hi_t hi; register mad_fixed64lo_t lo; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); for (unsigned int start = startns; start < endns; start ++) { for (ch = 0; ch < nch; ++ch) { @@ -732,7 +732,7 @@ enum mad_flow synth_half(struct mad_synth *synth, struct mad_frame const *frame, register mad_fixed_t const(*Dptr)[32], *ptr; register mad_fixed64hi_t hi; register mad_fixed64lo_t lo; - stack(__FUNCTION__, __FILE__, __LINE__); + stackenter(__FUNCTION__, __FILE__, __LINE__); for (unsigned int start = startns; start < endns; start ++) { for (ch = 0; ch < nch; ++ch) { sbsample = &frame->sbsample[ch];