]> git.sesse.net Git - vlc/blobdiff - modules/misc/quartztext.c
Fixed infinite loop if alsa was closed before playing any audio.
[vlc] / modules / misc / quartztext.c
index c088cebcb1148930b9612cdcec49994074f34f10..ba78fef11660e126f0d2306a5fb3a28e205ad6d3 100644 (file)
 // Preamble
 //////////////////////////////////////////////////////////////////////////////
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_vout.h>
 #include <vlc_osd.h>
 #include <vlc_block.h>
@@ -65,8 +70,8 @@ static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region,
                        ATSUStyle *pp_styles );
 static ATSUStyle CreateStyle( char *psz_fontname, int i_font_size,
                               uint32_t i_font_color,
-                              vlc_bool_t b_bold, vlc_bool_t b_italic,
-                              vlc_bool_t b_uline );
+                              bool b_bold, bool b_italic,
+                              bool b_uline );
 //////////////////////////////////////////////////////////////////////////////
 // Module descriptor
 //////////////////////////////////////////////////////////////////////////////
@@ -77,8 +82,8 @@ static ATSUStyle CreateStyle( char *psz_fontname, int i_font_size,
 // override the fallback font selection used when this style information is
 // absent.
 vlc_module_begin();
-    set_shortname( _("Mac Text renderer"));
-    set_description( _("Quartz font renderer") );
+    set_shortname( N_("Mac Text renderer"));
+    set_description( N_("Quartz font renderer") );
     set_category( CAT_VIDEO );
     set_subcategory( SUBCAT_VIDEO_SUBPIC );
 
@@ -137,10 +142,7 @@ static int Create( vlc_object_t *p_this )
     // Allocate structure
     p_filter->p_sys = p_sys = malloc( sizeof( filter_sys_t ) );
     if( !p_sys )
-    {
-        msg_Err( p_filter, "out of memory" );
         return VLC_ENOMEM;
-    }
     p_sys->psz_font_name  = strdup( DEFAULT_FONT );
     p_sys->i_font_opacity = 255;
     p_sys->i_font_color   = DEFAULT_FONT_COLOR;
@@ -179,8 +181,7 @@ static void Destroy( vlc_object_t *p_this )
         free( p_sys->p_fonts );
     }
 
-    if( p_sys->psz_font_name ) free( p_sys->psz_font_name );
-
+    free( p_sys->psz_font_name );
     free( p_sys );
 }
 
