Bug 635726 - Escape backoff in Ogg seek when we back off back to start of seek target range. r=doublec
authorChris Pearce <chris@pearce.org.nz>
Thu, 07 Jul 2011 09:51:26 +1200
changeset 72438 2b2d322e42415cb185cb338ab7ebe5c63db2d940
parent 72437 4d17b74a1df220fad9d18f66e7cbb39139188b98
child 72439 078d03b6ab08561dcca10a37107c285c81d6b97f
push id429
push usercpearce@mozilla.com
push dateWed, 06 Jul 2011 21:52:08 +0000
treeherdermozilla-inbound@2b2d322e4241 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec
bugs635726
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 635726 - Escape backoff in Ogg seek when we back off back to start of seek target range. r=doublec
content/media/ogg/nsOggReader.cpp
--- a/content/media/ogg/nsOggReader.cpp
+++ b/content/media/ogg/nsOggReader.cpp
@@ -1258,16 +1258,27 @@ nsresult nsOggReader::SeekBisection(PRIn
       if (mustBackoff) {
         // We previously failed to determine the time at the guess offset,
         // probably because we ran out of data to decode. This usually happens
         // when we guess very close to the end offset. So reduce the guess
         // offset using an exponential backoff until we determine the time.
         SEEK_LOG(PR_LOG_DEBUG, ("Backing off %d bytes, backsteps=%d",
           static_cast<PRInt32>(PAGE_STEP * pow(2.0, backsteps)), backsteps));
         guess -= PAGE_STEP * static_cast<ogg_int64_t>(pow(2.0, backsteps));
+
+        if (guess <= startOffset) {
+          // We've tried to backoff to before the start offset of our seek
+          // range. This means we couldn't find a seek termination position
+          // near the end of the seek range, so just set the seek termination
+          // condition, and break out of the bisection loop. We'll begin
+          // decoding from the start of the seek range.
+          interval = 0;
+          break;
+        }
+
         backsteps = NS_MIN(backsteps + 1, maxBackStep);
         // We reset mustBackoff. If we still need to backoff further, it will
         // be set to PR_TRUE again.
         mustBackoff = PR_FALSE;
       } else {
         backsteps = 0;
       }
       guess = NS_MAX(guess, startOffset + startLength);