]> git.sesse.net Git - vlc/blobdiff - modules/access/screen/win32.c
Merge commit 'origin/1.0-bugfix'
[vlc] / modules / access / screen / win32.c
index 6b4ddbfc3b3a610878dcf7fe85bf9075ea65eee7..01cac097c9d8711324ea49465ffc669950ef2a04 100644 (file)
@@ -55,16 +55,16 @@ int screen_InitCapture( demux_t *p_demux )
     screen_data_t *p_data;
     int i_chroma, i_bits_per_pixel;
 
-    p_sys->p_data = p_data = malloc( sizeof( screen_data_t ) );
+    p_sys->p_data = p_data = calloc( 1, sizeof( screen_data_t ) );
     if( !p_data )
         return VLC_ENOMEM;
-    memset( p_data, 0, sizeof( screen_data_t ) );
 
     /* Get the device context for the whole screen */
     p_data->hdc_src = CreateDC( "DISPLAY", NULL, NULL, NULL );
     if( !p_data->hdc_src )
     {
         msg_Err( p_demux, "cannot get device context" );
+        free( p_data );
         return VLC_EGENERIC;
     }
 
@@ -72,6 +72,7 @@ int screen_InitCapture( demux_t *p_demux )
     if( !p_data->hdc_dst )
     {
         msg_Err( p_demux, "cannot get compat device context" );
+        free( p_data );
         ReleaseDC( 0, p_data->hdc_src );
         return VLC_EGENERIC;
     }
@@ -80,19 +81,20 @@ int screen_InitCapture( demux_t *p_demux )
     switch( i_bits_per_pixel )
     {
     case 8: /* FIXME: set the palette */
-        i_chroma = VLC_FOURCC('R','G','B','2'); break;
+        i_chroma = VLC_CODEC_RGB8; break;
     case 15:
     case 16:    /* Yes it is really 15 bits (when using BI_RGB) */
-        i_chroma = VLC_FOURCC('R','V','1','5'); break;
+        i_chroma = VLC_CODEC_RGB15; break;
     case 24:
-        i_chroma = VLC_FOURCC('R','V','2','4'); break;
+        i_chroma = VLC_CODEC_RGB24; break;
     case 32:
-        i_chroma = VLC_FOURCC('R','V','3','2'); break;
+        i_chroma = VLC_CODEC_RGB32; break;
     default:
         msg_Err( p_demux, "unknown screen depth %i",
                  p_sys->fmt.video.i_bits_per_pixel );
+        DeleteDC( p_data->hdc_dst );
         ReleaseDC( 0, p_data->hdc_src );
-        ReleaseDC( 0, p_data->hdc_dst );
+        free( p_data );
         return VLC_EGENERIC;
     }
 
@@ -106,17 +108,17 @@ int screen_InitCapture( demux_t *p_demux )
 
     switch( i_chroma )
     {
-    case VLC_FOURCC('R','V','1','5'):
+    case VLC_CODEC_RGB15:
         p_sys->fmt.video.i_rmask = 0x7c00;
         p_sys->fmt.video.i_gmask = 0x03e0;
         p_sys->fmt.video.i_bmask = 0x001f;
         break;
-    case VLC_FOURCC('R','V','2','4'):
+    case VLC_CODEC_RGB24:
         p_sys->fmt.video.i_rmask = 0x00ff0000;
         p_sys->fmt.video.i_gmask = 0x0000ff00;
         p_sys->fmt.video.i_bmask = 0x000000ff;
         break;
-    case VLC_FOURCC('R','V','3','2'):
+    case VLC_CODEC_RGB32:
         p_sys->fmt.video.i_rmask = 0x00ff0000;
         p_sys->fmt.video.i_gmask = 0x0000ff00;
         p_sys->fmt.video.i_bmask = 0x000000ff;
@@ -170,7 +172,7 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
 
     if( p_data->bmi.bmiHeader.biSize == 0 )
     {
-        vlc_value_t val;
+        int i_val;
         /* Create the bitmap info header */
         p_data->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
         p_data->bmi.bmiHeader.biWidth = p_sys->fmt.video.i_width;
@@ -184,14 +186,11 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
         p_data->bmi.bmiHeader.biClrUsed = 0;
         p_data->bmi.bmiHeader.biClrImportant = 0;
 
-        var_Create( p_demux, "screen-fragment-size",
-                    VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-        var_Get( p_demux, "screen-fragment-size", &val );
-        p_data->i_fragment_size =
-            val.i_int > 0 ? val.i_int : p_sys->fmt.video.i_height;
-        p_data->i_fragment_size =
-            val.i_int > p_sys->fmt.video.i_height ? p_sys->fmt.video.i_height :
-            p_data->i_fragment_size;
+        i_val = var_CreateGetInteger( p_demux, "screen-fragment-size" );
+        p_data->i_fragment_size = i_val > 0 ? i_val : p_sys->fmt.video.i_height;
+        p_data->i_fragment_size = i_val > p_sys->fmt.video.i_height ?
+                                            p_sys->fmt.video.i_height :
+                                            p_data->i_fragment_size;
         p_sys->f_fps *= (p_sys->fmt.video.i_height/p_data->i_fragment_size);
         p_sys->i_incr = 1000000 / p_sys->f_fps;
         p_data->i_fragment = 0;
@@ -248,7 +247,7 @@ block_t *screen_Capture( demux_t *p_demux )
         if( !( p_data->p_block = CaptureBlockNew( p_demux ) ) )
         {
             msg_Warn( p_demux, "cannot get block" );
-            return 0;
+            return NULL;
         }
     }
 
@@ -264,7 +263,7 @@ block_t *screen_Capture( demux_t *p_demux )
                  p_sys->fmt.video.i_width, p_data->i_fragment_size,
                  p_data->hdc_src, p_sys->i_left, p_sys->i_top +
                  p_data->i_fragment * p_data->i_fragment_size,
-                 IS_WINNT ? SRCCOPY | CAPTUREBLT : SRCCOPY ) )
+                 SRCCOPY | CAPTUREBLT ) )
     {
         msg_Err( p_demux, "error during BitBlt()" );
         return NULL;