Bug 1423253 - Remove DirectMediaStreamTrackListener::mMedia. r=padenot
authorAndreas Pehrson <apehrson@mozilla.com>
Fri, 22 Mar 2019 11:44:54 +0000
changeset 465656 30552dd7fbfca8881c22e4b90ba8bd62c87056c1
parent 465655 c608a0db006386acb5b125dd5aa3f4dbf093093e
child 465657 81d85b9029903a05648fd609d4f425b0add12c6c
push id35744
push userapavel@mozilla.com
push dateFri, 22 Mar 2019 16:44:08 +0000
treeherdermozilla-central@e66a2b59914d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1423253
milestone68.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 1423253 - Remove DirectMediaStreamTrackListener::mMedia. r=padenot It is unnecessary. Differential Revision: https://phabricator.services.mozilla.com/D22924
dom/media/MediaStreamListener.cpp
dom/media/MediaStreamListener.h
--- a/dom/media/MediaStreamListener.cpp
+++ b/dom/media/MediaStreamListener.cpp
@@ -14,23 +14,21 @@ namespace mozilla {
 #ifdef LOG
 #  undef LOG
 #endif
 
 #define LOG(type, msg) MOZ_LOG(gMediaStreamGraphLog, type, msg)
 
 void DirectMediaStreamTrackListener::MirrorAndDisableSegment(
     AudioSegment& aFrom, AudioSegment& aTo) {
-  aTo.Clear();
   aTo.AppendNullData(aFrom.GetDuration());
 }
 
 void DirectMediaStreamTrackListener::MirrorAndDisableSegment(
     VideoSegment& aFrom, VideoSegment& aTo, DisabledTrackMode aMode) {
-  aTo.Clear();
   if (aMode == DisabledTrackMode::SILENCE_BLACK) {
     for (VideoSegment::ChunkIterator it(aFrom); !it.IsEnded(); it.Next()) {
       aTo.AppendFrame(do_AddRef(it->mFrame.GetImage()),
                       it->mFrame.GetIntrinsicSize(), it->GetPrincipalHandle(),
                       true);
       aTo.ExtendLastFrameBy(it->GetDuration());
     }
   } else if (aMode == DisabledTrackMode::SILENCE_FREEZE) {
@@ -45,29 +43,27 @@ void DirectMediaStreamTrackListener::
   if (mDisabledFreezeCount == 0 && mDisabledBlackCount == 0) {
     NotifyRealtimeTrackData(aGraph, aTrackOffset, aMedia);
     return;
   }
 
   DisabledTrackMode mode = mDisabledBlackCount > 0
                                ? DisabledTrackMode::SILENCE_BLACK
                                : DisabledTrackMode::SILENCE_FREEZE;
-  if (!mMedia) {
-    mMedia = aMedia.CreateEmptyClone();
-  }
+  UniquePtr<MediaSegment> media(aMedia.CreateEmptyClone());
   if (aMedia.GetType() == MediaSegment::AUDIO) {
     MirrorAndDisableSegment(static_cast<AudioSegment&>(aMedia),
-                            static_cast<AudioSegment&>(*mMedia));
+                            static_cast<AudioSegment&>(*media));
   } else if (aMedia.GetType() == MediaSegment::VIDEO) {
     MirrorAndDisableSegment(static_cast<VideoSegment&>(aMedia),
-                            static_cast<VideoSegment&>(*mMedia), mode);
+                            static_cast<VideoSegment&>(*media), mode);
   } else {
     MOZ_CRASH("Unsupported media type");
   }
-  NotifyRealtimeTrackData(aGraph, aTrackOffset, *mMedia);
+  NotifyRealtimeTrackData(aGraph, aTrackOffset, *media);
 }
 
 void DirectMediaStreamTrackListener::IncreaseDisabled(DisabledTrackMode aMode) {
   if (aMode == DisabledTrackMode::SILENCE_FREEZE) {
     ++mDisabledFreezeCount;
   } else if (aMode == DisabledTrackMode::SILENCE_BLACK) {
     ++mDisabledBlackCount;
   } else {
--- a/dom/media/MediaStreamListener.h
+++ b/dom/media/MediaStreamListener.h
@@ -175,19 +175,18 @@ class DirectMediaStreamTrackListener : p
   void NotifyRealtimeTrackDataAndApplyTrackDisabling(MediaStreamGraph* aGraph,
                                                      StreamTime aTrackOffset,
                                                      MediaSegment& aMedia);
 
   void IncreaseDisabled(DisabledTrackMode aMode);
   void DecreaseDisabled(DisabledTrackMode aMode);
 
   // Matches the number of disabled streams to which this listener is attached.
-  // The number of streams are those between the stream the listener was added
-  // and the SourceMediaStream that is the input of the data.
+  // The number of streams are those between the stream where the listener was
+  // added and the SourceMediaStream that is the source of the data reaching
+  // this listener.
   Atomic<int32_t> mDisabledFreezeCount;
   Atomic<int32_t> mDisabledBlackCount;
-
-  nsAutoPtr<MediaSegment> mMedia;
 };
 
 }  // namespace mozilla
 
 #endif  // MOZILLA_MEDIASTREAMLISTENER_h_