]> git.sesse.net Git - vlc/blobdiff - modules/gui/fbosd.c
svg module: fix memleak.
[vlc] / modules / gui / fbosd.c
index ec58670475df3cb73689137887b602ebc775f49c..2a7e1b4eadda6e17cbf5bf4b5fbd0975826c66e9 100644 (file)
@@ -29,7 +29,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_plugin.h>
 
 #include <errno.h>
@@ -159,16 +159,18 @@ static picture_t *RenderText( intf_thread_t *, const char *,
 #define DISPLAY_LONGTEXT N_( "All rendered images and text will be " \
     "displayed on the overlay framebuffer." )
 
-static int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
-static const char *ppsz_pos_descriptions[] =
+static const int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
+static const char *const ppsz_pos_descriptions[] =
 { N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
   N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
 
-static int pi_color_values[] = { 0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0,
+static const int pi_color_values[] = {
+               0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0,
                0x00FFFFFF, 0x00800000, 0x00FF0000, 0x00FF00FF, 0x00FFFF00,
                0x00808000, 0x00008000, 0x00008080, 0x0000FF00, 0x00800080,
                0x00000080, 0x000000FF, 0x0000FFFF};
-static const char *ppsz_color_descriptions[] = { N_("Default"), N_("Black"),
+static const char *const ppsz_color_descriptions[] = {
+               N_("Default"), N_("Black"),
                N_("Gray"), N_("Silver"), N_("White"), N_("Maroon"), N_("Red"),
                N_("Fuchsia"), N_("Yellow"), N_("Olive"), N_("Green"),
                N_("Teal"), N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"),
@@ -519,7 +521,7 @@ static void Destroy( vlc_object_t *p_this )
     if( p_sys->p_image )
         image_HandlerDelete( p_sys->p_image );
     if( p_sys->p_overlay )
-        p_sys->p_overlay->pf_release( p_sys->p_overlay );
+        picture_Release( p_sys->p_overlay );
 
     free( p_sys->p_style );
     free( p_sys );
@@ -531,7 +533,7 @@ static int OpenBlending( intf_thread_t *p_intf )
     if( p_intf->p_sys->p_blend ) return VLC_EGENERIC;
 
     p_intf->p_sys->p_blend =
-            vlc_object_create( p_intf, VLC_OBJECT_FILTER );
+            vlc_object_create( p_intf, sizeof(filter_t) );
     vlc_object_attach( p_intf->p_sys->p_blend, p_intf );
     p_intf->p_sys->p_blend->fmt_out.video.i_x_offset =
         p_intf->p_sys->p_blend->fmt_out.video.i_y_offset = 0;
@@ -576,7 +578,7 @@ static int OpenTextRenderer( intf_thread_t *p_intf )
     if( p_intf->p_sys->p_text ) return VLC_EGENERIC;
 
     p_intf->p_sys->p_text =
-            vlc_object_create( p_intf, VLC_OBJECT_FILTER );
+            vlc_object_create( p_intf, sizeof(filter_t) );
     vlc_object_attach( p_intf->p_sys->p_text, p_intf );
 
     p_intf->p_sys->p_text->fmt_out.video.i_width =
@@ -626,8 +628,11 @@ static void CloseTextRenderer( intf_thread_t *p_intf )
 static picture_t *AllocatePicture( vlc_object_t *p_this,
                                    video_format_t *p_fmt )
 {
-    picture_t *p_pic = malloc( sizeof( picture_t ) );
-    if( !p_pic ) return NULL;
+    picture_t *p_picture = picture_New( p_fmt->i_chroma,
+                                        p_fmt->i_width, p_fmt->i_height,
+                                        p_fmt->i_aspect );
+    if( !p_picture )
+        return NULL;
 
     if( !p_fmt->p_palette &&
         ( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') ) )
@@ -635,24 +640,16 @@ static picture_t *AllocatePicture( vlc_object_t *p_this,
         p_fmt->p_palette = malloc( sizeof(video_palette_t) );
         if( !p_fmt->p_palette )
         {
-            free( p_pic );
+            picture_Release( p_picture );
             return NULL;
         }
     }
-    else p_fmt->p_palette = NULL;
-
-    p_pic->p_data_orig = NULL;
-
-    vout_AllocatePicture( p_this, p_pic, p_fmt->i_chroma,
-                          p_fmt->i_width, p_fmt->i_height, p_fmt->i_aspect );
-
-    if( !p_pic->i_planes )
+    else
     {
-        free( p_pic );
-        free( p_fmt->p_palette );
-        return NULL;
+        p_fmt->p_palette = NULL;
     }
-    return p_pic;
+
+    return p_picture;
 }
 
 /*****************************************************************************
@@ -663,18 +660,15 @@ static void DeAllocatePicture( vlc_object_t *p_this, picture_t *p_pic,
                                video_format_t *p_fmt )
 {
     VLC_UNUSED(p_this);
-    if( p_pic )
-    {
-        free( p_pic->p_data_orig );
-        if( p_pic->pf_release ) p_pic->pf_release( p_pic );
-        else free( p_pic );
-    }
+
     if( p_fmt )
     {
         free( p_fmt->p_palette );
         p_fmt->p_palette = NULL;
     }
-    p_pic = NULL;
+
+    if( p_pic )
+        picture_Release( p_pic );
 }
 
 /*****************************************************************************
@@ -1205,7 +1199,7 @@ static void Render( intf_thread_t *p_intf, struct fbosd_render_t *render )
         {
             RenderPicture( p_intf, render->i_x, render->i_y,
                            p_pic, p_sys->p_overlay );
-            p_pic->pf_release( p_pic );
+            picture_Release( p_pic );
         }
     }
     else if( render->i_type == FBOSD_RENDER_TEXT )
@@ -1230,7 +1224,7 @@ static void Render( intf_thread_t *p_intf, struct fbosd_render_t *render )
         {
             RenderPicture( p_intf, render->i_x, render->i_y,
                            p_text, p_sys->p_overlay );
-            p_text->pf_release( p_text );
+            picture_Release( p_text );
         }
 #endif
     }