openbsd-ports/audio/soundtracker/patches/patch-app_time-buffer_c
espie 2d6f9f9727 soundtracker, from maintainer.
A music editing program, in the grand tradition of amiga tracker programs.
2002-02-05 18:04:10 +00:00

76 lines
1.6 KiB
Plaintext

$OpenBSD: patch-app_time-buffer_c,v 1.1.1.1 2002/02/05 18:04:10 espie Exp $
--- app/time-buffer.c.orig Mon Feb 4 04:06:19 2002
+++ app/time-buffer.c Mon Feb 4 04:39:34 2002
@@ -21,13 +21,14 @@
#include "time-buffer.h"
+#include <pthread.h>
#include <glib.h>
/* This implementation of the time buffer interface might be rather
suboptimal... */
struct time_buffer {
- GMutex *mutex;
+ pthread_mutex_t mutex;
GList *list;
};
@@ -42,7 +43,9 @@ time_buffer_new (double maxtimedelta)
time_buffer *t = g_new(time_buffer, 1);
if(t) {
- t->mutex = g_mutex_new();
+ if (pthread_mutex_init(&t->mutex, NULL) != 0) {
+ return NULL;
+ }
t->list = NULL;
}
@@ -54,7 +57,7 @@ time_buffer_destroy (time_buffer *t)
{
if(t) {
g_list_free(t->list);
- g_mutex_free(t->mutex);
+ pthread_mutex_destroy(&t->mutex);
g_free(t);
}
}
@@ -75,10 +78,10 @@ time_buffer_add (time_buffer *t,
{
time_buffer_item *a = item;
- g_mutex_lock(t->mutex);
+ pthread_mutex_lock(&t->mutex);
a->time = time;
t->list = g_list_append(t->list, a);
- g_mutex_unlock(t->mutex);
+ pthread_mutex_unlock(&t->mutex);
return TRUE;
}
@@ -91,11 +94,11 @@ time_buffer_get (time_buffer *t,
void *result = NULL;
GList *list;
- g_mutex_lock(t->mutex);
+ pthread_mutex_lock(&t->mutex);
l = g_list_length(t->list);
if(l == 0) {
- g_mutex_unlock(t->mutex);
+ pthread_mutex_unlock(&t->mutex);
return NULL;
}
@@ -114,7 +117,7 @@ time_buffer_get (time_buffer *t,
result = t->list->data;
- g_mutex_unlock(t->mutex);
+ pthread_mutex_unlock(&t->mutex);
return result;
}