1
|
diff --git a/src/audacious/adder.c b/src/audacious/adder.c
|
2
|
index 0e5379d..37cc5e6 100644
|
3
|
--- a/src/audacious/adder.c
|
4
|
+++ b/src/audacious/adder.c
|
5
|
@@ -18,7 +18,6 @@
|
6
|
*/
|
7
|
|
8
|
#include <dirent.h>
|
9
|
-#include <pthread.h>
|
10
|
#include <string.h>
|
11
|
#include <sys/stat.h>
|
12
|
|
13
|
@@ -54,10 +53,10 @@ static GList * add_tasks = NULL;
|
14
|
static GList * add_results = NULL;
|
15
|
static int current_playlist_id = -1;
|
16
|
|
17
|
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
18
|
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
|
19
|
+static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
20
|
+static GCond cond;
|
21
|
static bool_t add_quit;
|
22
|
-static pthread_t add_thread;
|
23
|
+static GThread *add_thread;
|
24
|
static int add_source = 0;
|
25
|
|
26
|
static int status_source = 0;
|
27
|
@@ -98,7 +97,7 @@ static bool_t status_cb (void * unused)
|
28
|
gtk_widget_destroyed, & status_window);
|
29
|
}
|
30
|
|
31
|
- pthread_mutex_lock (& mutex);
|
32
|
+ g_static_mutex_lock (& mutex);
|
33
|
|
34
|
char scratch[128];
|
35
|
snprintf (scratch, sizeof scratch, dngettext (PACKAGE, "%d file found",
|
36
|
@@ -115,13 +114,13 @@ static bool_t status_cb (void * unused)
|
37
|
gtk_label_set_text ((GtkLabel *) status_count_label, scratch);
|
38
|
}
|
39
|
|
40
|
- pthread_mutex_unlock (& mutex);
|
41
|
+ g_static_mutex_unlock (& mutex);
|
42
|
return TRUE;
|
43
|
}
|
44
|
|
45
|
static void status_update (const char * filename, int found)
|
46
|
{
|
47
|
- pthread_mutex_lock (& mutex);
|
48
|
+ g_static_mutex_lock (& mutex);
|
49
|
|
50
|
snprintf (status_path, sizeof status_path, "%s", filename);
|
51
|
status_count = found;
|
52
|
@@ -129,7 +128,7 @@ static void status_update (const char * filename, int found)
|
53
|
if (! status_source)
|
54
|
status_source = g_timeout_add (250, status_cb, NULL);
|
55
|
|
56
|
- pthread_mutex_unlock (& mutex);
|
57
|
+ g_static_mutex_unlock (& mutex);
|
58
|
}
|
59
|
|
60
|
static void status_done_locked (void)
|
61
|
@@ -397,7 +396,7 @@ static void add_generic (char * filename, Tuple * tuple,
|
62
|
|
63
|
static bool_t add_finish (void * unused)
|
64
|
{
|
65
|
- pthread_mutex_lock (& mutex);
|
66
|
+ g_static_mutex_lock (& mutex);
|
67
|
|
68
|
while (add_results)
|
69
|
{
|
70
|
@@ -449,21 +448,23 @@ static bool_t add_finish (void * unused)
|
71
|
if (! add_tasks)
|
72
|
status_done_locked ();
|
73
|
|
74
|
- pthread_mutex_unlock (& mutex);
|
75
|
+ g_static_mutex_unlock (& mutex);
|
76
|
|
77
|
hook_call ("playlist add complete", NULL);
|
78
|
return FALSE;
|
79
|
}
|
80
|
|
81
|
-static void * add_worker (void * unused)
|
82
|
+static gpointer add_worker (gpointer unused)
|
83
|
{
|
84
|
- pthread_mutex_lock (& mutex);
|
85
|
+ g_static_mutex_lock (& mutex);
|
86
|
|
87
|
while (! add_quit)
|
88
|
{
|
89
|
if (! add_tasks)
|
90
|
{
|
91
|
- pthread_cond_wait (& cond, & mutex);
|
92
|
+ GMutex *gmutex = g_static_mutex_get_mutex(& mutex);
|
93
|
+
|
94
|
+ g_cond_wait (& cond, gmutex);
|
95
|
continue;
|
96
|
}
|
97
|
|
98
|
@@ -471,7 +472,7 @@ static void * add_worker (void * unused)
|
99
|
add_tasks = g_list_delete_link (add_tasks, add_tasks);
|
100
|
|
101
|
current_playlist_id = task->playlist_id;
|
102
|
- pthread_mutex_unlock (& mutex);
|
103
|
+ g_static_mutex_unlock (& mutex);
|
104
|
|
105
|
AddResult * result = add_result_new (task->playlist_id, task->at,
|
106
|
task->play);
|
107
|
@@ -493,7 +494,7 @@ static void * add_worker (void * unused)
|
108
|
|
109
|
add_task_free (task);
|
110
|
|
111
|
- pthread_mutex_lock (& mutex);
|
112
|
+ g_static_mutex_lock (& mutex);
|
113
|
current_playlist_id = -1;
|
114
|
|
115
|
add_results = g_list_append (add_results, result);
|
116
|
@@ -502,25 +503,25 @@ static void * add_worker (void * unused)
|
117
|
add_source = g_timeout_add (0, add_finish, NULL);
|
118
|
}
|
119
|
|
120
|
- pthread_mutex_unlock (& mutex);
|
121
|
+ g_static_mutex_unlock (& mutex);
|
122
|
return NULL;
|
123
|
}
|
124
|
|
125
|
void adder_init (void)
|
126
|
{
|
127
|
- pthread_mutex_lock (& mutex);
|
128
|
+ g_static_mutex_lock (& mutex);
|
129
|
add_quit = FALSE;
|
130
|
- pthread_create (& add_thread, NULL, add_worker, NULL);
|
131
|
- pthread_mutex_unlock (& mutex);
|
132
|
+ add_thread = g_thread_new (NULL, add_worker, NULL);
|
133
|
+ g_static_mutex_unlock (& mutex);
|
134
|
}
|
135
|
|
136
|
void adder_cleanup (void)
|
137
|
{
|
138
|
- pthread_mutex_lock (& mutex);
|
139
|
+ g_static_mutex_lock (& mutex);
|
140
|
add_quit = TRUE;
|
141
|
- pthread_cond_broadcast (& cond);
|
142
|
- pthread_mutex_unlock (& mutex);
|
143
|
- pthread_join (add_thread, NULL);
|
144
|
+ g_cond_broadcast (& cond);
|
145
|
+ g_static_mutex_unlock (& mutex);
|
146
|
+ g_thread_join (add_thread);
|
147
|
|
148
|
g_list_free_full (add_tasks, (GDestroyNotify) add_task_free);
|
149
|
add_tasks = NULL;
|
150
|
@@ -562,15 +563,15 @@ void playlist_entry_insert_filtered (int playlist, int at,
|
151
|
|
152
|
AddTask * task = add_task_new (playlist_id, at, play, filenames, tuples, filter, user);
|
153
|
|
154
|
- pthread_mutex_lock (& mutex);
|
155
|
+ g_static_mutex_lock (& mutex);
|
156
|
add_tasks = g_list_append (add_tasks, task);
|
157
|
- pthread_cond_broadcast (& cond);
|
158
|
- pthread_mutex_unlock (& mutex);
|
159
|
+ g_cond_broadcast (& cond);
|
160
|
+ g_static_mutex_unlock (& mutex);
|
161
|
}
|
162
|
|
163
|
bool_t playlist_add_in_progress (int playlist)
|
164
|
{
|
165
|
- pthread_mutex_lock (& mutex);
|
166
|
+ g_static_mutex_lock (& mutex);
|
167
|
|
168
|
if (playlist >= 0)
|
169
|
{
|
170
|
@@ -597,10 +598,10 @@ bool_t playlist_add_in_progress (int playlist)
|
171
|
goto YES;
|
172
|
}
|
173
|
|
174
|
- pthread_mutex_unlock (& mutex);
|
175
|
+ g_static_mutex_unlock (& mutex);
|
176
|
return FALSE;
|
177
|
|
178
|
YES:
|
179
|
- pthread_mutex_unlock (& mutex);
|
180
|
+ g_static_mutex_unlock (& mutex);
|
181
|
return TRUE;
|
182
|
}
|