Bug 1628779 - Disable getting the input and output latency on Linux. r=achronop
authorPaul Adenot <paul@paul.cx>
Thu, 28 May 2020 09:55:44 +0000
changeset 532748 5e969a4bab421cfb0c9c6816eafd46a3eeb147f5
parent 532747 17fc3a2a42b5d725e99c51de4b4dda8061415fab
child 532749 079826b74356c53b5a396c57d029dfd0647fbd4d
push id117348
push userpadenot@mozilla.com
push dateThu, 28 May 2020 09:58:56 +0000
treeherderautoland@5e969a4bab42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersachronop
bugs1628779
milestone78.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 1628779 - Disable getting the input and output latency on Linux. r=achronop Differential Revision: https://phabricator.services.mozilla.com/D76899
dom/media/MediaTrackGraph.cpp
--- a/dom/media/MediaTrackGraph.cpp
+++ b/dom/media/MediaTrackGraph.cpp
@@ -3630,38 +3630,53 @@ uint32_t MediaTrackGraphImpl::AudioOutpu
 }
 
 double MediaTrackGraph::AudioOutputLatency() {
   return static_cast<MediaTrackGraphImpl*>(this)->CachedAudioOutputLatency();
 }
 
 double MediaTrackGraphImpl::CachedAudioOutputLatency() {
   MOZ_ASSERT(NS_IsMainThread());
+#ifdef XP_LINUX
+  if (mAudioOutputLatency == 0.0) {
+    // periodic latency gathering is not enabled on Linux/Android, get a
+    // number like this for now.
+    MonitorAutoLock lock(mMonitor);
+    if (CurrentDriver()->AsAudioCallbackDriver()) {
+      mAudioOutputLatency = CurrentDriver()
+                                ->AsAudioCallbackDriver()
+                                ->AudioOutputLatency()
+                                .ToSeconds();
+    }
+  }
+#endif
   return mAudioOutputLatency;
 }
 
 double MediaTrackGraphImpl::CachedAudioInputLatency() {
   MOZ_ASSERT(NS_IsMainThread());
   return mAudioInputLatency;
 }
 
 void MediaTrackGraphImpl::UpdateAudioLatencies() {
+#if defined(XP_WIN) || defined(XP_MACOSX)
   RefPtr<MediaTrackGraphImpl> self = this;
   NS_DispatchBackgroundTask(
       NS_NewRunnableFunction("UpdateLatency", [self{std::move(self)}]() {
         MonitorAutoLock lock(self->mMonitor);
         if (self->CurrentDriver()->AsAudioCallbackDriver()) {
           AudioCallbackDriver* driver =
               self->CurrentDriver()->AsAudioCallbackDriver();
           if (driver->InputChannelCount()) {
             self->mAudioInputLatency = driver->AudioInputLatency().ToSeconds();
           }
           self->mAudioOutputLatency = driver->AudioOutputLatency().ToSeconds();
         }
       }));
+#endif
 }
 
 double MediaTrackGraphImpl::AudioOutputLatencyGraphThread() {
   AssertOnGraphThreadOrNotRunning();
   return mAudioOutputLatency;
 }
 double MediaTrackGraphImpl::AudioInputLatencyGraphThread() {
   AssertOnGraphThreadOrNotRunning();