shithub: libdvdcss

Download patch

ref: 29dd1a4f43b2063d05ed8e8be01102481ea21c0a
parent: 2f0dbbe6d5890e06b2ac7943a9afaf94f249836c
author: Diego Biurrun <diego@biurrun.de>
date: Tue Nov 4 09:18:09 EST 2014

libdvdcss: Factor out cache initialization from dvdcss_open()

--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -420,6 +420,24 @@
                  dvdcss->psz_cachefile );
 }
 
+static void init_cache( dvdcss_t dvdcss )
+{
+    /* Set CSS key cache directory. */
+    const char *psz_cache = set_cache_directory( dvdcss );
+
+    /* If the cache is enabled, initialize the cache directory. */
+    if( psz_cache )
+    {
+        init_cache_dir( dvdcss, psz_cache );
+    }
+
+    /* If the cache is enabled, create a DVD-specific subdirectory. */
+    if( psz_cache )
+    {
+        create_cache_subdir( dvdcss, psz_cache );
+    }
+}
+
 /**
  * \brief Open a DVD device or directory and return a dvdcss instance.
  *
@@ -436,7 +454,6 @@
 {
     int i_ret;
 
-    const char *psz_cache;
 #ifdef DVDCSS_RAW_OPEN
     const char *psz_raw_device = getenv( "DVDCSS_RAW_DEVICE" );
 #endif
@@ -467,9 +484,6 @@
         goto error;
     }
 
-    /* Set CSS key cache directory. */
-    psz_cache = set_cache_directory( dvdcss );
-
     /* Open device. */
     dvdcss_check_device( dvdcss );
     i_ret = dvdcss_open_device( dvdcss );
@@ -518,17 +532,7 @@
         }
     }
 
-    /* If the cache is enabled, initialize the cache directory. */
-    if( psz_cache )
-    {
-        init_cache_dir( dvdcss, psz_cache );
-    }
-
-    /* If the cache is enabled, extract a unique disc ID */
-    if( psz_cache )
-    {
-        create_cache_subdir( dvdcss, psz_cache );
-    }
+    init_cache( dvdcss );
 
 #ifdef DVDCSS_RAW_OPEN
     if( psz_raw_device != NULL )