Bug 1345756: P3. Fix coding style. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 09 Mar 2017 10:40:37 +0100
changeset 496773 b4f52f481c49f32664c4aabe1f7ad28b5c44a5e4
parent 496772 a1c4ceb4af485e3ac99bfa314e07912bfb0d1d33
child 496774 12f3640ac1dbaa276784383e02f9fad2cc50490b
push id48688
push userbmo:jyavenard@mozilla.com
push dateFri, 10 Mar 2017 17:25:09 +0000
reviewersgerald
bugs1345756
milestone55.0a1
Bug 1345756: P3. Fix coding style. r?gerald MozReview-Commit-ID: HxdcqxWbJzC
dom/media/mediasource/MediaSourceDemuxer.cpp
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -1,41 +1,43 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "MediaSourceDemuxer.h"
+
+#include "MediaSourceUtils.h"
+#include "OpusDecoder.h"
+#include "SourceBufferList.h"
+#include "nsPrintfCString.h"
+
 #include <algorithm>
 #include <limits>
 #include <stdint.h>
 
-#include "MediaSourceDemuxer.h"
-#include "MediaSourceUtils.h"
-#include "SourceBufferList.h"
-#include "nsPrintfCString.h"
-#include "OpusDecoder.h"
-
 namespace mozilla {
 
 typedef TrackInfo::TrackType TrackType;
 using media::TimeUnit;
 using media::TimeIntervals;
 
 MediaSourceDemuxer::MediaSourceDemuxer(AbstractThread* aAbstractMainThread)
   : mTaskQueue(new AutoTaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK),
                                  /* aSupportsTailDispatch = */ false))
   , mMonitor("MediaSourceDemuxer")
 {
   MOZ_ASSERT(NS_IsMainThread());
 }
 
 // Due to inaccuracies in determining buffer end
 // frames (Bug 1065207). This value is based on videos seen in the wild.
