diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2020-05-12 10:12:58 -0600 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2020-05-12 11:34:37 -0600 |
commit | 98d56d6b21e9616b873a90d27dfbe9e7e52fa1de (patch) | |
tree | 6cc8bfb7241b803a0718797a078db4dec88043f5 /libs/pbd | |
parent | 376d4f2e684e255e126c9737c618d32ea4a97de7 (diff) |
Add API to PlaybackBuffer to compute amount of data that can overwritten
The distance is between a given offset in the buffer (probably a
read position at some point in time) and the write ptr. Any data after
the write ptr is "old" and not readable, and thus not worth overwriting
since we would not read it anyway.
Diffstat (limited to 'libs/pbd')
-rw-r--r-- | libs/pbd/pbd/playback_buffer.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/pbd/pbd/playback_buffer.h b/libs/pbd/pbd/playback_buffer.h index 75a30bc86f..2926e90be2 100644 --- a/libs/pbd/pbd/playback_buffer.h +++ b/libs/pbd/pbd/playback_buffer.h @@ -122,6 +122,18 @@ public: } } + /* write thread */ + guint overwritable_at (guint r) const { + guint w; + + w = g_atomic_int_get (&write_idx); + + if (w > r) { + return w - r; + } + return (w - r + size) & size_mask; + } + /* read-thead */ guint read (T *dest, guint cnt, bool commit = true, guint offset = 0); |