[libdvdcss-devel] [PATCH 1/7] Clean up and simplify raw device support.

Diego Biurrun diego at biurrun.de
Sun Nov 16 20:37:08 CET 2014


Treat access to raw devices just like accessing any other device instead of
providing different semantics. libdvdcss now tries raw devices on all OSes
and bails out instead of continuing if accessing a raw device failed.
---
 src/device.c    | 28 +++++-----------------------
 src/device.h    |  9 ---------
 src/libdvdcss.c | 11 -----------
 3 files changed, 5 insertions(+), 43 deletions(-)

diff --git a/src/device.c b/src/device.c
index 9d9946c..2e0c463 100644
--- a/src/device.c
+++ b/src/device.c
@@ -343,8 +343,11 @@ void dvdcss_check_device ( dvdcss_t dvdcss )
 
 int dvdcss_open_device ( dvdcss_t dvdcss )
 {
-    const char *psz_device = dvdcss->psz_device;
-
+    const char *psz_device = getenv( "DVDCSS_RAW_DEVICE" );
+    if( !psz_device )
+    {
+         psz_device = dvdcss->psz_device;
+    }
     print_debug( dvdcss, "opening target `%s'", psz_device );
 
 #if defined( WIN32 )
@@ -389,27 +392,6 @@ int dvdcss_open_device ( dvdcss_t dvdcss )
     }
 }
 
-#ifdef DVDCSS_RAW_OPEN
-int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
-{
-    int i_fd = open( psz_device, 0 );
-
-    if( i_fd == -1 )
-    {
-        print_debug( dvdcss, "cannot open %s (%s)",
-                             psz_device, strerror(errno) );
-        print_error( dvdcss, "failed to open raw device, but continuing" );
-        return -1;
-    }
-    else
-    {
-        dvdcss->i_fd = i_fd;
-    }
-
-    return 0;
-}
-#endif /* DVDCSS_RAW_OPEN */
-
 int dvdcss_close_device ( dvdcss_t dvdcss )
 {
 #if defined( WIN32 )
diff --git a/src/device.h b/src/device.h
index ff1e67f..e098ec2 100644
--- a/src/device.h
+++ b/src/device.h
@@ -44,10 +44,6 @@ struct iovec
 
 #include "dvdcss/dvdcss.h"
 
-#if !defined(WIN32) && !defined(__OS2__)
-#   define DVDCSS_RAW_OPEN
-#endif
-
 
 /*****************************************************************************
  * Device reading prototypes
@@ -57,9 +53,4 @@ void dvdcss_check_device ( dvdcss_t );
 int  dvdcss_open_device  ( dvdcss_t );
 int  dvdcss_close_device ( dvdcss_t );
 
-/*****************************************************************************
- * Device reading prototypes, raw-device specific
- *****************************************************************************/
-int dvdcss_raw_open      ( dvdcss_t, const char * );
-
 #endif /* DVDCSS_DEVICE_H */
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 89bf6fd..c57773a 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -461,10 +461,6 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
 {
     int i_ret;
 
-#ifdef DVDCSS_RAW_OPEN
-    const char *psz_raw_device = getenv( "DVDCSS_RAW_DEVICE" );
-#endif
-
     /* Allocate the library structure. */
     dvdcss_t dvdcss = malloc( sizeof( *dvdcss ) );
     if( dvdcss == NULL )
@@ -539,13 +535,6 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
 
     init_cache( dvdcss );
 
-#ifdef DVDCSS_RAW_OPEN
-    if( psz_raw_device != NULL )
-    {
-        dvdcss_raw_open( dvdcss, psz_raw_device );
-    }
-#endif /* DVDCSS_RAW_OPEN */
-
     /* Seek to the beginning, just for safety. */
     dvdcss->pf_seek( dvdcss, 0 );
 
-- 
2.1.0



More information about the libdvdcss-devel mailing list