1
0
Fork 0
forked from len0rd/rockbox

opus fix playback opustag skipping

Change-Id: I9ec35e276e24ec7b5a2e1199d6264d9f2d5d9fc2
This commit is contained in:
William Wilgus 2019-01-24 22:54:34 -06:00
parent 07084f62c4
commit 8cadef4cbb

View file

@ -72,7 +72,8 @@ static int seek_ogg_page(uint64_t filepos)
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 @@ static int seek_ogg_page(uint64_t filepos)
/* 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 */