]> git.sesse.net Git - vlc/blobdiff - modules/gui/fbosd.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / modules / gui / fbosd.c
index 710452ce9d1454a96127f173fa3552e63a7336f4..ccc747ee467211a83820e886f456860f4c7d03ec 100644 (file)
@@ -31,8 +31,9 @@
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
+#include <vlc_fs.h>
+#include <vlc_modules.h>
 
-#include <errno.h>
 #include <stdlib.h>                                                /* free() */
 #include <string.h>                                            /* strerror() */
 #include <fcntl.h>                                                 /* open() */
@@ -174,50 +175,50 @@ static const char *const ppsz_color_descriptions[] = {
                N_("Teal"), N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"),
                N_("Aqua") };
 
-vlc_module_begin();
-    set_shortname( "fbosd" );
-    set_category( CAT_INTERFACE );
-    set_subcategory( SUBCAT_INTERFACE_MAIN );
+vlc_module_begin ()
+    set_shortname( "fbosd" )
+    set_category( CAT_INTERFACE )
+    set_subcategory( SUBCAT_INTERFACE_MAIN )
 
-    add_file( "fbosd-dev", "/dev/fb1", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
-              false );
+    add_file( "fbosd-dev", "/dev/fb0", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
+              false )
     add_string( "fbosd-aspect-ratio", "", NULL, ASPECT_RATIO_TEXT,
-                ASPECT_RATIO_LONGTEXT, true );
+                ASPECT_RATIO_LONGTEXT, true )
 
     add_string( "fbosd-image", NULL, NULL, FBOSD_IMAGE_TEXT,
-                FBOSD_IMAGE_LONGTEXT, true );
+                FBOSD_IMAGE_LONGTEXT, true )
     add_string( "fbosd-text", NULL, NULL, FBOSD_TEXT,
-                FBOSD_LONGTEXT, true );
+                FBOSD_LONGTEXT, true )
 
     add_integer_with_range( "fbosd-alpha", 255, 0, 255, NULL, ALPHA_TEXT,
-                            ALPHA_LONGTEXT, true );
+                            ALPHA_LONGTEXT, true )
 
-    set_section( N_("Position"), NULL );
+    set_section( N_("Position"), NULL )
     add_integer( "fbosd-x", 0, NULL, POSX_TEXT,
-                 POSX_LONGTEXT, false );
+                 POSX_LONGTEXT, false )
     add_integer( "fbosd-y", 0, NULL, POSY_TEXT,
-                 POSY_LONGTEXT, false );
-    add_integer( "fbosd-position", 8, NULL, POS_TEXT, POS_LONGTEXT, true );
+                 POSY_LONGTEXT, false )
+    add_integer( "fbosd-position", 8, NULL, POS_TEXT, POS_LONGTEXT, true )
         change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL );
 
-    set_section( N_("Font"), NULL );
+    set_section( N_("Font"), NULL )
     add_integer_with_range( "fbosd-font-opacity", 255, 0, 255, NULL,
-        OPACITY_TEXT, OPACITY_LONGTEXT, false );
+        OPACITY_TEXT, OPACITY_LONGTEXT, false )
     add_integer( "fbosd-font-color", 0x00FFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT,
-                 false );
+                 false )
         change_integer_list( pi_color_values, ppsz_color_descriptions, NULL );
     add_integer( "fbosd-font-size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT,
-                 false );
+                 false )
 
-    set_section( N_("Commands"), NULL );
-    add_bool( "fbosd-clear", false, NULL, CLEAR_TEXT, CLEAR_LONGTEXT, true );
-    add_bool( "fbosd-render", false, NULL, RENDER_TEXT, RENDER_LONGTEXT, true );
-    add_bool( "fbosd-display", false, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, true );
+    set_section( N_("Commands"), NULL )
+    add_bool( "fbosd-clear", false, NULL, CLEAR_TEXT, CLEAR_LONGTEXT, true )
+    add_bool( "fbosd-render", false, NULL, RENDER_TEXT, RENDER_LONGTEXT, true )
+    add_bool( "fbosd-display", false, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, true )
 
