fix opus & vorbis last decode

This commit is contained in:
philippe44
2022-11-10 23:05:17 -08:00
parent 6c524cd094
commit a81d0e0513
2 changed files with 10 additions and 4 deletions

View File

@@ -44,6 +44,7 @@
struct opus { struct opus {
struct OggOpusFile *of; struct OggOpusFile *of;
bool end;
#if FRAME_BUF #if FRAME_BUF
u8_t *write_buf; u8_t *write_buf;
#endif #endif
@@ -118,7 +119,7 @@ static decode_state opus_decompress(void) {
LOCK_S; LOCK_S;
if (stream.state <= DISCONNECT && !_buf_used(streambuf)) { if (stream.state <= DISCONNECT && u->end) {
UNLOCK_S; UNLOCK_S;
return DECODE_COMPLETE; return DECODE_COMPLETE;
} }
@@ -171,6 +172,8 @@ static decode_state opus_decompress(void) {
write_buf = process.inbuf; write_buf = process.inbuf;
); );
u->end = frames == 0;
// write the decoded frames into outputbuf then unpack them (they are 16 bits) // write the decoded frames into outputbuf then unpack them (they are 16 bits)
n = OP(u, read, u->of, (opus_int16*) write_buf, frames * channels, NULL); n = OP(u, read, u->of, (opus_int16*) write_buf, frames * channels, NULL);
@@ -261,6 +264,7 @@ static void opus_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) {
OP(u, free, u->of); OP(u, free, u->of);
u->of = NULL; u->of = NULL;
} }
u->end = false;
} }
static void opus_close(void) { static void opus_close(void) {

View File

@@ -54,7 +54,7 @@
struct vorbis { struct vorbis {
OggVorbis_File *vf; OggVorbis_File *vf;
bool opened; bool opened, end;
#if FRAME_BUF #if FRAME_BUF
u8_t *write_buf; u8_t *write_buf;
#endif #endif
@@ -140,7 +140,7 @@ static decode_state vorbis_decode(void) {
LOCK_S; LOCK_S;
if (stream.state <= DISCONNECT && !_buf_used(streambuf)) { if (stream.state <= DISCONNECT && v->end) {
UNLOCK_S; UNLOCK_S;
return DECODE_COMPLETE; return DECODE_COMPLETE;
} }
@@ -204,6 +204,7 @@ static decode_state vorbis_decode(void) {
); );
bytes = frames * 2 * channels; // samples returned are 16 bits bytes = frames * 2 * channels; // samples returned are 16 bits
v->end = frames == 0;
// write the decoded frames into outputbuf even though they are 16 bits per sample, then unpack them // write the decoded frames into outputbuf even though they are 16 bits per sample, then unpack them
#ifdef TREMOR_ONLY #ifdef TREMOR_ONLY
@@ -324,6 +325,7 @@ static void vorbis_close(void) {
v->write_buf = NULL; v->write_buf = NULL;
#endif #endif
v->vf = NULL; v->vf = NULL;
v->end = false;
} }
static bool load_vorbis() { static bool load_vorbis() {