Skip to content

Commit dbda3e0

Browse files
committed
flush: decode only complete segments
1 parent 41b6b0c commit dbda3e0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/AACDecoderHelix.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class AACDecoderHelix : public CommonHelix {
104104

105105
/// decods the data and removes the decoded frame from the buffer
106106
int decode() override {
107+
LOG_HELIX(LogLevelHelix::Debug, "decode");
107108
int processed = 0;
108109
int available = frame_buffer.available();
109110
int bytes_left = frame_buffer.available();

src/CommonHelix.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,14 @@ class CommonHelix {
102102
void flush() {
103103
int rc = 1;
104104
while (rc >= 0) {
105+
// we must start with sych word
105106
if (!presync()) break;
107+
// we must end with synch world
108+
if (findSynchWord(3) < 0) break;
106109
rc = decode();
107110
if (!resynch(rc)) break;
108111
// remove processed data
109-
frame_buffer.clearArray(rc);
112+
if (rc > 0) frame_buffer.clearArray(rc);
110113
}
111114
}
112115

@@ -155,6 +158,7 @@ class CommonHelix {
155158
bool rc = true;
156159
int pos = findSynchWord();
157160
if (pos > 3) rc = removeInvalidData(pos);
161+
158162
return rc;
159163
}
160164

0 commit comments

Comments
 (0)