-    set_description( N_("GNU/Linux osd/overlay framebuffer interface") );
-    set_capability( "interface", 10 );
-    set_callbacks( Create, Destroy );
-vlc_module_end();
+    set_description( N_("GNU/Linux osd/overlay framebuffer interface") )
+    set_capability( "interface", 10 )
+    set_callbacks( Create, Destroy )
+vlc_module_end ()
 
 /*****************************************************************************
  * fbosd_render_t: render descriptor
@@ -234,7 +235,7 @@ struct fbosd_render_t
     int             i_state;
 
     /* Font style */
-    text_style_t    text_style;                              /* font control */
+    text_style_t*   p_text_style;                            /* font control */
     char            *psz_string;
 
     /* Position */
@@ -306,32 +307,34 @@ static int Create( vlc_object_t *p_this )
     int i;
 
     /* Allocate instance and initialize some members */
-    p_intf->p_sys = p_sys = malloc( sizeof( intf_sys_t ) );
+    p_intf->p_sys = p_sys = calloc( 1, sizeof( intf_sys_t ) );
     if( !p_intf->p_sys )
         return VLC_ENOMEM;
-    memset( p_sys, 0, sizeof(intf_sys_t) );
 
-    p_sys->p_style = malloc( sizeof( text_style_t ) );
+    p_sys->p_style = text_style_New();
     if( !p_sys->p_style )
     {
         free( p_intf->p_sys );
         return VLC_ENOMEM;
     }
-    vlc_memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ) );
 
     p_intf->pf_run = Run;
 
     p_sys->p_image = image_HandlerCreate( p_this );
     if( !p_sys->p_image )
     {
-        free( p_intf->p_sys->p_style );
-        free( p_intf->p_sys );
+        text_style_Delete( p_sys->p_style );
+        free( p_sys );
         return VLC_ENOMEM;
     }
 
     p_sys->i_alpha = var_CreateGetIntegerCommand( p_intf, "fbosd-alpha" );
     var_AddCallback( p_intf, "fbosd-alpha", OverlayCallback, NULL );
 
+    /* Use PAL by default */
+    p_sys->i_width  = p_sys->fmt_out.i_width  = 704;
+    p_sys->i_height = p_sys->fmt_out.i_height = 576;
+
     p_sys->i_aspect = -1;
     psz_aspect =
             var_CreateGetNonEmptyString( p_intf, "fbosd-aspect-ratio" );
@@ -344,19 +347,15 @@ static int Create( vlc_object_t *p_this )
             *psz_parser++ = '\0';
             p_sys->i_aspect = ( atoi( psz_aspect )
                               * VOUT_ASPECT_FACTOR ) / atoi( psz_parser );
-            p_sys->fmt_out.i_aspect = p_sys->i_aspect;
+            p_sys->fmt_out.i_sar_num = p_sys->i_aspect    * p_sys->i_height;
+            p_sys->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR * p_sys->i_width;
         }
         msg_Dbg( p_intf, "using aspect ratio %d:%d",
                   atoi( psz_aspect ), atoi( psz_parser ) );
 
         free( psz_aspect );
-        psz_aspect = NULL;
     }
 
-    /* Use PAL by default */
-    p_sys->i_width  = p_sys->fmt_out.i_width  = 704;
-    p_sys->i_height = p_sys->fmt_out.i_height = 576;
-
     psz_tmp = var_CreateGetNonEmptyStringCommand( p_intf, "fbosd-image" );
     var_AddCallback( p_intf, "fbosd-image", OverlayCallback, NULL );
     if( psz_tmp && *psz_tmp )
@@ -397,10 +396,7 @@ static int Create( vlc_object_t *p_this )
     var_AddCallback( p_intf, "fbosd-font-opacity", OverlayCallback, NULL );
 
     for( i = 0; i < FBOSD_RENDER_MAX; i++ )
