free previous opus on open

This commit is contained in:
philippe44
2019-08-03 01:30:17 -07:00
parent 2af82edce4
commit 3cc31133a0

View File

@@ -246,8 +246,11 @@ static decode_state opus_decompress(void) {
static void opus_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) { static void opus_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) {
if (!u->of) { if (!u->of) {
#if FRAME_BUF #if FRAME_BUF
u->write_buf = malloc(FRAME_BUF * BYTES_PER_FRAME); if (!u->write_buf) u->write_buf = malloc(FRAME_BUF * BYTES_PER_FRAME);
#endif #endif
} else {
OP(u, free, u->of);
u->of = NULL;
} }
u->opened = false; u->opened = false;
} }
@@ -305,7 +308,7 @@ struct codec *register_opus(void) {
} }
u->of = NULL; u->of = NULL;
u->opened = false; u->write_buf = NULL;
if (!load_opus()) { if (!load_opus()) {
return NULL; return NULL;