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

Commit dd5bd298 authored by Marco Nelissen's avatar Marco Nelissen Committed by Android (Google) Code Review
Browse files

Merge "Move COM tag parsing to constructor"

parents 3a382b58 7306a388
Loading
Loading
Loading
Loading
+31 −27
Original line number Diff line number Diff line
@@ -348,6 +348,37 @@ MP3Extractor::MP3Extractor(
    }

    mInitCheck = OK;

    // get iTunes-style gapless info if present
    ID3 id3(mDataSource);
    if (id3.isValid()) {
        ID3::Iterator *com = new ID3::Iterator(id3, "COM");
        if (com->done()) {
            delete com;
            com = new ID3::Iterator(id3, "COMM");
        }
        while(!com->done()) {
            String8 commentdesc;
            String8 commentvalue;
            com->getString(&commentdesc, &commentvalue);
            const char * desc = commentdesc.string();
            const char * value = commentvalue.string();

            // first 3 characters are the language, which we don't care about
            if(strlen(desc) > 3 && strcmp(desc + 3, "iTunSMPB") == 0) {

                int32_t delay, padding;
                if (sscanf(value, " %*x %x %x %*x", &delay, &padding) == 2) {
                    mMeta->setInt32(kKeyEncoderDelay, delay);
                    mMeta->setInt32(kKeyEncoderPadding, padding);
                }
                break;
            }
            com->next();
        }
        delete com;
        com = NULL;
    }
}

size_t MP3Extractor::countTracks() {
@@ -555,33 +586,6 @@ sp<MetaData> MP3Extractor::getMetaData() {
        return meta;
    }

    ID3::Iterator *com = new ID3::Iterator(id3, "COM");
    if (com->done()) {
        delete com;
        com = new ID3::Iterator(id3, "COMM");
    }
    while(!com->done()) {
        String8 commentdesc;
        String8 commentvalue;
        com->getString(&commentdesc, &commentvalue);
        const char * desc = commentdesc.string();
        const char * value = commentvalue.string();

        // first 3 characters are the language, which we don't care about
        if(strlen(desc) > 3 && strcmp(desc + 3, "iTunSMPB") == 0) {

            int32_t delay, padding;
            if (sscanf(value, " %*x %x %x %*x", &delay, &padding) == 2) {
                mMeta->setInt32(kKeyEncoderDelay, delay);
                mMeta->setInt32(kKeyEncoderPadding, padding);
            }
            break;
        }
        com->next();
    }
    delete com;
    com = NULL;

    struct Map {
        int key;
        const char *tag1;