-    {
-        vlc_memcpy( &p_sys->render[i].text_style, &default_text_style,
-                    sizeof( text_style_t ) );
-    }
+        p_sys->render[i].p_text_style = text_style_New();
 
     p_sys->b_clear = var_CreateGetBoolCommand( p_intf, "fbosd-clear" );
     p_sys->b_render = var_CreateGetBoolCommand( p_intf, "fbosd-render" );
@@ -467,9 +463,10 @@ static int Create( vlc_object_t *p_this )
 static void Destroy( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
-    intf_sys_t *p_sys = (intf_sys_t *) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
     int i;
 
+
     p_sys->b_need_update = false;
     p_sys->b_render = false;
     p_sys->b_clear = false;
@@ -509,6 +506,7 @@ static void Destroy( vlc_object_t *p_this )
     {
         free( p_sys->render[i].psz_string );
         p_sys->render[i].i_state = FBOSD_STATE_FREE;
+        text_style_Delete( p_sys->render[i].p_text_style );
     }
 
 #if defined(FBOSD_BLENDING)
@@ -521,7 +519,7 @@ static void Destroy( vlc_object_t *p_this )
     if( p_sys->p_overlay )
         picture_Release( p_sys->p_overlay );
 
-    free( p_sys->p_style );
+    text_style_Delete( p_sys->p_style );
     free( p_sys );
 }
 
@@ -535,19 +533,21 @@ static int OpenBlending( intf_thread_t *p_intf )
     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;
-    p_intf->p_sys->p_blend->fmt_out.video.i_aspect =
-            p_intf->p_sys->fmt_out.i_aspect;
+    p_intf->p_sys->p_blend->fmt_out.video.i_sar_num =
+            p_intf->p_sys->fmt_out.i_sar_num;
+    p_intf->p_sys->p_blend->fmt_out.video.i_sar_den =
+            p_intf->p_sys->fmt_out.i_sar_den;
     p_intf->p_sys->p_blend->fmt_out.video.i_chroma =
             p_intf->p_sys->fmt_out.i_chroma;
-    if( config_GetInt( p_intf, "freetype-yuvp" ) )
+    if( var_InheritBool( p_intf, "freetype-yuvp" ) )
         p_intf->p_sys->p_blend->fmt_in.video.i_chroma =
-                VLC_FOURCC('Y','U','V','P');
+                VLC_CODEC_YUVP;
     else
         p_intf->p_sys->p_blend->fmt_in.video.i_chroma =
-                VLC_FOURCC('Y','U','V','A');
+                VLC_CODEC_YUVA;
 
     p_intf->p_sys->p_blend->p_module =
-        module_Need( p_intf->p_sys->p_blend, "video blending", 0, 0 );
+        module_need( p_intf->p_sys->p_blend, "video blending", NULL, false );
 
     if( !p_intf->p_sys->p_blend->p_module )
         return VLC_EGENERIC;
@@ -560,10 +560,9 @@ static void CloseBlending( intf_thread_t *p_intf )
     if( p_intf->p_sys->p_blend )
     {
         if( p_intf->p_sys->p_blend->p_module )
-            module_Unneed( p_intf->p_sys->p_blend,
+            module_unneed( p_intf->p_sys->p_blend,
                            p_intf->p_sys->p_blend->p_module );
 
-        vlc_object_detach( p_intf->p_sys->p_blend );
         vlc_object_release( p_intf->p_sys->p_blend );
     }
 }
