Bug 1061046. Part 1: Move GraphRate() to MediaStreamGraph so it's public. r=karlt
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 18 Sep 2014 11:50:01 +1200
changeset 216590 8803f3f31a911b0c8aacefef700f02edc85cf95b
parent 216589 3909450514b4b686f79c869e8c4d1f89c9180e16
child 216591 99f0e4fdb42c7f176f48a05707ff97578993cf40
push idunknown
push userunknown
push dateunknown
reviewerskarlt
bugs1061046
milestone36.0a1
Bug 1061046. Part 1: Move GraphRate() to MediaStreamGraph so it's public. r=karlt
dom/camera/CameraPreviewMediaStream.h
dom/media/MediaStreamGraph.cpp
dom/media/MediaStreamGraph.h
dom/media/MediaStreamGraphImpl.h
--- a/dom/camera/CameraPreviewMediaStream.h
+++ b/dom/camera/CameraPreviewMediaStream.h
@@ -11,17 +11,17 @@
 
 namespace mozilla {
 
 class FakeMediaStreamGraph : public MediaStreamGraph
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FakeMediaStreamGraph)
 public:
   FakeMediaStreamGraph()
-    : MediaStreamGraph()
+    : MediaStreamGraph(16000)
   {
   }
 
   virtual void
   DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable) MOZ_OVERRIDE;
 
 protected:
   ~FakeMediaStreamGraph()
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -2712,24 +2712,24 @@ ProcessedMediaStream::DestroyImpl()
   // MediaStreamGraphImpl::RemoveStream() will also call
   // SetStreamOrderDirty(), for other reasons.
 }
 
 MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime,
                                            TrackRate aSampleRate,
                                            DOMMediaStream::TrackTypeHints aHint= DOMMediaStream::HINT_CONTENTS_UNKNOWN,
                                            dom::AudioChannel aChannel)
-  : mProcessingGraphUpdateIndex(0)
+  : MediaStreamGraph(aSampleRate)
+  , mProcessingGraphUpdateIndex(0)
   , mPortCount(0)
   , mNeedAnotherIteration(false)
   , mGraphDriverAsleep(false)
   , mMonitor("MediaStreamGraphImpl")
   , mLifecycleState(LIFECYCLE_THREAD_NOT_STARTED)
   , mEndTime(GRAPH_TIME_MAX)
-  , mSampleRate(aSampleRate)
   , mForceShutDown(false)
   , mPostedRunInStableStateEvent(false)
   , mFlushSourcesNow(false)
   , mFlushSourcesOnNextIteration(false)
   , mDetectedNotRunning(false)
   , mPostedRunInStableState(false)
   , mRealtime(aRealtime)
   , mNonRealtimeProcessing(false)
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -1189,31 +1189,44 @@ public:
    * Should only be called during MediaStreamListener callbacks or during
    * ProcessedMediaStream::ProcessInput().
    */
   virtual void DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable)
   {
     *mPendingUpdateRunnables.AppendElement() = aRunnable;
   }
 
+  /**
+   * Returns graph sample rate in Hz.
+   */
+  TrackRate GraphRate() const { return mSampleRate; }
+
 protected:
-  MediaStreamGraph()
+  MediaStreamGraph(TrackRate aSampleRate)
     : mNextGraphUpdateIndex(1)
+    , mSampleRate(aSampleRate)
   {
     MOZ_COUNT_CTOR(MediaStreamGraph);
   }
   virtual ~MediaStreamGraph()
   {
     MOZ_COUNT_DTOR(MediaStreamGraph);
   }
 
   // Media graph thread only
   nsTArray<nsCOMPtr<nsIRunnable> > mPendingUpdateRunnables;
 
   // Main thread only
   // The number of updates we have sent to the media graph thread + 1.
   // We start this at 1 just to ensure that 0 is usable as a special value.
   int64_t mNextGraphUpdateIndex;
+
+  /**
+   * Sample rate at which this graph runs. For real time graphs, this is
+   * the rate of the audio mixer. For offline graphs, this is the rate specified
+   * at construction.
+   */
+  TrackRate mSampleRate;
 };
 
 }
 
 #endif /* MOZILLA_MEDIASTREAMGRAPH_H_ */
--- a/dom/media/MediaStreamGraphImpl.h
+++ b/dom/media/MediaStreamGraphImpl.h
@@ -394,17 +394,16 @@ public:
    * Mark the media stream order as dirty.
    */
   void SetStreamOrderDirty()
   {
     mStreamOrderDirty = true;
   }
 
   TrackRate AudioSampleRate() const { return mSampleRate; }
-  TrackRate GraphRate() const { return mSampleRate; }
   // Always stereo for now.
   uint32_t AudioChannelCount() { return 2; }
 
   double MediaTimeToSeconds(GraphTime aTime)
   {
     return TrackTicksToSeconds(GraphRate(), aTime);
   }
   GraphTime SecondsToMediaTime(double aS)
@@ -590,22 +589,16 @@ public:
   };
   LifecycleState mLifecycleState;
   /**
    * The graph should stop processing at or after this time.
    */
   GraphTime mEndTime;
 
   /**
-   * Sample rate at which this graph runs. For real time graphs, this is
-   * the rate of the audio mixer. For offline graphs, this is the rate specified
-   * at construction.
-   */
-  TrackRate mSampleRate;
-  /**
    * True when we need to do a forced shutdown during application shutdown.
    */
   bool mForceShutDown;
   /**
    * True when we have posted an event to the main thread to run
    * RunInStableState() and the event hasn't run yet.
    */
   bool mPostedRunInStableStateEvent;