Backed out changeset 81cee5ae7973 (bug 904617)
authorEd Morley <emorley@mozilla.com>
Mon, 16 Sep 2013 08:43:47 +0100
changeset 160231 0e8ce62c84c2b3c1d09a0c022c12ccbce894cb69
parent 160230 744da56423ba54ee5f4ba1ca8f8bbe4f099ddf23
child 160232 320ad574006f38bc5b9a21d2d304168f7d48199e
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs904617
milestone26.0a1
backs out81cee5ae79732d1ef7e18e1f189a9a26b2e7a015
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
Backed out changeset 81cee5ae7973 (bug 904617)
content/media/AudioSegment.cpp
content/media/AudioSegment.h
content/media/AudioStream.cpp
content/media/Latency.cpp
content/media/Latency.h
content/media/Makefile.in
content/media/MediaSegment.h
content/media/MediaStreamGraph.cpp
content/media/VideoSegment.h
content/media/moz.build
content/media/test/graph_latency.py
content/media/webrtc/MediaEngineWebRTC.h
layout/build/nsLayoutStatics.cpp
--- a/content/media/AudioSegment.cpp
+++ b/content/media/AudioSegment.cpp
@@ -2,17 +2,16 @@
 /* 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 "AudioSegment.h"
 
 #include "AudioStream.h"
 #include "AudioChannelFormat.h"
-#include "Latency.h"
 
 namespace mozilla {
 
 template <class SrcT, class DestT>
 static void
 InterleaveAndConvertBuffer(const SrcT** aSourceChannels,
                            int32_t aLength, float aVolume,
                            int32_t aChannels,
@@ -133,17 +132,17 @@ DownmixAndInterleave(const nsTArray<cons
     AudioChannelsDownMix(channelData, outputChannelBuffers.Elements(),
                          aOutputChannels, aDuration);
   }
   InterleaveAndConvertBuffer(outputChannelData.Elements(), AUDIO_FORMAT_FLOAT32,
                              aDuration, aVolume, aOutputChannels, aOutput);
 }
 
 void
-AudioSegment::WriteTo(uint64_t aID, AudioStream* aOutput)
+AudioSegment::WriteTo(AudioStream* aOutput)
 {
   uint32_t outputChannels = aOutput->GetChannels();
   nsAutoTArray<AudioDataValue,AUDIO_PROCESSING_FRAMES*GUESS_AUDIO_CHANNELS> buf;
   nsAutoTArray<const void*,GUESS_AUDIO_CHANNELS> channelData;
 
   for (ChunkIterator ci(*this); !ci.IsEnded(); ci.Next()) {
     AudioChunk& c = *ci;
     TrackTicks offset = 0;
@@ -179,18 +178,15 @@ AudioSegment::WriteTo(uint64_t aID, Audi
                                      outputChannels,
                                      buf.Elements());
         }
       } else {
         // Assumes that a bit pattern of zeroes == 0.0f
         memset(buf.Elements(), 0, buf.Length()*sizeof(AudioDataValue));
       }
       aOutput->Write(buf.Elements(), int32_t(duration));
-      if(!c.mTimeStamp.IsNull())
-        LogLatency(AsyncLatencyLogger::AudioMediaStreamTrack, aID,
-                   (mozilla::TimeStamp::Now() - c.mTimeStamp).ToMilliseconds());
       offset += duration;
     }
   }
   aOutput->Start();
 }
 
 }
--- a/content/media/AudioSegment.h
+++ b/content/media/AudioSegment.h
@@ -4,19 +4,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_AUDIOSEGMENT_H_
 #define MOZILLA_AUDIOSEGMENT_H_
 
 #include "MediaSegment.h"
 #include "AudioSampleFormat.h"
 #include "SharedBuffer.h"
-#ifdef MOZILLA_INTERNAL_API
-#include "mozilla/TimeStamp.h"
-#endif
 
 namespace mozilla {
 
 class AudioStream;
 
 /**
  * For auto-arrays etc, guess this as the common number of channels.
  */