@@ -590,13 +589,13 @@ static int OpenTextRenderer( intf_thread_t *p_intf )
     if( psz_modulename && *psz_modulename )
     {
         p_intf->p_sys->p_text->p_module =
-            module_Need( p_intf->p_sys->p_text, "text renderer",
+            module_need( p_intf->p_sys->p_text, "text renderer",
                             psz_modulename, true );
     }
     if( !p_intf->p_sys->p_text->p_module )
     {
         p_intf->p_sys->p_text->p_module =
-            module_Need( p_intf->p_sys->p_text, "text renderer", 0, 0 );
+            module_need( p_intf->p_sys->p_text, "text renderer", NULL, false );
     }
     free( psz_modulename );
 
@@ -611,10 +610,9 @@ static void CloseTextRenderer( intf_thread_t *p_intf )
     if( p_intf->p_sys->p_text )
     {
         if( p_intf->p_sys->p_text->p_module )
-            module_Unneed( p_intf->p_sys->p_text,
+            module_unneed( p_intf->p_sys->p_text,
                            p_intf->p_sys->p_text->p_module );
 
-        vlc_object_detach( p_intf->p_sys->p_text );
         vlc_object_release( p_intf->p_sys->p_text );
     }
 }
@@ -625,14 +623,12 @@ static void CloseTextRenderer( intf_thread_t *p_intf )
  *****************************************************************************/
 static picture_t *AllocatePicture( video_format_t *p_fmt )
 {
-    picture_t *p_picture = picture_New( p_fmt->i_chroma,
-                                        p_fmt->i_width, p_fmt->i_height,
-                                        p_fmt->i_aspect );
+    picture_t *p_picture = picture_NewFromFormat( p_fmt );
     if( !p_picture )
         return NULL;
 
     if( !p_fmt->p_palette &&
-        ( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') ) )
+        ( p_fmt->i_chroma == VLC_CODEC_YUVP ) )
     {
         p_fmt->p_palette = malloc( sizeof(video_palette_t) );
         if( !p_fmt->p_palette )
@@ -673,7 +669,7 @@ static void DeAllocatePicture( picture_t *p_pic, video_format_t *p_fmt )
 static void SetOverlayTransparency( intf_thread_t *p_intf,
                                     bool b_transparent )
 {
-    intf_sys_t *p_sys = (intf_sys_t *) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
     size_t i_size = p_sys->fmt_out.i_width * p_sys->fmt_out.i_height
                         * p_sys->i_bytes_per_pixel;
     size_t i_page_size = (p_sys->i_page_size > i_size) ?
@@ -698,7 +694,7 @@ static int BlendPicture( intf_thread_t *p_intf, video_format_t *p_fmt_src,
                          video_format_t *p_fmt_dst, picture_t *p_pic_src,
                          picture_t *p_pic_dst )
 {
-    intf_sys_t *p_sys = (intf_sys_t *) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
     if( p_sys->p_blend && p_sys->p_blend->p_module )
     {
         int i_x_offset = p_sys->i_x;
@@ -741,13 +737,13 @@ static int InvertAlpha( intf_thread_t *p_intf, picture_t **p_pic, video_format_t
 
     switch( fmt.i_chroma )
     {
-        case VLC_FOURCC('R','V','2','4'):
+        case VLC_CODEC_RGB24:
             p_begin = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels;
             p_end   = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels +
                       ( fmt.i_height * (*p_pic)->p[Y_PLANE].i_pitch );
             i_skip = 3;
             break;
-        case VLC_FOURCC('R','V','3','2'):
+        case VLC_CODEC_RGB32:
             p_begin = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels;
             p_end   = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels +
                       ( fmt.i_height * (*p_pic)->p[Y_PLANE].i_pitch );
@@ -838,7 +834,7 @@ static int RenderPicture( intf_thread_t *p_intf, int i_x_offset, int i_y_offset,
 static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string,
                               text_style_t *p_style, video_format_t *p_fmt )
 {
-    intf_sys_t *p_sys = (intf_sys_t *) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
     subpicture_region_t *p_region;
     picture_t *p_dest = NULL;
 
@@ -846,28 +842,27 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string,
 
     if( p_sys->p_text && p_sys->p_text->p_module )
     {
-        p_region = (subpicture_region_t *) malloc( sizeof(subpicture_region_t) );
+        video_format_t fmt;
+
+        memset( &fmt, 0, sizeof(fmt) );
+        fmt.i_chroma = VLC_CODEC_TEXT;
+        fmt.i_width  = fmt.i_visible_width = 0;
+        fmt.i_height = fmt.i_visible_height = 0;
+        fmt.i_x_offset = 0;
+        fmt.i_y_offset = 0;
+
+        p_region = subpicture_region_New( &fmt );
         if( !p_region )
             return p_dest;
 
-        memset( p_region, 0, sizeof(subpicture_region_t) );
-
         p_region->psz_text = strdup( psz_string );
         if( !p_region->psz_text )
         {
-            free( p_region );
+            subpicture_region_Delete( p_region );
             return NULL;
         }
-        p_region->p_style = p_style;
-
-        p_region->fmt.i_chroma = VLC_FOURCC('T','E','X','T');
-        p_region->fmt.i_aspect = 0;
-        p_region->fmt.i_width = p_region->fmt.i_visible_width = 0;
-        p_region->fmt.i_height = p_region->fmt.i_visible_height = 0;
-        p_region->fmt.i_x_offset = 0;
-        p_region->fmt.i_y_offset = 0;
-
-        p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
+        p_region->p_style = text_style_Duplicate( p_style );
+        p_region->i_align = SUBPICTURE_ALIGN_LEFT | SUBPICTURE_ALIGN_TOP;
 
         if( p_sys->p_text->pf_render_text )
         {
@@ -887,24 +882,19 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string,
             p_dest = AllocatePicture( VLC_OBJECT(p_intf), &fmt_out );
             if( !p_dest )
             {
-                picture_Release( p_region->p_picture );
-                free( p_region->psz_text );
-                free( p_region );
+                subpicture_region_Delete( p_region );
                 return NULL;
             }
-            vout_CopyPicture( VLC_OBJECT(p_intf), p_dest, p_region->p_picture );
+            picture_Copy( p_dest, p_region->p_picture );
 #else
             fmt_out.i_chroma = p_fmt->i_chroma;
-            p_dest = ConvertImage( p_intf, &p_region->p_picture,
+            p_dest = ConvertImage( p_intf, p_region->p_picture,
                                    &p_region->fmt, &fmt_out );
 #endif
-            picture_Release( p_region->p_picture );
-            free( p_region->psz_text );
-            free( p_region );
+            subpicture_region_Delete( p_region );
             return p_dest;
         }
-        free( p_region->psz_text );
-        free( p_region );
+        subpicture_region_Delete( p_region );
     }
     return p_dest;
 }
@@ -942,7 +932,7 @@ static picture_t *LoadImage( intf_thread_t *p_intf, video_format_t *p_fmt,
 static picture_t *ConvertImage( intf_thread_t *p_intf, picture_t *p_pic,
                          video_format_t *p_fmt_in, video_format_t *p_fmt_out )
 {
-    intf_sys_t *p_sys = (intf_sys_t *) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
     picture_t  *p_old = NULL;
 
     if( p_sys->p_image )
@@ -962,22 +952,22 @@ static picture_t *ConvertImage( intf_thread_t *p_intf, picture_t *p_pic,
  *****************************************************************************/
 static int Init( intf_thread_t *p_intf )
 {
-    intf_sys_t *p_sys = (intf_sys_t *) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
 
     /* Initialize the output structure: RGB with square pixels, whatever
      * the input format is, since it's the only format we know */
     switch( p_sys->var_info.bits_per_pixel )
     {
     case 8: /* FIXME: set the palette */
-        p_sys->fmt_out.i_chroma = VLC_FOURCC('R','G','B','2'); break;
+        p_sys->fmt_out.i_chroma = VLC_CODEC_RGB8; break;
     case 15:
-        p_sys->fmt_out.i_chroma = VLC_FOURCC('R','V','1','5'); break;
+        p_sys->fmt_out.i_chroma = VLC_CODEC_RGB15; break;
     case 16:
-        p_sys->fmt_out.i_chroma = VLC_FOURCC('R','V','1','6'); break;
+        p_sys->fmt_out.i_chroma = VLC_CODEC_RGB16; break;
     case 24:
-        p_sys->fmt_out.i_chroma = VLC_FOURCC('R','V','2','4'); break;
+        p_sys->fmt_out.i_chroma = VLC_CODEC_RGB24; break;
     case 32:
-        p_sys->fmt_out.i_chroma = VLC_FOURCC('R','V','3','2'); break;
+        p_sys->fmt_out.i_chroma = VLC_CODEC_RGB32; break;
     default:
         msg_Err( p_intf, "unknown screen depth %i",
                  p_sys->var_info.bits_per_pixel );
@@ -991,12 +981,14 @@ static int Init( intf_thread_t *p_intf )
     /* Assume we have square pixels */
     if( p_sys->i_aspect < 0 )
     {
-        p_sys->fmt_out.i_aspect = ( p_sys->i_width
-                                  * VOUT_ASPECT_FACTOR ) / p_sys->i_height;
+        p_sys->fmt_out.i_sar_num = 1;
+        p_sys->fmt_out.i_sar_den = 1;
+    }
+    else
+    {
+        p_sys->fmt_out.i_sar_num = p_sys->i_aspect    * p_sys->i_height;
+        p_sys->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR * p_sys->i_width;
     }
-    else p_sys->fmt_out.i_aspect = p_sys->i_aspect;
-
-    p_sys->fmt_out.i_sar_num = p_sys->fmt_out.i_sar_den = 1;
 
     /* Allocate overlay buffer */
     p_sys->p_overlay = AllocatePicture( &p_sys->fmt_out );
@@ -1034,7 +1026,7 @@ static int Init( intf_thread_t *p_intf )
  *****************************************************************************/
 static void End( intf_thread_t *p_intf )
 {
-    intf_sys_t *p_sys = (intf_sys_t *) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
 
     /* CleanUp */
     SetOverlayTransparency( p_intf, false );
@@ -1057,21 +1049,21 @@ static void End( intf_thread_t *p_intf )
  *****************************************************************************/
 static int OpenDisplay( intf_thread_t *p_intf )
 {
-    intf_sys_t *p_sys = (intf_sys_t *) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
     char *psz_device;                             /* framebuffer device path */
     struct fb_fix_screeninfo    fix_info;     /* framebuffer fix information */
 
     /* Open framebuffer device */
-    if( !(psz_device = config_GetPsz( p_intf, "fbosd-dev" )) )
+    if( !(psz_device = var_InheritString( p_intf, "fbosd-dev" )) )
     {
         msg_Err( p_intf, "don't know which fb osd/overlay device to open" );
         return VLC_EGENERIC;
     }
 
-    p_sys->i_fd = open( psz_device, O_RDWR );
+    p_sys->i_fd = vlc_open( psz_device, O_RDWR );
     if( p_sys->i_fd == -1 )
     {
-        msg_Err( p_intf, "cannot open %s (%s)", psz_device, strerror(errno) );
+        msg_Err( p_intf, "cannot open %s (%m)", psz_device );
         free( psz_device );
         return VLC_EGENERIC;
     }
@@ -1080,7 +1072,7 @@ static int OpenDisplay( intf_thread_t *p_intf )
     /* Get framebuffer device information */
     if( ioctl( p_sys->i_fd, FBIOGET_VSCREENINFO, &p_sys->var_info ) )
     {
-        msg_Err( p_intf, "cannot get fb info (%s)", strerror(errno) );
+        msg_Err( p_intf, "cannot get fb info (%m)" );
         close( p_sys->i_fd );
         return VLC_EGENERIC;
     }
@@ -1162,7 +1154,7 @@ static int OpenDisplay( intf_thread_t *p_intf )
  *****************************************************************************/
 static void CloseDisplay( intf_thread_t *p_intf )
 {
-    intf_sys_t *p_sys = (intf_sys_t *) p_intf;
+    intf_sys_t *p_sys = p_intf->p_sys;
 
     /* Restore palette */
     if( p_sys->var_info.bits_per_pixel == 8 )
@@ -1178,7 +1170,7 @@ static void CloseDisplay( intf_thread_t *p_intf )
 
 static void Render( intf_thread_t *p_intf, struct fbosd_render_t *render )
 {
-    intf_sys_t *p_sys = (intf_sys_t*) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
 
     if( render->i_state != FBOSD_STATE_RENDER ) return;
     if( !render->psz_string ) return;
@@ -1200,7 +1192,7 @@ static void Render( intf_thread_t *p_intf, struct fbosd_render_t *render )
 #if defined(FBOSD_BLENDING)
         video_format_t fmt_in;
         memset( &fmt_in, 0, sizeof(video_format_t) );
-        p_text = RenderText( p_intf, render->psz_string, &render->text_style,
+        p_text = RenderText( p_intf, render->psz_string, render->p_text_style,
                              &fmt_in );
         if( p_text )
         {
@@ -1210,7 +1202,7 @@ static void Render( intf_thread_t *p_intf, struct fbosd_render_t *render )
             DeAllocatePicture( p_text, &fmt_in );
         }
 #else
-        p_text = RenderText( p_intf, render->psz_string, &render->text_style,
+        p_text = RenderText( p_intf, render->psz_string, render->p_text_style,
                              &p_sys->fmt_out );
         if( p_text )
         {
@@ -1224,10 +1216,10 @@ static void Render( intf_thread_t *p_intf, struct fbosd_render_t *render )
 
 static void RenderClear( intf_thread_t *p_intf, struct fbosd_render_t *render )
 {
-    intf_sys_t *p_sys = (intf_sys_t*) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
 
-    vlc_memcpy( &render->text_style, &default_text_style,
-                sizeof( text_style_t ) );
+    text_style_Delete( render->p_text_style );
+    render->p_text_style = text_style_New();
     free( render->psz_string );
     render->psz_string = NULL;
 
@@ -1241,7 +1233,7 @@ static void RenderClear( intf_thread_t *p_intf, struct fbosd_render_t *render )
 
 static bool isRendererReady( intf_thread_t *p_intf )
 {
-    intf_sys_t *p_sys = (intf_sys_t*) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
     int i;
 
     /* Check if there are more items to render */
@@ -1261,7 +1253,7 @@ static bool isRendererReady( intf_thread_t *p_intf )
  *****************************************************************************/
 static void Run( intf_thread_t *p_intf )
 {
-    intf_sys_t *p_sys = (intf_sys_t*) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
     int canc = vlc_savecancel();
 
     while( vlc_object_alive( p_intf ) )
@@ -1319,7 +1311,7 @@ static int OverlayCallback( vlc_object_t *p_this, char const *psz_cmd,
                  vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
     intf_thread_t *p_intf = (intf_thread_t *) p_this;
-    intf_sys_t *p_sys = (intf_sys_t*) p_intf->p_sys;
+    intf_sys_t *p_sys = p_intf->p_sys;
     VLC_UNUSED(oldval); VLC_UNUSED(p_data);
 
     if( !strncmp( psz_cmd, "fbosd-display", 13 ) )
@@ -1405,15 +1397,15 @@ static int OverlayCallback( vlc_object_t *p_this, char const *psz_cmd,
         }
         else if( !strncmp( psz_cmd, "fbosd-font-size", 15 ) )
         {
-            p_sys->render[i].text_style.i_font_size = newval.i_int;
+            p_sys->render[i].p_text_style->i_font_size = newval.i_int;
         }
         else if( !strncmp( psz_cmd, "fbosd-font-color", 16 ) )
         {
-            p_sys->render[i].text_style.i_font_color = newval.i_int;
+            p_sys->render[i].p_text_style->i_font_color = newval.i_int;
         }
         else if( !strncmp( psz_cmd, "fbosd-font-opacity", 18 ) )
         {
-            p_sys->render[i].text_style.i_font_alpha = 255 - newval.i_int;
+            p_sys->render[i].p_text_style->i_font_alpha = 255 - newval.i_int;
         }
         else if( !strncmp( psz_cmd, "fbosd-alpha", 11 ) )
         {