Bug 1049323 - Tidy up SourceBufferResource logging. r=cajbir
authorMatthew Gregan <kinetik@flim.org>
Mon, 11 Aug 2014 13:21:17 +1200
changeset 198811 c31b14487caf4210e2a8bcb5510a436263b081f1
parent 198810 e39901ab943017cda7dae1a02515236b2500d609
child 198812 d532a13b92edd6a95ac87741c0c7db5df863f530
push id47494
push usermgregan@mozilla.com
push dateMon, 11 Aug 2014 02:06:55 +0000
treeherdermozilla-inbound@c9c9e94945fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir
bugs1049323
milestone34.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 1049323 - Tidy up SourceBufferResource logging. r=cajbir
content/media/mediasource/SourceBufferResource.cpp
--- a/content/media/mediasource/SourceBufferResource.cpp
+++ b/content/media/mediasource/SourceBufferResource.cpp
@@ -10,88 +10,99 @@
 #include <algorithm>
 
 #include "nsISeekableStream.h"
 #include "nsISupportsImpl.h"
 #include "prenv.h"
 #include "prlog.h"
 
 #ifdef PR_LOGGING
-extern PRLogModuleInfo* gMediaSourceLog;
-#define MSE_DEBUG(...) PR_LOG(gMediaSourceLog, PR_LOG_DEBUG, (__VA_ARGS__))
+PRLogModuleInfo* GetSourceBufferResourceLog()
+{
+  static PRLogModuleInfo* sLogModule;
+  if (!sLogModule) {
+    sLogModule = PR_NewLogModule("SourceBufferResource");
+  }
+  return sLogModule;
+}
+
+#define SBR_DEBUG(...) PR_LOG(GetSourceBufferResourceLog(), PR_LOG_DEBUG, (__VA_ARGS__))
+#define SBR_DEBUGV(...) PR_LOG(GetSourceBufferResourceLog(), PR_LOG_DEBUG+1, (__VA_ARGS__))
 #else
