ref: a8cdb36570a3b28e116c75c3a5bd38d71a6f2ccc
parent: ebbbe9db422d99f182f7e95055c248ea1757e0ec
author: Sam Hocevar <[email protected]>
date: Mon Jan 27 19:41:10 EST 2003
* ./test/csstest.c: we align our read buffer in case of raw device access. * ./src/libdvdcss.c: updated documentation about raw devices.
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -5,7 +5,7 @@
* H�kan Hjort <[email protected]>
*
* Copyright (C) 1998-2002 VideoLAN
- * $Id: libdvdcss.c,v 1.27 2003/01/27 16:57:19 sam Exp $
+ * $Id: libdvdcss.c,v 1.28 2003/01/28 00:41:10 sam Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -77,7 +77,11 @@
* decrypt a DVD stored on a hard disc, or a DVD with the wrong region
* on an RPC2 drive.
*
- * \li \b DVDCSS_RAW_DEVICE: specify the raw device to use.
+ * \li \b DVDCSS_RAW_DEVICE: specify the raw device to use. Exact usage will
+ * depend on your operating system, the Linux utility to set up raw devices
+ * is \c raw(8) for instance. Please note that on most operating systems,
+ * using a raw device requires highly aligned buffers: Linux requires a
+ * 2048 bytes alignment (which is the size of a DVD sector).
*
* \li \b DVDCSS_CACHE: specify a directory in which to store title key
* values. This will speed up descrambling of DVDs which are in the
--- a/test/csstest.c
+++ b/test/csstest.c
@@ -1,8 +1,9 @@
/* csstest.c - test program for libdvdcss
- *
+ *
* Samuel Hocevar <[email protected]> - June 2001
* Updated on Nov 13th 2001 for libdvdcss version 1.0.0
* Additional error checks on Aug 9th 2002
+ * Aligned data reads on Jan 28th 2003
*
* This piece of code is public domain */
@@ -16,10 +17,11 @@
int main( int i_argc, char *ppsz_argv[] )
{
- dvdcss_t dvdcss;
- unsigned char p_buffer[ DVDCSS_BLOCK_SIZE ];
- unsigned int i_sector;
- int i_ret;
+ dvdcss_t dvdcss;
+ unsigned char p_data[ DVDCSS_BLOCK_SIZE * 2 ];
+ unsigned char *p_buffer;
+ unsigned int i_sector;
+ int i_ret;
/* Print version number */
printf( "cool, I found libdvdcss version %s\n", dvdcss_interface_2 );
@@ -41,6 +43,10 @@
printf( "argh ! couldn't open DVD (%s)\n", ppsz_argv[1] );
return -1;
}
+
+ /* Align our read buffer */
+ p_buffer = p_data + DVDCSS_BLOCK_SIZE
+ - ((long int)p_data & (DVDCSS_BLOCK_SIZE-1));
/* Set the file descriptor at sector i_sector and read one sector */
i_ret = dvdcss_seek( dvdcss, i_sector, DVDCSS_NOFLAGS );