openbsd-ports/audio/soundtracker/patches/patch-app_event-waiter_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

90 lines
1.9 KiB
Plaintext

$OpenBSD: patch-app_event-waiter_c,v 1.1.1.1 2002/02/05 18:04:10 espie Exp $
--- app/event-waiter.c.orig Mon Feb 4 04:24:29 2002
+++ app/event-waiter.c Mon Feb 4 04:37:54 2002
@@ -22,9 +22,10 @@
#include "event-waiter.h"
#include <glib.h>
+#include <pthread.h>
struct event_waiter {
- GMutex *mutex;
+ pthread_mutex_t mutex;
int counter;
double time;
};
@@ -35,7 +36,9 @@ event_waiter_new (void)
event_waiter *e = g_new(event_waiter, 1);
if(e) {
- e->mutex = g_mutex_new();
+ if (pthread_mutex_init(&e->mutex, NULL) != 0) {
+ return NULL;
+ }
event_waiter_reset(e);
}
@@ -46,7 +49,7 @@ void
event_waiter_destroy (event_waiter *e)
{
if(e) {
- g_mutex_free(e->mutex);
+ pthread_mutex_destroy(&e->mutex);
g_free(e);
}
}
@@ -56,10 +59,10 @@ event_waiter_reset (event_waiter *e)
{
g_assert(e);
- g_mutex_lock(e->mutex);
+ pthread_mutex_lock(&e->mutex);
e->counter = 0;
e->time = 0.0;
- g_mutex_unlock(e->mutex);
+ pthread_mutex_unlock(&e->mutex);
}
void
@@ -67,9 +70,9 @@ event_waiter_start (event_waiter *e)
{
g_assert(e);
- g_mutex_lock(e->mutex);
+ pthread_mutex_lock(&e->mutex);
e->counter++;
- g_mutex_unlock(e->mutex);
+ pthread_mutex_unlock(&e->mutex);
}
void
@@ -78,14 +81,14 @@ event_waiter_confirm (event_waiter *e,
{
g_assert(e);
- g_mutex_lock(e->mutex);
+ pthread_mutex_lock(&e->mutex);
if(e->counter > 0) {
e->counter--;
}
if(readytime >= e->time) {
e->time = readytime;
}
- g_mutex_unlock(e->mutex);
+ pthread_mutex_unlock(&e->mutex);
}
gboolean
@@ -96,9 +99,9 @@ event_waiter_ready (event_waiter *e,
g_assert(e);
- g_mutex_lock(e->mutex);
+ pthread_mutex_lock(&e->mutex);
result = (e->counter == 0 && currenttime >= e->time);
- g_mutex_unlock(e->mutex);
+ pthread_mutex_unlock(&e->mutex);
return result;
}