From 78a16e41dc2ba93197dd4d491c7818fe4b4be93a Mon Sep 17 00:00:00 2001 From: Philippe G Date: Sun, 10 Jan 2021 21:57:22 -0800 Subject: [PATCH] simplify alac writebuf alloc --- components/squeezelite/alac.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/squeezelite/alac.c b/components/squeezelite/alac.c index 94ff7acf..f410be2d 100644 --- a/components/squeezelite/alac.c +++ b/components/squeezelite/alac.c @@ -120,15 +120,14 @@ static int read_mp4_header(void) { if (!strcmp(type, "alac") && bytes > len) { u8_t *ptr = streambuf->readp + 36; unsigned int block_size; + l->play = l->trak; l->decoder = alac_create_decoder(len - 36, ptr, &l->sample_size, &l->sample_rate, &l->channels, &block_size); - l->play = l->trak; l->writebuf = malloc(block_size + 256); + LOG_INFO("allocated write buffer of %u bytes", block_size); if (!l->writebuf) { - LOG_ERROR("cannot allocate write buffer for %u bytes", block_size); + LOG_ERROR("allocation failed"); return -1; - } else { - LOG_INFO("write buffer of %u bytes", block_size); - } + } } // extract the total number of samples from stts