Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99c60f86 authored by Ray Essick's avatar Ray Essick
Browse files

Handle opus v0 and v1

extractor insisted on v1 opus header; v0 is same format, so we can
easily handle that as well.

Bug: 137530136
Test: play opus v0 content
parent c727c342
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -1062,8 +1062,15 @@ media_status_t MyOpusExtractor::verifyOpusHeader(MediaBufferHelper *buffer) {
    size_t size = buffer->range_length();

    if (size < kOpusHeaderSize
            || memcmp(data, "OpusHead", 8)
            || /* version = */ data[8] != 1) {
            || memcmp(data, "OpusHead", 8)) {
        return AMEDIA_ERROR_MALFORMED;
    }
    // allow both version 0 and 1. Per the opus specification:
    // An earlier draft of the specification described a version 0, but the only difference
    // between version 1 and version 0 is that version 0 did not specify the semantics for
    // handling the version field
    if ( /* version = */ data[8] > 1) {
        ALOGW("no support for opus version %d", data[8]);
        return AMEDIA_ERROR_MALFORMED;
    }