Bug 1335066 - Fix logging in TrackEncoder.cpp. r=pehrsons
authorPaul Adenot <paul@paul.cx>
Mon, 30 Jan 2017 17:44:07 +0100
changeset 331706 30293a6c6e4ae95a743a2dee67eba031a6e28700
parent 331705 3cee898946d9b792b82e2c0a29ec9854b96aa2c3
child 331707 468f75ba2034e33ae82dcd349425e51b6bbf7a48
push id31281
push userkwierso@gmail.com
push dateMon, 30 Jan 2017 23:45:09 +0000
treeherdermozilla-central@1fe66bd0efba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1335066
milestone54.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 1335066 - Fix logging in TrackEncoder.cpp. r=pehrsons This was a mix of Android logging for b2g and normal logging and also noop logging statement. This makes everything use MOZ_LOG. MozReview-Commit-ID: BGE2JVcCVdF
dom/media/encoder/TrackEncoder.cpp
--- a/dom/media/encoder/TrackEncoder.cpp
+++ b/dom/media/encoder/TrackEncoder.cpp
@@ -3,24 +3,17 @@
  * 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 "TrackEncoder.h"
 #include "AudioChannelFormat.h"
 #include "MediaStreamGraph.h"
 #include "MediaStreamListener.h"
 #include "mozilla/Logging.h"
 #include "VideoUtils.h"
-
-#undef LOG
-#ifdef MOZ_WIDGET_GONK
-#include <android/log.h>
-#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "MediaEncoder", ## args);
-#else
-#define LOG(args, ...)
-#endif
+#include "mozilla/Logging.h"
 
 namespace mozilla {
 
 LazyLogModule gTrackEncoderLog("TrackEncoder");
 #define TRACK_LOG(type, msg) MOZ_LOG(gTrackEncoderLog, type, msg)
 
 static const int DEFAULT_CHANNELS = 1;
 static const int DEFAULT_SAMPLING_RATE = 16000;
@@ -73,42 +66,42 @@ AudioTrackEncoder::NotifyQueuedTrackChan
     while (!iter.IsEnded()) {
       AudioChunk chunk = *iter;
 
       // The number of channels is determined by the first non-null chunk, and
       // thus the audio encoder is initialized at this time.
       if (!chunk.IsNull()) {
         nsresult rv = Init(chunk.mChannelData.Length(), aGraph->GraphRate());
         if (NS_FAILED(rv)) {
-          LOG("[AudioTrackEncoder]: Fail to initialize the encoder!");
+          TRACK_LOG(LogLevel::Error, ("[AudioTrackEncoder]: Fail to initialize the encoder!"));
           NotifyCancel();
         }
         break;
       }
 
       iter.Next();
     }
 
     mNotInitDuration += aQueuedMedia.GetDuration();
     if (!mInitialized &&
         (mNotInitDuration / aGraph->GraphRate() > INIT_FAILED_DURATION) &&
         mInitCounter > 1) {
-      LOG("[AudioTrackEncoder]: Initialize failed for 30s.");
+      TRACK_LOG(LogLevel::Warning, ("[AudioTrackEncoder]: Initialize failed for 30s."));
       NotifyEndOfStream();
       return;
     }
   }
 
   // Append and consume this raw segment.
   AppendAudioSegment(audio);
 
 
   // The stream has stopped and reached the end of track.
   if (aTrackEvents == TrackEventCommand::TRACK_EVENT_ENDED) {
-    LOG("[AudioTrackEncoder]: Receive TRACK_EVENT_ENDED .");
+    TRACK_LOG(LogLevel::Info, ("[AudioTrackEncoder]: Receive TRACK_EVENT_ENDED ."));
     NotifyEndOfStream();
   }
 }
 
 void
 AudioTrackEncoder::NotifyEndOfStream()
 {
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
@@ -211,29 +204,29 @@ VideoTrackEncoder::Init(const VideoSegme
    VideoChunk chunk = *iter;
    if (!chunk.IsNull()) {
      gfx::IntSize imgsize = chunk.mFrame.GetImage()->GetSize();
      gfx::IntSize intrinsicSize = chunk.mFrame.GetIntrinsicSize();
      nsresult rv = Init(imgsize.width, imgsize.height,
                         intrinsicSize.width, intrinsicSize.height);
 
      if (NS_FAILED(rv)) {
-       LOG("[VideoTrackEncoder]: Fail to initialize the encoder!");
+       TRACK_LOG(LogLevel::Error, ("[VideoTrackEncoder]: Fail to initialize the encoder!"));
        NotifyCancel();
      }
      break;
    }
 
    iter.Next();
   }
 
   mNotInitDuration += aSegment.GetDuration();
   if ((mNotInitDuration / mTrackRate > INIT_FAILED_DURATION) &&
       mInitCounter > 1) {
-    LOG("[VideoTrackEncoder]: Initialize failed for %ds.", INIT_FAILED_DURATION);
+    TRACK_LOG(LogLevel::Debug, ("[VideoTrackEncoder]: Initialize failed for %ds.", INIT_FAILED_DURATION));
     NotifyEndOfStream();
     return;
   }
 }
 
 void
 VideoTrackEncoder::SetCurrentFrames(const VideoSegment& aSegment)
 {
@@ -269,17 +262,17 @@ VideoTrackEncoder::NotifyQueuedTrackChan
 
    // Check and initialize parameters for codec encoder.
   Init(video);
 
   AppendVideoSegment(video);
 
   // The stream has stopped and reached the end of track.
   if (aTrackEvents == TrackEventCommand::TRACK_EVENT_ENDED) {
-    LOG("[VideoTrackEncoder]: Receive TRACK_EVENT_ENDED .");
+    TRACK_LOG(LogLevel::Info, ("[VideoTrackEncoder]: Receive TRACK_EVENT_ENDED ."));
     NotifyEndOfStream();
   }
 
 }
 
 nsresult
 VideoTrackEncoder::AppendVideoSegment(const VideoSegment& aSegment)
 {