]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/marq.c
Added and used text_style_* methods.
[vlc] / modules / video_filter / marq.c
index 00bbd2e90890c091b898cbb7666498bcc9a6ba6c..1d8388b7a7c3c0a2b57f0903aad70a98e224f819 100644 (file)
@@ -69,6 +69,8 @@ static const char *const ppsz_color_descriptions[] = {
  *****************************************************************************/
 struct filter_sys_t
 {
+    vlc_mutex_t lock;
+
     int i_xoff, i_yoff;  /* offsets for the display string in the video window */
     int i_pos; /* permit relative positioning (top, bottom, left, right, center) */
     int i_timeout;
@@ -201,8 +203,8 @@ static int CreateFilter( vlc_object_t *p_this )
     if( p_sys == NULL )
         return VLC_ENOMEM;
 
-    p_sys->p_style = malloc( sizeof( text_style_t ) );
-    memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ) );
+    vlc_mutex_init( &p_sys->lock );
+    p_sys->p_style = text_style_New();
 
     config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                        p_filter->p_cfg );
@@ -239,7 +241,7 @@ static void DestroyFilter( vlc_object_t *p_this )
     filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    free( p_sys->p_style );
+    text_style_Delete( p_sys->p_style );
     free( p_sys->psz_marquee );
 
     /* Delete the marquee variables */
@@ -255,6 +257,7 @@ static void DestroyFilter( vlc_object_t *p_this )
     DEL_VAR( "marq-opacity" );
     DEL_VAR( "marq-size" );
 
+    vlc_mutex_destroy( &p_sys->lock );
     free( p_sys );
 }
 
@@ -269,10 +272,9 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     subpicture_t *p_spu = NULL;
     video_format_t fmt;
 
+    vlc_mutex_lock( &p_sys->lock );
     if( p_sys->last_time + p_sys->i_refresh > date )
-        return NULL;
-
-    vlc_object_lock( p_filter );
+        goto out;
     if( p_sys->b_need_update == false )
         goto out;
 
@@ -320,10 +322,10 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     p_spu->p_region->i_x = p_sys->i_xoff;
     p_spu->p_region->i_y = p_sys->i_yoff;
 
-    p_spu->p_region->p_style = p_sys->p_style;
+    p_spu->p_region->p_style = text_style_Duplicate( p_sys->p_style );
 
 out:
-    vlc_object_unlock( p_filter );
+    vlc_mutex_unlock( &p_sys->lock );
     return p_spu;
 }
 
@@ -334,10 +336,12 @@ static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var,
                             vlc_value_t oldval, vlc_value_t newval,
                             void *p_data )
 {
-    VLC_UNUSED(oldval);
     filter_sys_t *p_sys = (filter_sys_t *) p_data;
 
-    vlc_object_lock( p_this );
+    VLC_UNUSED(oldval);
+    VLC_UNUSED(p_this);
+
+    vlc_mutex_lock( &p_sys->lock );
     if( !strncmp( psz_var, "marq-marquee", 7 ) )
     {
         free( p_sys->psz_marquee );
@@ -378,6 +382,6 @@ static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var,
         p_sys->i_xoff = -1;       /* force to relative positioning */
     }
     p_sys->b_need_update = true;
-    vlc_object_unlock( p_this );
+    vlc_mutex_unlock( &p_sys->lock );
     return VLC_SUCCESS;
 }