Skip to content

Commit

Permalink
Ogg & Opus: Also support LOOPEND, a "standard" used outside of the RP…
Browse files Browse the repository at this point in the history
…G Maker world
  • Loading branch information
Ghabry committed Aug 31, 2021
1 parent fa17880 commit faea9ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/decoder_oggvorbis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ bool OggVorbisDecoder::Open(Filesystem_Stream::InputStream stream) {
if (len >= 0) {
loop.end = std::min<int64_t>(loop.start + len, total);
}
} else {
str = vorbis_comment_query(vc, "LOOPEND", 0);
if (str) {
int end = atoi(str);
if (end >= 0) {
loop.end = Utils::Clamp<int64_t>(end, loop.start, total);
}
}
}

if (loop.start == total) {
Expand Down
8 changes: 8 additions & 0 deletions src/decoder_opus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ bool OpusDecoder::Open(Filesystem_Stream::InputStream stream) {
if (len >= 0) {
loop.end = std::min<int64_t>(loop.start + len, total);
}
} else {
str = opus_tags_query(ot, "LOOPEND", 0);
if (str) {
int end = atoi(str);
if (end >= 0) {
loop.end = Utils::Clamp<int64_t>(end, loop.start, total);
}
}
}

if (loop.start == total) {
Expand Down

0 comments on commit faea9ae

Please sign in to comment.