# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_osd.h>
#include <vlc_block.h>
#include <fontconfig/fontconfig.h>
#endif
+#include <assert.h>
+
typedef struct line_desc_t line_desc_t;
/*****************************************************************************
subpicture_region_t * );
static char *FontConfig_Select( FcConfig *, const char *,
bool, bool, int * );
-static int CheckIfFontBuildComplete( filter_t *p_filter );
+static int BuildDone( vlc_object_t*, const char *, vlc_value_t, vlc_value_t,
+ void* );
#endif
static line_desc_t *NewLine( int );
"fonts that will be rendered on the video. If absolute font size is set, "\
"relative size will be overriden." )
-static int pi_sizes[] = { 20, 18, 16, 12, 6 };
-static const char *ppsz_sizes_text[] = { N_("Smaller"), N_("Small"), N_("Normal"),
- N_("Large"), N_("Larger") };
+static const int pi_sizes[] = { 20, 18, 16, 12, 6 };
+static const char *const ppsz_sizes_text[] = {
+ N_("Smaller"), N_("Small"), N_("Normal"), N_("Large"), N_("Larger") };
#define YUVP_TEXT N_("Use YUVP renderer")
#define YUVP_LONGTEXT N_("This renders the font using \"paletized YUV\". " \
"This option is only needed if you want to encode into DVB subtitles" )
#define EFFECT_OUTLINE 2
#define EFFECT_OUTLINE_FAT 3
-static int pi_effects[] = { 1, 2, 3 };
-static const char *ppsz_effects_text[] = { N_("Background"),N_("Outline"),
- N_("Fat Outline") };
-static int pi_color_values[] = {
+static int const pi_effects[] = { 1, 2, 3 };
+static const char *const ppsz_effects_text[] = {
+ N_("Background"),N_("Outline"), N_("Fat Outline") };
+static const int pi_color_values[] = {
0x00000000, 0x00808080, 0x00C0C0C0, 0x00FFFFFF, 0x00800000,
0x00FF0000, 0x00FF00FF, 0x00FFFF00, 0x00808000, 0x00008000, 0x00008080,
0x0000FF00, 0x00800080, 0x00000080, 0x000000FF, 0x0000FFFF };
-static const char *ppsz_color_descriptions[] = {
+static const char *const ppsz_color_descriptions[] = {
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( _("Text renderer"));
- set_description( _("Freetype2 font renderer") );
+ set_shortname( N_("Text renderer"));
+ set_description( N_("Freetype2 font renderer") );
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_SUBPIC );
char *psz_fontfile = NULL;
int i_error;
vlc_value_t val;
- vlc_mutex_t *lock;
vlc_object_t *p_fontbuilder;
/* Allocate structure */
p_sys->p_fontconfig = NULL;
/* Check for an existing Fontbuilder thread */
- lock = var_AcquireMutex( "fontbuilder" );
+ vlc_mutex_t *lock = var_AcquireMutex( "fontbuilder" );
p_fontbuilder = vlc_object_find_name( p_filter->p_libvlc,
"fontlist builder",
FIND_CHILD );
var_Create( p_fontbuilder, "build-done", VLC_VAR_BOOL );
var_SetBool( p_fontbuilder, "build-done", false );
+ var_AddCallback( p_fontbuilder, "build-done", BuildDone, p_sys );
if( vlc_thread_create( p_fontbuilder,
"fontlist builder",
}
#ifdef HAVE_FONTCONFIG
+ vlc_mutex_t *lock = var_AcquireMutex( "fontbuilder" );
+ vlc_object_t *p_fontbuilder = vlc_object_find_name( p_filter->p_libvlc,
+ "fontlist builder", FIND_CHILD );
+ if( p_fontbuilder )
+ {
+ var_DelCallback( p_fontbuilder, "build-done", BuildDone, p_sys );
+ vlc_object_release( p_fontbuilder );
+ }
+ vlc_mutex_unlock( lock );
+
vlc_mutex_destroy( &p_sys->fontconfig_lock );
if( p_sys->p_fontconfig )
msg_Dbg( p_this, "Took %ld seconds", (long)((t2 - t1)/1000000) );
lock = var_AcquireMutex( "fontbuilder" );
+
var_SetBool( p_this, "build-done", true );
FcConfigDestroy( p_fontconfig );
return VLC_EGENERIC;
}
-static int CheckIfFontBuildComplete( filter_t *p_filter )
+static int BuildDone( vlc_object_t *p_this, const char *psz_var,
+ vlc_value_t oldval, vlc_value_t newval, void *param )
{
- filter_sys_t *p_sys = p_filter->p_sys;
- vlc_object_t *p_fb = vlc_object_find_name( p_filter->p_libvlc,
- "fontlist builder",
- FIND_CHILD );
- if( p_fb )
- {
- vlc_mutex_t *lock = var_AcquireMutex( "fontbuilder" );
- vlc_value_t val;
-
- if( VLC_SUCCESS == var_Get( p_fb, "build-done", &val ))
- {
- p_sys->b_fontconfig_ok = val.b_bool;
-
- if( p_sys->b_fontconfig_ok )
- {
- FcInit();
- p_sys->p_fontconfig = FcConfigGetCurrent();
- }
- else
- msg_Dbg( p_filter, "Font Build still not complete" );
- }
- vlc_mutex_unlock( lock );
- vlc_object_release( p_fb );
-
- return VLC_SUCCESS;
- }
- return VLC_EGENERIC;
+ (void)p_this;
+ (void)psz_var;
+ (void)oldval;
+ ((filter_sys_t*)param)->b_fontconfig_ok = newval.b_bool;
+ assert( newval.b_bool );
+ return VLC_SUCCESS;
}
static int ProcessLines( filter_t *p_filter,
/* Look for a match amongst our attachments first */
CheckForEmbeddedFont( p_sys, &p_face, p_style );
- if( !p_sys->b_fontconfig_ok )
- {
- if( VLC_EGENERIC == CheckIfFontBuildComplete( p_filter ))
- msg_Err( p_filter, "Can't find FontBuilder thread!" );
- }
-
if( ! p_face && p_sys->b_fontconfig_ok )
{
char *psz_fontfile;