Bug 1221587: patch 10 - Improve logging of callback driver/switching r=padenot draft
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 06 Jan 2016 16:20:20 +0800
changeset 320109 61c26d69c64da7c5d291ead0627fc6549d99a7d2
parent 320108 f8d215bccfa4dd0ca0cc5d6afc994012e4029f4e
child 320110 d991f940fbc5e6104926b561af7bb236f7db8ea8
push id9134
push userrjesup@wgate.com
push dateFri, 08 Jan 2016 16:39:51 +0000
reviewerspadenot
bugs1221587
milestone46.0a1
Bug 1221587: patch 10 - Improve logging of callback driver/switching r=padenot
dom/media/GraphDriver.cpp
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -90,16 +90,22 @@ void GraphDriver::SwitchAtNextIteration(
       PreviousDriver() &&
       PreviousDriver()->AsAudioCallbackDriver()->IsSwitchingDevice() &&
       PreviousDriver() != aNextDriver) {
     return;
   }
   LIFECYCLE_LOG("Switching to new driver: %p (%s)",
       aNextDriver, aNextDriver->AsAudioCallbackDriver() ?
       "AudioCallbackDriver" : "SystemClockDriver");
+ if (mNextDriver &&
+       mNextDriver != GraphImpl()->CurrentDriver()) {
+    LIFECYCLE_LOG("Discarding previous next driver: %p (%s)",
+        mNextDriver.get(), mNextDriver->AsAudioCallbackDriver() ?
+        "AudioCallbackDriver" : "SystemClockDriver");
+  }
   SetNextDriver(aNextDriver);
 }
 
 GraphTime
 GraphDriver::StateComputedTime() const
 {
   return mGraphImpl->mStateComputedTime;
 }
@@ -470,23 +476,23 @@ AsyncCubebTask::Run()
     // assumes the caller does.
     return NS_OK;
   }
 
   MOZ_ASSERT(mDriver);
 
   switch(mOperation) {
     case AsyncCubebOperation::INIT: {
-      LIFECYCLE_LOG("AsyncCubebOperation::INIT\n");
+      LIFECYCLE_LOG("AsyncCubebOperation::INIT driver=%p\n", mDriver.get());
       mDriver->Init();
       mDriver->CompleteAudioContextOperations(mOperation);
       break;
     }
     case AsyncCubebOperation::SHUTDOWN: {
-      LIFECYCLE_LOG("AsyncCubebOperation::SHUTDOWN\n");
+      LIFECYCLE_LOG("AsyncCubebOperation::SHUTDOWN driver=%p\n", mDriver.get());
       mDriver->Stop();
 
       mDriver->CompleteAudioContextOperations(mOperation);
 
       mDriver = nullptr;
       mShutdownGrip = nullptr;
       break;
     }
@@ -568,17 +574,17 @@ AudioCallbackDriver::Init()
 
   if (cubeb_get_min_latency(CubebUtils::GetCubebContext(), output, &latency) != CUBEB_OK) {
     NS_WARNING("Could not get minimal latency from cubeb.");
     return;
   }
 
   input = output;
   input.devid = mGraphImpl->mInputDeviceID;
-  
+
   cubeb_stream* stream;
   // XXX Only pass input params if we have an input listener.  Always
   // set up output because it's easier, and it will just get silence.
   // XXX Add support for adding/removing an input listener later.
   if (cubeb_stream_init(CubebUtils::GetCubebContext(), &stream,
                         "AudioCallbackDriver",
                         mGraphImpl->mInputWanted ? &input : nullptr,
                         mGraphImpl->mOutputWanted ? &output : nullptr, latency,
@@ -845,21 +851,21 @@ AudioCallbackDriver::DataCallback(AudioD
     // We want the interval [mIterationStart; mIterationEnd] to be before the
     // interval [stateComputedTime; nextStateComputedTime]. We also want
     // the distance between these intervals to be roughly equivalent each time, to
     // ensure there is no clock drift between current time and state time. Since
     // we can't act on the state time because we have to fill the audio buffer, we
     // reclock the current time against the state time, here.
     mIterationEnd = mIterationStart + 0.8 * inGraph;
 
-    STREAM_LOG(LogLevel::Debug, ("interval[%ld; %ld] state[%ld; %ld] (frames: %ld) (durationMS: %u) (duration ticks: %ld)\n",
-                              (long)mIterationStart, (long)mIterationEnd,
-                              (long)stateComputedTime, (long)nextStateComputedTime,
-                              (long)aFrames, (uint32_t)durationMS,
-                              (long)(nextStateComputedTime - stateComputedTime)));
+    STREAM_LOG(LogLevel::Verbose, ("interval[%ld; %ld] state[%ld; %ld] (frames: %ld) (durationMS: %u) (duration ticks: %ld)\n",
+                                   (long)mIterationStart, (long)mIterationEnd,
+                                   (long)stateComputedTime, (long)nextStateComputedTime,
+                                   (long)aFrames, (uint32_t)durationMS,
+                                   (long)(nextStateComputedTime - stateComputedTime)));
 
     mCurrentTimeStamp = TimeStamp::Now();
 
     if (stateComputedTime < mIterationEnd) {
       STREAM_LOG(LogLevel::Warning, ("Media graph global underrun detected"));
       mIterationEnd = stateComputedTime;
     }