]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_property.c
Add mutex locks to mlt_property_anim_get functions.
[mlt] / src / framework / mlt_property.c
index d9932dab3111703eaf12b1351ebd2f7657f69b34..4b5f4cc38b7fbb454545bb4aa6e7afcb0940f417 100644 (file)
@@ -462,8 +462,8 @@ static double mlt_property_atof( const char *value, double fps, locale_t locale
 #if defined(__GLIBC__) || defined(__DARWIN__)
                if ( locale )
                        result = strtod_l( value, &end, locale );
+        else
 #endif
-               else
                        result = strtod( value, &end );
                if ( end && end[0] == '%' )
                        result /= 100.0;
@@ -774,10 +774,10 @@ void mlt_property_pass( mlt_property self, mlt_property that )
                self->destructor = free;
                self->serialiser = that->serialiser;
        }
-       else if ( self->types & mlt_prop_data && self->serialiser != NULL )
+       else if ( self->types & mlt_prop_data && that->serialiser != NULL )
        {
                self->types = mlt_prop_string;
-               self->prop_string = self->serialiser( self->data, self->length );
+               self->prop_string = that->serialiser( that->data, that->length );
        }
        pthread_mutex_unlock( &self->mutex );
 }
@@ -1125,9 +1125,11 @@ static void refresh_animation( mlt_property self, double fps, locale_t locale, i
                else
                {
                        mlt_animation_set_length( self->animation, length );
+                       pthread_mutex_lock( &self->mutex );
                        self->types |= mlt_prop_data;
                        self->data = self->animation;
                        self->serialiser = (mlt_serialiser) mlt_animation_serialize;
+                       pthread_mutex_unlock( &self->mutex );
                }
        }
        else if ( self->prop_string )
@@ -1150,6 +1152,7 @@ static void refresh_animation( mlt_property self, double fps, locale_t locale, i
 
 double mlt_property_anim_get_double( mlt_property self, double fps, locale_t locale, int position, int length )
 {
+       pthread_mutex_lock( &self->mutex );
        double result;
        if ( self->animation || ( ( self->types & mlt_prop_string ) && self->prop_string ) )
        {
@@ -1166,6 +1169,7 @@ double mlt_property_anim_get_double( mlt_property self, double fps, locale_t loc
        {
                result = mlt_property_get_double( self, fps, locale );
        }
+       pthread_mutex_unlock( &self->mutex );
        return result;
 }
 
@@ -1183,6 +1187,7 @@ double mlt_property_anim_get_double( mlt_property self, double fps, locale_t loc
 
 int mlt_property_anim_get_int( mlt_property self, double fps, locale_t locale, int position, int length )
 {
+       pthread_mutex_lock( &self->mutex );
        int result;
        if ( self->animation || ( ( self->types & mlt_prop_string ) && self->prop_string ) )
        {
@@ -1199,6 +1204,7 @@ int mlt_property_anim_get_int( mlt_property self, double fps, locale_t locale, i
        {
                result = mlt_property_get_int( self, fps, locale );
        }
+       pthread_mutex_unlock( &self->mutex );
        return result;
 }
 
@@ -1216,6 +1222,7 @@ int mlt_property_anim_get_int( mlt_property self, double fps, locale_t locale, i
 
 char* mlt_property_anim_get_string( mlt_property self, double fps, locale_t locale, int position, int length )
 {
+       pthread_mutex_lock( &self->mutex );
        char *result;
        if ( self->animation || ( ( self->types & mlt_prop_string ) && self->prop_string ) )
        {
@@ -1226,14 +1233,12 @@ char* mlt_property_anim_get_string( mlt_property self, double fps, locale_t loca
                        refresh_animation( self, fps, locale, length );
                mlt_animation_get_item( self->animation, &item, position );
 
-               pthread_mutex_lock( &self->mutex );
                if ( self->prop_string )
                        free( self->prop_string );
                self->prop_string = mlt_property_get_string_l( item.property, locale );
                if ( self->prop_string )
                        self->prop_string = strdup( self->prop_string );
                self->types |= mlt_prop_string;
-               pthread_mutex_unlock( &self->mutex );
 
                result = self->prop_string;
                mlt_property_close( item.property );
@@ -1242,6 +1247,7 @@ char* mlt_property_anim_get_string( mlt_property self, double fps, locale_t loca
        {
                result = mlt_property_get_string_l( self, locale );
        }
+       pthread_mutex_unlock( &self->mutex );
        return result;
 }
 
@@ -1444,8 +1450,8 @@ mlt_rect mlt_property_get_rect( mlt_property self, locale_t locale )
 #if defined(__GLIBC__) || defined(__DARWIN__)
                        if ( locale )
                                temp = strtod_l( value, &p, locale );
+            else
 #endif
-                       else
                                temp = strtod( value, &p );
                        if ( p != value )
                        {
@@ -1519,6 +1525,7 @@ int mlt_property_anim_set_rect( mlt_property self, mlt_rect value, double fps, l
 
 mlt_rect mlt_property_anim_get_rect( mlt_property self, double fps, locale_t locale, int position, int length )
 {
+       pthread_mutex_lock( &self->mutex );
        mlt_rect result;
        if ( self->animation || ( ( self->types & mlt_prop_string ) && self->prop_string ) )
        {
@@ -1536,5 +1543,6 @@ mlt_rect mlt_property_anim_get_rect( mlt_property self, double fps, locale_t loc
        {
                result = mlt_property_get_rect( self, locale );
        }
+       pthread_mutex_unlock( &self->mutex );
        return result;
 }