Bug 1276851 - Remove AudioStream::mIsFirst. r=kinetik.
authorJW Wang <jwwang@mozilla.com>
Tue, 31 May 2016 14:18:58 +0800
changeset 338875 bdb2c38f67dfa6fec43aa81b1e6e0153fd9d9554
parent 338874 408312a8ef14c74061503cc2cd8539d4bdaa3fee
child 338876 bc2bd91854befe145331375bb36cb89dd3f9f3ba
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1276851
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 1276851 - Remove AudioStream::mIsFirst. r=kinetik. MozReview-Commit-ID: H9KCM2zZulA
dom/media/AudioStream.cpp
dom/media/AudioStream.h
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -322,17 +322,17 @@ int AudioStream::InvokeCubeb(Function aF
   return aFunction(mCubebStream.get(), Forward<Args>(aArgs)...);
 }
 
 nsresult
 AudioStream::Init(uint32_t aNumChannels, uint32_t aRate,
                   const dom::AudioChannel aAudioChannel)
 {
   auto startTime = TimeStamp::Now();
-  mIsFirst = CubebUtils::GetFirstStream();
+  auto isFirst = CubebUtils::GetFirstStream();
 
   LOG("%s channels: %d, rate: %d", __FUNCTION__, aNumChannels, aRate);
   mInRate = mOutRate = aRate;
   mChannels = aNumChannels;
   mOutChannels = aNumChannels;
 
   mDumpFile = OpenDumpFile(this);
 
@@ -349,21 +349,22 @@ 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, startTime);
+  return OpenCubeb(params, startTime, isFirst);
 }
 
 nsresult
-AudioStream::OpenCubeb(cubeb_stream_params &aParams, TimeStamp aStartTime)
+AudioStream::OpenCubeb(cubeb_stream_params& aParams,
+                       TimeStamp aStartTime, bool aIsFirst)
 {
   cubeb* cubebContext = CubebUtils::GetCubebContext();
   if (!cubebContext) {
     NS_WARNING("Can't get cubeb context!");
     return NS_ERROR_FAILURE;
   }
 
   cubeb_stream* stream = nullptr;
@@ -373,19 +374,19 @@ AudioStream::OpenCubeb(cubeb_stream_para
                         DataCallback_S, StateCallback_S, this) == CUBEB_OK) {
     mCubebStream.reset(stream);
   } else {
     NS_WARNING(nsPrintfCString("AudioStream::OpenCubeb() %p failed to init cubeb", this).get());
     return NS_ERROR_FAILURE;
   }
 
   TimeDuration timeDelta = TimeStamp::Now() - aStartTime;
-  LOG("creation time %sfirst: %u ms", mIsFirst ? "" : "not ",
+  LOG("creation time %sfirst: %u ms", aIsFirst ? "" : "not ",
       (uint32_t) timeDelta.ToMilliseconds());
-  Telemetry::Accumulate(mIsFirst ? Telemetry::AUDIOSTREAM_FIRST_OPEN_MS :
+  Telemetry::Accumulate(aIsFirst ? Telemetry::AUDIOSTREAM_FIRST_OPEN_MS :
       Telemetry::AUDIOSTREAM_LATER_OPEN_MS, timeDelta.ToMilliseconds());
 
   return NS_OK;
 }
 
 void
 AudioStream::SetVolume(double aVolume)
 {
--- a/dom/media/AudioStream.h
+++ b/dom/media/AudioStream.h
@@ -308,17 +308,18 @@ 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, TimeStamp aStartTime);
+  nsresult OpenCubeb(cubeb_stream_params& aParams,
+                     TimeStamp aStartTime, bool aIsFirst);
 
   static long DataCallback_S(cubeb_stream*, void* aThis,
                              const void* /* aInputBuffer */, void* aOutputBuffer,
                              long aFrames)
   {
     return static_cast<AudioStream*>(aThis)->DataCallback(aOutputBuffer, aFrames);
   }
 
@@ -366,16 +367,15 @@ private:
     STARTED,     // cubeb started.
     STOPPED,     // Stopped by a call to Pause().
     DRAINED,     // StateCallback has indicated that the drain is complete.
     ERRORED,     // Stream disabled due to an internal error.
     SHUTDOWN     // Shutdown has been called
   };
 
   StreamState mState;
-  bool mIsFirst;
 
   DataSource& mDataSource;
 };
 
 } // namespace mozilla
 
 #endif