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 98748 596ebdcb918886af05f0d7e8a2319d5ecc67891e
parent 98747 1d1aabb06e7c4bf79ad13c4d47ce83ff68896762
child 98749 717abd8063e2eb36882e3dd3851788241aeda761
push id1729
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 20:02:43 +0000
treeherdermozilla-aurora@f4e75e148951 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec
bugs723860
milestone16.0a1
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