summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-04-14 03:57:26 +0200
committerRobin Gareus <robin@gareus.org>2020-04-14 03:57:26 +0200
commitea2bda666813ed7b8963ee2884f7a496b8284b08 (patch)
treeb6bddc9e65df364163f86e7390c981dc6c6c1d8e /libs/pbd
parentd5f25f998bb5a5cb8aefbba8679e63ffa0062d55 (diff)
Fix playback alignment when adding/removing channels
The disk-reader assumes that all playback ringbuffers are in sync and have the same fill_level.
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/pbd/playback_buffer.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/libs/pbd/pbd/playback_buffer.h b/libs/pbd/pbd/playback_buffer.h
index 4b0b900217..75a30bc86f 100644
--- a/libs/pbd/pbd/playback_buffer.h
+++ b/libs/pbd/pbd/playback_buffer.h
@@ -65,10 +65,20 @@ public:
/* writer, when seeking, may block */
Glib::Threads::Mutex::Lock lm (_reset_lock);
SpinLock sl (_reservation_lock);
- g_atomic_int_set (&write_idx, g_atomic_int_get (&read_idx));
+ g_atomic_int_set (&read_idx, 0);
+ g_atomic_int_set (&write_idx, 0);
g_atomic_int_set (&reserved, 0);
}
+ /* called from rt (reader) thread for new buffers */
+ void align_to (PlaybackBuffer const& other) {
+ Glib::Threads::Mutex::Lock lm (_reset_lock);
+ write_idx = other.write_idx;
+ read_idx = other.read_idx;
+ reserved = other.reserved;
+ memset (buf, 0, size * sizeof (T));
+ }
+
/* write-thread */
guint write_space () const {
guint w, r;