Bug 1319445 - Don't use direct listener for audio in PeerConnection with full duplex. r?jesup, r?padenot
MozReview-Commit-ID: 278Rrdzr3lQ
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -43,16 +43,17 @@
#include "transportlayer.h"
#include "transportlayerdtls.h"
#include "transportlayerice.h"
#include "runnable_utils.h"
#include "libyuv/convert.h"
#include "mozilla/SharedThreadPool.h"
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
#include "mozilla/PeerIdentity.h"
+#include "mozilla/Preferences.h"
#include "mozilla/TaskQueue.h"
#endif
#include "mozilla/gfx/Point.h"
#include "mozilla/gfx/Types.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/Sprintf.h"
@@ -1449,21 +1450,32 @@ void MediaPipelineTransmit::AttachToTrac
description_ += track_id;
description_ += "]";
// TODO(ekr@rtfm.com): Check for errors
MOZ_MTLOG(ML_DEBUG, "Attaching pipeline to track "
<< static_cast<void *>(domtrack_) << " conduit type=" <<
(conduit_->type() == MediaSessionConduit::AUDIO ?"audio":"video"));
- // Register the Listener directly with the source if we can.
- // We also register it as a non-direct listener so we fall back to that
- // if installing the direct listener fails. As a direct listener we get access
- // to direct unqueued (and not resampled) data.
- domtrack_->AddDirectListener(listener_);
+#if !defined(MOZILLA_EXTERNAL_LINKAGE)
+ // With full duplex we don't risk having audio come in late to the MSG
+ // so we won't need a direct listener.
+ const bool enableDirectListener =
+ !Preferences::GetBool("media.navigator.audio.full_duplex", false);
+#else
+ const bool enableDirectListener = true;
+#endif
+
+ if (enableDirectListener) {
+ // Register the Listener directly with the source if we can.
+ // We also register it as a non-direct listener so we fall back to that
+ // if installing the direct listener fails. As a direct listener we get access
+ // to direct unqueued (and not resampled) data.
+ domtrack_->AddDirectListener(listener_);
+ }
domtrack_->AddListener(listener_);
#ifndef MOZILLA_INTERNAL_API
// this enables the unit tests that can't fiddle with principals and the like
listener_->SetEnabled(true);
#endif
}