[libdvdcss-devel] [PATCH 7/7] Directly expose uint8_t in the API instead of hiding it behind void*.

Diego Biurrun diego at biurrun.de
Tue Nov 4 20:15:06 CET 2014


---

unsigned char might also work.

 src/dvdcss/dvdcss.h |  4 +++-
 src/libdvdcss.c     | 18 ++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index db418fc..4cf86a6 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -35,6 +35,8 @@
 extern "C" {
 #endif
 
+#include <stdint.h>
+
 /** Library instance handle, to be used for each library call. */
 typedef struct dvdcss* dvdcss_t;
 
@@ -79,7 +81,7 @@ LIBDVDCSS_EXPORT int      dvdcss_seek  ( struct dvdcss *,
                                int i_blocks,
                                int i_flags );
 LIBDVDCSS_EXPORT int      dvdcss_read  ( struct dvdcss *,
-                               void *p_buffer,
+                               uint8_t *p_buffer,
                                int i_blocks,
                                int i_flags );
 LIBDVDCSS_EXPORT int      dvdcss_readv ( struct dvdcss *,
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index a72dffb..9e10095 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -630,14 +630,12 @@ LIBDVDCSS_EXPORT int dvdcss_seek ( struct dvdcss *dvdcss, int i_blocks, int i_fl
  * \warning dvdcss_read() expects to be able to write \p i_blocks *
  *          #DVDCSS_BLOCK_SIZE bytes into \p p_buffer.
  */
-LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
-                                          int i_blocks,
-                                          int i_flags )
+LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, uint8_t *p_buffer,
+                                   int i_blocks, int i_flags )
 {
-    uint8_t *_p_buffer = p_buffer;
     int i_ret, i_index;
 
-    i_ret = dvdcss->pf_read( dvdcss, _p_buffer, i_blocks );
+    i_ret = dvdcss->pf_read( dvdcss, p_buffer, i_blocks );
 
     if( i_ret <= 0
          || !dvdcss->b_scrambled
@@ -652,14 +650,14 @@ LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
          * check that there are no encrypted blocks */
         for( i_index = i_ret; i_index; i_index-- )
         {
-            if( _p_buffer[0x14] & 0x30 )
+            if( p_buffer[0x14] & 0x30 )
             {
                 print_error( dvdcss, "no key but found encrypted block" );
                 /* Only return the initial range of unscrambled blocks? */
                 /* or fail completely? return 0; */
                 break;
             }
-            _p_buffer = _p_buffer + DVDCSS_BLOCK_SIZE;
+            p_buffer = p_buffer + DVDCSS_BLOCK_SIZE;
         }
     }
     else
@@ -667,9 +665,9 @@ LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
         /* Decrypt the blocks we managed to read */
         for( i_index = i_ret; i_index; i_index-- )
         {
-            dvdcss_unscramble( dvdcss->css.p_title_key, _p_buffer );
-            _p_buffer[0x14] &= 0x8f;
-            _p_buffer = _p_buffer + DVDCSS_BLOCK_SIZE;
+            dvdcss_unscramble( dvdcss->css.p_title_key, p_buffer );
+            p_buffer[0x14] &= 0x8f;
+            p_buffer = p_buffer + DVDCSS_BLOCK_SIZE;
         }
     }
 
-- 
1.9.1



More information about the libdvdcss-devel mailing list