opus fix playback opustag skipping
Change-Id: I9ec35e276e24ec7b5a2e1199d6264d9f2d5d9fc2
diff --git a/lib/rbcodec/codecs/opus.c b/lib/rbcodec/codecs/opus.c
index acae1aa..f0ad5e8 100644
--- a/lib/rbcodec/codecs/opus.c
+++ b/lib/rbcodec/codecs/opus.c
@@ -72,7 +72,8 @@
ci->seek_buffer(ci->curpos - sizeof(buf));
LOGF("next page %ld", ci->curpos);
return 1;
- }
+ } else
+ ci->seek_buffer(ci->curpos - (sizeof(buf) - 1));
}
}
return 0;
@@ -81,20 +82,19 @@
/* seek to comment header */
static int seek_opus_tags(void)
{
- int pos = 0;
- const int64_t maxpos = sizeof(OpusHeader) + 1024;
const char synccode[] = "OpusTags";
- char buf[sizeof(synccode)];
+ char buf[sizeof(synccode) - 1]; /* Exclude null */
ci->seek_buffer(0);
- while (ci->read_filebuf(buf, 1) == 1 && ci->curpos < maxpos) {
+ while (ci->read_filebuf(buf, 1) == 1) {
if (buf[0] == synccode[0]) {
- if (ci->read_filebuf(&buf[1], sizeof(buf) - 2) != sizeof(buf) - 2)
+ if (ci->read_filebuf(&buf[1], sizeof(buf) - 1) != sizeof(buf) - 1)
break;
if (memcmp(buf, synccode, sizeof(buf)) == 0) {
ci->seek_buffer(ci->curpos - sizeof(buf));
LOGF("OpusTags %ld", ci->curpos);
return 1;
- }
+ } else
+ ci->seek_buffer(ci->curpos - (sizeof(buf) - 1));
}
}
/* comment header not found probably invalid file */