[vlc-devel] [PATCH] FreeType: Create() must lock before calling non-thread-safe FontContfig.

Jerome Forissier jerome at taodyne.com
Thu Jan 31 09:41:33 CET 2013


Fixes frequent crashes observed when starting simultaneous playback of
several videos.
---
modules/text_renderer/freetype.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index 622bb11..17a03e7 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -2711,6 +2711,9 @@ static int Create( vlc_object_t *p_this )
    p_sys->psz_fontfamily = psz_fontfamily;
#ifdef HAVE_STYLES
#ifdef HAVE_FONTCONFIG
+    static vlc_mutex_t fontconfig_lock = VLC_STATIC_MUTEX;
+    vlc_mutex_lock(&fontconfig_lock);
+
    FontConfig_BuildCache( p_filter );

    /* */
@@ -2789,6 +2792,9 @@ static int Create( vlc_object_t *p_this )

#ifdef HAVE_STYLES
    free( psz_fontfile );
+#ifdef HAVE_FONTCONFIG
+    vlc_mutex_unlock(&fontconfig_lock);
+#endif
#endif

    return VLC_SUCCESS;
@@ -2798,6 +2804,9 @@ error:
    if( p_sys->p_library ) FT_Done_FreeType( p_sys->p_library );
#ifdef HAVE_STYLES
    free( psz_fontfile );
+#ifdef HAVE_FONTCONFIG
+    vlc_mutex_unlock(&fontconfig_lock);
+#endif
#endif
    free( psz_fontfamily );
    free( p_sys );
-- 
1.8.1.2




More information about the vlc-devel mailing list