-const TimeUnit MediaSourceDemuxer::EOS_FUZZ = media::TimeUnit::FromMicroseconds(500000);
+const TimeUnit MediaSourceDemuxer::EOS_FUZZ =
+  media::TimeUnit::FromMicroseconds(500000);
 
 RefPtr<MediaSourceDemuxer::InitPromise>
 MediaSourceDemuxer::Init()
 {
   RefPtr<MediaSourceDemuxer> self = this;
   return InvokeAsync(GetTaskQueue(), __func__,
     [self](){
       if (self->ScanSourceBuffersForContent()) {
@@ -44,17 +46,18 @@ MediaSourceDemuxer::Init()
 
       RefPtr<InitPromise> p = self->mInitPromise.Ensure(__func__);
 
       return p;
     });
 }
 
 void
-MediaSourceDemuxer::AddSizeOfResources(MediaSourceDecoder::ResourceSizes* aSizes)
+MediaSourceDemuxer::AddSizeOfResources(
+  MediaSourceDecoder::ResourceSizes* aSizes)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // NB: The track buffers must only be accessed on the TaskQueue.
   RefPtr<MediaSourceDemuxer> self = this;
   RefPtr<MediaSourceDecoder::ResourceSizes> sizes = aSizes;
   nsCOMPtr<nsIRunnable> task =
     NS_NewRunnableFunction([self, sizes] () {
@@ -247,46 +250,50 @@ MediaSourceDemuxer::~MediaSourceDemuxer(
 
 void
 MediaSourceDemuxer::GetMozDebugReaderData(nsACString& aString)
 {
   MonitorAutoLock mon(mMonitor);
   nsAutoCString result;
   result += nsPrintfCString("Dumping Data for Demuxer: %p\n", this);
   if (mAudioTrack) {
-    result += nsPrintfCString("\tDumping Audio Track Buffer(%s): mLastAudioTime=%f\n"
-                              "\t\tAudio Track Buffer Details: NumSamples=%"
-                              PRIuSIZE " Size=%u Evictable=%u "
-                              "NextGetSampleIndex=%u NextInsertionIndex=%d\n",
-                              mAudioTrack->mAudioTracks.mInfo->mMimeType.get(),
-                              mAudioTrack->mAudioTracks.mNextSampleTime.ToSeconds(),
-                              mAudioTrack->mAudioTracks.mBuffers[0].Length(),
-                              mAudioTrack->mAudioTracks.mSizeBuffer,
-                              mAudioTrack->Evictable(TrackInfo::kAudioTrack),
-                              mAudioTrack->mAudioTracks.mNextGetSampleIndex.valueOr(-1),
-                              mAudioTrack->mAudioTracks.mNextInsertionIndex.valueOr(-1));
+    result += nsPrintfCString(
+      "\tDumping Audio Track Buffer(%s): mLastAudioTime=%f\n"
+      "\t\tAudio Track Buffer Details: NumSamples=%" PRIuSIZE
+      " Size=%u Evictable=%u "
+      "NextGetSampleIndex=%u NextInsertionIndex=%d\n",
+      mAudioTrack->mAudioTracks.mInfo->mMimeType.get(),
+      mAudioTrack->mAudioTracks.mNextSampleTime.ToSeconds(),
+      mAudioTrack->mAudioTracks.mBuffers[0].Length(),
+      mAudioTrack->mAudioTracks.mSizeBuffer,
+      mAudioTrack->Evictable(TrackInfo::kAudioTrack),
+      mAudioTrack->mAudioTracks.mNextGetSampleIndex.valueOr(-1),
+      mAudioTrack->mAudioTracks.mNextInsertionIndex.valueOr(-1));
 
-    result += nsPrintfCString("\t\tAudio Track Buffered: ranges=%s\n",
-                              DumpTimeRanges(mAudioTrack->SafeBuffered(TrackInfo::kAudioTrack)).get());
+    result += nsPrintfCString(
+      "\t\tAudio Track Buffered: ranges=%s\n",
+      DumpTimeRanges(mAudioTrack->SafeBuffered(TrackInfo::kAudioTrack)).get());
   }
   if (mVideoTrack) {
-    result += nsPrintfCString("\tDumping Video Track Buffer(%s): mLastVideoTime=%f\n"
-                              "\t\tVideo Track Buffer Details: NumSamples=%"
-                              PRIuSIZE " Size=%u Evictable=%u "
-                              "NextGetSampleIndex=%u NextInsertionIndex=%d\n",
-                              mVideoTrack->mVideoTracks.mInfo->mMimeType.get(),
-                              mVideoTrack->mVideoTracks.mNextSampleTime.ToSeconds(),
-                              mVideoTrack->mVideoTracks.mBuffers[0].Length(),
-                              mVideoTrack->mVideoTracks.mSizeBuffer,
-                              mVideoTrack->Evictable(TrackInfo::kVideoTrack),
-                              mVideoTrack->mVideoTracks.mNextGetSampleIndex.valueOr(-1),
-                              mVideoTrack->mVideoTracks.mNextInsertionIndex.valueOr(-1));
+    result += nsPrintfCString(
+      "\tDumping Video Track Buffer(%s): mLastVideoTime=%f\n"
+      "\t\tVideo Track Buffer Details: NumSamples=%" PRIuSIZE
+      " Size=%u Evictable=%u "
+      "NextGetSampleIndex=%u NextInsertionIndex=%d\n",
+      mVideoTrack->mVideoTracks.mInfo->mMimeType.get(),
+      mVideoTrack->mVideoTracks.mNextSampleTime.ToSeconds(),
+      mVideoTrack->mVideoTracks.mBuffers[0].Length(),
+      mVideoTrack->mVideoTracks.mSizeBuffer,
+      mVideoTrack->Evictable(TrackInfo::kVideoTrack),
+      mVideoTrack->mVideoTracks.mNextGetSampleIndex.valueOr(-1),
+      mVideoTrack->mVideoTracks.mNextInsertionIndex.valueOr(-1));
 
-    result += nsPrintfCString("\t\tVideo Track Buffered: ranges=%s\n",
-                              DumpTimeRanges(mVideoTrack->SafeBuffered(TrackInfo::kVideoTrack)).get());
+    result += nsPrintfCString(
+      "\t\tVideo Track Buffered: ranges=%s\n",
+      DumpTimeRanges(mVideoTrack->SafeBuffered(TrackInfo::kVideoTrack)).get());
   }
   aString += result;
 }
 
 MediaSourceTrackDemuxer::MediaSourceTrackDemuxer(MediaSourceDemuxer* aParent,
                                                  TrackInfo::TrackType aType,
                                                  TrackBuffersManager* aManager)
   : mParent(aParent)
@@ -330,34 +337,34 @@ MediaSourceTrackDemuxer::Reset()
   RefPtr<MediaSourceTrackDemuxer> self = this;
   nsCOMPtr<nsIRunnable> task =
     NS_NewRunnableFunction([self] () {
       self->mNextSample.reset();
       self->mReset = true;
       self->mManager->Seek(self->mType, TimeUnit(), TimeUnit());
       {
         MonitorAutoLock mon(self->mMonitor);
-        self->mNextRandomAccessPoint =
-          self->mManager->GetNextRandomAccessPoint(self->mType,
-                                                   MediaSourceDemuxer::EOS_FUZZ);
+        self->mNextRandomAccessPoint = self->mManager->GetNextRandomAccessPoint(
+          self->mType, MediaSourceDemuxer::EOS_FUZZ);
       }
     });
   mParent->GetTaskQueue()->Dispatch(task.forget());
 }
 
 nsresult
 MediaSourceTrackDemuxer::GetNextRandomAccessPoint(media::TimeUnit* aTime)
 {
   MonitorAutoLock mon(mMonitor);
   *aTime = mNextRandomAccessPoint;
   return NS_OK;
 }
 
 RefPtr<MediaSourceTrackDemuxer::SkipAccessPointPromise>
-MediaSourceTrackDemuxer::SkipToNextRandomAccessPoint(const media::TimeUnit& aTimeThreshold)
+MediaSourceTrackDemuxer::SkipToNextRandomAccessPoint(
+  const media::TimeUnit& aTimeThreshold)
 {
   return InvokeAsync<media::TimeUnit&&>(
            mParent->GetTaskQueue(), this, __func__,
            &MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint,
            aTimeThreshold);
 }
 
 media::TimeIntervals
@@ -435,18 +442,18 @@ MediaSourceTrackDemuxer::DoGetSamples(in
     TimeIntervals buffered = mManager->Buffered(mType);
     buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ / 2);
 
     if (!buffered.Length() && mManager->IsEnded()) {
       return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_END_OF_STREAM,
                                              __func__);
     }
     if (!buffered.ContainsWithStrictEnd(TimeUnit::FromMicroseconds(0))) {
-      return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA,
-                                             __func__);
+      return SamplesPromise::CreateAndReject(
+        NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA, __func__);
     }
     mReset = false;
   }
   RefPtr<MediaRawData> sample;
   if (mNextSample) {
     sample = mNextSample.ref();
     mNextSample.reset();
   } else {
@@ -469,17 +476,18 @@ MediaSourceTrackDemuxer::DoGetSamples(in
     MonitorAutoLock mon(mMonitor);
     mNextRandomAccessPoint =
       mManager->GetNextRandomAccessPoint(mType, MediaSourceDemuxer::EOS_FUZZ);
   }
   return SamplesPromise::CreateAndResolve(samples, __func__);
 }
 
 RefPtr<MediaSourceTrackDemuxer::SkipAccessPointPromise>
-MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint(const media::TimeUnit& aTimeThreadshold)
+MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint(
+  const media::TimeUnit& aTimeThreadshold)
 {
   uint32_t parsed = 0;
   // Ensure that the data we are about to skip to is still available.
   TimeIntervals buffered = mManager->Buffered(mType);
   buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ / 2);
   if (buffered.ContainsWithStrictEnd(aTimeThreadshold)) {
     bool found;
     parsed = mManager->SkipToNextRandomAccessPoint(mType,