<div dir="ltr">Updated.<br><div><br>From 7b3b41a62ac7c39e93dd0ba6421cd8fa04484b61 Mon Sep 17 00:00:00 2001<br>From: ace20022 <<a href="mailto:ace20022@ymail.com">ace20022@ymail.com</a>><br>Date: Fri, 19 Sep 2014 16:00:06 +0200<br>Subject: [PATCH] Add the possibility to set the persistent/cache root path via<br> bd_set_player_setting_str().<br><br>---<br> src/libbluray/bdj/bdj.c | 22 +++++++++++++++-------<br> src/libbluray/bdj/bdj.h |  8 +++++++-<br> src/libbluray/bluray.c  | 47 ++++++++++++++++++++++++++++++++++++++++++++++-<br> src/libbluray/bluray.h  |  2 ++<br> 4 files changed, 70 insertions(+), 9 deletions(-)<br><br>diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c<br>index c54e7ee..f94b94e 100644<br>--- a/src/libbluray/bdj/bdj.c<br>+++ b/src/libbluray/bdj/bdj.c<br>@@ -254,7 +254,7 @@ static const char *_find_libbluray_jar(void)<br>     return classpath;<br> }<br> <br>-static const char *_bdj_persistent_root(void)<br>+static const char *_bdj_persistent_root(BDJ_STORAGE *storage)<br> {<br>     static const char *root = NULL;<br> <br>@@ -262,6 +262,10 @@ static const char *_bdj_persistent_root(void)<br>         return root;<br>     }<br> <br>+    if (storage && storage->persistent_root) {<br>+        return storage->persistent_root;<br>+    }<br>+<br>     root = getenv("LIBBLURAY_PERSISTENT_ROOT");<br>     if (root) {<br>         return root;<br>@@ -278,7 +282,7 @@ static const char *_bdj_persistent_root(void)<br>     return root;<br> }<br> <br>-static const char *_bdj_buda_root(void)<br>+static const char *_bdj_buda_root(BDJ_STORAGE *storage)<br> {<br>     static const char *root = NULL;<br> <br>@@ -286,6 +290,10 @@ static const char *_bdj_buda_root(void)<br>         return root;<br>     }<br> <br>+    if (storage && storage->cache_root) {<br>+        return storage->cache_root;<br>+    }<br>+<br>     root = getenv("LIBBLURAY_CACHE_ROOT");<br>     if (root) {<br>         return root;<br>@@ -383,7 +391,7 @@ static int _find_jvm(void *jvm_lib, JNIEnv **env, JavaVM **jvm)<br>     return 0;<br> }<br> <br>-static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv **env, JavaVM **jvm)<br>+static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv **env, JavaVM **jvm, BDJ_STORAGE *storage)<br> {<br>     (void)java_home;  /* used only with J2ME */<br> <br>@@ -396,8 +404,8 @@ static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv **env, JavaV<br>     JavaVMOption* option = calloc(1, sizeof(JavaVMOption) * 20);<br>     int n = 0;<br>     JavaVMInitArgs args;<br>-    option[n++].optionString = str_printf("-Ddvb.persistent.root=%s", _bdj_persistent_root());<br>-    option[n++].optionString = str_printf("-Dbluray.bindingunit.root=%s", _bdj_buda_root());<br>+    option[n++].optionString = str_printf("-Ddvb.persistent.root=%s", _bdj_persistent_root(storage));<br>+    option[n++].optionString = str_printf("-Dbluray.bindingunit.root=%s", _bdj_buda_root(storage));<br> <br>     option[n++].optionString = str_dup   ("-Dawt.toolkit=java.awt.BDToolkit");<br>     option[n++].optionString = str_dup   ("-Djava.awt.graphicsenv=java.awt.BDGraphicsEnvironment");<br>@@ -452,7 +460,7 @@ static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv **env, JavaV<br> }<br> <br> BDJAVA* bdj_open(const char *path, struct bluray *bd,<br>-                 bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf)<br>+                 bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf, BDJ_STORAGE *storage)<br> {<br>     BD_DEBUG(DBG_BDJ, "bdj_open()\n");<br> <br>@@ -467,7 +475,7 @@ BDJAVA* bdj_open(const char *path, struct bluray *bd,<br> <br>     JNIEnv* env = NULL;<br>     JavaVM *jvm = NULL;<br>-    if (!_find_jvm(jvm_lib, &env, &jvm) && !_create_jvm(jvm_lib, java_home, &env, &jvm)) {<br>+    if (!_find_jvm(jvm_lib, &env, &jvm) && !_create_jvm(jvm_lib, java_home, &env, &jvm, storage)) {<br>         dl_dlclose(jvm_lib);<br>         return NULL;<br>     }<br>diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h<br>index a177510..721c02f 100644<br>--- a/src/libbluray/bdj/bdj.h<br>+++ b/src/libbluray/bdj/bdj.h<br>@@ -42,6 +42,11 @@ typedef enum {<br>     BDJ_EVENT_RATE,<br> } BDJ_EVENT;<br> <br>+typedef struct {<br>+    char *persistent_root;<br>+    char *cache_root;<br>+} BDJ_STORAGE;<br>+<br> /* bdj_get_uo_mask() */<br> #define BDJ_MENU_CALL_MASK     0x01<br> #define BDJ_TITLE_SEARCH_MASK  0x02<br>@@ -55,7 +60,8 @@ typedef void (*bdj_overlay_cb)(struct bluray *, const unsigned *, int, int,<br>                                int, int, int, int);<br> <br> BD_PRIVATE BDJAVA* bdj_open(const char *path, struct bluray *bd,<br>-                            bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf);<br>+                            bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf,<br>+                            BDJ_STORAGE *storage);<br> BD_PRIVATE void bdj_close(BDJAVA *bdjava);<br> BD_PRIVATE int  bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param);<br> BD_PRIVATE int  bdj_get_uo_mask(BDJAVA *bdjava);<br>diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c<br>index 320f009..68fa674 100644<br>--- a/src/libbluray/bluray.c<br>+++ b/src/libbluray/bluray.c<br>@@ -159,6 +159,7 @@ struct bluray {<br>     uint8_t        hdmv_suspended;<br> #ifdef USING_BDJAVA<br>     BDJAVA         *bdjava;<br>+    BDJ_STORAGE    *bdjstorage;<br> #endif<br>     /* delayed sending of BDJ_EVENT_END_OF_PLAYLIST:<br>      * 1 - message pending. 3 - message sent. */<br>@@ -1236,7 +1237,7 @@ static int _start_bdj(BLURAY *bd, unsigned title)<br> {<br> #ifdef USING_BDJAVA<br>     if (bd->bdjava == NULL) {<br>-        bd->bdjava = bdj_open(bd->device_path, bd, _bdj_osd_cb, bd->argb_buffer);<br>+        bd->bdjava = bdj_open(bd->device_path, bd, _bdj_osd_cb, bd->argb_buffer, bd->bdjstorage);<br>         if (!bd->bdjava) {<br>             return 0;<br>         }<br>@@ -1283,6 +1284,19 @@ static void _close_bdj(BLURAY *bd)<br> #define _close_bdj(bd) do{}while(0)<br> #endif<br> <br>+#ifdef USING_BDJAVA<br>+static void _storage_free(BLURAY *bd)<br>+{<br>+  if (bd->bdjstorage){<br>+    X_FREE(bd->bdjstorage->cache_root);<br>+    X_FREE(bd->bdjstorage->persistent_root);<br>+    X_FREE(bd->bdjstorage);<br>+  }<br>+}<br>+#else<br>+#define _storage_free(bd) do{}while(0)<br>+#endif<br>+<br> #ifdef HAVE_MNTENT_H<br> /*<br>  * Replace device node (/dev/sr0) by mount point<br>@@ -1423,6 +1437,7 @@ void bd_close(BLURAY *bd)<br>     _free_event_queue(bd);<br>     X_FREE(bd->device_path);<br>     array_free((void**)&bd->titles);<br>+    _storage_free(bd);<br> <br>     bd_mutex_destroy(&bd->mutex);<br> <br>@@ -2588,6 +2603,36 @@ int bd_set_player_setting_str(BLURAY *bd, uint32_t idx, const char *s)<br>         case BLURAY_PLAYER_SETTING_COUNTRY_CODE:<br>             return bd_set_player_setting(bd, idx, str_to_uint32(s, 2));<br> <br>+#ifdef USING_BDJAVA<br>+        case BLURAY_PLAYER_CACHE_ROOT:<br>+        case BLURAY_PLAYER_PERSISTENT_ROOT:<br>+            if (!bd->bdjstorage) {<br>+                bd->bdjstorage = calloc(1, sizeof(BDJ_STORAGE));<br>+            }<br>+            switch (idx) {<br>+                case BLURAY_PLAYER_CACHE_ROOT:<br>+                    if (bd->bdjstorage) {<br>+                        if (bd->bdjstorage->cache_root)<br>+                            X_FREE(bd->bdjstorage->cache_root);<br>+                        bd->bdjstorage->cache_root = str_dup(s);<br>+                        BD_DEBUG(DBG_BDJ, "Cache root dir set to %s\n", bd->bdjstorage->cache_root);<br>+                        return 1;<br>+                    }<br>+                    else<br>+                        return 0;<br>+<br>+                case BLURAY_PLAYER_PERSISTENT_ROOT:<br>+                    if (bd->bdjstorage) {<br>+                        if (bd->bdjstorage->persistent_root)<br>+                            X_FREE(bd->bdjstorage->persistent_root);<br>+                        bd->bdjstorage->persistent_root = str_dup(s);<br>+                        BD_DEBUG(DBG_BDJ, "Persistent root dir set to %s\n", bd->bdjstorage->persistent_root);<br>+                        return 1;<br>+                    }<br>+                    else<br>+                        return 0;<br>+            }<br>+#endif /* USING_BDJAVA */<br>         default:<br>             return 0;<br>     }<br>diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h<br>index 54f4df7..7e991df 100644<br>--- a/src/libbluray/bluray.h<br>+++ b/src/libbluray/bluray.h<br>@@ -561,6 +561,8 @@ typedef enum {<br>     BLURAY_PLAYER_SETTING_PLAYER_PROFILE = 31,  /* Profile1: 0, Profile1+: 1, Profile2: 3, Profile3: 8 */<br> <br>     BLURAY_PLAYER_SETTING_DECODE_PG      = 0x100, /* enable/disable PG (subtitle) decoder */<br>+    BLURAY_PLAYER_PERSISTENT_ROOT        = 400,  /* Root path (string) to the BD_J persistent storage location */<br>+    BLURAY_PLAYER_CACHE_ROOT             = 401,  /* Root path (string) to the BD_J cache storage location */<br> } bd_player_setting;<br> <br> /**<br>-- <br>1.9.2.msysgit.0<br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-26 12:27 GMT+02:00 Petri Hintukainen <span dir="ltr"><<a href="mailto:phintuka@users.sourceforge.net" target="_blank">phintuka@users.sourceforge.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On ma, 2014-09-22 at 10:21 +0200, Andreas Zelend wrote:<br>
> From 72b9bb8c2c20e7e2080e16c3129e73fb7acf9933 Mon Sep 17 00:00:00 2001<br>
> From: ace20022 <<a href="mailto:ace20022@ymail.com">ace20022@ymail.com</a>><br>
> Date: Fri, 19 Sep 2014 16:00:06 +0200<br>
> Subject: [PATCH 1/2] Add the possibility to set the persistent/cache<br>
> root path<br>
>  via bd_set_player_setting_str().<br>
><br>
> ---<br>
>  src/examples/bdj_test.c |  5 ++++-<br>
>  src/libbluray/bdj/bdj.c | 34 +++++++++++++++++++++++-----------<br>
>  src/libbluray/bdj/bdj.h |  8 +++++++-<br>
>  src/libbluray/bluray.c  | 43<br>
> ++++++++++++++++++++++++++++++++++++++++++-<br>
>  src/libbluray/bluray.h  |  2 ++<br>
>  5 files changed, 78 insertions(+), 14 deletions(-)<br>
><br>
> diff --git a/src/examples/bdj_test.c b/src/examples/bdj_test.c<br>
> index d9ebd16..b258562 100644<br>
> --- a/src/examples/bdj_test.c<br>
> +++ b/src/examples/bdj_test.c<br>
> @@ -31,6 +31,7 @@<br>
>  #include <unistd.h><br>
><br>
>  #include "libbluray/bluray.h"<br>
> +#include "file/dirs.h"<br>
><br>
>  #if defined(_WIN32)<br>
>  #include <windows.h><br>
> @@ -53,7 +54,9 @@ int main(int argc, char** argv)<br>
>      BLURAY* bd = bd_open(argv[1], NULL);<br>
><br>
>      bd_get_titles(bd, TITLES_ALL, 0);<br>
> -<br>
> +<br>
> +    bd_set_player_setting_str(bd, BLURAY_PLAYER_PERSISTENT_ROOT,<br>
> file_get_data_home());<br>
> +    bd_set_player_setting_str(bd, BLURAY_PLAYER_CACHE_ROOT,<br>
> file_get_cache_home());<br>
<br>
file_*() functions are library internal and can't be used in<br>
applications. Linking bdj_test fails:<br>
  bdj_test.c:58: undefined reference to `file_get_data_home'<br>
  bdj_test.c:59: undefined reference to `file_get_cache_home'<br>
<br>
Also note that those two directories must be different (I think in<br>
Windows data and cache home are mapped to the same location).<br>
<br>
>      if (!bd_start_bdj(bd, argv[2])) {<br>
>          printf("Failed to start BD-J application.\n");<br>
>      } else {<br>
> diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c<br>
> index c54e7ee..b250aa0 100644<br>
> --- a/src/libbluray/bdj/bdj.c<br>
> +++ b/src/libbluray/bdj/bdj.c<br>
> @@ -155,10 +155,10 @@ static void *_load_jvm(const char **p_java_home)<br>
>      static const char  jvm_lib[]  = "jvm";<br>
>  # else<br>
>      static const char *jvm_path[] = {NULL, JDK_HOME,<br>
> -                                    "/usr/lib/jvm/default-java",<br>
> -                                    "/usr/lib/jvm/java-6-openjdk",<br>
> -                                    "/usr/lib/jvm/java-7-openjdk",<br>
> -<br>
> "/etc/java-config-2/current-system-vm"};<br>
> +                     "/usr/lib/jvm/default-java",<br>
> +                     "/usr/lib/jvm/java-6-openjdk",<br>
> +                     "/usr/lib/jvm/java-7-openjdk",<br>
> +                     "/etc/java-config-2/current-system-vm"};<br>
>      static const char  jvm_dir[]  = "jre/lib/" JAVA_ARCH "/server";<br>
>      static const char  jvm_lib[]  = "libjvm";<br>
>  # endif<br>
<br>
Unrelated change<br>
<br>
> @@ -254,7 +254,7 @@ static const char *_find_libbluray_jar(void)<br>
>      return classpath;<br>
>  }<br>
><br>
> -static const char *_bdj_persistent_root(void)<br>
> +static const char *_bdj_persistent_root(BDJ_STORAGE *storage)<br>
>  {<br>
>      static const char *root = NULL;<br>
><br>
> @@ -262,6 +262,12 @@ static const char *_bdj_persistent_root(void)<br>
>          return root;<br>
>      }<br>
><br>
> +    if (storage) {<br>
> +        root = storage->persistent_root;<br>
> +        if (root)<br>
> +            return root;<br>
> +    }<br>
> +<br>
>      root = getenv("LIBBLURAY_PERSISTENT_ROOT");<br>
>      if (root) {<br>
>          return root;<br>
<br>
There's problem with assigning the pointer to<br>
    static const char *root;<br>
The string is allocated in bd_set_player_setting_str() and freed in<br>
bd_close(). When playing second disc, it will use already freed pointer.<br>
<br>
Maybe just<br>
    if (storage && storage->persistent_root) {<br>
        return storage->persistent_root;<br>
    }<br>
<br>
> @@ -278,7 +284,7 @@ static const char *_bdj_persistent_root(void)<br>
>      return root;<br>
>  }<br>
><br>
> -static const char *_bdj_buda_root(void)<br>
> +static const char *_bdj_buda_root(BDJ_STORAGE *storage)<br>
>  {<br>
>      static const char *root = NULL;<br>
><br>
> @@ -286,6 +292,12 @@ static const char *_bdj_buda_root(void)<br>
>          return root;<br>
>      }<br>
><br>
> +    if (storage) {<br>
> +        root = storage->cache_root;<br>
> +        if (root)<br>
> +            return root;<br>
> +    }<br>
> +<br>
>      root = getenv("LIBBLURAY_CACHE_ROOT");<br>
>      if (root) {<br>
>          return root;<br>
<br>
Same here.<br>
<br>
> @@ -383,7 +395,7 @@ static int _find_jvm(void *jvm_lib, JNIEnv **env,<br>
> JavaVM **jvm)<br>
>      return 0;<br>
>  }<br>
><br>
> -static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv<br>
> **env, JavaVM **jvm)<br>
> +static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv<br>
> **env, JavaVM **jvm, BDJ_STORAGE *storage)<br>
>  {<br>
>      (void)java_home;  /* used only with J2ME */<br>
><br>
> @@ -396,8 +408,8 @@ static int _create_jvm(void *jvm_lib, const char<br>
> *java_home, JNIEnv **env, JavaV<br>
>      JavaVMOption* option = calloc(1, sizeof(JavaVMOption) * 20);<br>
>      int n = 0;<br>
>      JavaVMInitArgs args;<br>
> -    option[n++].optionString = str_printf("-Ddvb.persistent.root=%s",<br>
> _bdj_persistent_root());<br>
> -    option[n++].optionString = str_printf("-Dbluray.bindingunit.root=<br>
> %s", _bdj_buda_root());<br>
> +    option[n++].optionString = str_printf("-Ddvb.persistent.root=%s",<br>
> _bdj_persistent_root(storage));<br>
> +    option[n++].optionString = str_printf("-Dbluray.bindingunit.root=<br>
> %s", _bdj_buda_root(storage));<br>
><br>
>      option[n++].optionString = str_dup<br>
> ("-Dawt.toolkit=java.awt.BDToolkit");<br>
>      option[n++].optionString = str_dup<br>
> ("-Djava.awt.graphicsenv=java.awt.BDGraphicsEnvironment");<br>
> @@ -452,7 +464,7 @@ static int _create_jvm(void *jvm_lib, const char<br>
> *java_home, JNIEnv **env, JavaV<br>
>  }<br>
><br>
>  BDJAVA* bdj_open(const char *path, struct bluray *bd,<br>
> -                 bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf)<br>
> +                 bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf,<br>
> BDJ_STORAGE *storage)<br>
>  {<br>
>      BD_DEBUG(DBG_BDJ, "bdj_open()\n");<br>
><br>
> @@ -467,7 +479,7 @@ BDJAVA* bdj_open(const char *path, struct bluray<br>
> *bd,<br>
><br>
>      JNIEnv* env = NULL;<br>
>      JavaVM *jvm = NULL;<br>
> -    if (!_find_jvm(jvm_lib, &env, &jvm) && !_create_jvm(jvm_lib,<br>
> java_home, &env, &jvm)) {<br>
> +    if (!_find_jvm(jvm_lib, &env, &jvm) && !_create_jvm(jvm_lib,<br>
> java_home, &env, &jvm, storage)) {<br>
>          dl_dlclose(jvm_lib);<br>
>          return NULL;<br>
>      }<br>
> diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h<br>
> index a177510..721c02f 100644<br>
> --- a/src/libbluray/bdj/bdj.h<br>
> +++ b/src/libbluray/bdj/bdj.h<br>
> @@ -42,6 +42,11 @@ typedef enum {<br>
>      BDJ_EVENT_RATE,<br>
>  } BDJ_EVENT;<br>
><br>
> +typedef struct {<br>
> +    char *persistent_root;<br>
> +    char *cache_root;<br>
> +} BDJ_STORAGE;<br>
> +<br>
>  /* bdj_get_uo_mask() */<br>
>  #define BDJ_MENU_CALL_MASK     0x01<br>
>  #define BDJ_TITLE_SEARCH_MASK  0x02<br>
> @@ -55,7 +60,8 @@ typedef void (*bdj_overlay_cb)(struct bluray *,<br>
> const unsigned *, int, int,<br>
>                                 int, int, int, int);<br>
><br>
>  BD_PRIVATE BDJAVA* bdj_open(const char *path, struct bluray *bd,<br>
> -                            bdj_overlay_cb osd_cb, struct<br>
> bd_argb_buffer_s *buf);<br>
> +                            bdj_overlay_cb osd_cb, struct<br>
> bd_argb_buffer_s *buf,<br>
> +                            BDJ_STORAGE *storage);<br>
>  BD_PRIVATE void bdj_close(BDJAVA *bdjava);<br>
>  BD_PRIVATE int  bdj_process_event(BDJAVA *bdjava, unsigned ev,<br>
> unsigned param);<br>
>  BD_PRIVATE int  bdj_get_uo_mask(BDJAVA *bdjava);<br>
> diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c<br>
> index 320f009..efca0c4 100644<br>
> --- a/src/libbluray/bluray.c<br>
> +++ b/src/libbluray/bluray.c<br>
> @@ -159,6 +159,7 @@ struct bluray {<br>
>      uint8_t        hdmv_suspended;<br>
>  #ifdef USING_BDJAVA<br>
>      BDJAVA         *bdjava;<br>
> +    BDJ_STORAGE    *bdjstorage;<br>
>  #endif<br>
>      /* delayed sending of BDJ_EVENT_END_OF_PLAYLIST:<br>
>       * 1 - message pending. 3 - message sent. */<br>
> @@ -1236,7 +1237,7 @@ static int _start_bdj(BLURAY *bd, unsigned<br>
> title)<br>
>  {<br>
>  #ifdef USING_BDJAVA<br>
>      if (bd->bdjava == NULL) {<br>
> -        bd->bdjava = bdj_open(bd->device_path, bd, _bdj_osd_cb,<br>
> bd->argb_buffer);<br>
> +        bd->bdjava = bdj_open(bd->device_path, bd, _bdj_osd_cb,<br>
> bd->argb_buffer, bd->bdjstorage);<br>
>          if (!bd->bdjava) {<br>
>              return 0;<br>
>          }<br>
> @@ -1283,6 +1284,19 @@ static void _close_bdj(BLURAY *bd)<br>
>  #define _close_bdj(bd) do{}while(0)<br>
>  #endif<br>
><br>
> +#ifdef USING_BDJAVA<br>
> +static void _storage_free(BLURAY *bd)<br>
> +{<br>
> +  if (bd->bdjstorage){<br>
> +    X_FREE(bd->bdjstorage->cache_root);<br>
> +    X_FREE(bd->bdjstorage->persistent_root);<br>
> +    X_FREE(bd->bdjstorage);<br>
> +  }<br>
> +}<br>
> +#else<br>
> +#define _storage_free(bd) do{}while(0)<br>
> +#endif<br>
> +<br>
>  #ifdef HAVE_MNTENT_H<br>
>  /*<br>
>   * Replace device node (/dev/sr0) by mount point<br>
> @@ -1423,6 +1437,7 @@ void bd_close(BLURAY *bd)<br>
>      _free_event_queue(bd);<br>
>      X_FREE(bd->device_path);<br>
>      array_free((void**)&bd->titles);<br>
> +    _storage_free(bd);<br>
><br>
>      bd_mutex_destroy(&bd->mutex);<br>
><br>
> @@ -2588,6 +2603,32 @@ int bd_set_player_setting_str(BLURAY *bd,<br>
> uint32_t idx, const char *s)<br>
>          case BLURAY_PLAYER_SETTING_COUNTRY_CODE:<br>
>              return bd_set_player_setting(bd, idx, str_to_uint32(s,<br>
> 2));<br>
><br>
> +#ifdef USING_BDJAVA<br>
> +        case BLURAY_PLAYER_CACHE_ROOT:<br>
> +        case BLURAY_PLAYER_PERSISTENT_ROOT:<br>
> +          if (!bd->bdjstorage) {<br>
> +            bd->bdjstorage = malloc(sizeof(BDJ_STORAGE*));<br>
<br>
Use calloc() or initialize to zero<br>
(nothing guarantees both strings are set by the app)<br>
<br>
> +          }<br>
> +          switch (idx) {<br>
> +          case BLURAY_PLAYER_CACHE_ROOT:<br>
> +            if (bd->bdjstorage) {<br>
> +              bd->bdjstorage->cache_root = str_dup(s);<br>
<br>
This will leak memory if already set<br>
<br>
> +              BD_DEBUG(DBG_BDJ, "Cache root dir set to %s\n",<br>
> bd->bdjstorage->cache_root);<br>
> +              return 1;<br>
> +            }<br>
> +            else<br>
> +              return 0;<br>
> +<br>
> +          case BLURAY_PLAYER_PERSISTENT_ROOT:<br>
> +            if (bd->bdjstorage) {<br>
> +              bd->bdjstorage->persistent_root = str_dup(s);<br>
<br>
Same<br>
<br>
> +              BD_DEBUG(DBG_BDJ, "Persistent root dir set to %s\n",<br>
> bd->bdjstorage->persistent_root);<br>
> +              return 1;<br>
> +            }<br>
> +            else<br>
> +              return 0;<br>
> +          }<br>
> +#endif /* USING_BDJAVA */<br>
>          default:<br>
>              return 0;<br>
>      }<br>
> diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h<br>
> index 54f4df7..7e991df 100644<br>
> --- a/src/libbluray/bluray.h<br>
> +++ b/src/libbluray/bluray.h<br>
> @@ -561,6 +561,8 @@ typedef enum {<br>
>      BLURAY_PLAYER_SETTING_PLAYER_PROFILE = 31,  /* Profile1: 0,<br>
> Profile1+: 1, Profile2: 3, Profile3: 8 */<br>
><br>
>      BLURAY_PLAYER_SETTING_DECODE_PG      = 0x100, /* enable/disable<br>
> PG (subtitle) decoder */<br>
> +    BLURAY_PLAYER_PERSISTENT_ROOT        = 400,  /* Root path<br>
> (string) to the BD_J persistent storage location */<br>
> +    BLURAY_PLAYER_CACHE_ROOT             = 401,  /* Root path<br>
> (string) to the BD_J cache storage location */<br>
>  } bd_player_setting;<br>
><br>
>  /**<br>
<br>
<br>
_______________________________________________<br>
libbluray-devel mailing list<br>
<a href="mailto:libbluray-devel@videolan.org">libbluray-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/libbluray-devel" target="_blank">https://mailman.videolan.org/listinfo/libbluray-devel</a><br>
</blockquote></div><br></div>