@@ -100,19 +97,16 @@ struct AudioChunk {
     mVolume = 1.0f;
   }
 
   TrackTicks mDuration; // in frames within the buffer
   nsRefPtr<ThreadSharedObject> mBuffer; // the buffer object whose lifetime is managed; null means data is all zeroes
   nsTArray<const void*> mChannelData; // one pointer per channel; empty if and only if mBuffer is null
   float mVolume; // volume multiplier to apply (1.0f if mBuffer is nonnull)
   SampleFormat mBufferFormat; // format of frames in mBuffer (only meaningful if mBuffer is nonnull)
-#ifdef MOZILLA_INTERNAL_API
-  mozilla::TimeStamp mTimeStamp;           // time at which this has been fetched from the MediaEngine
-#endif
 };
 
 /**
  * A list of audio samples consisting of a sequence of slices of SharedBuffers.
  * The audio rate is determined by the track, not stored in this class.
  */
 class AudioSegment : public MediaSegmentBase<AudioSegment, AudioChunk> {
 public:
@@ -126,50 +120,41 @@ public:
   {
     AudioChunk* chunk = AppendChunk(aDuration);
     chunk->mBuffer = aBuffer;
     for (uint32_t channel = 0; channel < aChannelData.Length(); ++channel) {
       chunk->mChannelData.AppendElement(aChannelData[channel]);
     }
     chunk->mVolume = 1.0f;
     chunk->mBufferFormat = AUDIO_FORMAT_FLOAT32;
-#ifdef MOZILLA_INTERNAL_API
-    chunk->mTimeStamp = TimeStamp::Now();
-#endif
   }
   void AppendFrames(already_AddRefed<ThreadSharedObject> aBuffer,
                     const nsTArray<const int16_t*>& aChannelData,
                     int32_t aDuration)
   {
     AudioChunk* chunk = AppendChunk(aDuration);
     chunk->mBuffer = aBuffer;
     for (uint32_t channel = 0; channel < aChannelData.Length(); ++channel) {
       chunk->mChannelData.AppendElement(aChannelData[channel]);
     }
     chunk->mVolume = 1.0f;
     chunk->mBufferFormat = AUDIO_FORMAT_S16;
-#ifdef MOZILLA_INTERNAL_API
-    chunk->mTimeStamp = TimeStamp::Now();
-#endif
   }
   // Consumes aChunk, and returns a pointer to the persistent copy of aChunk
   // in the segment.
   AudioChunk* AppendAndConsumeChunk(AudioChunk* aChunk)
   {
     AudioChunk* chunk = AppendChunk(aChunk->mDuration);
     chunk->mBuffer = aChunk->mBuffer.forget();
     chunk->mChannelData.SwapElements(aChunk->mChannelData);
     chunk->mVolume = aChunk->mVolume;
     chunk->mBufferFormat = aChunk->mBufferFormat;
-#ifdef MOZILLA_INTERNAL_API
-    chunk->mTimeStamp = TimeStamp::Now();
-#endif
     return chunk;
   }
   void ApplyVolume(float aVolume);
-  void WriteTo(uint64_t aID, AudioStream* aOutput);
+  void WriteTo(AudioStream* aOutput);
 
   static Type StaticType() { return AUDIO; }
 };
 
 }
 
 #endif /* MOZILLA_AUDIOSEGMENT_H_ */
--- a/content/media/AudioStream.cpp
+++ b/content/media/AudioStream.cpp
@@ -9,17 +9,16 @@
 #include "prdtoa.h"
 #include "AudioStream.h"
 #include "VideoUtils.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/Mutex.h"
 #include <algorithm>
 #include "mozilla/Preferences.h"
 #include "soundtouch/SoundTouch.h"
-#include "Latency.h"
 
 #if defined(MOZ_CUBEB)
 #include "nsAutoRef.h"
 #include "cubeb/cubeb.h"
 
 template <>
 class nsAutoRefTraits<cubeb_stream> : public nsPointerRefTraits<cubeb_stream>
 {
@@ -500,26 +499,24 @@ WriteDumpFile(FILE* aDumpFile, AudioStre
   fflush(aDumpFile);
 }
 
 #if defined(MOZ_CUBEB)
 BufferedAudioStream::BufferedAudioStream()
   : mMonitor("BufferedAudioStream"), mLostFrames(0), mDumpFile(nullptr),
     mVolume(1.0), mBytesPerFrame(0), mState(INITIALIZED)
 {
-  AsyncLatencyLogger::Get(true)->AddRef();
 }
 
 BufferedAudioStream::~BufferedAudioStream()
 {
   Shutdown();
   if (mDumpFile) {
     fclose(mDumpFile);
   }
-  AsyncLatencyLogger::Get()->Release();
 }
 
 nsresult
 BufferedAudioStream::EnsureTimeStretcherInitialized()
 {
   MonitorAutoLock mon(mMonitor);
   return AudioStream::EnsureTimeStretcherInitialized();
 }
@@ -626,16 +623,17 @@ BufferedAudioStream::Write(const AudioDa
           return NS_ERROR_FAILURE;
         }
       }
       mon.Wait();
     }
   }
 
   mWritten += aFrames;
