Skip to content

Commit

Permalink
fix opus & vorbis last decode
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe44 committed Nov 11, 2022
1 parent 6c524cd commit a81d0e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions components/squeezelite/opus.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

struct opus {
struct OggOpusFile *of;
bool end;
#if FRAME_BUF
u8_t *write_buf;
#endif
Expand Down Expand Up @@ -118,7 +119,7 @@ static decode_state opus_decompress(void) {

LOCK_S;

if (stream.state <= DISCONNECT && !_buf_used(streambuf)) {
if (stream.state <= DISCONNECT && u->end) {
UNLOCK_S;
return DECODE_COMPLETE;
}
Expand Down Expand Up @@ -170,6 +171,8 @@ static decode_state opus_decompress(void) {
frames = process.max_in_frames;
write_buf = process.inbuf;
);

u->end = frames == 0;

// 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);
Expand Down Expand Up @@ -260,7 +263,8 @@ static void opus_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) {
} else {
OP(u, free, u->of);
u->of = NULL;
}
}
u->end = false;
}

static void opus_close(void) {
Expand Down
6 changes: 4 additions & 2 deletions components/squeezelite/vorbis.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

struct vorbis {
OggVorbis_File *vf;
bool opened;
bool opened, end;
#if FRAME_BUF
u8_t *write_buf;
#endif
Expand Down Expand Up @@ -140,7 +140,7 @@ static decode_state vorbis_decode(void) {

LOCK_S;

if (stream.state <= DISCONNECT && !_buf_used(streambuf)) {
if (stream.state <= DISCONNECT && v->end) {
UNLOCK_S;
return DECODE_COMPLETE;
}
Expand Down Expand Up @@ -204,6 +204,7 @@ static decode_state vorbis_decode(void) {
);

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
#ifdef TREMOR_ONLY
Expand Down Expand Up @@ -324,6 +325,7 @@ static void vorbis_close(void) {
v->write_buf = NULL;
#endif
v->vf = NULL;
v->end = false;
}

static bool load_vorbis() {
Expand Down

0 comments on commit a81d0e0

Please sign in to comment.