Bug 723860 - Early bail from reader's GetBuffered() if not yet initialized. r=doublec
authorMatthew Gregan <kinetik@flim.org>
Wed, 06 Jun 2012 17:58:07 +1200
changeset 96025 596ebdcb918886af05f0d7e8a2319d5ecc67891e
parent 96024 1d1aabb06e7c4bf79ad13c4d47ce83ff68896762
child 96026 717abd8063e2eb36882e3dd3851788241aeda761
push id10353
push usermgregan@mozilla.com
push dateThu, 07 Jun 2012 03:12:48 +0000
treeherdermozilla-inbound@596ebdcb9188 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec
bugs723860
milestone16.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 723860 - Early bail from reader's GetBuffered() if not yet initialized. r=doublec
content/media/gstreamer/nsGStreamerReader.cpp
content/media/ogg/nsOggReader.cpp
content/media/wave/nsWaveReader.cpp
--- a/content/media/gstreamer/nsGStreamerReader.cpp
+++ b/content/media/gstreamer/nsGStreamerReader.cpp
@@ -500,16 +500,20 @@ nsresult nsGStreamerReader::Seek(PRInt64
   LOG(PR_LOG_DEBUG, ("seek succeeded"));
 
   return DecodeToTarget(aTarget);
 }
 
 nsresult nsGStreamerReader::GetBuffered(nsTimeRanges* aBuffered,
                                         PRInt64 aStartTime)
 {
+  if (!mInfo.mHasVideo && !mInfo.mHasAudio) {
+    return NS_OK;
+  }
+
   GstFormat format = GST_FORMAT_TIME;
   MediaResource* resource = mDecoder->GetResource();
   gint64 resourceLength = resource->GetLength();
   nsTArray<MediaByteRange> ranges;
   resource->GetCachedRanges(ranges);
 
   if (mDecoder->OnStateMachineThread())
     /* Report the position from here while buffering as we can't report it from
--- a/content/media/ogg/nsOggReader.cpp
+++ b/content/media/ogg/nsOggReader.cpp
@@ -1527,18 +1527,17 @@ nsresult nsOggReader::SeekBisection(PRIn
 
   return NS_OK;
 }
 
 nsresult nsOggReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
 {
   // HasAudio and HasVideo are not used here as they take a lock and cause
   // a deadlock. Accessing mInfo doesn't require a lock - it doesn't change
-  // after metadata is read and GetBuffered isn't called before metadata is
-  // read.
+  // after metadata is read.
   if (!mInfo.mHasVideo && !mInfo.mHasAudio) {
     // No need to search through the file if there are no audio or video tracks
     return NS_OK;
   }
 
   MediaResource* resource = mDecoder->GetResource();
   nsTArray<MediaByteRange> ranges;
   nsresult res = resource->GetCachedRanges(ranges);
--- a/content/media/wave/nsWaveReader.cpp
+++ b/content/media/wave/nsWaveReader.cpp
@@ -234,16 +234,19 @@ nsresult nsWaveReader::Seek(PRInt64 aTar
 }
 
 static double RoundToUsecs(double aSeconds) {
   return floor(aSeconds * USECS_PER_S) / USECS_PER_S;
 }
 
 nsresult nsWaveReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
 {
+  if (!mInfo.mHasAudio) {
+    return NS_OK;
+  }
   PRInt64 startOffset = mDecoder->GetResource()->GetNextCachedData(mWavePCMOffset);
   while (startOffset >= 0) {
     PRInt64 endOffset = mDecoder->GetResource()->GetCachedDataEnd(startOffset);
     // Bytes [startOffset..endOffset] are cached.
     NS_ASSERTION(startOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
     NS_ASSERTION(endOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
 
     // We need to round the buffered ranges' times to microseconds so that they