X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Ffbosd.c;h=f64b4b1253f334cbecca2545dc4c598d334ff878;hb=ffbbecfb7ae45598ce967a828ee778316f515089;hp=bb32b4f8d501fb83d4c56c8575394b99eb101ba1;hpb=b46799c7b42ebefaebbdf35a97f4602aba210ef4;p=vlc diff --git a/modules/gui/fbosd.c b/modules/gui/fbosd.c index bb32b4f8d5..f64b4b1253 100644 --- a/modules/gui/fbosd.c +++ b/modules/gui/fbosd.c @@ -29,7 +29,7 @@ # include "config.h" #endif -#include +#include #include #include @@ -79,10 +79,8 @@ static void CloseTextRenderer( intf_thread_t * ); static int OverlayCallback( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * ); -static picture_t *AllocatePicture( vlc_object_t *, - video_format_t * ); -static void DeAllocatePicture( vlc_object_t *, picture_t *, - video_format_t * ); +static picture_t *AllocatePicture( video_format_t * ); +static void DeAllocatePicture( picture_t *, video_format_t * ); static void SetOverlayTransparency( intf_thread_t *, bool ); static picture_t *LoadImage( intf_thread_t *, video_format_t *, @@ -159,25 +157,27 @@ 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"), 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 ); @@ -192,32 +192,32 @@ vlc_module_begin(); add_integer_with_range( "fbosd-alpha", 255, 0, 255, NULL, ALPHA_TEXT, ALPHA_LONGTEXT, true ); - set_section( N_("Position"), NULL ); + set_section( N_("Position"), NULL ) add_integer( "fbosd-x", 0, NULL, POSX_TEXT, 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 ); - change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 ); + 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 ); add_integer( "fbosd-font-color", 0x00FFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT, false ); - change_integer_list( pi_color_values, ppsz_color_descriptions, 0 ); + change_integer_list( pi_color_values, ppsz_color_descriptions, NULL ); add_integer( "fbosd-font-size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, 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( _("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 @@ -238,7 +238,7 @@ struct fbosd_render_t char *psz_string; /* Position */ - bool b_absolute; + bool b_absolute; int i_x; int i_y; int i_pos; @@ -519,7 +519,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 +531,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; @@ -547,7 +547,7 @@ static int OpenBlending( intf_thread_t *p_intf ) VLC_FOURCC('Y','U','V','A'); 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,7 +560,7 @@ 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 ); @@ -576,7 +576,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 = @@ -590,13 +590,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,7 +611,7 @@ 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 ); @@ -623,11 +623,13 @@ static void CloseTextRenderer( intf_thread_t *p_intf ) * AllocatePicture: * allocate a picture buffer for use with the overlay fb. *****************************************************************************/ -static picture_t *AllocatePicture( vlc_object_t *p_this, - video_format_t *p_fmt ) +static picture_t *AllocatePicture( 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,46 +637,32 @@ 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; } /***************************************************************************** * DeAllocatePicture: * Deallocate a picture buffer and free all associated memory. *****************************************************************************/ -static void DeAllocatePicture( vlc_object_t *p_this, picture_t *p_pic, - video_format_t *p_fmt ) +static void DeAllocatePicture( 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 ); } /***************************************************************************** @@ -858,27 +846,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_FOURCC('T','E','X','T'); + fmt.i_aspect = 0; + 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; if( p_sys->p_text->pf_render_text ) @@ -895,29 +883,23 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string, fmt_out.i_bits_per_pixel = 32; vlc_memcpy( p_fmt, &fmt_out, sizeof(video_format_t) ); + /* FIXME not needed to copy the picture anymore no ? */ p_dest = AllocatePicture( VLC_OBJECT(p_intf), &fmt_out ); if( !p_dest ) { - if( p_region->picture.pf_release ) - p_region->picture.pf_release( &p_region->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->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->picture, + p_dest = ConvertImage( p_intf, &p_region->p_picture, &p_region->fmt, &fmt_out ); #endif - if( p_region->picture.pf_release ) - p_region->picture.pf_release( &p_region->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; } @@ -1012,8 +994,7 @@ static int Init( intf_thread_t *p_intf ) p_sys->fmt_out.i_sar_num = p_sys->fmt_out.i_sar_den = 1; /* Allocate overlay buffer */ - p_sys->p_overlay = AllocatePicture( VLC_OBJECT(p_intf), - &p_sys->fmt_out ); + p_sys->p_overlay = AllocatePicture( &p_sys->fmt_out ); if( !p_sys->p_overlay ) return VLC_EGENERIC; SetOverlayTransparency( p_intf, true ); @@ -1061,7 +1042,7 @@ static void End( intf_thread_t *p_intf ) msg_Err( p_intf, "unable to clear overlay" ); } - DeAllocatePicture( VLC_OBJECT(p_intf), p_intf->p_sys->p_overlay, + DeAllocatePicture( p_intf->p_sys->p_overlay, &p_intf->p_sys->fmt_out ); p_intf->p_sys->p_overlay = NULL; } @@ -1205,7 +1186,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 ) @@ -1221,7 +1202,7 @@ static void Render( intf_thread_t *p_intf, struct fbosd_render_t *render ) BlendPicture( p_intf, &fmt_in, &p_sys->fmt_out, p_text, p_sys->p_overlay ); msg_Dbg( p_intf, "releasing picture" ); - DeAllocatePicture( VLC_OBJECT( p_intf ), p_text, &fmt_in ); + DeAllocatePicture( p_text, &fmt_in ); } #else p_text = RenderText( p_intf, render->psz_string, &render->text_style, @@ -1230,7 +1211,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 } @@ -1276,8 +1257,9 @@ 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; + int canc = vlc_savecancel(); - while( !intf_ShouldDie( p_intf ) ) + while( vlc_object_alive( p_intf ) ) { int i; @@ -1321,13 +1303,11 @@ static void Run( intf_thread_t *p_intf ) p_sys->b_need_update = false; } - if( vlc_CPU() & CPU_CAPABILITY_FPU ) - msleep( INTF_IDLE_SLEEP ); - else - msleep( 500 ); + msleep( INTF_IDLE_SLEEP ); } End( p_intf ); + vlc_restorecancel( canc ); } static int OverlayCallback( vlc_object_t *p_this, char const *psz_cmd,