[beast: 55/95] BSE: port midi receiver to Rapicorn Mutex



commit 0e982334288483a02aa2a8b80054495a1992ad4f
Author: Tim Janik <timj gnu org>
Date:   Wed Mar 20 02:41:08 2013 +0100

    BSE: port midi receiver to Rapicorn Mutex

 bse/bsemain.cc         |    1 -
 bse/bsemidireceiver.cc |   19 +++++++++----------
 bse/bsemidireceiver.hh |    4 ++--
 3 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 2ac56ec..56167d5 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -197,7 +197,6 @@ bse_init_core (void)
   /* initialize GSL components */
   gsl_init ();
   /* remaining BSE components */
-  _bse_midi_init ();
   bse_plugin_init_builtins ();
   /* initialize C wrappers around C++ generated types */
   _bse_init_c_wrappers ();
diff --git a/bse/bsemidireceiver.cc b/bse/bsemidireceiver.cc
index 3c3c90d..2e88ef7 100644
--- a/bse/bsemidireceiver.cc
+++ b/bse/bsemidireceiver.cc
@@ -14,14 +14,18 @@ namespace {
 using namespace Bse;
 using namespace Birnet;
 using namespace std;
+
 static SFI_MSG_TYPE_DEFINE (debug_midi_receiver, "midi-receiver", SFI_MSG_DEBUG, NULL);
+#undef DEBUG // FIXME
 #define DEBUG(...)              sfi_debug (debug_midi_receiver, __VA_ARGS__)
 static SFI_MSG_TYPE_DEFINE (debug_midi_events, "midi-events", SFI_MSG_DEBUG, NULL);
 #define DEBUG_EVENTS(...)       sfi_debug (debug_midi_events, __VA_ARGS__)
+
 /* --- variables --- */
-static BirnetMutex                         global_midi_mutex = { 0, };
-#define        BSE_MIDI_RECEIVER_LOCK()        GSL_SPIN_LOCK (&global_midi_mutex)
-#define        BSE_MIDI_RECEIVER_UNLOCK()      GSL_SPIN_UNLOCK (&global_midi_mutex)
+static Bse::Mutex global_midi_mutex;
+#define        BSE_MIDI_RECEIVER_LOCK()        global_midi_mutex.lock()
+#define        BSE_MIDI_RECEIVER_UNLOCK()      global_midi_mutex.unlock()
+
 /********************************************************************************
  *
  * Busy/idle states of a voice input and correspondance with table entries:
@@ -1085,16 +1089,11 @@ struct _BseMidiReceiver : public MidiReceiver {
 /* --- prototypes --- */
 static gint    midi_receiver_process_event_L  (BseMidiReceiver        *self,
                                                guint64                 max_tick_stamp);
+
 /* --- variables --- */
 static vector<BseMidiReceiver*> farm_residents;
+
 /* --- function --- */
-void
-_bse_midi_init (void)
-{
-  static gboolean initialized = FALSE;
-  g_assert (initialized++ == FALSE);
-  sfi_mutex_init (&global_midi_mutex);
-}
 static gint
 events_cmp (gconstpointer a,
             gconstpointer b,
diff --git a/bse/bsemidireceiver.hh b/bse/bsemidireceiver.hh
index 3c834c7..57ea18f 100644
--- a/bse/bsemidireceiver.hh
+++ b/bse/bsemidireceiver.hh
@@ -92,7 +92,7 @@ void             bse_midi_receiver_enter_farm              (BseMidiReceiver   *s
 void             bse_midi_receiver_farm_distribute_event   (BseMidiEvent      *event);
 void             bse_midi_receiver_farm_process_events     (guint64            max_tick_stamp);
 void             bse_midi_receiver_leave_farm              (BseMidiReceiver   *self);
-/* --- internal --- */
-void            _bse_midi_init                 (void);
+
 G_END_DECLS
+
 #endif /* __BSE_MIDI_RECEIVER_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]