Bug 1276569. Part 4 - remove mStartTime. r=kinetik.
authorJW Wang <jwwang@mozilla.com>
Mon, 30 May 2016 16:38:37 +0800
changeset 340631 eaf90fc6c08264b8fd26125f62178dee4cf2ce43
parent 340630 2981353a3ae77aa0bfc6e899d62c62aa1a527b4b
child 340632 00287f808a350be8ff8a452695d303968c825b4f
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1276569
milestone49.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 1276569. Part 4 - remove mStartTime. r=kinetik. MozReview-Commit-ID: EbTqf4nY8NR
dom/media/AudioStream.cpp
dom/media/AudioStream.h
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -314,17 +314,17 @@ template <>
 struct ToCubebFormat<AUDIO_FORMAT_S16> {
   static const cubeb_sample_format value = CUBEB_SAMPLE_S16NE;
 };
 
 nsresult
 AudioStream::Init(uint32_t aNumChannels, uint32_t aRate,
                   const dom::AudioChannel aAudioChannel)
 {
-  mStartTime = TimeStamp::Now();
+  auto startTime = TimeStamp::Now();
   mIsFirst = CubebUtils::GetFirstStream();
 
   if (!CubebUtils::GetCubebContext()) {
     return NS_ERROR_FAILURE;
   }
 
   LOG("%s channels: %d, rate: %d", __FUNCTION__, aNumChannels, aRate);
   mInRate = mOutRate = aRate;
@@ -346,23 +346,23 @@ AudioStream::Init(uint32_t aNumChannels,
   if (params.stream_type == CUBEB_STREAM_TYPE_MAX) {
     return NS_ERROR_INVALID_ARG;
   }
 #endif
 
   params.format = ToCubebFormat<AUDIO_OUTPUT_FORMAT>::value;
   mAudioClock.Init();
 
-  return OpenCubeb(params);
+  return OpenCubeb(params, startTime);
 }
 
 // This code used to live inside AudioStream::Init(), but on Mac (others?)
 // it has been known to take 300-800 (or even 8500) ms to execute(!)
 nsresult
-AudioStream::OpenCubeb(cubeb_stream_params &aParams)
+AudioStream::OpenCubeb(cubeb_stream_params &aParams, TimeStamp aStartTime)
 {
   cubeb* cubebContext = CubebUtils::GetCubebContext();
   if (!cubebContext) {
     NS_WARNING("Can't get cubeb context!");
     MonitorAutoLock mon(mMonitor);
     mState = AudioStream::ERRORED;
     return NS_ERROR_FAILURE;
   }
@@ -385,23 +385,21 @@ AudioStream::OpenCubeb(cubeb_stream_para
       mState = ERRORED;
       NS_WARNING(nsPrintfCString("AudioStream::OpenCubeb() %p failed to init cubeb", this).get());
       return NS_ERROR_FAILURE;
     }
   }
 
   mState = INITIALIZED;
 
-  if (!mStartTime.IsNull()) {
-    TimeDuration timeDelta = TimeStamp::Now() - mStartTime;
-    LOG("creation time %sfirst: %u ms", mIsFirst ? "" : "not ",
-        (uint32_t) timeDelta.ToMilliseconds());
-    Telemetry::Accumulate(mIsFirst ? Telemetry::AUDIOSTREAM_FIRST_OPEN_MS :
-        Telemetry::AUDIOSTREAM_LATER_OPEN_MS, timeDelta.ToMilliseconds());
-  }
+  TimeDuration timeDelta = TimeStamp::Now() - aStartTime;
+  LOG("creation time %sfirst: %u ms", mIsFirst ? "" : "not ",
+      (uint32_t) timeDelta.ToMilliseconds());
+  Telemetry::Accumulate(mIsFirst ? Telemetry::AUDIOSTREAM_FIRST_OPEN_MS :
+      Telemetry::AUDIOSTREAM_LATER_OPEN_MS, timeDelta.ToMilliseconds());
 
   return NS_OK;
 }
 
 void
 AudioStream::SetVolume(double aVolume)
 {
   MOZ_ASSERT(aVolume >= 0.0 && aVolume <= 1.0, "Invalid volume");
--- a/dom/media/AudioStream.h
+++ b/dom/media/AudioStream.h
@@ -308,17 +308,17 @@ protected:
 
   // Return the position, measured in audio frames played since the stream was
   // opened, of the audio hardware, not adjusted for the changes of playback
   // rate or underrun frames.
   // Caller must own the monitor.
   int64_t GetPositionInFramesUnlocked();
 
 private:
-  nsresult OpenCubeb(cubeb_stream_params &aParams);
+  nsresult OpenCubeb(cubeb_stream_params &aParams, TimeStamp aStartTime);
 
   static long DataCallback_S(cubeb_stream*, void* aThis,
                              const void* /* aInputBuffer */, void* aOutputBuffer,
                              long aFrames)
   {
     return static_cast<AudioStream*>(aThis)->DataCallback(aOutputBuffer, aFrames);
   }
 
@@ -347,19 +347,16 @@ private:
   uint32_t mInRate;
   // Output rate in Hz (characteristic of the playback rate)
   uint32_t mOutRate;
   uint32_t mChannels;
   uint32_t mOutChannels;
   AudioClock mAudioClock;
   soundtouch::SoundTouch* mTimeStretcher;
 
-  // Stream start time for stream open delay telemetry.
-  TimeStamp mStartTime;
-
   // Output file for dumping audio
   FILE* mDumpFile;
 
   // Owning reference to a cubeb_stream.
   UniquePtr<cubeb_stream, CubebDestroyPolicy> mCubebStream;
 
   enum StreamState {
     INITIALIZED, // Initialized, playback has not begun.