summaryrefslogtreecommitdiff
path: root/libs/ardour/butler.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-04-14 22:06:12 +0000
committerCarl Hetherington <carl@carlh.net>2010-04-14 22:06:12 +0000
commit8783fc35f27b8583755d53d70efbf6cece27ca29 (patch)
tree50f35241556a6e4f83bf883e2516072a62db510b /libs/ardour/butler.cc
parent72f8544b2411c0bb9a8a46b2d27c5e94c2c0b803 (diff)
Suspend deletion of cross-thread pools until they are empty. Prevents crashes when the freeze thread completes.
git-svn-id: svn://localhost/ardour2/branches/3.0@6893 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/butler.cc')
-rw-r--r--libs/ardour/butler.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc
index 571ac5f883..8b88197073 100644
--- a/libs/ardour/butler.cc
+++ b/libs/ardour/butler.cc
@@ -43,8 +43,10 @@ Butler::Butler(Session& s)
, thread(0)
, audio_dstream_buffer_size(0)
, midi_dstream_buffer_size(0)
+ , pool_trash(16)
{
g_atomic_int_set(&should_do_transport_work, 0);
+ SessionEvent::pool->set_trash (&pool_trash);
}
Butler::~Butler()
@@ -331,6 +333,8 @@ Butler::thread_work ()
paused.signal();
}
+
+ empty_pool_trash ();
}
pthread_exit_pbd (0);
@@ -394,4 +398,35 @@ Butler::write_data_rate () const
return _write_data_rate > 10485.7600000f ? 0.0f : _write_data_rate;
}
+void
+Butler::empty_pool_trash ()
+{
+ /* look in the trash, deleting empty pools until we come to one that is not empty */
+
+ RingBuffer<CrossThreadPool*>::rw_vector vec;
+ pool_trash.get_read_vector (&vec);
+
+ guint deleted = 0;
+
+ for (int i = 0; i < 2; ++i) {
+ for (guint j = 0; j < vec.len[i]; ++j) {
+ if (vec.buf[i][j]->empty()) {
+ delete vec.buf[i][j];
+ ++deleted;
+ } else {
+ /* found a non-empty pool, so stop deleting */
+ if (deleted) {
+ pool_trash.increment_read_idx (deleted);
+ }
+ return;
+ }
+ }
+ }
+
+ if (deleted) {
+ pool_trash.increment_read_idx (deleted);
+ }
+}
+
} // namespace ARDOUR
+