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.
This commit is contained in:
Paul Davis
2020-05-12 10:12:58 -06:00
parent 376d4f2e68
commit 98d56d6b21

View File

@@ -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);