Bug 1026336 - Fix warnings in content/media/webrtc and mark FAIL_ON_WARNINGS. r=jesup
authorChris Peterson <cpeterson@mozilla.com>
Sun, 15 Jun 2014 11:57:30 -0700
changeset 190040 855ac2eeb5fccfef003ebde2de46e32cc019885c
parent 190039 66db03e176d4d63c6954c41fb61c28b75524b84f
child 190041 c416861823d207479b069a85a8ab1fca56dd2b7b
push id8288
push userryanvm@gmail.com
push dateMon, 23 Jun 2014 14:59:00 +0000
treeherderb2g-inbound@c65bf5a0595c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1026336
milestone33.0a1
Bug 1026336 - Fix warnings in content/media/webrtc and mark FAIL_ON_WARNINGS. r=jesup
content/media/webrtc/LoadManager.cpp
content/media/webrtc/LoadManager.h
content/media/webrtc/LoadManagerFactory.cpp
content/media/webrtc/MediaEngineWebRTC.h
content/media/webrtc/PeerIdentity.cpp
content/media/webrtc/moz.build
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/media-conduit/VideoConduit.h
--- a/content/media/webrtc/LoadManager.cpp
+++ b/content/media/webrtc/LoadManager.cpp
@@ -35,25 +35,25 @@ namespace mozilla {
 
 NS_IMPL_ISUPPORTS(LoadManagerSingleton, nsIObserver)
 
 
 LoadManagerSingleton::LoadManagerSingleton(int aLoadMeasurementInterval,
                                            int aAveragingMeasurements,
                                            float aHighLoadThreshold,
                                            float aLowLoadThreshold)
-  : mLoadSum(0.0f),
+  : mLock("LoadManager"),
+    mCurrentState(webrtc::kLoadNormal),
+    mOveruseActive(false),
+    mLoadSum(0.0f),
     mLoadSumMeasurements(0),
-    mOveruseActive(false),
     mLoadMeasurementInterval(aLoadMeasurementInterval),
     mAveragingMeasurements(aAveragingMeasurements),
     mHighLoadThreshold(aHighLoadThreshold),
-    mLowLoadThreshold(aLowLoadThreshold),
-    mCurrentState(webrtc::kLoadNormal),
-    mLock("LoadManager")
+    mLowLoadThreshold(aLowLoadThreshold)
 {
 #if defined(PR_LOGGING)
   if (!gLoadManagerLog)
     gLoadManagerLog = PR_NewLogModule("LoadManager");
 #endif
   LOG(("LoadManager - Initializing (%dms x %d, %f, %f)",
        mLoadMeasurementInterval, mAveragingMeasurements,
        mHighLoadThreshold, mLowLoadThreshold));
--- a/content/media/webrtc/LoadManager.h
+++ b/content/media/webrtc/LoadManager.h
@@ -49,18 +49,18 @@ private:
                          float aHighLoadThreshold,
                          float aLowLoadThreshold);
     ~LoadManagerSingleton();
 
     void LoadHasChanged();
 
     nsRefPtr<LoadMonitor> mLoadMonitor;
 
-    // This protexts access to the mObservers list, the current state, pretty much all
-    // the other members (below)
+    // This protects access to the mObservers list, the current state, and
+    // pretty much all the other members (below).
     Mutex mLock;
     nsTArray<webrtc::CPULoadStateObserver*> mObservers;
     webrtc::CPULoadState mCurrentState;
     // Set when overuse was signaled to us, and hasn't been un-signaled yet.
     bool  mOveruseActive;
     float mLoadSum;
     int   mLoadSumMeasurements;
     // Load measurement settings
--- a/content/media/webrtc/LoadManagerFactory.cpp
+++ b/content/media/webrtc/LoadManagerFactory.cpp
@@ -24,19 +24,19 @@ LoadManagerSingleton::Get() {
   if (!sSingleton) {
     MOZ_ASSERT(NS_IsMainThread());
 
     int loadMeasurementInterval =
       mozilla::Preferences::GetInt("media.navigator.load_adapt.measure_interval", 1000);
     int averagingSeconds =
       mozilla::Preferences::GetInt("media.navigator.load_adapt.avg_seconds", 3);
     float highLoadThreshold =
-      mozilla::Preferences::GetFloat("media.navigator.load_adapt.high_load", 0.90);
+      mozilla::Preferences::GetFloat("media.navigator.load_adapt.high_load", 0.90f);
     float lowLoadThreshold =
-      mozilla::Preferences::GetFloat("media.navigator.load_adapt.low_load", 0.40);
+      mozilla::Preferences::GetFloat("media.navigator.load_adapt.low_load", 0.40f);
 
     sSingleton = new LoadManagerSingleton(loadMeasurementInterval,
                                           averagingSeconds,
                                           highLoadThreshold,
                                           lowLoadThreshold);
 
     nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
     if (obs) {
--- a/content/media/webrtc/MediaEngineWebRTC.h
+++ b/content/media/webrtc/MediaEngineWebRTC.h
@@ -262,23 +262,23 @@ private:
 };
 
 class MediaEngineWebRTCAudioSource : public MediaEngineAudioSource,
                                      public webrtc::VoEMediaProcess
 {
 public:
   MediaEngineWebRTCAudioSource(webrtc::VoiceEngine* aVoiceEnginePtr, int aIndex,
     const char* name, const char* uuid)
-    : mVoiceEngine(aVoiceEnginePtr)
+    : mSamples(0)
+    , mVoiceEngine(aVoiceEnginePtr)
     , mMonitor("WebRTCMic.Monitor")
     , mCapIndex(aIndex)
     , mChannel(-1)
     , mInitDone(false)
     , mStarted(false)
-    , mSamples(0)
     , mEchoOn(false), mAgcOn(false), mNoiseOn(false)
     , mEchoCancel(webrtc::kEcDefault)
     , mAGC(webrtc::kAgcDefault)
     , mNoiseSuppress(webrtc::kNsDefault)
     , mPlayoutDelay(0)
     , mNullTransport(nullptr) {
     MOZ_ASSERT(aVoiceEnginePtr);
     mState = kReleased;
@@ -314,16 +314,23 @@ public:
 
   // VoEMediaProcess.
   void Process(int channel, webrtc::ProcessingTypes type,
                int16_t audio10ms[], int length,
                int samplingFreq, bool isStereo);
 
   NS_DECL_THREADSAFE_ISUPPORTS
 
+protected:
+  // mSamples is an int to avoid conversions when comparing/etc to
+  // samplingFreq & length. Making mSamples protected instead of private is a
+  // silly way to avoid -Wunused-private-field warnings when PR_LOGGING is not
+  // #defined. mSamples is not actually expected to be used by a derived class.
+  int mSamples;
+
 private:
   static const unsigned int KMaxDeviceNameLength = 128;
   static const unsigned int KMaxUniqueIdLength = 256;
 
   void Init();
   void Shutdown();
 
   webrtc::VoiceEngine* mVoiceEngine;
@@ -339,17 +346,16 @@ private:
   Monitor mMonitor;
   nsTArray<SourceMediaStream *> mSources; // When this goes empty, we shut down HW
 
   int mCapIndex;
   int mChannel;
   TrackID mTrackID;
   bool mInitDone;
   bool mStarted;
-  int mSamples; // int to avoid conversions when comparing/etc to samplingFreq & length
 
   nsString mDeviceName;
   nsString mDeviceUUID;
 
   bool mEchoOn, mAgcOn, mNoiseOn;
   webrtc::EcModes  mEchoCancel;
   webrtc::AgcModes mAGC;
   webrtc::NsModes  mNoiseSuppress;
--- a/content/media/webrtc/PeerIdentity.cpp
+++ b/content/media/webrtc/PeerIdentity.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=2 ts=2 sts=2 expandtab
  * 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 "PeerIdentity.h"
 
+#include "mozilla/DebugOnly.h"
 #include "nsCOMPtr.h"
 #include "nsIIDNService.h"
 #include "nsNetCID.h"
 #include "nsServiceManagerUtils.h"
 
 namespace mozilla {
 
 bool
@@ -71,14 +72,14 @@ PeerIdentity::GetHost(const nsAString& a
   }
 }
 
 /* static */ void
 PeerIdentity::GetNormalizedHost(const nsCOMPtr<nsIIDNService>& aIdnService,
                                 const nsAString& aHost,
                                 nsACString& aNormalizedHost)
 {
-  nsCString chost = NS_ConvertUTF16toUTF8(aHost);
-  nsresult rv = aIdnService->ConvertUTF8toACE(chost, aNormalizedHost);
-  NS_WARN_IF(NS_FAILED(rv));
+  const nsCString chost = NS_ConvertUTF16toUTF8(aHost);
+  DebugOnly<nsresult> rv = aIdnService->ConvertUTF8toACE(chost, aNormalizedHost);
+  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to convert UTF-8 host to ASCII");
 }
 
 } /* namespace mozilla */
--- a/content/media/webrtc/moz.build
+++ b/content/media/webrtc/moz.build
@@ -52,8 +52,16 @@ EXPORTS.mozilla += [
     'PeerIdentity.h',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'gklayout'
 if CONFIG['OS_ARCH'] == 'WINNT':
     DEFINES['NOMINMAX'] = True
+
+
+if CONFIG['_MSC_VER']:
+  CXXFLAGS += [
+    '-wd4275', # non dll-interface class used as base for dll-interface class
+  ]
+
+FAIL_ON_WARNINGS = True
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -51,16 +51,40 @@ mozilla::RefPtr<VideoSessionConduit> Vid
     CSFLogError(logTag,  "%s VideoConduit Init Failed ", __FUNCTION__);
     delete obj;
     return nullptr;
   }
   CSFLogDebug(logTag,  "%s Successfully created VideoConduit ", __FUNCTION__);
   return obj;
 }
 
+WebrtcVideoConduit::WebrtcVideoConduit():
+  mOtherDirection(nullptr),
+  mShutDown(false),
+  mVideoEngine(nullptr),
+  mTransport(nullptr),
+  mRenderer(nullptr),
+  mPtrExtCapture(nullptr),
+  mEngineTransmitting(false),
+  mEngineReceiving(false),
+  mChannel(-1),
+  mCapId(-1),
+  mCurSendCodecConfig(nullptr),
+  mSendingWidth(0),
+  mSendingHeight(0),
+  mReceivingWidth(640),
+  mReceivingHeight(480),
+  mVideoLatencyTestEnable(false),
+  mVideoLatencyAvg(0),
+  mMinBitrate(200),
+  mStartBitrate(300),
+  mMaxBitrate(2000)
+{
+}
+
 WebrtcVideoConduit::~WebrtcVideoConduit()
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
   CSFLogDebug(logTag,  "%s ", __FUNCTION__);
 
   for(std::vector<VideoCodecConfig*>::size_type i=0;i < mRecvCodecList.size();i++)
   {
     delete mRecvCodecList[i];
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h
@@ -216,41 +216,18 @@ public:
 
   unsigned int SendingMaxFr() {
     if(mCurSendCodecConfig) {
       return mCurSendCodecConfig->mMaxFrameRate;
     }
     return 0;
   }
 
-  WebrtcVideoConduit():
-                      mOtherDirection(nullptr),
-                      mShutDown(false),
-                      mVideoEngine(nullptr),
-                      mTransport(nullptr),
-                      mRenderer(nullptr),
-                      mPtrExtCapture(nullptr),
-                      mEngineTransmitting(false),
-                      mEngineReceiving(false),
-                      mChannel(-1),
-                      mCapId(-1),
-                      mCurSendCodecConfig(nullptr),
-                      mSendingWidth(0),
-                      mSendingHeight(0),
-                      mReceivingWidth(640),
-                      mReceivingHeight(480),
-                      mVideoLatencyTestEnable(false),
-                      mVideoLatencyAvg(0),
-                      mMinBitrate(200),
-                      mStartBitrate(300),
-                      mMaxBitrate(2000)
-  {
-  }
-
-  virtual ~WebrtcVideoConduit() ;
+  WebrtcVideoConduit();
+  virtual ~WebrtcVideoConduit();
 
   MediaConduitErrorCode Init(WebrtcVideoConduit *other);
 
   int GetChannel() { return mChannel; }
   webrtc::VideoEngine* GetVideoEngine() { return mVideoEngine; }
   bool GetLocalSSRC(unsigned int* ssrc);
   bool GetRemoteSSRC(unsigned int* ssrc);
   bool GetVideoEncoderStats(double* framerateMean,