зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1500713: P2 - Seek MP3 parser to the original position if it fails parsing. r=kinetik,jya
Depends on D19096 Differential Revision: https://phabricator.services.mozilla.com/D19097 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
321883e56f
Коммит
97d1b59173
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/EndianUtils.h"
|
||||
#include "mozilla/Pair.h"
|
||||
#include "mozilla/ResultExtensions.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "VideoUtils.h"
|
||||
|
||||
extern mozilla::LazyLogModule gMediaDemuxerLog;
|
||||
|
@ -82,8 +83,7 @@ Result<bool, nsresult> FrameParser::Parse(BufferReader* aReader,
|
|||
// ID3v1 tags may only be at file end.
|
||||
// TODO: should we try to read ID3 tags at end of file/mid-stream, too?
|
||||
const size_t prevReaderOffset = aReader->Offset();
|
||||
uint32_t tagSize;
|
||||
MOZ_TRY_VAR(tagSize, mID3Parser.Parse(aReader));
|
||||
const uint32_t tagSize = mID3Parser.Parse(aReader).unwrapOr(0);
|
||||
if (!!tagSize) {
|
||||
// ID3 tag found, skip past it.
|
||||
const uint32_t skipSize = tagSize - ID3Parser::ID3Header::SIZE;
|
||||
|
@ -356,7 +356,10 @@ Result<bool, nsresult> FrameParser::VBRHeader::ParseXing(
|
|||
};
|
||||
|
||||
MOZ_ASSERT(aReader);
|
||||
|
||||
// Seek backward to the original position before leaving this scope.
|
||||
const size_t prevReaderOffset = aReader->Offset();
|
||||
auto scopeExit = MakeScopeExit([&] { aReader->Seek(prevReaderOffset); });
|
||||
|
||||
// We have to search for the Xing header as its position can change.
|
||||
for (auto res = aReader->PeekU32();
|
||||
|
@ -402,7 +405,6 @@ Result<bool, nsresult> FrameParser::VBRHeader::ParseXing(
|
|||
mScale = Some(scale);
|
||||
}
|
||||
|
||||
aReader->Seek(prevReaderOffset);
|
||||
return mType == XING;
|
||||
}
|
||||
|
||||
|
@ -421,7 +423,10 @@ Result<bool, nsresult> FrameParser::VBRHeader::ParseVBRI(
|
|||
if (sync.isOk()) { // To avoid compiler complains 'set but unused'.
|
||||
MOZ_ASSERT((sync.unwrap() & 0xFFE0) == 0xFFE0);
|
||||
}
|
||||
|
||||
// Seek backward to the original position before leaving this scope.
|
||||
const size_t prevReaderOffset = aReader->Offset();
|
||||
auto scopeExit = MakeScopeExit([&] { aReader->Seek(prevReaderOffset); });
|
||||
|
||||
// VBRI have a fixed relative position, so let's check for it there.
|
||||
if (aReader->Remaining() > MIN_FRAME_SIZE) {
|
||||
|
@ -433,11 +438,9 @@ Result<bool, nsresult> FrameParser::VBRHeader::ParseVBRI(
|
|||
MOZ_TRY_VAR(frames, aReader->ReadU32());
|
||||
mNumAudioFrames = Some(frames);
|
||||
mType = VBRI;
|
||||
aReader->Seek(prevReaderOffset);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
aReader->Seek(prevReaderOffset);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче