]> git.sesse.net Git - vlc/blobdiff - src/misc/image.c
Couldn't bootstrap properly if a number existed anywhere in the path
[vlc] / src / misc / image.c
index e5b3266e8061e24958edb7603d7b87c876193d24..463b43ce233b3bbbfea0afbe405a2ada34755985 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * image.c : wrapper for image reading/writing facilities
  *****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
+ * Copyright (C) 2004-2007 the VideoLAN team
  * $Id$
  *
  * Author: Gildas Bazin <gbazin@videolan.org>
@@ -30,6 +30,7 @@
  * Preamble
  *****************************************************************************/
 #include <ctype.h>
+#include <errno.h>
 #include <vlc/vlc.h>
 #include <vlc_codec.h>
 #include <vlc_filter.h>
@@ -242,7 +243,7 @@ static picture_t *ImageReadUrl( image_handler_t *p_image, const char *psz_url,
  *
  */
 
-void PicRelease( picture_t *p_pic ){};
+static void PicRelease( picture_t *p_pic ) { (void)p_pic; }
 
 static block_t *ImageWrite( image_handler_t *p_image, picture_t *p_pic,
                             video_format_t *p_fmt_in,
@@ -351,22 +352,30 @@ static int ImageWriteUrl( image_handler_t *p_image, picture_t *p_pic,
     file = utf8_fopen( psz_url, "wb" );
     if( !file )
     {
-        msg_Dbg( p_image->p_parent, "could not open file %s for writing",
-                 psz_url );
+        msg_Err( p_image->p_parent, "%s: %m", psz_url );
         return VLC_EGENERIC;
     }
 
     p_block = ImageWrite( p_image, p_pic, p_fmt_in, p_fmt_out );
 
+    int err = 0;
     if( p_block )
     {
-        fwrite( p_block->p_buffer, sizeof(char), p_block->i_buffer, file );
+        if( fwrite( p_block->p_buffer, p_block->i_buffer, 1, file ) != 1 )
+            err = errno;
         block_Release( p_block );
     }
 
-    fclose( file );
+    if( fclose( file ) && !err )
+        err = errno;
+
+    if( err )
+    {
+       errno = err;
+       msg_Err( p_image->p_parent, "%s: %m", psz_url );
+    }
 
-    return p_block ? VLC_SUCCESS : VLC_EGENERIC;
+    return err ? VLC_EGENERIC : VLC_SUCCESS;
 }
 
 /**
@@ -445,6 +454,7 @@ static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic,
         p_fmt_in->i_height == p_fmt_out->i_height )
     {
         /* Duplicate image */
+        p_pif->pf_release( p_pif ); /* XXX: Better fix must be possible */
         p_pif = p_image->p_filter->pf_vout_buffer_new( p_image->p_filter );
         if( p_pif ) vout_CopyPicture( p_image->p_parent, p_pif, p_pic );
     }
@@ -500,7 +510,7 @@ static picture_t *ImageFilter( image_handler_t *p_image, picture_t *p_pic,
 static struct
 {
     vlc_fourcc_t i_codec;
-    char *psz_ext;
+    const char *psz_ext;
 
 } ext_table[] =
 {
@@ -594,6 +604,7 @@ static picture_t *video_new_buffer( decoder_t *p_dec )
 
 static void video_del_buffer( decoder_t *p_dec, picture_t *p_pic )
 {
+    (void)p_dec;
     if( p_pic && p_pic->p_data_orig ) free( p_pic->p_data_orig );
     if( p_pic && p_pic->p_sys ) free( p_pic->p_sys );
     if( p_pic ) free( p_pic );
@@ -601,10 +612,12 @@ static void video_del_buffer( decoder_t *p_dec, picture_t *p_pic )
 
 static void video_link_picture( decoder_t *p_dec, picture_t *p_pic )
 {
+    (void)p_dec; (void)p_pic;
 }
 
 static void video_unlink_picture( decoder_t *p_dec, picture_t *p_pic )
 {
+    (void)p_dec; (void)p_pic;
 }
 
 static decoder_t *CreateDecoder( vlc_object_t *p_this, video_format_t *fmt )