Use Glib::Threads::RecMutex rather than Glib::RecMutex where
authorCarl Hetherington <carl@carlh.net>
Thu, 26 Apr 2012 08:44:06 +0000 (08:44 +0000)
committerCarl Hetherington <carl@carlh.net>
Thu, 26 Apr 2012 08:44:06 +0000 (08:44 +0000)
available; the latter is deprecated and there is some
evidence to suggest that it is broken on some glibmm
versions (around 2.31.0 ish) See, for example
https://github.com/lightspark/lightspark/issues/168

git-svn-id: svn://localhost/ardour2/branches/3.0@12094 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/playlist.h
libs/ardour/audio_playlist.cc
libs/ardour/midi_playlist.cc
wscript

index 3648ceda8f124d332eb40d9f02444f0cfd468c6a..d57df6999b5fe32f9910f9dc2b993861d00b716b 100644 (file)
@@ -31,7 +31,9 @@
 #include <sys/stat.h>
 
 #include <glib.h>
-
+#ifdef HAVE_GLIB_THREADS_RECMUTEX
+#include <glibmm/threads.h>
+#endif
 
 #include "pbd/undo.h"
 #include "pbd/stateful.h"
@@ -253,7 +255,11 @@ public:
        int             _sort_id;
        mutable gint    block_notifications;
        mutable gint    ignore_state_changes;
+#ifdef HAVE_GLIB_THREADS_RECMUTEX
+       mutable Glib::Threads::RecMutex region_lock;
+#else
        mutable Glib::RecMutex region_lock;
+#endif 
        std::set<boost::shared_ptr<Region> > pending_adds;
        std::set<boost::shared_ptr<Region> > pending_removes;
        RegionList       pending_bounds;
index 06f9b3bc65fe9c2933e02eed7a177f777105e746..ebebc62c3385e262d9305cc69abf2ee757f3add7 100644 (file)
@@ -186,7 +186,11 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, fr
           its OK to block (for short intervals).
        */
 
+#ifdef HAVE_GLIB_THREADS_RECMUTEX
+       Glib::Threads::RecMutex::Lock lm (region_lock);
+#else  
        Glib::RecMutex::Lock rm (region_lock);
+#endif 
 
        /* Find all the regions that are involved in the bit we are reading,
           and sort them by descending layer and ascending position.
index 9b0eb374d5f1f6dc72219451856486f2c513d866..7e3d70bfe0915a32dc6aab5271adf9aefcabe8ce 100644 (file)
@@ -107,7 +107,11 @@ MidiPlaylist::read (Evoral::EventSink<framepos_t>& dst, framepos_t start, framec
           its OK to block (for short intervals).
        */
 
+#ifdef HAVE_GLIB_THREADS_RECMUTEX
+       Glib::Threads::RecMutex::Lock rm (region_lock);
+#else  
        Glib::RecMutex::Lock rm (region_lock);
+#endif 
        DEBUG_TRACE (DEBUG::MidiPlaylistIO, string_compose ("++++++ %1 .. %2  +++++++ %3 trackers +++++++++++++++++\n", 
                                                            start, start + dur, _note_trackers.size()));
 
@@ -294,7 +298,11 @@ MidiPlaylist::read (Evoral::EventSink<framepos_t>& dst, framepos_t start, framec
 void
 MidiPlaylist::clear_note_trackers ()
 {
+#ifdef HAVE_GLIB_THREADS_RECMUTEX
+       Glib::Threads::RecMutex::Lock rm (region_lock);
+#else  
        Glib::RecMutex::Lock rm (region_lock);
+#endif 
        for (NoteTrackers::iterator n = _note_trackers.begin(); n != _note_trackers.end(); ++n) {
                delete n->second;
        }
@@ -399,7 +407,11 @@ MidiPlaylist::contained_automation()
           its OK to block (for short intervals).
        */
 
+#ifdef HAVE_GLIB_THREADS_RECMUTEX
+       Glib::Threads::RecMutex::Lock rm (region_lock);
+#else  
        Glib::RecMutex::Lock rm (region_lock);
+#endif 
 
        set<Evoral::Parameter> ret;
 
diff --git a/wscript b/wscript
index 6f58ceb67a0489a370f73b25a8c5153906849845..19c22dd2ea0f47faacc47e0b9a1e593fae1a5cb8 100644 (file)
--- a/wscript
+++ b/wscript
@@ -548,6 +548,14 @@ def configure(conf):
     autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', atleast_version='1.0.18')
     autowaf.check_pkg(conf, 'giomm-2.4', uselib_store='GIOMM', atleast_version='2.2')
 
+    conf.check_cxx(fragment = '#include <glibmm/threads.h>\nstatic Glib::Threads::RecMutex foo;\nint main () {}',
+                   uselib = ['GLIBMM'],
+                   msg = 'Checking for Glib::Threads::RecMutex',
+                   mandatory = False,
+                   okmsg = 'yes',
+                   errmsg = 'no; using deprecated API',
+                   define_name = 'HAVE_GLIB_THREADS_RECMUTEX')
+
     for i in children:
         sub_config_and_use(conf, i)