Bug 941298 - Fix errors in content/media/fmp4 on Linux with clang and --enable-warnings-as-errors r=cpearce
authorEdwin Flores <eflores@mozilla.com>
Fri, 21 Mar 2014 19:35:14 +1300
changeset 193198 ca38dab56641978e78d3ac3a030faaa8640fc001
parent 193197 56244a819a290e6fae4018223022173ec7971ddc
child 193199 2df0b05cb91129ad5677d9e465c42a5edfe3f3c9
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs941298
milestone31.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 941298 - Fix errors in content/media/fmp4 on Linux with clang and --enable-warnings-as-errors r=cpearce
content/media/fmp4/BlankDecoderModule.cpp
content/media/fmp4/MP4Reader.cpp
content/media/fmp4/demuxer/basictypes.h
content/media/fmp4/demuxer/box_reader.h
content/media/fmp4/demuxer/mp4_demuxer.cc
--- a/content/media/fmp4/BlankDecoderModule.cpp
+++ b/content/media/fmp4/BlankDecoderModule.cpp
@@ -40,18 +40,18 @@ public:
   }
 
   class OutputEvent : public nsRunnable {
   public:
     OutputEvent(mp4_demuxer::MP4Sample* aSample,
                 MediaDataDecoderCallback* aCallback,
                 BlankMediaDataCreator* aCreator)
       : mSample(aSample)
+      , mCreator(aCreator)
       , mCallback(aCallback)
-      , mCreator(aCreator)
     {
     }
     NS_IMETHOD Run() MOZ_OVERRIDE
     {
       mCallback->Output(mCreator->Create(mSample->composition_timestamp,
                                          mSample->duration,
                                          mSample->byte_offset));
       return NS_OK;
@@ -156,20 +156,19 @@ private:
 };
 
 
 class BlankAudioDataCreator {
 public:
   BlankAudioDataCreator(uint32_t aChannelCount,
                         uint32_t aSampleRate,
                         uint16_t aBitsPerSample)
-    : mFrameSum(0),
-      mChannelCount(aChannelCount),
-      mSampleRate(aSampleRate),
-      mBitsPerSample(aBitsPerSample)
+    : mFrameSum(0)
+    , mChannelCount(aChannelCount)
+    , mSampleRate(aSampleRate)
   {
   }
 
   MediaData* Create(Microseconds aDTS,
                     Microseconds aDuration,
                     int64_t aOffsetInStream)
   {
     // Convert duration to frames. We add 1 to duration to account for
@@ -199,17 +198,16 @@ public:
                          samples,
                          mChannelCount);
   }
 
 private:
   int64_t mFrameSum;
   uint32_t mChannelCount;
   uint32_t mSampleRate;
-  uint16_t mBitsPerSample;
 };
 
 class BlankDecoderModule : public PlatformDecoderModule {
 public:
 
   // Called when the decoders have shutdown. Main thread only.
   virtual nsresult Shutdown() MOZ_OVERRIDE {
     return NS_OK;
--- a/content/media/fmp4/MP4Reader.cpp
+++ b/content/media/fmp4/MP4Reader.cpp
@@ -44,17 +44,17 @@ class MP4Stream : public mp4_demuxer::St
 public:
 
   MP4Stream(MediaResource* aResource)
     : mResource(aResource)
   {
     MOZ_COUNT_CTOR(MP4Stream);
     MOZ_ASSERT(aResource);
   }
-  ~MP4Stream() {
+  virtual ~MP4Stream() {
     MOZ_COUNT_DTOR(MP4Stream);
   }
 
   virtual bool ReadAt(int64_t aOffset,
                       uint8_t* aBuffer,
                       uint32_t aCount,
                       uint32_t* aBytesRead) MOZ_OVERRIDE {
     uint32_t sum = 0;
@@ -78,20 +78,20 @@ public:
   }
 
 private:
   RefPtr<MediaResource> mResource;
 };
 
 MP4Reader::MP4Reader(AbstractMediaDecoder* aDecoder)
   : MediaDecoderReader(aDecoder)
-  , mLayersBackendType(layers::LayersBackend::LAYERS_NONE)
   , mAudio("MP4 audio decoder data", Preferences::GetUint("media.mp4-audio-decode-ahead", 2))
   , mVideo("MP4 video decoder data", Preferences::GetUint("media.mp4-video-decode-ahead", 2))
   , mLastReportedNumDecodedFrames(0)
+  , mLayersBackendType(layers::LayersBackend::LAYERS_NONE)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
   MOZ_COUNT_CTOR(MP4Reader);
 }
 
 MP4Reader::~MP4Reader()
 {
   MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
@@ -366,26 +366,28 @@ MP4Reader::Decode(TrackType aTrack)
       data.mMonitor.Wait();
     }
   }
   data.mMonitor.AssertCurrentThreadOwns();
   data.mMonitor.Unlock();
   return true;
 }
 
