Bug 1616661 - Special-case AirPods in device enumeration. r=achronop a=jcristau
☠☠ backed out by be31d6a4cc2a ☠ ☠
authorJan-Ivar Bruaroey <jib@mozilla.com>
Mon, 24 Feb 2020 16:51:48 +0000
changeset 524623 24241169e9d68b39500c3012d7794c0d386482ae
parent 524622 503310a33dad556274aa02dd06136ca601e5ccf2
child 524624 7d86454fd261ff5028988de190372aff143d873e
push id918
push userryanvm@gmail.com
push dateThu, 27 Feb 2020 19:00:46 +0000
treeherdermozilla-esr68@7d86454fd261 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersachronop, jcristau
bugs1616661
milestone68.6.0
Bug 1616661 - Special-case AirPods in device enumeration. r=achronop a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D63387
dom/media/MediaManager.cpp
dom/media/MediaManager.h
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -737,22 +737,27 @@ MediaDevice::MediaDevice(const RefPtr<Au
   // when we do not instantiate a MediaEngineSource
   // during EnumerateDevices.
   MOZ_ASSERT(mKind == dom::MediaDeviceKind::Audiooutput);
   MOZ_ASSERT(mSinkInfo);
 }
 
 MediaDevice::MediaDevice(const RefPtr<MediaDevice>& aOther, const nsString& aID,
                          const nsString& aGroupID, const nsString& aRawID)
+    : MediaDevice(aOther, aID, aGroupID, aRawID, aOther->mName) {}
+
+MediaDevice::MediaDevice(const RefPtr<MediaDevice>& aOther, const nsString& aID,
+                         const nsString& aGroupID, const nsString& aRawID,
+                         const nsString& aName)
     : mSource(aOther->mSource),
       mSinkInfo(aOther->mSinkInfo),
       mKind(aOther->mKind),
       mScary(aOther->mScary),
       mType(aOther->mType),
-      mName(aOther->mName),
+      mName(aName),
       mID(aID),
       mGroupID(aGroupID),
       mRawID(aRawID) {
   MOZ_ASSERT(aOther);
 }
 
 /**
  * Helper functions that implement the constraints algorithm from
@@ -2969,17 +2974,22 @@ void MediaManager::AnonymizeDevices(Medi
       // Use window id to salt group id in order to make it session based as
       // required by the spec. This does not provide unique group ids through
       // out a browser restart. However, this is not agaist the spec.
       // Furtermore, since device ids are the same after a browser restart the
       // fingerprint is not bigger.
       groupId.AppendInt(aWindowId);
       AnonymizeId(groupId, aOriginKey);
 
-      device = new MediaDevice(device, id, groupId, rawId);
+      nsString name;
+      device->GetName(name);
+      if (name.Find(NS_LITERAL_STRING("AirPods")) != -1) {
+        name = NS_LITERAL_STRING("AirPods");
+      }
+      device = new MediaDevice(device, id, groupId, rawId, name);
     }
   }
 }
 
 /* static */
 nsresult MediaManager::AnonymizeId(nsAString& aId,
                                    const nsACString& aOriginKey) {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -72,16 +72,20 @@ class MediaDevice : public nsIMediaDevic
 
   MediaDevice(const RefPtr<AudioDeviceInfo>& aAudioDeviceInfo,
               const nsString& aID, const nsString& aGroupID,
               const nsString& aRawID = NS_LITERAL_STRING(""));
 
   MediaDevice(const RefPtr<MediaDevice>& aOther, const nsString& aID,
               const nsString& aGroupID, const nsString& aRawID);
 
+  MediaDevice(const RefPtr<MediaDevice>& aOther, const nsString& aID,
+              const nsString& aGroupID, const nsString& aRawID,
+              const nsString& aName);
+
   uint32_t GetBestFitnessDistance(
       const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
       bool aIsChrome);
 
   nsresult Allocate(const dom::MediaTrackConstraints& aConstraints,
                     const MediaEnginePrefs& aPrefs,
                     const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
                     const char** aOutBadConstraint);