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

Commit a8156a48 authored by Ian Baker's avatar Ian Baker Committed by Android (Google) Code Review
Browse files

Merge "Revert "Faster sniffing for MIDIExtractor""

parents 249f9147 2497451c
Loading
Loading
Loading
Loading
+5 −22
Original line number Diff line number Diff line
@@ -327,29 +327,12 @@ media_status_t MidiExtractor::getMetaData(AMediaFormat *meta)

bool SniffMidi(CDataSource *source, float *confidence)
{
    // look for standard prefix / magic number info in the files.
    // "MThd" for midi
    // "XMF_"
    // this will be very fast.
    //
    char hdr_magic[4];
    if (source->readAt(source->handle, 0, hdr_magic, sizeof(hdr_magic)) == sizeof(hdr_magic)) {
        if (memcmp(hdr_magic,"MThd", sizeof(hdr_magic)) == 0) {
            *confidence = 0.85;
            ALOGV("SniffMidi: yes, MThd");
    MidiEngine p(source, NULL, NULL);
    if (p.initCheck() == OK) {
        *confidence = 0.8;
        ALOGV("SniffMidi: yes");
        return true;
    }
        if (memcmp(hdr_magic,"XMF_", sizeof(hdr_magic)) == 0) {
            *confidence = 0.85;
            ALOGV("SniffMidi: yes, XMF_");
            return true;
        }
    }

    // alternatives:
    // instantiate MidiEngine, (expensively) parsing the entire file to decide.


    ALOGV("SniffMidi: no");
    return false;