summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-04-26 08:44:06 +0000
committerCarl Hetherington <carl@carlh.net>2012-04-26 08:44:06 +0000
commit42d018ffa81b026ff4dc5d6a290bb118c6f244e7 (patch)
treedf263a1d835627ab70f7a46a1ca8102bf6be2f3e
parentec97b8e58d4d476cd340cddfabc388505fb1ef7e (diff)
Use Glib::Threads::RecMutex rather than Glib::RecMutex where
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
-rw-r--r--libs/ardour/ardour/playlist.h8
-rw-r--r--libs/ardour/audio_playlist.cc4
-rw-r--r--libs/ardour/midi_playlist.cc12
-rw-r--r--wscript8
4 files changed, 31 insertions, 1 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 3648ceda8f..d57df6999b 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -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;
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index 06f9b3bc65..ebebc62c33 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -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.
diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc
index 9b0eb374d5..7e3d70bfe0 100644
--- a/libs/ardour/midi_playlist.cc
+++ b/libs/ardour/midi_playlist.cc
@@ -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 6f58ceb67a..19c22dd2ea 100644
--- 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)