diff --git a/dom/media/webm/WebMReader.cpp b/dom/media/webm/WebMReader.cpp index 6a96a8772f24..5ae7e335cf2c 100644 --- a/dom/media/webm/WebMReader.cpp +++ b/dom/media/webm/WebMReader.cpp @@ -750,8 +750,16 @@ nsresult WebMReader::SeekInternal(int64_t aTarget) uint64_t target = aTarget * NS_PER_USEC; if (mSeekPreroll) { - target = std::max(uint64_t(StartTime() * NS_PER_USEC), - target - mSeekPreroll); + uint64_t startTime = uint64_t(StartTime()) * NS_PER_USEC; + if (target < mSeekPreroll || target - mSeekPreroll < startTime) { + target = startTime; + } else { + target -= mSeekPreroll; + } + LOG(LogLevel::Debug, + ("Reader [%p] SeekPreroll: %f StartTime: %f AdjustedTarget: %f", + this, double(mSeekPreroll) / NS_PER_S, + double(startTime) / NS_PER_S, double(target) / NS_PER_S)); } int r = nestegg_track_seek(mContext, trackToSeek, target); if (r != 0) {