+#ifdef LOG_SAMPLE_DECODE
 static const char*
 TrackTypeToStr(TrackType aTrack)
 {
   MOZ_ASSERT(aTrack == kAudio || aTrack == kVideo);
   switch (aTrack) {
     case kAudio: return "Audio";
     case kVideo: return "Video";
     default: return "Unknown";
   }
 }
+#endif
 
 void
 MP4Reader::Output(mp4_demuxer::TrackType aTrack, MediaData* aSample)
 {
 #ifdef LOG_SAMPLE_DECODE
   LOG("Decoded %s sample time=%lld dur=%lld",
       TrackTypeToStr(aTrack), aSample->mTime, aSample->mDuration);
 #endif
--- a/content/media/fmp4/demuxer/basictypes.h
+++ b/content/media/fmp4/demuxer/basictypes.h
@@ -56,22 +56,22 @@ namespace mp4_demuxer {
     } while (0)
 
 #define arraysize(f) (sizeof(f) / sizeof(*f))
 
 #ifdef LOG_DEMUXER
 #ifdef PR_LOGGING
 #define DMX_LOG(...) PR_LOG(GetDemuxerLog(), PR_LOG_DEBUG, (__VA_ARGS__))
 #else
-#define DMX_LOG(...) 0
+#define DMX_LOG(...) (void)0
 #endif
 #else
 // define DMX_LOG as 0, so that if(condition){DMX_LOG(...)} branches don't elicit
 // a warning-as-error.
-#define DMX_LOG(...) 0
+#define DMX_LOG(...) (void)0
 #endif
 
 // A macro to disallow the evil copy constructor and operator= functions
 // This should be used in the private: declarations for a class
 #define DISALLOW_COPY_AND_ASSIGN(TypeName)  \
   TypeName(const TypeName&);      \
   void operator=(const TypeName&)
 
--- a/content/media/fmp4/demuxer/box_reader.h
+++ b/content/media/fmp4/demuxer/box_reader.h
@@ -22,17 +22,17 @@ struct Box {
   virtual ~Box();
   virtual bool Parse(BoxReader* reader) = 0;
   virtual FourCC BoxType() const = 0;
 };
 
 class StreamReader {
  public:
   StreamReader(Stream* stream, int64_t offset, int64_t size)
-    : stream_(stream), start_(offset), pos_(0), size_(size) {}
+    : start_(offset), size_(size), pos_(0), stream_(stream) {}
 
   bool HasBytes(int count) { return (pos() + count <= size()); }
 
   // Read a value from the stream, perfoming endian correction, and advance the
   // stream pointer.
   bool Read1(uint8_t* v)  WARN_UNUSED_RESULT;
   bool Read2(uint16_t* v) WARN_UNUSED_RESULT;
   bool Read2s(int16_t* v) WARN_UNUSED_RESULT;
--- a/content/media/fmp4/demuxer/mp4_demuxer.cc
+++ b/content/media/fmp4/demuxer/mp4_demuxer.cc
@@ -92,18 +92,16 @@ bool MP4Demuxer::Init()
   }
   return state_  >= kParsingBoxes &&
          state_ < kError;
 }
 
 void MP4Demuxer::Reset() {
   moov_ = nullptr;
   runs_ = nullptr;
-  stream_offset_; // TODO; Not sure if this needs to be reset?
-  DMX_LOG("Warning: resetting stream_offset_\n");
   moof_head_ = 0;
   mdat_tail_ = 0;
 }
 
 // TODO(xhwang): Figure out the init data type appropriately once it's spec'ed.
 static const char kMp4InitDataType[] = "video/mp4";
 
 bool MP4Demuxer::ParseMoov(BoxReader* reader) {
@@ -298,25 +296,17 @@ bool MP4Demuxer::ParseBox() {
   }
 
   stream_offset_ += reader->size();
 
   return true;
 }
 
 bool MP4Demuxer::EmitSample(nsAutoPtr<MP4Sample>* sample) {
-  bool ok = true;
   if (!runs_->IsRunValid()) {
-
-    // Flush any buffers we've gotten in this chunk so that buffers don't
-    // cross NewSegment() calls
-    //ok = SendAndFlushSamples(/*audio_buffers, video_buffers*/);
-    //if (!ok)
-    //  return false;
-
     ChangeState(kParsingBoxes);
     //end_of_segment_cb_.Run();
     return true;
   }
 
   if (!runs_->IsSampleValid()) {
     runs_->AdvanceRun();
     return true;