1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 06:01:13 +02:00

More uses of SampleBuffer, eliminating explicit DeleteSamples calls

This commit is contained in:
Paul Licameli
2016-02-01 10:16:00 -05:00
parent 508286661a
commit 321d5259a2
22 changed files with 145 additions and 156 deletions

View File

@@ -25,17 +25,16 @@
#include "RingBuffer.h"
RingBuffer::RingBuffer(sampleFormat format, int size)
: mFormat(format)
, mBufferSize(size > 64 ? size : 64)
, mBuffer(mBufferSize, mFormat)
{
mFormat = format;
mBufferSize = (size > 64? size: 64);
mStart = 0;
mEnd = 0;
mBuffer = NewSamples(mBufferSize, mFormat);
}
RingBuffer::~RingBuffer()
{
DeleteSamples(mBuffer);
}
int RingBuffer::Len()
@@ -74,7 +73,7 @@ int RingBuffer::Put(samplePtr buffer, sampleFormat format,
block = mBufferSize - pos;
CopySamples(src, format,
mBuffer + pos * SAMPLE_SIZE(mFormat), mFormat,
mBuffer.ptr() + pos * SAMPLE_SIZE(mFormat), mFormat,
block);
src += block * SAMPLE_SIZE(format);
@@ -116,7 +115,7 @@ int RingBuffer::Get(samplePtr buffer, sampleFormat format,
if (block > mBufferSize - mStart)
block = mBufferSize - mStart;
CopySamples(mBuffer + mStart * SAMPLE_SIZE(mFormat), mFormat,
CopySamples(mBuffer.ptr() + mStart * SAMPLE_SIZE(mFormat), mFormat,
dest, format,
block);