AAC files might be blocked in a loop at the end

This commit is contained in:
Philippe G
2020-05-13 20:11:45 -07:00
parent edf1d454a2
commit 7d2d4a6f77
2 changed files with 7 additions and 7 deletions

View File

@@ -58,6 +58,7 @@ void embedded_init(void);
void register_external(void);
void deregister_external(void);
void decode_restore(int external);
// used when other client wants to use slimproto socket to send messages
extern mutex_type slimp_mutex;
#define LOCK_P mutex_lock(slimp_mutex)
#define UNLOCK_P mutex_unlock(slimp_mutex)

View File

@@ -418,15 +418,14 @@ static decode_state helixaac_decode(void) {
}
}
if (bytes_wrap < WRAPBUF_LEN && bytes_total > WRAPBUF_LEN) {
if (bytes_wrap < WRAPBUF_LEN && (bytes_total > WRAPBUF_LEN || stream.state <= DISCONNECT)) {
// make a local copy of frames which may have wrapped round the end of streambuf
memcpy(a->wrap_buf, streambuf->readp, bytes_wrap);
memcpy(a->wrap_buf + bytes_wrap, streambuf->buf, WRAPBUF_LEN - bytes_wrap);
memcpy(a->wrap_buf + bytes_wrap, streambuf->buf, min(WRAPBUF_LEN, bytes_total) - bytes_wrap);
sptr = a->wrap_buf;
bytes = bytes_wrap = WRAPBUF_LEN;
bytes = bytes_wrap = min(WRAPBUF_LEN, bytes_total);
} else {
sptr = streambuf->readp;
bytes = bytes_wrap;
}