Skip to content

Commit

Permalink
flush: decode only complete segments
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Feb 17, 2025
1 parent 41b6b0c commit dbda3e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/AACDecoderHelix.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class AACDecoderHelix : public CommonHelix {

/// decods the data and removes the decoded frame from the buffer
int decode() override {
LOG_HELIX(LogLevelHelix::Debug, "decode");
int processed = 0;
int available = frame_buffer.available();
int bytes_left = frame_buffer.available();
Expand Down
6 changes: 5 additions & 1 deletion src/CommonHelix.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ class CommonHelix {
void flush() {
int rc = 1;
while (rc >= 0) {
// we must start with sych word
if (!presync()) break;
// we must end with synch world
if (findSynchWord(3) < 0) break;
rc = decode();
if (!resynch(rc)) break;
// remove processed data
frame_buffer.clearArray(rc);
if (rc > 0) frame_buffer.clearArray(rc);
}
}

Expand Down Expand Up @@ -155,6 +158,7 @@ class CommonHelix {
bool rc = true;
int pos = findSynchWord();
if (pos > 3) rc = removeInvalidData(pos);

return rc;
}

Expand Down

0 comments on commit dbda3e0

Please sign in to comment.