CONFIG_DIR = /etc
#CONFIG_DIR = $(PREFIX)/etc
-# Pick your sound support. The most featureful form of sound support is
+# Pick your sound support. The most featureful form of sound support is
# through libao. Comment all of these out if you don't want sound.
#
#SOUND = none
##########################################################################
-# The configuration options below are intended mainly for older flavors
-# of Unix. For Linux, BSD, and Solaris released since 2003, you can
+# The configuration options below are intended mainly for older flavors
+# of Unix. For Linux, BSD, and Solaris released since 2003, you can
# ignore this section.
##########################################################################
CURSES = -lncurses
#CURSES = -lcurses
-# Just in case your operating system keeps its user-added header files
+# Just in case your operating system keeps its user-added header files
# somewhere unusual...
#
#INCL = -I/usr/local/include
#NO_MEMMOVE = yes
# Default sample rate for sound effects.
-# All modern sound interfaces can be expected to support 44100 Hz sample
-# rates. Earlier ones, particularly ones in Sun 4c workstations support
+# All modern sound interfaces can be expected to support 44100 Hz sample
+# rates. Earlier ones, particularly ones in Sun 4c workstations support
# only up to 8000 Hz.
SAMPLERATE = 44100
$(CURSES_DIR)/ux_blorb.o \
$(CURSES_DIR)/ux_audio.o \
$(CURSES_DIR)/ux_resource.o \
- $(CURSES_DIR)/ux_audio_none.o
+ $(CURSES_DIR)/ux_audio_none.o \
+ $(CURSES_DIR)/ux_locks.o
DUMB_DIR = $(SRCDIR)/dumb
DUMB_TARGET = $(SRCDIR)/frotz_dumb.a
#endif
#include "ux_frotz.h"
+#include "ux_locks.h"
#ifndef NO_SOUND
float *musicbuffer;
int musicsamples;
-int musicnum;
/*
while(pthread_kill(playaiff_id, 0) == 0);
}
- if (music_playing && (number == musicnum || number == 0)) {
- music_playing = FALSE;
+ if (get_music_playing() && (number == get_musicnum () || number == 0)) {
+ set_music_playing(false);
while(pthread_kill(playmusic_id, 0) == 0);
}
* handled here.
*
* This function should be able to play OGG chunks, but because of a bug
- * or oversight in Libsndfile, that library is incapable of playing OGG
+ * or oversight in Libsndfile, that library is incapable of playing OGG
* data which are embedded in a larger file.
*
*/
EFFECT myeffect = *raw_effect;
- musicnum = myeffect.number;
+ set_musicnum(myeffect.number);
filestart = ftell(myeffect.fp);
fseek(myeffect.fp, myeffect.result.data.startpos, SEEK_SET);
--- /dev/null
+
+#include <pthread.h>
+#include <stdbool.h>
+
+#include "ux_locks.h"
+
+static bool music_playing = false;
+static pthread_mutex_t music_playing_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static int musicnum = 0;
+static pthread_mutex_t musicnum_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+bool
+get_music_playing (void)
+{
+ bool value;
+
+ pthread_mutex_lock (&music_playing_mutex);
+ value = music_playing;
+ pthread_mutex_unlock (&music_playing_mutex);
+ return value;
+}
+
+
+bool
+set_music_playing (bool new_value)
+{
+ bool old_value;
+
+ pthread_mutex_lock (&music_playing_mutex);
+ old_value = music_playing;
+ music_playing = new_value;
+ pthread_mutex_unlock (&music_playing_mutex);
+ return old_value;
+}
+
+
+int
+get_musicnum (void)
+{
+ int value;
+
+ pthread_mutex_lock (&musicnum_mutex);
+ value = musicnum;
+ pthread_mutex_unlock (&musicnum_mutex);
+ return value;
+}
+
+
+int
+set_musicnum (int new_value)
+{
+ int old_value;
+
+ pthread_mutex_lock (&musicnum_mutex);
+ old_value = musicnum;
+ musicnum = new_value;
+ pthread_mutex_unlock (&musicnum_mutex);
+ return old_value;
+}
--- /dev/null
+bool get_music_playing (void);
+bool set_music_playing (bool new_value);
+
+int get_musicnum (void);
+int set_musicnum (int new_value);