@@ -391,7 +392,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
         ATSUStyle p_style = CreateStyle( p_sys->psz_font_name, i_font_size,
                                          (i_font_color & 0xffffff) |
                                          ((i_font_alpha & 0xff) << 24),
-                                         VLC_FALSE, VLC_FALSE, VLC_FALSE );
+                                         false, false, false );
         if( p_style )
         {
             RenderYUVA( p_filter, p_region_out, psz_utf16_str, i_string_length,
@@ -407,7 +408,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
 
 
 static ATSUStyle CreateStyle( char *psz_fontname, int i_font_size, uint32_t i_font_color,
-                              vlc_bool_t b_bold, vlc_bool_t b_italic, vlc_bool_t b_uline )
+                              bool b_bold, bool b_italic, bool b_uline )
 {
     ATSUStyle   p_style;
     OSStatus    status;
@@ -545,8 +546,8 @@ static int PeekFont( font_stack_t **p_font, char **psz_name, int *i_size,
 }
 
 static ATSUStyle GetStyleFromFontStack( filter_sys_t *p_sys,
-        font_stack_t **p_fonts, vlc_bool_t b_bold, vlc_bool_t b_italic,
-        vlc_bool_t b_uline )
+        font_stack_t **p_fonts, bool b_bold, bool b_italic,
+        bool b_uline )
 {
     ATSUStyle   p_style = NULL;
 
@@ -594,7 +595,7 @@ static int HandleFontAttributes( xml_reader_t *p_xml_reader,
         {
             if( !strcasecmp( "face", psz_name ) )
             {
-                if( psz_fontname ) free( psz_fontname );
+                free( psz_fontname );
                 psz_fontname = strdup( psz_value );
             }
             else if( !strcasecmp( "size", psz_name ) )
@@ -658,9 +659,9 @@ static int ProcessNodes( filter_t *p_filter,
 
     char *psz_node  = NULL;
 
-    vlc_bool_t b_italic = VLC_FALSE;
-    vlc_bool_t b_bold   = VLC_FALSE;
-    vlc_bool_t b_uline  = VLC_FALSE;
+    bool b_italic = false;
+    bool b_bold   = false;
+    bool b_uline  = false;
 
     if( VLC_SUCCESS == var_Get( p_filter, "scale", &val ))
         i_scale = val.i_int;
@@ -674,11 +675,11 @@ static int ProcessNodes( filter_t *p_filter,
                    ((p_font_style->i_font_alpha & 0xff) << 24) );
 
         if( p_font_style->i_style_flags & STYLE_BOLD )
-            b_bold = VLC_TRUE;
+            b_bold = true;
         if( p_font_style->i_style_flags & STYLE_ITALIC )
-            b_italic = VLC_TRUE;
+            b_italic = true;
         if( p_font_style->i_style_flags & STYLE_UNDERLINE )
-            b_uline = VLC_TRUE;
+            b_uline = true;
     }
     else
     {
@@ -704,11 +705,11 @@ static int ProcessNodes( filter_t *p_filter,
                     if( !strcasecmp( "font", psz_node ) )
                         PopFont( &p_fonts );
                     else if( !strcasecmp( "b", psz_node ) )
-                        b_bold   = VLC_FALSE;
+                        b_bold   = false;
                     else if( !strcasecmp( "i", psz_node ) )
-                        b_italic = VLC_FALSE;
+                        b_italic = false;
                     else if( !strcasecmp( "u", psz_node ) )
-                        b_uline  = VLC_FALSE;
+                        b_uline  = false;
 
                     free( psz_node );
                 }
@@ -720,11 +721,11 @@ static int ProcessNodes( filter_t *p_filter,
                     if( !strcasecmp( "font", psz_node ) )
                         rv = HandleFontAttributes( p_xml_reader, &p_fonts, i_scale );
                     else if( !strcasecmp( "b", psz_node ) )
-                        b_bold = VLC_TRUE;
+                        b_bold = true;
                     else if( !strcasecmp( "i", psz_node ) )
-                        b_italic = VLC_TRUE;
+                        b_italic = true;
                     else if( !strcasecmp( "u", psz_node ) )
-                        b_uline = VLC_TRUE;
+                        b_uline = true;
                     else if( !strcasecmp( "br", psz_node ) )
                     {
                         uint32_t i_string_length;
@@ -821,13 +822,13 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
     p_sub = stream_MemoryNew( VLC_OBJECT(p_filter),
                               (uint8_t *) p_region_in->psz_html,
                               strlen( p_region_in->psz_html ),
-                              VLC_TRUE );
+                              true );
     if( p_sub )
     {
         p_xml = xml_Create( p_filter );
         if( p_xml )
         {
-            vlc_bool_t b_karaoke = VLC_FALSE;
+            bool b_karaoke = false;
 
             p_xml_reader = xml_ReaderCreate( p_xml, p_sub );
             if( p_xml_reader )
@@ -842,12 +843,12 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
                         /* We're going to have to render the text a number
                          * of times to show the progress marker on the text.
                          */
-                        var_SetBool( p_filter, "text-rerender", VLC_TRUE );
-                        b_karaoke = VLC_TRUE;
+                        var_SetBool( p_filter, "text-rerender", true );
+                        b_karaoke = true;
                     }
                     else if( !strcasecmp( "text", psz_node ) )
                     {
-                        b_karaoke = VLC_FALSE;
+                        b_karaoke = false;
                     }
                     else
                     {
@@ -1028,7 +1029,7 @@ static offscreen_bitmap_t *Compose( int i_text_align, UniChar *psz_utf16_str, ui
                     // you move down the page
                     y -= ascent;
 
-                    // Set the outlining for this line to be dependant on the size of the line -
+                    // Set the outlining for this line to be dependent on the size of the line -
                     // make it about 5% of the ascent, with a minimum at 1.0
                     float f_thickness = FixedToFloat( ascent ) * 0.05;
                     CGContextSetLineWidth( p_context, (( f_thickness > 1.0 ) ? 1.0 : f_thickness ));