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

Commit a063cd64 authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "Instead of asserting, publish no tracks if an MP3Extractor is used on...

Merge "Instead of asserting, publish no tracks if an MP3Extractor is used on non-mp3 content." into gingerbread
parents 0727a865 3e0f2be7
Loading
Loading
Loading
Loading
+39 −37
Original line number Diff line number Diff line
@@ -459,7 +459,8 @@ private:

MP3Extractor::MP3Extractor(
        const sp<DataSource> &source, const sp<AMessage> &meta)
    : mDataSource(source),
    : mInitCheck(NO_INIT),
      mDataSource(source),
      mFirstFramePos(-1),
      mFixedHeader(0),
      mByteNumber(0) {
@@ -480,10 +481,13 @@ MP3Extractor::MP3Extractor(
        success = true;
    } else {
        success = Resync(mDataSource, 0, &pos, &header);
        CHECK(success);
    }

    if (success) {
    if (!success) {
        // mInitCheck will remain NO_INIT
        return;
    }

    mFirstFramePos = pos;
    mFixedHeader = header;

@@ -515,18 +519,16 @@ MP3Extractor::MP3Extractor(
                    8000LL * (fileSize - mFirstFramePos) / bitrate);
        }
    }
    }
}

MP3Extractor::~MP3Extractor() {
    mInitCheck = OK;
}

size_t MP3Extractor::countTracks() {
    return (mFirstFramePos < 0) ? 0 : 1;
    return mInitCheck != OK ? 0 : 1;
}

sp<MediaSource> MP3Extractor::getTrack(size_t index) {
    if (mFirstFramePos < 0 || index != 0) {
    if (mInitCheck != OK || index != 0) {
        return NULL;
    }

@@ -536,7 +538,7 @@ sp<MediaSource> MP3Extractor::getTrack(size_t index) {
}

sp<MetaData> MP3Extractor::getTrackMetaData(size_t index, uint32_t flags) {
    if (mFirstFramePos < 0 || index != 0) {
    if (mInitCheck != OK || index != 0) {
        return NULL;
    }

@@ -713,7 +715,7 @@ status_t MP3Source::read(
sp<MetaData> MP3Extractor::getMetaData() {
    sp<MetaData> meta = new MetaData;

    if (mFirstFramePos < 0) {
    if (mInitCheck != OK) {
        return meta;
    }

+2 −3
Original line number Diff line number Diff line
@@ -37,10 +37,9 @@ public:

    virtual sp<MetaData> getMetaData();

protected:
    virtual ~MP3Extractor();

private:
    status_t mInitCheck;

    sp<DataSource> mDataSource;
    off_t mFirstFramePos;
    sp<MetaData> mMeta;