From 9b39483361a36eafab0a4b247eecef94e5ba13f6 Mon Sep 17 00:00:00 2001 From: philippe44 Date: Mon, 4 Nov 2019 12:17:23 -0800 Subject: [PATCH] get 2K of IRAM back --- components/squeezelite/helix-aac.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/squeezelite/helix-aac.c b/components/squeezelite/helix-aac.c index ef5d1b0e..c52b88ef 100644 --- a/components/squeezelite/helix-aac.c +++ b/components/squeezelite/helix-aac.c @@ -45,6 +45,7 @@ struct helixaac { HAACDecoder hAac; u8_t type; u8_t *write_buf; + u8_t *wrap_buf; // following used for mp4 only u32_t consume; u32_t pos; @@ -418,13 +419,11 @@ static decode_state helixaac_decode(void) { } if (bytes_wrap < WRAPBUF_LEN && bytes_total > WRAPBUF_LEN) { - // make a local copy of frames which may have wrapped round the end of streambuf - static u8_t buf[WRAPBUF_LEN]; - memcpy(buf, streambuf->readp, bytes_wrap); - memcpy(buf + bytes_wrap, streambuf->buf, WRAPBUF_LEN - bytes_wrap); + memcpy(a->wrap_buf, streambuf->readp, bytes_wrap); + memcpy(a->wrap_buf + bytes_wrap, streambuf->buf, WRAPBUF_LEN - bytes_wrap); - sptr = buf; + sptr = a->wrap_buf; bytes = bytes_wrap = WRAPBUF_LEN; } else { @@ -590,6 +589,7 @@ static void helixaac_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) { } else { a->hAac = HAAC(a, InitDecoder); a->write_buf = malloc(FRAME_BUF * BYTES_PER_FRAME); + a->wrap_buf = malloc(WRAPBUF_LEN); } } @@ -605,6 +605,7 @@ static void helixaac_close(void) { a->stsc = NULL; } free(a->write_buf); + free(a->wrap_buf); } static bool load_helixaac() {