+
   return NS_OK;
 }
 
 uint32_t
 BufferedAudioStream::Available()
 {
   MonitorAutoLock mon(mMonitor);
   NS_ABORT_IF_FALSE(mBuffer.Length() % mBytesPerFrame == 0, "Buffer invariant violated.");
@@ -895,24 +893,16 @@ BufferedAudioStream::DataCallback(void* 
              ("AudioStream %p lost %d frames", this, underrunFrames));
     }
 #endif
     mLostFrames += underrunFrames;
     servicedFrames += underrunFrames;
   }
 
   WriteDumpFile(mDumpFile, this, aFrames, aBuffer);
-  if (PR_LOG_TEST(GetLatencyLog(), PR_LOG_DEBUG)) {
-    uint32_t latency = UINT32_MAX;
-    if (cubeb_stream_get_latency(mCubebStream, &latency)) {
-      NS_WARNING("Could not get latency from cubeb.");
-    }
-    LogLatency(AsyncLatencyLogger::AudioStream, 0, (mBuffer.Length() * 1000) / mOutRate);
-    LogLatency(AsyncLatencyLogger::Cubeb, 0, (latency * 1000) / mOutRate);
-  }
 
   mAudioClock.UpdateWritePosition(servicedFrames);
   return servicedFrames;
 }
 
 void
 BufferedAudioStream::StateCallback(cubeb_state aState)
 {
@@ -979,17 +969,17 @@ uint64_t AudioClock::GetPosition()
       mBasePosition = mPreviousPosition;
     } else {
       diffOffset = position - mPlaybackRateChangeOffset;
     }
     position =  static_cast<uint64_t>(mBasePosition +
       (static_cast<float>(USECS_PER_S * diffOffset) / mOutRate));
     return position;
   }
-  return UINT64_MAX;
+  return -1;
 }
 
 uint64_t AudioClock::GetPositionInFrames()
 {
   return (GetPosition() * mOutRate) / USECS_PER_S;
 }
 
 void AudioClock::SetPlaybackRate(double aPlaybackRate)
