shithub: libdvdcss

Download patch

ref: ba96985769d21f10d173aaed3f23cae051c8b610
parent: b45e2bc2d228c3b1ddadf2092af174f32f524280
author: Sam Hocevar <[email protected]>
date: Fri Aug 9 18:03:34 EDT 2002

* ./src/css.c: in case of a region mismatch and when the drive needs to
    be reset, we read the first sector of the disc instead of closing and
    reopening it.


--- a/src/css.c
+++ b/src/css.c
@@ -2,7 +2,7 @@
  * css.c: Functions for DVD authentication and descrambling
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: css.c,v 1.12 2002/08/09 14:10:43 sam Exp $
+ * $Id: css.c,v 1.13 2002/08/09 22:03:34 sam Exp $
  *
  * Author: St�phane Borel <[email protected]>
  *         H�kan Hjort <[email protected]>
@@ -436,6 +436,7 @@
  *****************************************************************************/
 int _dvdcss_titlekey( dvdcss_handle dvdcss, int i_pos, dvd_key_t p_title_key )
 {
+    static u8 p_garbage[ 2048 ];          /* static because we never read it */
     u8  p_key[KEY_SIZE];
     int i, i_ret = 0;
 
@@ -521,11 +522,12 @@
         }
 
         /* The title key request failed */
-        _dvdcss_debug( dvdcss, "reopening disc and cracking title key" );
+        _dvdcss_debug( dvdcss, "resetting drive and cracking title key" );
 
-        /* Close and reopen everything */
-        _dvdcss_close( dvdcss );
-        _dvdcss_open( dvdcss );
+        /* Read an unscrambled sector and reset the drive */
+        _dvdcss_seek( dvdcss, 0 );
+        _dvdcss_read( dvdcss, p_garbage, 1 );
+        _dvdcss_seek( dvdcss, 0 );
         _dvdcss_disckey( dvdcss );
 
         /* Fallback */