Skip to content

Commit 8b5a7e4

Browse files
committed
RingBuffer: peekArray
1 parent af48f6c commit 8b5a7e4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/AudioTools/Buffers.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,21 @@ class RingBuffer : public BaseBuffer<T> {
257257
return _aucBuffer[_iTail];
258258
}
259259

260+
virtual int peekArray(T*data, int n){
261+
if (isEmpty()) return -1;
262+
int result = 0;
263+
int count = _numElems;
264+
int tail = _iTail;
265+
for (int j=0;j<n;j++){
266+
data[j] = _aucBuffer[tail];
267+
tail = nextIndex(tail);
268+
count--;
269+
result++;
270+
if (count==0)break;
271+
}
272+
return result;
273+
}
274+
260275
// checks if the buffer is full
261276
virtual bool isFull() { return available() == max_size; }
262277

0 commit comments

Comments
 (0)