deleted file mode 100644
--- a/content/media/Latency.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- 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/. */
-
-// We want this available in opt builds
-#define FORCE_PR_LOG
-
-#include "Latency.h"
-#include "nsThreadUtils.h"
-#include <prlog.h>
-#include <cmath>
-#include <algorithm>
-
-
-using namespace mozilla;
-
-const char* LatencyLogIndex2Strings[] = {
-  "Audio MediaStreamTrack",
-  "Video MediaStreamTrack",
-  "Cubeb",
-  "AudioStream",
-  "NetStat"
-};
-
-AsyncLatencyLogger* gAsyncLogger = nullptr;
-
-PRLogModuleInfo*
-GetLatencyLog()
-{
-  static PRLogModuleInfo* sLog;
-  if (!sLog) {
-    sLog = PR_NewLogModule("MediaLatency");
-  }
-  return sLog;
-}
-
-
-class LogEvent : public nsRunnable
-{
-public:
-  LogEvent(AsyncLatencyLogger::LatencyLogIndex aIndex, uint64_t aID, int64_t aValue) :
-    mIndex(aIndex),
-    mID(aID),
-    mValue(aValue)
-  {}
-  ~LogEvent() {}
-
-  NS_IMETHOD Run() {
-    AsyncLatencyLogger::Get(true)->WriteLog(mIndex, mID, mValue);
-    return NS_OK;
-  }
-
-protected:
-  AsyncLatencyLogger::LatencyLogIndex mIndex;
-  uint64_t mID;
-  int64_t mValue;
-};
-
-// This is the only function that clients should use.
-void LogLatency(AsyncLatencyLogger::LatencyLogIndex aIndex, uint64_t aID, int64_t aValue)
-{
-  AsyncLatencyLogger::Get()->Log(aIndex, aID, aValue);
-}
-
-void AsyncLatencyLogger::InitializeStatics()
-{
-  NS_ASSERTION(NS_IsMainThread(), "Main thread only");
-  GetLatencyLog();
-  gAsyncLogger = new AsyncLatencyLogger();
-}
-
-void AsyncLatencyLogger::Shutdown()
-{
-}
-
-/* static */
-AsyncLatencyLogger* AsyncLatencyLogger::Get(bool aStartTimer)
-{
-  if (aStartTimer) {
-    gAsyncLogger->Init();
-  }
-  return gAsyncLogger;
-}
-
-AsyncLatencyLogger::AsyncLatencyLogger()
-  : mThread(nullptr),
-    mMutex("AsyncLatencyLogger")
-{ }
-
-AsyncLatencyLogger::~AsyncLatencyLogger()
-{
-  MutexAutoLock lock(mMutex);
-  if (mThread) {
-    mThread->Shutdown();
-  }
-  mStart = TimeStamp();
-}
-
-void AsyncLatencyLogger::Init()
-{
-  MutexAutoLock lock(mMutex);
-  if (mStart.IsNull()) {
-    mStart = TimeStamp::Now();
-    nsresult rv = NS_NewNamedThread("Latency Logger", getter_AddRefs(mThread));
-    NS_ENSURE_SUCCESS_VOID(rv);
-  }
-}
-
-// aID is a sub-identifier (in particular a specific MediaStramTrack)
-void AsyncLatencyLogger::WriteLog(LatencyLogIndex aIndex, uint64_t aID, int64_t aValue)
-{
-  PR_LOG(GetLatencyLog(), PR_LOG_DEBUG,
-         ("%s,%llu,%lld.,%lld.",
-          LatencyLogIndex2Strings[aIndex], aID, GetTimeStamp(), aValue));
-}
-
-int64_t AsyncLatencyLogger::GetTimeStamp()
-{
-  TimeDuration t = TimeStamp::Now() - mStart;
-  return t.ToMilliseconds();
-}
-
-void AsyncLatencyLogger::Log(LatencyLogIndex aIndex, uint64_t aID, int64_t aValue)
-{
-  if (PR_LOG_TEST(GetLatencyLog(), PR_LOG_DEBUG)) {
-    nsCOMPtr<nsIRunnable> event = new LogEvent(aIndex, aID, aValue);
-    if (mThread) {
-      mThread->Dispatch(event, NS_DISPATCH_NORMAL);
-    }
-  }
-}
-
deleted file mode 100644
--- a/content/media/Latency.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- 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/. */
-
-#ifndef MOZILLA_LATENCY_H
-#define MOZILLA_LATENCY_H
-
-#include "mozilla/TimeStamp.h"
-#include "prlog.h"
-#include "nsCOMPtr.h"
-#include "nsIThread.h"
-#include "mozilla/Monitor.h"
-#include "nsISupportsImpl.h"
-
-class AsyncLatencyLogger;
-class LogEvent;
-
-PRLogModuleInfo* GetLatencyLog();
-
-// This class is a singleton. It is refcounted.
-class AsyncLatencyLogger
-{
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AsyncLatencyLogger);
-public:
-  enum LatencyLogIndex {
-    AudioMediaStreamTrack,
-    VideoMediaStreamTrack,
-    Cubeb,
-    AudioStream,
-    NetEQ,
-    _MAX_INDEX
-  };
-  void Log(LatencyLogIndex index, uint64_t aID, int64_t value);
-  void WriteLog(LatencyLogIndex index, uint64_t aID, int64_t value);
-
-  static AsyncLatencyLogger* Get(bool aStartTimer = false);
-  static void InitializeStatics();
-  static void Shutdown();
-private:
-  AsyncLatencyLogger();
-  ~AsyncLatencyLogger();
-  int64_t GetTimeStamp();
-  void Init();
-  // The thread on which the IO happens
-  nsCOMPtr<nsIThread> mThread;
-  // This can be initialized on multiple threads, but is protected by a
-  // monitor. After the initialization phase, it is accessed on the log
-  // thread only.
-  mozilla::TimeStamp mStart;
-  // This monitor protects mStart and mMediaLatencyLog for the
-  // initialization sequence. It is initialized at layout startup, and
-  // destroyed at layout shutdown.
-  mozilla::Mutex mMutex;
-};
-
-void LogLatency(AsyncLatencyLogger::LatencyLogIndex index, uint64_t aID, int64_t value);
-
-#endif
--- a/content/media/Makefile.in
+++ b/content/media/Makefile.in
@@ -16,11 +16,10 @@ LOCAL_INCLUDES  += \
   $(NULL)
 
 ifdef MOZ_DIRECTSHOW
 LOCAL_INCLUDES += -I$(topsrcdir)/media/webrtc/trunk/webrtc/modules/video_capture/windows/
 endif
 
 CFLAGS   += $(GSTREAMER_CFLAGS)
 CXXFLAGS += $(GSTREAMER_CFLAGS)
