#include <stdlib.h>
#include <string.h>
#include <locale.h>
+#include <pthread.h>
/** Bit pattern used internally to indicated representations available.
int length;
mlt_destructor destructor;
mlt_serialiser serialiser;
+
+ pthread_mutex_t mutex;
};
/** Construct a property and initialize it
self->length = 0;
self->destructor = NULL;
self->serialiser = NULL;
+ pthread_mutex_init( &self->mutex, NULL );
}
return self;
}
#else
const char *localename = locale->__names[ LC_NUMERIC ];
#endif
+ // Protect damaging the global locale from a temporary locale on another thread.
+ pthread_mutex_lock( &self->mutex );
+
+ // Get the current locale
const char *orig_localename = setlocale( LC_NUMERIC, NULL );
// Set the new locale
}
// Restore the current locale
setlocale( LC_NUMERIC, orig_localename );
+ pthread_mutex_unlock( &self->mutex );
}
// Return the string (may be NULL)
void mlt_property_close( mlt_property self )
{
mlt_property_clear( self );
+ pthread_mutex_destroy( &self->mutex );
free( self );
}