Blob Blame History Raw
diff -Nurb --strip-trailing-cr xmp-3.4.0-orig/src/plugin/audacious3.c xmp-3.4.0/src/plugin/audacious3.c
--- xmp-3.4.0-orig/src/plugin/audacious3.c	2012-06-15 13:51:40.650150003 +0200
+++ xmp-3.4.0/src/plugin/audacious3.c	2012-06-15 15:34:22.493836696 +0200
@@ -31,6 +31,7 @@
 static GCond *seek_cond;
 static gint jumpToTime = -1;
 static gboolean stop_flag = FALSE;
+static GMutex *probe_mutex;
 
 static xmp_context ctx;
 
@@ -175,6 +176,7 @@
 	xmp_drv_register(&drv_smix);
 	ctx = xmp_create_context();
 
+    probe_mutex = g_mutex_new();
 	jumpToTime = -1;
 	seek_mutex = g_mutex_new();
 	seek_cond = g_cond_new();
@@ -205,6 +207,7 @@
 {
 	g_cond_free(seek_cond);
 	g_mutex_free(seek_mutex);
+    g_mutex_free(probe_mutex);
 	xmp_free_context(ctx);
 }
 
@@ -233,6 +236,7 @@
 	struct xmp_module_info mi;
 	struct xmp_options *opt;
 
+	g_mutex_lock(probe_mutex);
 	_D("filename = %s", filename);
 	strip_vfs(filename);		/* Sorry, no VFS support */
 
@@ -240,16 +244,18 @@
 	opt = xmp_get_options(ctx);
 	opt->skipsmp = 1;	/* don't load samples */
 	len = xmp_load_module(ctx, filename);
-	g_free(filename);
 
 	if (len < 0) {
+        g_free(filename);
 		xmp_free_context(ctx);
+        g_mutex_unlock(probe_mutex);
 		return NULL;
 	}
 
 	xmp_get_module_info(ctx, &mi);
 
 	tuple = tuple_new_from_filename(filename);
+    g_free(filename);
 	tuple_set_str(tuple, FIELD_TITLE, NULL, mi.name);
 	tuple_set_str(tuple, FIELD_CODEC, NULL, mi.type);
 	tuple_set_int(tuple, FIELD_LENGTH, NULL, len);
@@ -257,6 +263,7 @@
 	xmp_release_module(ctx);
 	xmp_free_context(ctx);
 
+    g_mutex_unlock(probe_mutex);
 	return tuple;
 }
 
@@ -340,7 +347,6 @@
 	_D("*** loading: %s", filename);
 
 	lret =  xmp_load_module(ctx, filename);
-	g_free(filename);
 
 	if (lret < 0) {
 		xmp_close_audio(ctx);
@@ -351,6 +357,7 @@
 	xmp_get_module_info(ctx, &xmp_cfg.mod_info);
 
 	tuple = tuple_new_from_filename(filename);
+	g_free(filename);
 	tuple_set_str(tuple, FIELD_TITLE, NULL, xmp_cfg.mod_info.name);
 	tuple_set_str(tuple, FIELD_CODEC, NULL, xmp_cfg.mod_info.type);
 	tuple_set_int(tuple, FIELD_LENGTH, NULL, lret);