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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user