diff --git a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp index 611c2186831..06ebd1b4fec 100644 --- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp @@ -111,7 +111,7 @@ private: status_t parseTrackFragmentRun(off64_t offset, off64_t size); status_t parseSampleAuxiliaryInformationSizes(off64_t offset, off64_t size); status_t parseSampleAuxiliaryInformationOffsets(off64_t offset, off64_t size); - void lookForMoof(); + status_t lookForMoof(); status_t moveToNextFragment(); struct TrackFragmentHeaderInfo { @@ -3204,14 +3204,14 @@ size_t MPEG4Source::parseNALSize(const uint8_t *data) const { return 0; } -void MPEG4Source::lookForMoof() { +status_t MPEG4Source::lookForMoof() { off64_t offset = 0; off64_t size; while (true) { uint32_t hdr[2]; auto x = mDataSource->readAt(offset, hdr, 8); if (x < 8) { - break; + return NOT_ENOUGH_DATA; } uint32_t chunk_size = ntohl(hdr[0]); uint32_t chunk_type = ntohl(hdr[1]); @@ -3220,10 +3220,10 @@ void MPEG4Source::lookForMoof() { if (chunk_type == FOURCC('m', 'o', 'o', 'f')) { mFirstMoofOffset = mCurrentMoofOffset = offset; parseChunk(&offset); - break; + return OK; } if (chunk_type == FOURCC('m', 'd', 'a', 't')) { - break; + return OK; } offset += chunk_size; } @@ -3237,8 +3237,7 @@ status_t MPEG4Source::read( CHECK(mStarted); if (!mLookedForMoof) { - mLookedForMoof = true; - lookForMoof(); + mLookedForMoof = lookForMoof() == OK; } if (mFirstMoofOffset > 0) {