Bug 1254858: P9. Search libmozav* lib relative to lgpllibs. r=glandium a=ritu
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 10 Mar 2016 17:56:34 +1100
changeset 325628 b2af7b49ae0ac63613ac33de668e3d04e7c8f90c
parent 325627 b00d99ebc124a8ed68de5dfe6ee130bc6072d780
child 325629 7dafc928792791134a92a684f2d35664a3fc1553
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium, ritu
bugs1254858
milestone47.0a2
Bug 1254858: P9. Search libmozav* lib relative to lgpllibs. r=glandium a=ritu XUL location can't be used as reference as its location varies. MozReview-Commit-ID: EKGVpjeepIR
dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
--- a/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
+++ b/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
@@ -3,20 +3,23 @@
 /* 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 "FFVPXRuntimeLinker.h"
 #include "FFmpegLibWrapper.h"
 #include "FFmpegLog.h"
 #include "nsIFile.h"
-#include "nsXPCOMPrivate.h" // for XUL_DLL
 #include "prmem.h"
 #include "prlink.h"
 
+// We use a known symbol located in lgpllibs to determine its location.
+// soundtouch happens to be always included in lgpllibs
+#include "soundtouch/SoundTouch.h"
+
 namespace mozilla
 {
 
 template <int V> class FFmpegDecoderModule
 {
 public:
   static already_AddRefed<PlatformDecoderModule> Create(FFmpegLibWrapper*);
 };
@@ -44,20 +47,26 @@ FFVPXRuntimeLinker::Init()
 {
   if (sLinkStatus) {
     return sLinkStatus == LinkStatus_SUCCEEDED;
   }
 
   MOZ_ASSERT(NS_IsMainThread());
   sLinkStatus = LinkStatus_FAILED;
 
-  // We retrieve the path of the XUL library as this is where mozavcodec and
-  // mozavutil libs are located.
+  // We retrieve the path of the lgpllibs library as this is where mozavcodec
+  // and mozavutil libs are located.
+  char* lgpllibsname = PR_GetLibraryName(nullptr, "lgpllibs");
+  if (!lgpllibsname) {
+    return false;
+  }
   char* path =
-    PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init);
+    PR_GetLibraryFilePathname(lgpllibsname,
+                              (PRFuncPtr)&soundtouch::SoundTouch::getVersionId);
+  PR_FreeLibraryName(lgpllibsname);
   if (!path) {
     return false;
   }
   nsCOMPtr<nsIFile> xulFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
   if (!xulFile ||
       NS_FAILED(xulFile->InitWithNativePath(nsDependentCString(path)))) {
     PR_Free(path);
     return false;