]> git.sesse.net Git - vlc/commitdiff
* Fixed crashes on exit in the directx plugin
authorGildas Bazin <gbazin@videolan.org>
Mon, 21 Jan 2002 07:00:21 +0000 (07:00 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 21 Jan 2002 07:00:21 +0000 (07:00 +0000)
* vout_PlacePicture is now accepting picture width=height=0

* Win32 (NT/2000/XP) fix for libdvdcss: first attempt to open the DVD
  device in read/write mode so we can use ioctls. If this fails
  (insufficent privileges) we at least open in read-only mode so the
  libdvdcss title decryption method can be used.

extras/libdvdcss/css.c
extras/libdvdcss/libdvdcss.c
plugins/directx/vout_events.c
src/video_output/vout_pictures.c

index 1bb447703adf022c05dbb8d0d7b9ca25d22003f8..557d2e465c679d9accfe96e504473fd7a561a851 100644 (file)
@@ -2,7 +2,7 @@
  * css.c: Functions for DVD authentification and unscrambling
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: css.c,v 1.20 2002/01/14 22:06:57 stef Exp $
+ * $Id: css.c,v 1.21 2002/01/21 07:00:21 gbazin Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *         Håkan Hjort <d95hjort@dtek.chalmers.se>
@@ -77,7 +77,13 @@ int CSSTest( dvdcss_handle dvdcss )
         /* Since it's the first ioctl we try to issue, we add a notice */
         _dvdcss_error( dvdcss, "css error: ioctl_ReadCopyright failed, "
                        "make sure there is a DVD in the drive, and that "
-                       "DVD ioctls were compiled in this libdvdcss version" );
+                       "DVD ioctls were compiled in this libdvdcss version."
+#if defined( WIN32 )
+                       "\nAlso note that if you are using Windows NT/2000/XP "
+                       "you need to have administrator priviledges to be able "
+                       "to use ioctls."
+#endif
+                     );
 
         return i_ret;
     }
index bcf1434e1d7dd0a6a3a9001579a689cf0ec55751..cd0782f78a46da1e47dddea30d299f3160d2cf96 100644 (file)
@@ -2,7 +2,7 @@
  * libdvdcss.c: DVD reading library.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: libdvdcss.c,v 1.28 2002/01/15 05:22:21 stef Exp $
+ * $Id: libdvdcss.c,v 1.29 2002/01/21 07:00:21 gbazin Exp $
  *
  * Authors: Stéphane Borel <stef@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -158,11 +158,16 @@ extern dvdcss_handle dvdcss_open ( char *psz_target )
         return NULL;
     }
 
+#if defined( WIN32 )
+    /* it's not possible to stat a drive letter. Fake a block device */
+    fileinfo.st_mode = S_IFBLK;
+#else
     if( stat( psz_target, &fileinfo ) < 0 )
     {
         _dvdcss_error( dvdcss, "dvdcss: can't stat target" );
     }
-    
+#endif
+
     if( S_ISBLK( fileinfo.st_mode ) || 
         S_ISCHR( fileinfo.st_mode ) )
     {        
@@ -479,10 +484,25 @@ static int _dvdcss_open ( dvdcss_handle dvdcss, char *psz_target )
     {
         char psz_dvd[7];
         _snprintf( psz_dvd, 7, "\\\\.\\%c:", psz_target[0] );
+
+        /* To have access to ioctls, we need read and write access to the
+         * device. This is only allowed if you have administrator priviledges
+         * so we allow for a fallback method where ioctls are not available but
+         * we at least have read access to the device.
+         * (See Microsoft Q241374: Read and Write Access Required for SCSI
+         * Pass Through Requests) */
         (HANDLE) dvdcss->i_fd =
                 CreateFile( psz_dvd, GENERIC_READ | GENERIC_WRITE,
                                 FILE_SHARE_READ | FILE_SHARE_WRITE,
-                                NULL, OPEN_EXISTING, 0, NULL );
+                                NULL, OPEN_EXISTING,
+                                FILE_FLAG_RANDOM_ACCESS, NULL );
+
+        if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
+            (HANDLE) dvdcss->i_fd =
+                    CreateFile( psz_dvd, GENERIC_READ, FILE_SHARE_READ,
+                                    NULL, OPEN_EXISTING,
+                                    FILE_FLAG_RANDOM_ACCESS, NULL );
+
         if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
         {
             _dvdcss_error( dvdcss, "failed opening device" );
index 362ca2aaa553164f52ace6c20a7ea4dfa2fdf3ce..af35919c87671f77843d80aff291a3173a29c61c 100644 (file)
@@ -2,7 +2,7 @@
  * vout_events.c: Windows DirectX video output events handler
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: vout_events.c,v 1.8 2002/01/17 23:02:45 gbazin Exp $
+ * $Id: vout_events.c,v 1.9 2002/01/21 07:00:21 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -142,7 +142,8 @@ void DirectXEventThread( vout_thread_t *p_vout )
             {
             case VK_ESCAPE:
             case VK_F12:
-                PostQuitMessage( 0 );
+                /* exit application */
+                p_main->p_intf->b_die = 1;
                 break;
             }
             TranslateMessage(&msg);
@@ -154,7 +155,8 @@ void DirectXEventThread( vout_thread_t *p_vout )
             {
             case 'q':
             case 'Q':
-                PostQuitMessage( 0 );
+                /* exit application */
+                p_main->p_intf->b_die = 1;
                 break;
 
             case 'f':                            /* switch to fullscreen */
@@ -385,7 +387,7 @@ static void DirectXCloseWindow( vout_thread_t *p_vout )
                      hInstance );          /* handle to application instance */
 
     /* free window background brush */
-    if( p_vout->p_sys->hwnd != NULL )
+    if( p_vout->p_sys->hbrush != NULL )
     {
         DeleteObject( p_vout->p_sys->hbrush );
         p_vout->p_sys->hbrush = NULL;
@@ -538,7 +540,10 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
     /* the window has been closed so shut down everything now */
     case WM_DESTROY:
         intf_WarnMsg( 4, "vout: WinProc WM_DESTROY" );
+        /* exit application */
+        p_main->p_intf->b_die = 1;
         PostQuitMessage( 0 );
+        return 0;
         break;
 
     case WM_SYSCOMMAND:
index f0fa3836636fe276ac4e076bb41f7e2301acba2a..5f0fbc009a77a4cd9769a0e14df62e5a6744771d 100644 (file)
@@ -2,7 +2,7 @@
  * vout_pictures.c : picture management functions
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
- * $Id: vout_pictures.c,v 1.11 2002/01/17 23:02:45 gbazin Exp $
+ * $Id: vout_pictures.c,v 1.12 2002/01/21 07:00:21 gbazin Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -395,7 +395,11 @@ void vout_PlacePicture( vout_thread_t *p_vout, int i_width, int i_height,
                         int *pi_x, int *pi_y, int *pi_width, int *pi_height )
 {
     if( (i_width <= 0) || (i_height <=0) )
+    {
+        *pi_width = *pi_height = *pi_x = *pi_y = 0;
+
         return;
+    }
 
     if( p_vout->b_scale )
     {