-DEFINES  += -DMOZILLA_INTERNAL_API
 
 AudioNodeEngineNEON.$(OBJ_SUFFIX): CXXFLAGS += -mfpu=neon
--- a/content/media/MediaSegment.h
+++ b/content/media/MediaSegment.h
@@ -2,21 +2,17 @@
 /* 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/. */
 
 #ifndef MOZILLA_MEDIASEGMENT_H_
 #define MOZILLA_MEDIASEGMENT_H_
 
 #include "nsTArray.h"
-#ifdef MOZILLA_INTERNAL_API
-#include "mozilla/TimeStamp.h"
-#endif
 #include <algorithm>
-#include "Latency.h"
 
 namespace mozilla {
 
 /**
  * We represent media times in 64-bit fixed point. So 1 MediaTime is
  * 1/(2^MEDIA_TIME_FRAC_BITS) seconds.
  */
 typedef int64_t MediaTime;
@@ -179,19 +175,16 @@ public:
     if (aDuration <= 0) {
       return;
     }
     if (!mChunks.IsEmpty() && mChunks[0].IsNull()) {
       mChunks[0].mDuration += aDuration;
     } else {
       mChunks.InsertElementAt(0)->SetNull(aDuration);
     }
-#ifdef MOZILLA_INTERNAL_API
-    mChunks[0].mTimeStamp = mozilla::TimeStamp::Now();
-#endif
     mDuration += aDuration;
   }
   virtual void AppendNullData(TrackTicks aDuration)
   {
     if (aDuration <= 0) {
       return;
     }
     if (!mChunks.IsEmpty() && mChunks[mChunks.Length() - 1].IsNull()) {
@@ -324,16 +317,13 @@ protected:
       t -= c->GetDuration();
       chunksToRemove = i + 1 - aStartIndex;
     }
     mChunks.RemoveElementsAt(aStartIndex, chunksToRemove);
     mDuration -= aDuration - t;
   }
 
   nsTArray<Chunk> mChunks;
-#ifdef MOZILLA_INTERNAL_API
-  mozilla::TimeStamp mTimeStamp;
-#endif
 };
 
 }
 
 #endif /* MOZILLA_MEDIASEGMENT_H_ */
--- a/content/media/MediaStreamGraph.cpp
+++ b/content/media/MediaStreamGraph.cpp
@@ -809,18 +809,17 @@ MediaStreamGraphImpl::PlayAudio(MediaStr
         output.AppendNullData(endTicks - sliceEnd);
         NS_ASSERTION(endTicks == sliceEnd || track->IsEnded(),
                      "Ran out of data but track not ended?");
         output.ApplyVolume(volume);
         LOG(PR_LOG_DEBUG+1, ("MediaStream %p writing samples for %f to %f (samples %lld to %lld)",
                              aStream, MediaTimeToSeconds(t), MediaTimeToSeconds(end),
                              startTicks, endTicks));
       }
