[libbluray-devel] Try to open libmmbd if libaacs/libbdplus not found

npzacs git at videolan.org
Fri Nov 8 10:35:10 CET 2013


libbluray | branch: master | npzacs <npzacs at gmail.com> | Fri Nov  8 11:03:59 2013 +0200| [a878cad54a2329c906d5b560511926f9b8c4da56] | committer: npzacs

Try to open libmmbd if libaacs/libbdplus not found

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=a878cad54a2329c906d5b560511926f9b8c4da56
---

 src/file/libaacs.c   |   33 +++++++++++++++++++++++++--------
 src/file/libbdplus.c |   31 ++++++++++++++++++++++++-------
 2 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/src/file/libaacs.c b/src/file/libaacs.c
index 9fddf2f..a5ec3d5 100644
--- a/src/file/libaacs.c
+++ b/src/file/libaacs.c
@@ -86,23 +86,40 @@ int libaacs_required(const char *device_path)
     return 0;
 }
 
+static void *_open_libaacs(void)
+{
+    const char * const libaacs[] = {
+      getenv("LIBAACS_PATH"),
+      "libaacs",
+      "libmmbd",
+    };
+    unsigned ii;
+
+    for (ii = 0; ii < sizeof(libaacs) / sizeof(libaacs[0]); ii++) {
+        if (libaacs[ii]) {
+            void *handle = dl_dlopen(libaacs[ii], "0");
+            if (handle) {
+                BD_DEBUG(DBG_BLURAY, "Using %s for AACS\n", libaacs[ii]);
+                return handle;
+            }
+        }
+    }
+
+    BD_DEBUG(DBG_BLURAY | DBG_CRIT, "No usable AACS libraries found!\n");
+    return NULL;
+}
+
 BD_AACS *libaacs_load(void)
 {
     BD_AACS *p = calloc(1, sizeof(BD_AACS));
 
-    const char *libaacs = getenv("LIBAACS_PATH");
-    if (!libaacs) {
-        libaacs = "libaacs";
-    }
-
-    p->h_libaacs = dl_dlopen(libaacs, "0");
+    p->h_libaacs = _open_libaacs();
     if (!p->h_libaacs) {
-        BD_DEBUG(DBG_BLURAY | DBG_CRIT, "libaacs not found!\n");
         X_FREE(p);
         return NULL;
     }
 
-    BD_DEBUG(DBG_BLURAY, "Loading libaacs (%p)\n", p->h_libaacs);
+    BD_DEBUG(DBG_BLURAY, "Loading aacs library (%p)\n", p->h_libaacs);
 
     *(void **)(&p->decrypt_unit) = dl_dlsym(p->h_libaacs, "aacs_decrypt_unit");
     *(void **)(&p->get_vid)      = dl_dlsym(p->h_libaacs, "aacs_get_vid");
diff --git a/src/file/libbdplus.c b/src/file/libbdplus.c
index 297d182..0c278bb 100644
--- a/src/file/libbdplus.c
+++ b/src/file/libbdplus.c
@@ -86,20 +86,37 @@ int libbdplus_required(const char *device_path)
     return 0;
 }
 
+static void *_libbdplus_open(void)
+{
+    const char * const libbdplus[] = {
+      getenv("LIBBDPLUS_PATH"),
+      "libbdplus",
+      "libmmbd",
+    };
+    unsigned ii;
+
+    for (ii = 0; ii < sizeof(libbdplus) / sizeof(libbdplus[0]); ii++) {
+        if (libbdplus[ii]) {
+            void *handle = dl_dlopen(libbdplus[ii], "0");
+            if (handle) {
+                BD_DEBUG(DBG_BLURAY, "Using %s for BD+\n", libbdplus[ii]);
+                return handle;
+            }
+        }
+    }
+
+    BD_DEBUG(DBG_BLURAY | DBG_CRIT, "No usable BD+ libraries found!\n");
+    return NULL;
+}
+
 BD_BDPLUS *libbdplus_load(void)
 {
     BD_BDPLUS *p = calloc(1, sizeof(BD_BDPLUS));
 
     BD_DEBUG(DBG_BDPLUS, "attempting to load libbdplus\n");
 
-    const char *libbdplus = getenv("LIBBDPLUS_PATH");
-    if (!libbdplus) {
-        libbdplus = "libbdplus";
-    }
-
-    p->h_libbdplus = dl_dlopen(libbdplus, "0");
+    p->h_libbdplus = _libbdplus_open();
     if (!p->h_libbdplus) {
-        BD_DEBUG(DBG_BLURAY | DBG_CRIT, "libbdplus not found!\n");
         X_FREE(p);
         return NULL;
     }



More information about the libbluray-devel mailing list