[libdvdcss-devel] Clean up and simplify raw device support.

Diego Biurrun git at videolan.org
Sun Nov 16 22:15:12 CET 2014


libdvdcss | branch: master | Diego Biurrun <diego at biurrun.de> | Fri Nov 14 11:15:12 2014 +0100| [6b95108d3de1755beab102b3a02ca7ef02494bd1] | committer: Diego Biurrun

Clean up and simplify raw device support.

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.

> http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=6b95108d3de1755beab102b3a02ca7ef02494bd1
---

 NEWS            |    1 +
 src/device.c    |   28 +++++-----------------------
 src/device.h    |    9 ---------
 src/libdvdcss.c |   11 -----------
 4 files changed, 6 insertions(+), 43 deletions(-)

diff --git a/NEWS b/NEWS
index 86c7780..db7aab0 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Changes since 1.3.0:
   * Replace BeOS support by Haiku support.
   * dvdcss_error() now returns "const char *" instad of "char *".
   * Drop support for MSVC versions before 2010.
+  * Raw device access now errors out if the device cannot be opened.
   * Miscellaneous cleanups to code, documentation, build system.
 
 
diff --git a/src/device.c b/src/device.c
index 72ebbea..6148f4a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -336,8 +336,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 )
@@ -382,27 +385,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 41479b5..4a58675 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -458,10 +458,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 )
@@ -536,13 +532,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 );
 



More information about the libdvdcss-devel mailing list