Bug 1288329: [ogg] P4. Fix coding style. r=gerald,jwwang
☠☠ backed out by 3f66f98ebf11 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 29 Jul 2016 10:47:03 +1000
changeset 349524 1406c14098f1fa36e557ffc5233991639342eeab
parent 349523 936b73eb37c6469fe8b31bf14965a5f04e25b740
child 349525 49ea83d00a77850710c8c57f408a080dc1557741
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, jwwang
bugs1288329
milestone50.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 1288329: [ogg] P4. Fix coding style. r=gerald,jwwang MozReview-Commit-ID: 1bAE92BECRD
dom/media/ogg/OggDemuxer.cpp
dom/media/ogg/OggDemuxer.h
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -25,17 +25,18 @@ extern mozilla::LazyLogModule gMediaDemu
 // Un-comment to enable logging of seek bisections.
 //#define SEEK_LOGGING
 #ifdef SEEK_LOGGING
 #define SEEK_LOG(type, msg) MOZ_LOG(gMediaDemuxerLog, type, msg)
 #else
 #define SEEK_LOG(type, msg)
 #endif
 
-namespace mozilla {
+namespace mozilla
+{
 
 using media::TimeUnit;
 using media::TimeInterval;
 using media::TimeIntervals;
 
 // The number of microseconds of "fuzz" we use in a bisection search over
 // HTTP. When we're seeking with fuzz, we'll stop the search if a bisection
 // lands between the seek target and OGG_SEEK_FUZZ_USECS microseconds before the
@@ -43,17 +44,18 @@ using media::TimeIntervals;
 // from an exisiting connection than to do another bisection inside that
 // small range, which would open a new HTTP connetion.
 static const uint32_t OGG_SEEK_FUZZ_USECS = 500000;
 
 // The number of microseconds of "pre-roll" we use for Opus streams.
 // The specification recommends 80 ms.
 static const int64_t OGG_SEEK_OPUS_PREROLL = 80 * USECS_PER_MS;
 
-class OggHeaders {
+class OggHeaders
+{
 public:
   OggHeaders() {}
   ~OggHeaders()
   {
     for (size_t i = 0; i < mHeaders.Length(); i++) {
       delete[] mHeaders[i];
     }
   }
@@ -755,18 +757,17 @@ OggDemuxer::ReadOggChain(const media::Ti
   if (!codecState) {
     return false;
   }
 
   if (mVorbisState && (codecState->GetType() == OggCodecState::TYPE_VORBIS)) {
     newVorbisState = static_cast<VorbisState*>(codecState.get());
   } else if (mOpusState && (codecState->GetType() == OggCodecState::TYPE_OPUS)) {
     newOpusState = static_cast<OpusState*>(codecState.get());
-  }
-  else {
+  } else {
     return false;
   }
 
   OggCodecState* state;
 
   mCodecStore.Add(serial, codecState.forget());
   state = mCodecStore.Get(serial);
 
@@ -819,18 +820,17 @@ OggDemuxer::ReadOggChain(const media::Ti
     chained = true;
     tags = newOpusState->GetTags();
   }
 
   if (chained) {
     SetChained();
     mInfo.mMediaSeekable = false;
     mDecodedAudioDuration += aLastEndTime;
-    if (mTimedMetadataEvent)
-    {
+    if (mTimedMetadataEvent) {
       mTimedMetadataEvent->Notify(
         TimedMetadata(mDecodedAudioDuration,
                       Move(tags),
                       nsAutoPtr<MediaInfo>(new MediaInfo(mInfo))));
     }
     return true;
   }
 
@@ -1252,29 +1252,27 @@ OggDemuxer::SeekToKeyframeUsingIndex(Tra
     return SEEK_INDEX_FAIL;
   }
   // We have an index from the Skeleton track, try to use it to seek.
   AutoTArray<uint32_t, 2> tracks;
   BuildSerialList(tracks);
   SkeletonState::nsSeekTarget keyframe;
   if (NS_FAILED(mSkeletonState->IndexedSeekTarget(aTarget,
                                                   tracks,
-                                                  keyframe)))
-  {
+                                                  keyframe))) {
     // Could not locate a keypoint for the target in the index.
     return SEEK_INDEX_FAIL;
   }
 
   // Remember original resource read cursor position so we can rollback on failure.
   int64_t tell = Resource(aType)->Tell();
 
   // Seek to the keypoint returned by the index.
   if (keyframe.mKeyPoint.mOffset > Resource(aType)->GetLength() ||
-      keyframe.mKeyPoint.mOffset < 0)
-  {
+      keyframe.mKeyPoint.mOffset < 0) {
     // Index must be invalid.
     return RollbackIndexedSeek(aType, tell);
   }
   LOG(LogLevel::Debug, ("Seeking using index to keyframe at offset %lld\n",
                      keyframe.mKeyPoint.mOffset));
   nsresult res = Resource(aType)->Seek(nsISeekableStream::NS_SEEK_SET,
                                        keyframe.mKeyPoint.mOffset);
   NS_ENSURE_SUCCESS(res, SEEK_FATAL_ERROR);
@@ -1303,18 +1301,17 @@ OggDemuxer::SeekToKeyframeUsingIndex(Tra
   uint32_t serial = ogg_page_serialno(&page);
   if (serial != keyframe.mSerial) {
     // Serialno of page at offset isn't what the index told us to expect.
     // Assume the index is invalid.
     return RollbackIndexedSeek(aType, tell);
   }
   OggCodecState* codecState = mCodecStore.Get(serial);
   if (codecState && codecState->mActive &&
-      ogg_stream_pagein(&codecState->mState, &page) != 0)
-  {
+      ogg_stream_pagein(&codecState->mState, &page) != 0) {
     // Couldn't insert page into the ogg resource, or somehow the resource
     // is no longer active.
     return RollbackIndexedSeek(aType, tell);
   }
   return SEEK_OK;
 }
 
 // Reads a page from the media resource.
@@ -1524,41 +1521,41 @@ OggTrackDemuxer::BreakCycles()
 // Returns an ogg page's checksum.
 ogg_uint32_t
 OggDemuxer::GetPageChecksum(ogg_page* page)
 {
   if (page == 0 || page->header == 0 || page->header_len < 25) {
     return 0;
   }
   const unsigned char* p = page->header + 22;
-  uint32_t c =  p[0] +
-               (p[1] << 8) +
-               (p[2] << 16) +
-               (p[3] << 24);
+  uint32_t c = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24);
   return c;
 }
 
 int64_t
 OggDemuxer::RangeStartTime(TrackInfo::TrackType aType, int64_t aOffset)
 {
   int64_t position = Resource(aType)->Tell();
   nsresult res = Resource(aType)->Seek(nsISeekableStream::NS_SEEK_SET, aOffset);
   NS_ENSURE_SUCCESS(res, 0);
   int64_t startTime = 0;
   FindStartTime(aType, startTime);
   res = Resource(aType)->Seek(nsISeekableStream::NS_SEEK_SET, position);
   NS_ENSURE_SUCCESS(res, -1);
   return startTime;
 }
 
-struct nsDemuxerAutoOggSyncState {
-  nsDemuxerAutoOggSyncState() {
+struct nsDemuxerAutoOggSyncState
+{
+  nsDemuxerAutoOggSyncState()
+  {
     ogg_sync_init(&mState);
   }
-  ~nsDemuxerAutoOggSyncState() {
+  ~nsDemuxerAutoOggSyncState()
+  {
     ogg_sync_clear(&mState);
   }
   ogg_sync_state mState;
 };
 
 int64_t
 OggDemuxer::RangeEndTime(TrackInfo::TrackType aType, int64_t aEndOffset)
 {
--- a/dom/media/ogg/OggDemuxer.h
+++ b/dom/media/ogg/OggDemuxer.h
@@ -56,47 +56,49 @@ private:
   media::TimeIntervals GetBuffered(TrackInfo::TrackType aType);
   void FindStartTime(int64_t& aOutStartTime);
   void FindStartTime(TrackInfo::TrackType, int64_t& aOutStartTime);
 
   nsresult SeekInternal(TrackInfo::TrackType aType, const media::TimeUnit& aTarget);
 
   // Seeks to the keyframe preceding the target time using available
   // keyframe indexes.
-  enum IndexedSeekResult {
+  enum IndexedSeekResult
+  {
     SEEK_OK,          // Success.
     SEEK_INDEX_FAIL,  // Failure due to no index, or invalid index.
     SEEK_FATAL_ERROR  // Error returned by a stream operation.
   };
   IndexedSeekResult SeekToKeyframeUsingIndex(TrackInfo::TrackType aType, int64_t aTarget);
 
   // Rolls back a seek-using-index attempt, returning a failure error code.
   IndexedSeekResult RollbackIndexedSeek(TrackInfo::TrackType aType, int64_t aOffset);
 
   // Represents a section of contiguous media, with a start and end offset,
   // and the timestamps of the start and end of that range, that is cached.
   // Used to denote the extremities of a range in which we can seek quickly
   // (because it's cached).
-  class SeekRange {
+  class SeekRange
+  {
   public:
     SeekRange()
-      : mOffsetStart(0),
-        mOffsetEnd(0),
-        mTimeStart(0),
-        mTimeEnd(0)
+      : mOffsetStart(0)
+      , mOffsetEnd(0)
+      , mTimeStart(0)
+      , mTimeEnd(0)
     {}
 
     SeekRange(int64_t aOffsetStart,
               int64_t aOffsetEnd,
               int64_t aTimeStart,
               int64_t aTimeEnd)
-      : mOffsetStart(aOffsetStart),
-        mOffsetEnd(aOffsetEnd),
-        mTimeStart(aTimeStart),
-        mTimeEnd(aTimeEnd)
+      : mOffsetStart(aOffsetStart)
+      , mOffsetEnd(aOffsetEnd)
+      , mTimeStart(aTimeStart)
+      , mTimeEnd(aTimeEnd)
     {}
 
     bool IsNull() const {
       return mOffsetStart == 0 &&
              mOffsetEnd == 0 &&
              mTimeStart == 0 &&
              mTimeEnd == 0;
     }
@@ -149,17 +151,18 @@ private:
                          int64_t aTarget,
                          const SeekRange& aRange,
                          uint32_t aFuzz);
 
   // Chunk size to read when reading Ogg files. Average Ogg page length
   // is about 4300 bytes, so we read the file in chunks larger than that.
   static const int PAGE_STEP = 8192;
 
-  enum PageSyncResult {
+  enum PageSyncResult
+  {
     PAGE_SYNC_ERROR = 1,
     PAGE_SYNC_END_OF_RANGE= 2,
     PAGE_SYNC_OK = 3
   };
   static PageSyncResult PageSync(MediaResourceIndex* aResource,
                                  ogg_sync_state* aState,
                                  bool aCachedDataOnly,
                                  int64_t aOffset,
@@ -240,17 +243,16 @@ private:
                        int64_t aEndOffset,
                        bool aCachedDataOnly);
 
   // Get the start time of the range beginning at aOffset. This is the start
   // time of the first aType sample we'd be able to play if we
   // started playback at aOffset.
   int64_t RangeStartTime(TrackInfo::TrackType aType, int64_t aOffset);
 
-
   MediaInfo mInfo;
   nsTArray<RefPtr<OggTrackDemuxer>> mDemuxers;
 
   // Map of codec-specific bitstream states.
   OggCodecStore mCodecStore;
 
   // Decode state of the Theora bitstream we're decoding, if we have video.
   TheoraState* mTheoraState;
@@ -304,17 +306,18 @@ private:
   int mOpusPreSkip;
   th_info mTheoraInfo;
 
   Maybe<int64_t> mStartTime;
 
   // Booleans to indicate if we have audio and/or video data
   bool HasVideo() const;
   bool HasAudio() const;
-  bool HasSkeleton() const {
+  bool HasSkeleton() const
+  {
     return mSkeletonState != 0 && mSkeletonState->mActive;
   }
   bool HaveStartTime () const;
   bool HaveStartTime (TrackInfo::TrackType aType);
   int64_t StartTime() const;
   int64_t StartTime(TrackInfo::TrackType aType);
 
   // The picture region inside Theora frame to be displayed, if we have