-#define MSE_DEBUG(...)
+#define SBR_DEBUG(...)
+#define SBR_DEBUGV(...)
 #endif
 
 namespace mozilla {
 
 namespace dom {
 
 class SourceBuffer;
 
 }  // namespace dom
 
 nsresult
 SourceBufferResource::Close()
 {
   ReentrantMonitorAutoEnter mon(mMonitor);
-  MSE_DEBUG("%p SBR::Close", this);
+  SBR_DEBUG("SourceBufferResource(%p)::Close", this);
   //MOZ_ASSERT(!mClosed);
   mClosed = true;
   mon.NotifyAll();
   return NS_OK;
 }
 
 nsresult
 SourceBufferResource::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
 {
+  SBR_DEBUGV("SourceBufferResource(%p)::Read(aBuffer=%p, aCount=%u, aBytes=%p)",
+             this, aBytes, aCount, aBytes);
   ReentrantMonitorAutoEnter mon(mMonitor);
   bool blockingRead = !!aBytes;
 
   while (blockingRead &&
          !mEnded &&
          mOffset + aCount > static_cast<uint64_t>(GetLength())) {
-    MSE_DEBUG("%p SBR::Read waiting for data", this);
+    SBR_DEBUGV("SourceBufferResource(%p)::Read waiting for data", this);
     mon.Wait();
   }
 
   uint32_t available = GetLength() - mOffset;
   uint32_t count = std::min(aCount, available);
-  if (!PR_GetEnv("MOZ_QUIET")) {
-    MSE_DEBUG("%p SBR::Read aCount=%u length=%u offset=%u "
-              "available=%u count=%u, blocking=%d bufComplete=%d",
-              this, aCount, GetLength(), mOffset, available, count,
-              blockingRead, mEnded);
-  }
+  SBR_DEBUGV("SourceBufferResource(%p)::Read() mOffset=%llu GetLength()=%u available=%u count=%u mEnded=%d",
+             this, mOffset, GetLength(), available, count, mEnded);
   if (available == 0) {
-    MSE_DEBUG("%p SBR::Read EOF", this);
+    SBR_DEBUGV("SourceBufferResource(%p)::Read() reached EOF", this);
     *aBytes = 0;
     return NS_OK;
   }
 
   mInputBuffer.CopyData(mOffset, count, aBuffer);
   *aBytes = count;
   mOffset += count;
   return NS_OK;
 }
 
 nsresult
 SourceBufferResource::ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes)
 {
+  SBR_DEBUG("SourceBufferResource(%p)::ReadAt(aOffset=%lld, aBuffer=%p, aCount=%u, aBytes=%p)",
+            this, aOffset, aBytes, aCount, aBytes);
   ReentrantMonitorAutoEnter mon(mMonitor);
   nsresult rv = Seek(nsISeekableStream::NS_SEEK_SET, aOffset);
   if (NS_FAILED(rv)) {
     return rv;
   }
   return Read(aBuffer, aCount, aBytes);
 }
 
 nsresult
 SourceBufferResource::Seek(int32_t aWhence, int64_t aOffset)
 {
+  SBR_DEBUG("SourceBufferResource(%p)::Seek(aWhence=%d, aOffset=%lld)", this, aWhence, aOffset);
   ReentrantMonitorAutoEnter mon(mMonitor);
   if (mClosed) {
     return NS_ERROR_FAILURE;
   }
 
   int64_t newOffset = mOffset;
   switch (aWhence) {
   case nsISeekableStream::NS_SEEK_END:
@@ -100,77 +111,86 @@ SourceBufferResource::Seek(int32_t aWhen
   case nsISeekableStream::NS_SEEK_CUR:
     newOffset += aOffset;
     break;
   case nsISeekableStream::NS_SEEK_SET:
     newOffset = aOffset;
     break;
   }
 
+  SBR_DEBUGV("SourceBufferResource(%p)::Seek() newOffset=%lld GetOffset()=%llu GetLength()=%llu)",
+             this, newOffset, mInputBuffer.GetOffset(), GetLength());
   if (newOffset < 0 || uint64_t(newOffset) < mInputBuffer.GetOffset() || newOffset > GetLength()) {
     return NS_ERROR_FAILURE;
   }
 
   mOffset = newOffset;
   mon.NotifyAll();
 
   return NS_OK;
 }
 
 nsresult
 SourceBufferResource::ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount)
 {
+  SBR_DEBUG("SourceBufferResource(%p)::ReadFromCache(aBuffer=%p, aOffset=%lld, aCount=%u)",
+            this, aBuffer, aOffset, aCount);
   return ReadAt(aOffset, aBuffer, aCount, nullptr);
 }
 
 bool
 SourceBufferResource::EvictData(uint32_t aThreshold)
 {
+  SBR_DEBUG("SourceBufferResource(%p)::EvictData(aThreshold=%u)", this, aThreshold);
   ReentrantMonitorAutoEnter mon(mMonitor);
   return mInputBuffer.Evict(mOffset, aThreshold);
 }
 
 void
 SourceBufferResource::EvictBefore(uint64_t aOffset)
 {
+  SBR_DEBUG("SourceBufferResource(%p)::EvictBefore(aOffset=%llu)", this, aOffset);
   ReentrantMonitorAutoEnter mon(mMonitor);
   // If aOffset is past the current playback offset we don't evict.
   if (aOffset < mOffset) {
     mInputBuffer.Evict(aOffset, 0);
   }
 }
 
 void
 SourceBufferResource::AppendData(const uint8_t* aData, uint32_t aLength)
 {
+  SBR_DEBUG("SourceBufferResource(%p)::AppendData(aData=%p, aLength=%u)", this, aData, aLength);
   ReentrantMonitorAutoEnter mon(mMonitor);
   mInputBuffer.PushBack(new ResourceItem(aData, aLength));
   mon.NotifyAll();
 }
 
 void
 SourceBufferResource::Ended()
 {
+  SBR_DEBUG("SourceBufferResource(%p)::Ended()", this);
   ReentrantMonitorAutoEnter mon(mMonitor);
   mEnded = true;
   mon.NotifyAll();
 }
 
 SourceBufferResource::~SourceBufferResource()
 {
+  SBR_DEBUG("SourceBufferResource(%p)::~SourceBufferResource()", this);
   MOZ_COUNT_DTOR(SourceBufferResource);
-  MSE_DEBUG("%p SBR::~SBR", this);
 }
 
 SourceBufferResource::SourceBufferResource(nsIPrincipal* aPrincipal,
                                            const nsACString& aType)
   : mPrincipal(aPrincipal)
   , mType(aType)
   , mMonitor("mozilla::SourceBufferResource::mMonitor")
   , mOffset(0)
   , mClosed(false)
   , mEnded(false)
 {
+  SBR_DEBUG("SourceBufferResource(%p)::SourceBufferResource(aPrincipal=%p, aType=%s)",
+            this, aPrincipal, nsCString(aType).get());
   MOZ_COUNT_CTOR(SourceBufferResource);
-  MSE_DEBUG("%p SBR::SBR()", this);
 }
 
 } // namespace mozilla