-      // XXX need unique id for stream & track
-      output.WriteTo((((uint64_t)i) << 32) | track->GetID(), audioOutput.mStream);
+      output.WriteTo(audioOutput.mStream);
       t = end;
     }
   }
 }
 
 static void
 SetImageToBlackPixel(PlanarYCbCrImage* aImage)
 {
--- a/content/media/VideoSegment.h
+++ b/content/media/VideoSegment.h
@@ -67,23 +67,21 @@ struct VideoChunk {
   {
     return aOther.mFrame == mFrame;
   }
   bool IsNull() const { return !mFrame.GetImage(); }
   void SetNull(TrackTicks aDuration)
   {
     mDuration = aDuration;
     mFrame.SetNull();
-    mTimeStamp = TimeStamp();
   }
   void SetForceBlack(bool aForceBlack) { mFrame.SetForceBlack(aForceBlack); }
 
   TrackTicks mDuration;
   VideoFrame mFrame;
-  mozilla::TimeStamp mTimeStamp;
 };
 
 class VideoSegment : public MediaSegmentBase<VideoSegment, VideoChunk> {
 public:
   typedef mozilla::layers::Image Image;
 
   VideoSegment();
   ~VideoSegment();
--- a/content/media/moz.build
+++ b/content/media/moz.build
@@ -64,17 +64,16 @@ EXPORTS += [
     'AudioSegment.h',
     'AudioStream.h',
     'BufferDecoder.h',
     'BufferMediaResource.h',
     'DOMMediaStream.h',
     'DecoderTraits.h',
     'EncodedBufferCache.h',
     'FileBlockCache.h',
-    'Latency.h',
     'MP3FrameParser.h',
     'MediaCache.h',
     'MediaDecoder.h',
     'MediaDecoderOwner.h',
     'MediaDecoderReader.h',
     'MediaDecoderStateMachine.h',
     'MediaMetadataManager.h',
     'MediaRecorder.h',
@@ -113,17 +112,16 @@ CPP_SOURCES += [
     'AudioSegment.cpp',
     'AudioStream.cpp',
     'AudioStreamTrack.cpp',
     'BufferDecoder.cpp',
     'DOMMediaStream.cpp',
     'DecoderTraits.cpp',
     'EncodedBufferCache.cpp',
     'FileBlockCache.cpp',
-    'Latency.cpp',
     'MP3FrameParser.cpp',
     'MediaCache.cpp',
     'MediaDecoder.cpp',
     'MediaDecoderReader.cpp',
     'MediaDecoderStateMachine.cpp',
     'MediaRecorder.cpp',
     'MediaResource.cpp',
     'MediaStreamGraph.cpp',
deleted file mode 100644
--- a/content/media/test/graph_latency.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env python
-# graph_latency.py - graph media latency
-#
-# 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/.
-
-# needs matplotlib (sudo aptitude install python-matplotlib)
-
-import matplotlib.pyplot as plt
-from matplotlib import rc
-import sys
-from pprint import pprint
-import re
-
-
-# FIX!  needs to be sum of a single mediastreamtrack and any output overhead for it
-# So there is one sum per MST
-def compute_sum(data):
-    'Compute the sum for each timestamp. This expects the output of parse_data.'
-    last_values = {}
-    out = ([],[])
-
-    for i in data:
-        if i[0] not in last_values.keys():
-          last_values[i[0]] = 0
-        last_values[i[0]] = float(i[3])
-        print last_values
-        out[0].append(i[2])
-        out[1].append(sum(last_values.values()))
-    return out
-
-
-def clean_data(raw_data):
-    '''
-    Remove the PR_LOG cruft at the beginning of each line and returns a list of
-    tuple.
-    '''
-    out = []
-    for line in raw_data:
-        match = re.match(r'(.*)#(.*)', line)
-        if match:
-	    continue
-	else:
-            out.append(line.split(": ")[1])
-    return out
-
-# returns a list of tuples
-def parse_data(raw_lines):
-    '''
-    Split each line by , and put every bit in a tuple.
-    '''
-    out = []
-    for line in raw_lines:
-        out.append(line.split(','))
-    return out
-
-if len(sys.argv) == 3:
-    name = sys.argv[1]
-    channels = int(sys.argv[2])
-else:
-    print sys.argv[0] + "latency_log"
-
-try:
-    f = open(sys.argv[1])
-except:
-    print "cannot open " + name
-
-raw_lines = f.readlines()
-lines = clean_data(raw_lines)
-data = parse_data(lines)
-
-final_data = {}
-
-for tupl in data:
-    name = tupl[0]
-    if tupl[1] != 0:
-        name = name+tupl[1]
-    if name not in final_data.keys():
-        final_data[name] = ([], [])
-# sanity-check values
-    if float(tupl[3]) < 10*1000:
-        final_data[name][0].append(float(tupl[2]))
-        final_data[name][1].append(float(tupl[3]))
-
-#overall = compute_sum(data)
-#final_data["overall"] = overall
-
-pprint(final_data)
-
-fig = plt.figure()
-for i in final_data.keys():
-    plt.plot(final_data[i][0], final_data[i][1], label=i)
-
-plt.legend()
-plt.suptitle("Latency in ms (y-axis) against time in ms (x-axis).")
-
-size = fig.get_size_inches()
-# make it gigantic so we can see things. sometimes, if the graph is too big,
-# this errors. reduce the factor so it stays under 2**15.
-fig.set_size_inches((size[0]*10, size[1]*2))
-name = sys.argv[1][:-4] + ".pdf"
-fig.savefig(name)
-
--- a/content/media/webrtc/MediaEngineWebRTC.h
+++ b/content/media/webrtc/MediaEngineWebRTC.h
@@ -349,34 +349,28 @@ public:
     : mMutex("mozilla::MediaEngineWebRTC")
     , mVideoEngine(nullptr)
     , mVoiceEngine(nullptr)
     , mVideoEngineInit(false)
     , mAudioEngineInit(false)
     , mCameraManager(aCameraManager)
     , mWindowId(aWindowId)
   {
-    AsyncLatencyLogger::Get(true)->AddRef();
   }
 #else
   MediaEngineWebRTC()
     : mMutex("mozilla::MediaEngineWebRTC")
     , mVideoEngine(nullptr)
     , mVoiceEngine(nullptr)
     , mVideoEngineInit(false)
     , mAudioEngineInit(false)
   {
   }
 #endif
-  ~MediaEngineWebRTC() {
-    Shutdown();
-#ifdef MOZ_B2G_CAMERA
-    AsyncLatencyLogger::Get()->Release();
-#endif
-  }
+  ~MediaEngineWebRTC() { Shutdown(); }
 
   // Clients should ensure to clean-up sources video/audio sources
   // before invoking Shutdown on this class.
   void Shutdown();
 
   virtual void EnumerateVideoDevices(nsTArray<nsRefPtr<MediaEngineVideoSource> >*);
   virtual void EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSource> >*);
 
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -87,17 +87,16 @@
 #include "WMFDecoder.h"
 #endif
 
 #ifdef MOZ_GSTREAMER
 #include "GStreamerFormatHelper.h"
 #endif
 
 #include "AudioStream.h"
-#include "Latency.h"
 #include "WebAudioUtils.h"
 
 #ifdef MOZ_WIDGET_GONK
 #include "nsVolumeService.h"
 using namespace mozilla::system;
 #endif
 
 #include "nsError.h"
@@ -245,17 +244,16 @@ nsLayoutStatics::Initialize()
 #endif
 
   rv = nsFocusManager::Init();
   if (NS_FAILED(rv)) {
     NS_ERROR("Could not initialize nsFocusManager");
     return rv;
   }
 
-  AsyncLatencyLogger::InitializeStatics();
   AudioStream::InitLibrary();
 
   nsContentSink::InitializeStatics();
   nsHtml5Module::InitializeStatics();
   nsLayoutUtils::Initialize();
   nsIPresShell::InitializeStatics();
   nsRefreshDriver::InitializeStatics();
 
@@ -351,17 +349,16 @@ nsLayoutStatics::Shutdown()
   MediaPluginHost::Shutdown();
 #endif
 
 #ifdef MOZ_GSTREAMER
   GStreamerFormatHelper::Shutdown();
 #endif
 
   AudioStream::ShutdownLibrary();
-  AsyncLatencyLogger::Shutdown();
   WebAudioUtils::Shutdown();
 
 #ifdef MOZ_WMF
   WMFDecoder::UnloadDLLs();
 #endif
 
 #ifdef MOZ_WIDGET_GONK
   nsVolumeService::Shutdown();