Always ignore found index entries after we detect

the stream is building the index on the fly once.
This allows to seek back to earlier positions, since
then the index will contain entries for later in the
stream and the logic to detect auto-generated indices
was broken.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38678 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-09-16 15:27:16 +00:00
parent 7b61b6b8e4
commit 8a7cbd8350

View File

@ -158,7 +158,7 @@ private:
media_format fFormat; media_format fFormat;
bool fStreamBuildsIndexWhileReading; mutable bool fStreamBuildsIndexWhileReading;
}; };
@ -960,12 +960,19 @@ AVFormatReader::StreamCookie::FindKeyFrame(uint32 flags, int64* frame,
bigtime_t timeDiff = foundTime > *time bigtime_t timeDiff = foundTime > *time
? foundTime - *time : *time - foundTime; ? foundTime - *time : *time - foundTime;
if (timeDiff > 1000000 && index == fStream->nb_index_entries - 1) { if (timeDiff > 1000000
&& (fStreamBuildsIndexWhileReading
|| index == fStream->nb_index_entries - 1)) {
// If the stream is building the index on the fly while parsing // If the stream is building the index on the fly while parsing
// it, we only have entries in the index for positions already // it, we only have entries in the index for positions already
// decoded, i.e. we cannot seek into the future. In that case, // decoded, i.e. we cannot seek into the future. In that case,
// just assume that we can seek where we want and leave time/frame // just assume that we can seek where we want and leave time/frame
// unmodified. // unmodified. Since successfully seeking one time will generate
// index entries for the seeked to position, we need to remember
// this in fStreamBuildsIndexWhileReading, since when seeking back
// there will be later index entries, but we still want to ignore
// the found entry.
fStreamBuildsIndexWhileReading = true;
TRACE_FIND(" Not trusting generic index entry. " TRACE_FIND(" Not trusting generic index entry. "
"(Current count: %d)\n", fStream->nb_index_entries); "(Current count: %d)\n", fStream->nb_index_entries);
} else } else