summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Klotz <uwe_klotz@web.de>2017-11-25 15:31:17 +0100
committerUwe Klotz <uwe_klotz@web.de>2017-11-25 16:02:02 +0100
commitee517e365d5ededd670381365669783da1bbcb75 (patch)
treef67b28a0eb343de03025b7302448b396bb9181e5
parent755d55bd59cc4018d4813f1f2ce3fecb3ae18f02 (diff)
Use "length" for both slices and ranges
This also avoids confusion between "slice" and "size" which sound very similar.
-rw-r--r--plugins/soundsourcem4a/soundsourcem4a.cpp18
-rwxr-xr-xplugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp18
-rw-r--r--src/analyzer/analyzerqueue.cpp2
-rw-r--r--src/engine/cachingreaderchunk.cpp2
-rw-r--r--src/sources/audiosource.cpp6
-rw-r--r--src/sources/audiosource.h8
-rw-r--r--src/sources/audiosourcestereoproxy.cpp25
-rw-r--r--src/sources/audiosourcestereoproxy.h7
-rw-r--r--src/sources/soundsourceffmpeg.cpp2
-rw-r--r--src/sources/soundsourceflac.cpp8
-rw-r--r--src/sources/soundsourcemodplug.cpp2
-rw-r--r--src/sources/soundsourcemp3.cpp2
-rw-r--r--src/sources/soundsourceoggvorbis.cpp2
-rw-r--r--src/sources/soundsourceopus.cpp2
-rw-r--r--src/test/samplebuffertest.cpp14
-rw-r--r--src/util/samplebuffer.h46
16 files changed, 84 insertions, 80 deletions
diff --git a/plugins/soundsourcem4a/soundsourcem4a.cpp b/plugins/soundsourcem4a/soundsourcem4a.cpp
index 7f1511fdca..1f4e8335da 100644
--- a/plugins/soundsourcem4a/soundsourcem4a.cpp
+++ b/plugins/soundsourcem4a/soundsourcem4a.cpp
@@ -449,13 +449,13 @@ ReadableSampleFrames SoundSourceM4A::readSampleFramesClamped(
SampleUtil::copy(
writableSampleFrames.writableData(outputSampleOffset),
readableSlice.data(),
- readableSlice.size());
- outputSampleOffset += readableSlice.size();
+ readableSlice.length());
+ outputSampleOffset += readableSlice.length();
}
- m_curFrameIndex += samples2frames(readableSlice.size());
+ m_curFrameIndex += samples2frames(readableSlice.length());
DEBUG_ASSERT(isValidFrameIndex(m_curFrameIndex));
- DEBUG_ASSERT(numberOfSamplesRemaining >= readableSlice.size());
- numberOfSamplesRemaining -= readableSlice.size();
+ DEBUG_ASSERT(numberOfSamplesRemaining >= readableSlice.length());
+ numberOfSamplesRemaining -= readableSlice.length();
if (0 == numberOfSamplesRemaining) {
break; // exit loop
}
@@ -508,7 +508,7 @@ ReadableSampleFrames SoundSourceM4A::readSampleFramesClamped(
const SampleBuffer::WritableSlice writableSlice(
m_sampleBuffer.writeToTail(writeToTailCount));
pDecodeBuffer = writableSlice.data();
- decodeBufferCapacity = writableSlice.size();
+ decodeBufferCapacity = writableSlice.length();
}
DEBUG_ASSERT(decodeBufferCapacityMin <= decodeBufferCapacity);
@@ -572,12 +572,12 @@ ReadableSampleFrames SoundSourceM4A::readSampleFramesClamped(
std::min(numberOfSamplesDecoded, numberOfSamplesRemaining);
const SampleBuffer::ReadableSlice readableSlice(
m_sampleBuffer.readFromHead(numberOfSamplesRead));
- DEBUG_ASSERT(readableSlice.size() == numberOfSamplesRead);
+ DEBUG_ASSERT(readableSlice.length() == numberOfSamplesRead);
if (writableSampleFrames.writableData()) {
SampleUtil::copy(
writableSampleFrames.writableData(outputSampleOffset),
readableSlice.data(),
- readableSlice.size());
+ readableSlice.length());
outputSampleOffset += numberOfSamplesRead;
}
}
@@ -596,7 +596,7 @@ ReadableSampleFrames SoundSourceM4A::readSampleFramesClamped(
IndexRange::forward(firstFrameIndex, samples2frames(numberOfSamples)),
SampleBuffer::ReadableSlice(
writableSampleFrames.writableData(),
- std::min(writableSampleFrames.writableSize(), numberOfSamples)));
+ std::min(writableSampleFrames.writableLength(), numberOfSamples)));
}
QString SoundSourceProviderM4A::getName() const {
diff --git a/plugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp b/plugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp
index 2c376b91b9..caf1da6bfa 100755
--- a/plugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp
+++ b/plugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp
@@ -269,19 +269,19 @@ ReadableSampleFrames SoundSourceMediaFoundation::readSampleFramesClamped(
SampleBuffer::ReadableSlice readableSlice(
m_sampleBuffer.readFromHead(
frames2samples(numberOfFramesRemaining)));
- DEBUG_ASSERT(readableSlice.size()
+ DEBUG_ASSERT(readableSlice.length()
<= frames2samples(numberOfFramesRemaining));
- if (readableSlice.size() > 0) {
+ if (readableSlice.length() > 0) {
DEBUG_ASSERT(m_currentFrameIndex < frameIndexMax());
if (pSampleBuffer) {
SampleUtil::copy(
pSampleBuffer,
readableSlice.data(),
- readableSlice.size());
- pSampleBuffer += readableSlice.size();
+ readableSlice.length());
+ pSampleBuffer += readableSlice.length();
}
- m_currentFrameIndex += samples2frames(readableSlice.size());
- numberOfFramesRemaining -= samples2frames(readableSlice.size());
+ m_currentFrameIndex += samples2frames(readableSlice.length());
+ numberOfFramesRemaining -= samples2frames(readableSlice.length());
}
if (numberOfFramesRemaining == 0) {
break; // finished reading
@@ -433,11 +433,11 @@ ReadableSampleFrames SoundSourceMediaFoundation::readSampleFramesClamped(
SampleBuffer::WritableSlice writableSlice(
m_sampleBuffer.writeToTail(lockedSampleBufferCount));
// The required capacity has been calculated in advance (see above)
- DEBUG_ASSERT(writableSlice.size() == lockedSampleBufferCount);
+ DEBUG_ASSERT(writableSlice.length() == lockedSampleBufferCount);
SampleUtil::copy(
writableSlice.data(),
pLockedSampleBuffer,
- writableSlice.size());
+ writableSlice.length());
HRESULT hrUnlock = pMediaBuffer->Unlock();
VERIFY_OR_DEBUG_ASSERT(SUCCEEDED(hrUnlock)) {
kLogger.warning()
@@ -466,7 +466,7 @@ ReadableSampleFrames SoundSourceMediaFoundation::readSampleFramesClamped(
IndexRange::forward(firstFrameIndex, numberOfFrames),
SampleBuffer::ReadableSlice(
writableSampleFrames.writableData(),
- std::min(writableSampleFrames.writableSize(), frames2samples(numberOfFrames))));
+ std::min(writableSampleFrames.writableLength(), frames2samples(numberOfFrames))));
}
//-------------------------------------------------------------------
diff --git a/src/analyzer/analyzerqueue.cpp b/src/analyzer/analyzerqueue.cpp
index 721dbeb5b6..1a62b91d8e 100644
--- a/src/analyzer/analyzerqueue.cpp
+++ b/src/analyzer/analyzerqueue.cpp
@@ -207,7 +207,7 @@ bool AnalyzerQueue::doAnalysis(
for (auto const& pAnalyzer: m_pAnalyzers) {
pAnalyzer->process(
readableSampleFrames.readableData(),
- readableSampleFrames.readableSize());
+ readableSampleFrames.readableLength());
}
} else {
// Partial analysis block of audio samples has been read.
diff --git a/src/engine/cachingreaderchunk.cpp b/src/engine/cachingreaderchunk.cpp
index ac4b981e81..9eb2dbbf08 100644
--- a/src/engine/cachingreaderchunk.cpp
+++ b/src/engine/cachingreaderchunk.cpp
@@ -34,7 +34,7 @@ CachingReaderChunk::CachingReaderChunk(
mixxx::SampleBuffer::WritableSlice sampleBuffer)
: m_index(kInvalidChunkIndex),
m_sampleBuffer(sampleBuffer) {
- DEBUG_ASSERT(sampleBuffer.size() == kSamples);
+ DEBUG_ASSERT(sampleBuffer.length() == kSamples);
}
CachingReaderChunk::~CachingReaderChunk() {
diff --git a/src/sources/audiosource.cpp b/src/sources/audiosource.cpp
index 24bc78bedf..301ae87397 100644
--- a/src/sources/audiosource.cpp
+++ b/src/sources/audiosource.cpp
@@ -107,10 +107,10 @@ WritableSampleFrames AudioSource::clampWritableSampleFrames(
IndexRange::between(sampleFrames.frameIndexRange().start(), readableFrameIndexRange.end());
const SINT minSampleBufferCapacity =
frames2samples(writableFrameIndexRange.length());
- VERIFY_OR_DEBUG_ASSERT(sampleFrames.writableSize() >= minSampleBufferCapacity) {
+ VERIFY_OR_DEBUG_ASSERT(sampleFrames.writableLength() >= minSampleBufferCapacity) {
kLogger.critical()
<< "Capacity of output buffer is too small"
- << sampleFrames.writableSize()
+ << sampleFrames.writableLength()
<< "<"
<< minSampleBufferCapacity
<< "to store all readable sample frames"
@@ -119,7 +119,7 @@ WritableSampleFrames AudioSource::clampWritableSampleFrames(
<< writableFrameIndexRange;
writableFrameIndexRange =
writableFrameIndexRange.splitAndShrinkFront(
- samples2frames(sampleFrames.writableSize()));
+ samples2frames(sampleFrames.writableLength()));
kLogger.warning()
<< "Reduced writable sample frames"
<< writableFrameIndexRange;
diff --git a/src/sources/audiosource.h b/src/sources/audiosource.h
index 075e6a0d59..8754014152 100644
--- a/src/sources/audiosource.h
+++ b/src/sources/audiosource.h
@@ -51,8 +51,8 @@ class ReadableSampleFrames final: public SampleFrames {
return m_readableSlice;
}
- SINT readableSize() const {
- return m_readableSlice.size();
+ SINT readableLength() const {
+ return m_readableSlice.length();
}
const CSAMPLE* readableData(SINT offset = 0) const {
@@ -87,8 +87,8 @@ class WritableSampleFrames final: public SampleFrames {
return m_writableSlice;
}
- SINT writableSize() const {
- return m_writableSlice.size();
+ SINT writableLength() const {
+ return m_writableSlice.length();
}
CSAMPLE* writableData(SINT offset = 0) const {
diff --git a/src/sources/audiosourcestereoproxy.cpp b/src/sources/audiosourcestereoproxy.cpp
index d63853f44e..ae7b950477 100644
--- a/src/sources/audiosourcestereoproxy.cpp
+++ b/src/sources/audiosourcestereoproxy.cpp
@@ -20,16 +20,16 @@ AudioSourceStereoProxy::AudioSourceStereoProxy(
m_tempSampleBuffer(
(m_pAudioSource->channelCount() != 2) ?
m_pAudioSource->frames2samples(maxReadableFrames) : 0),
- m_tempOutputBuffer(m_tempSampleBuffer) {
+ m_tempWritableSlice(m_tempSampleBuffer) {
setChannelCount(2);
}
AudioSourceStereoProxy::AudioSourceStereoProxy(
AudioSourcePointer pAudioSource,
- SampleBuffer::WritableSlice m_tempOutputBuffer)
+ SampleBuffer::WritableSlice tempWritableSlice)
: AudioSource(*pAudioSource),
m_pAudioSource(std::move(pAudioSource)),
- m_tempOutputBuffer(m_tempOutputBuffer) {
+ m_tempWritableSlice(std::move(tempWritableSlice)) {
setChannelCount(2);
}
@@ -42,13 +42,13 @@ bool isDisjunct(
if (slice1.data() == slice2.data()) {
return false;
}
- if ((slice1.size() == 0) || (slice2.size() == 0)) {
+ if ((slice1.length() == 0) || (slice2.length() == 0)) {
return true;
}
if (slice1.data() < slice2.data()) {
- return slice1.data(slice1.size()) <= slice2.data();
+ return slice1.data(slice1.length()) <= slice2.data();
} else {
- return slice2.data(slice2.size()) <= slice1.data();
+ return slice2.data(slice2.length()) <= slice1.data();
}
}
@@ -62,7 +62,7 @@ ReadableSampleFrames AudioSourceStereoProxy::readSampleFramesClamped(
// Check location and capacity of temporary buffer
VERIFY_OR_DEBUG_ASSERT(isDisjunct(
- m_tempOutputBuffer,
+ m_tempWritableSlice,
SampleBuffer::WritableSlice(sampleFrames.writableSlice()))) {
kLogger.warning()
<< "Overlap between output and temporary sample buffer detected";
@@ -70,11 +70,12 @@ ReadableSampleFrames AudioSourceStereoProxy::readSampleFramesClamped(
}
{
const SINT numberOfSamplesToRead =
- m_pAudioSource->frames2samples(sampleFrames.frameIndexRange().length());
- VERIFY_OR_DEBUG_ASSERT(m_tempOutputBuffer.size() >= numberOfSamplesToRead) {
+ m_pAudioSource->frames2samples(
+ sampleFrames.frameIndexRange().length());
+ VERIFY_OR_DEBUG_ASSERT(m_tempWritableSlice.length() >= numberOfSamplesToRead) {
kLogger.warning()
<< "Insufficient temporary sample buffer capacity"
- << m_tempOutputBuffer.size()
+ << m_tempWritableSlice.length()
<< "<"
<< numberOfSamplesToRead
<< "for reading frames"
@@ -88,7 +89,7 @@ ReadableSampleFrames AudioSourceStereoProxy::readSampleFramesClamped(
*m_pAudioSource,
WritableSampleFrames(
sampleFrames.frameIndexRange(),
- m_tempOutputBuffer));
+ m_tempWritableSlice));
if (readableSampleFrames.frameIndexRange().empty()) {
return readableSampleFrames;
}
@@ -115,7 +116,7 @@ ReadableSampleFrames AudioSourceStereoProxy::readSampleFramesClamped(
readableSampleFrames.frameIndexRange(),
SampleBuffer::ReadableSlice(
writableSlice.data(),
- writableSlice.size()));
+ writableSlice.length()));
}
}
diff --git a/src/sources/audiosourcestereoproxy.h b/src/sources/audiosourcestereoproxy.h
index 333b727e9b..7b3a8ad111 100644
--- a/src/sources/audiosourcestereoproxy.h
+++ b/src/sources/audiosourcestereoproxy.h
@@ -17,12 +17,15 @@ class AudioSourceStereoProxy: public AudioSource {
maxReadableFrames);
}
+ // Create an instance with its own temporary buffer
AudioSourceStereoProxy(
AudioSourcePointer pAudioSource,
SINT maxReadableFrames);
+ // Create an instance that borrows a writable slice of a
+ // temporary buffer owned by the caller
AudioSourceStereoProxy(
AudioSourcePointer pAudioSource,
- SampleBuffer::WritableSlice tempSampleBufferSlice);
+ SampleBuffer::WritableSlice tempWritableSlice);
void close() override {
m_pAudioSource->close();
@@ -41,7 +44,7 @@ class AudioSourceStereoProxy: public AudioSource {
private:
AudioSourcePointer m_pAudioSource;
SampleBuffer m_tempSampleBuffer;
- SampleBuffer::WritableSlice m_tempOutputBuffer;
+ SampleBuffer::WritableSlice m_tempWritableSlice;
};
} // namespace mixxx
diff --git a/src/sources/soundsourceffmpeg.cpp b/src/sources/soundsourceffmpeg.cpp
index 33293cedc2..002e441383 100644
--- a/src/sources/soundsourceffmpeg.cpp
+++ b/src/sources/soundsourceffmpeg.cpp
@@ -991,7 +991,7 @@ ReadableSampleFrames SoundSourceFFmpeg::readSampleFramesClamped(
IndexRange::forward(firstFrameIndex, numberOfFrames),
SampleBuffer::ReadableSlice(
writableSampleFrames.writableData(),
- std::min(writableSampleFrames.writableSize(), frames2samples(numberOfFrames))));
+ std::min(writableSampleFrames.writableLength(), frames2samples(numberOfFrames))));
}
} // namespace mixxx
diff --git a/src/sources/soundsourceflac.cpp b/src/sources/soundsourceflac.cpp
index 9c9ca440bf..24a1a6e3c3 100644
--- a/src/sources/soundsourceflac.cpp
+++ b/src/sources/soundsourceflac.cpp
@@ -265,12 +265,12 @@ ReadableSampleFrames SoundSourceFLAC::readSampleFramesClamped(
std::min(m_sampleBuffer.readableLength(), numberOfSamplesRemaining);
const SampleBuffer::ReadableSlice readableSlice(
m_sampleBuffer.readFromHead(numberOfSamplesRead));
- DEBUG_ASSERT(readableSlice.size() == numberOfSamplesRead);
+ DEBUG_ASSERT(readableSlice.length() == numberOfSamplesRead);
if (writableSampleFrames.writableData()) {
SampleUtil::copy(
writableSampleFrames.writableData(outputSampleOffset),
readableSlice.data(),
- readableSlice.size());
+ readableSlice.length());
outputSampleOffset += numberOfSamplesRead;
}
m_curFrameIndex += samples2frames(numberOfSamplesRead);
@@ -284,7 +284,7 @@ ReadableSampleFrames SoundSourceFLAC::readSampleFramesClamped(
IndexRange::forward(firstFrameIndex, samples2frames(numberOfSamples)),
SampleBuffer::ReadableSlice(
writableSampleFrames.writableData(),
- std::min(writableSampleFrames.writableSize(), numberOfSamples)));
+ std::min(writableSampleFrames.writableLength(), numberOfSamples)));
}
// flac callback methods
@@ -378,7 +378,7 @@ FLAC__StreamDecoderWriteStatus SoundSourceFLAC::flacWrite(
const SampleBuffer::WritableSlice writableSlice(
m_sampleBuffer.writeToTail(frames2samples(numReadableFrames)));
- const SINT numWritableFrames = samples2frames(writableSlice.size());
+ const SINT numWritableFrames = samples2frames(writableSlice.length());
DEBUG_ASSERT(numWritableFrames <= numReadableFrames);
if (numWritableFrames < numReadableFrames) {
kLogger.warning() << "Sample buffer has not enough free space for all decoded FLAC samples:"
diff --git a/src/sources/soundsourcemodplug.cpp b/src/sources/soundsourcemodplug.cpp
index eb167a8e6a..8d8c0ac7e8 100644
--- a/src/sources/soundsourcemodplug.cpp
+++ b/src/sources/soundsourcemodplug.cpp
@@ -191,7 +191,7 @@ ReadableSampleFrames SoundSourceModPlug::readSampleFramesClamped(
writableSampleFrames.frameIndexRange(),
SampleBuffer::ReadableSlice(
writableSampleFrames.writableData(),
- writableSampleFrames.writableSize()));
+ writableSampleFrames.writableLength()));
}
QString SoundSourceProviderModPlug::getName() const {
diff --git a/src/sources/soundsourcemp3.cpp b/src/sources/soundsourcemp3.cpp
index ef60dcd90b..e1cfbadbb0 100644
--- a/src/sources/soundsourcemp3.cpp
+++ b/src/sources/soundsourcemp3.cpp
@@ -711,7 +711,7 @@ ReadableSampleFrames SoundSourceMp3::readSampleFramesClamped(
IndexRange::forward(firstFrameIndex, numberOfFrames),
SampleBuffer::ReadableSlice(
writableSampleFrames.writableData(),
- std::min(writableSampleFrames.writableSize(), frames2samples(numberOfFrames))));
+ std::min(writableSampleFrames.writableLength(), frames2samples(numberOfFrames))));
}
QString SoundSourceProviderMp3::getName() const {
diff --git a/src/sources/soundsourceoggvorbis.cpp b/src/sources/soundsourceoggvorbis.cpp
index c1a1f0dd3f..247f48f2cf 100644
--- a/src/sources/soundsourceoggvorbis.cpp
+++ b/src/sources/soundsourceoggvorbis.cpp
@@ -191,7 +191,7 @@ ReadableSampleFrames SoundSourceOggVorbis::readSampleFramesClamped(
IndexRange::forward(firstFrameIndex, numberOfFrames),
SampleBuffer::ReadableSlice(
writableSampleFrames.writableData(),
- std::min(writableSampleFrames.writableSize(), frames2samples(numberOfFrames))));
+ std::min(writableSampleFrames.writableLength(), frames2samples(numberOfFrames))));
}
diff --git a/src/sources/soundsourceopus.cpp b/src/sources/soundsourceopus.cpp
index c363bd279f..06671ee751 100644
--- a/src/sources/soundsourceopus.cpp
+++ b/src/sources/soundsourceopus.cpp
@@ -368,7 +368,7 @@ ReadableSampleFrames SoundSourceOpus::readSampleFramesClamped(
IndexRange::forward(firstFrameIndex, numberOfFrames),
SampleBuffer::ReadableSlice(
writableSampleFrames.writableData(),
- std::min(writableSampleFrames.writableSize(), frames2samples(numberOfFrames))));
+ std::min(writableSampleFrames.writableLength(), frames2samples(numberOfFrames))));
}
QString SoundSourceProviderOpus::getName() const {
diff --git a/src/test/samplebuffertest.cpp b/src/test/samplebuffertest.cpp
index 1ee43f7b24..cc2cdf4094 100644
--- a/src/test/samplebuffertest.cpp
+++ b/src/test/samplebuffertest.cpp
@@ -16,24 +16,24 @@ public:
protected:
static const SINT kCapacity;
- SINT writeToTail(mixxx::ReadAheadSampleBuffer* pSampleBuffer, SINT size) {
+ SINT writeToTail(mixxx::ReadAheadSampleBuffer* pSampleBuffer, SINT length) {
const mixxx::SampleBuffer::WritableSlice writableSlice(
- pSampleBuffer->writeToTail(size));
- for (SINT i = 0; i < writableSlice.size(); ++i) {
+ pSampleBuffer->writeToTail(length));
+ for (SINT i = 0; i < writableSlice.length(); ++i) {
writableSlice[i] = m_writeValue;
m_writeValue += CSAMPLE_ONE;
}
- return writableSlice.size();
+ return writableSlice.length();
}
SINT readFromHeadAndVerify(mixxx::ReadAheadSampleBuffer* pSampleBuffer, SINT maxReadLength) {
const mixxx::SampleBuffer::ReadableSlice readableSlice(
pSampleBuffer->readFromHead(maxReadLength));
- for (SINT i = 0; i < readableSlice.size(); ++i) {
+ for (SINT i = 0; i < readableSlice.length(); ++i) {
EXPECT_EQ(readableSlice[i], m_readValue);
m_readValue += CSAMPLE_ONE;
}
- return readableSlice.size();
+ return readableSlice.length();
}
SINT dropFromTailAndVerify(mixxx::ReadAheadSampleBuffer* pSampleBuffer, SINT maxDropLength) {
@@ -66,7 +66,7 @@ TEST_F(ReadAheadSampleBufferTest, emptyWithoutCapacity) {
const mixxx::SampleBuffer::WritableSlice writableSlice(
sampleBuffer.writeToTail(10));
EXPECT_EQ(writableSlice.data(), static_cast<CSAMPLE*>(NULL));
- EXPECT_EQ(writableSlice.size(), 0);
+ EXPECT_EQ(writableSlice.length(), 0);
EXPECT_TRUE(sampleBuffer.empty());
const SINT droppedLength(
diff --git a/src/util/samplebuffer.h b/src/util/samplebuffer.h
index 52abf86e7c..4495c99de6 100644
--- a/src/util/samplebuffer.h
+++ b/src/util/samplebuffer.h
@@ -98,80 +98,80 @@ class SampleBuffer {
public:
ReadableSlice()
: m_data(nullptr),
- m_size(0) {
+ m_length(0) {
}
- ReadableSlice(const CSAMPLE* data, SINT size)
+ ReadableSlice(const CSAMPLE* data, SINT length)
: m_data(data),
- m_size(size) {
- DEBUG_ASSERT(size >= 0);
- DEBUG_ASSERT((size == 0) || (m_data != nullptr));
+ m_length(length) {
+ DEBUG_ASSERT(m_length >= 0);
+ DEBUG_ASSERT((m_length == 0) || (m_data != nullptr));
}
ReadableSlice(const SampleBuffer& buffer, SINT offset, SINT length)
: m_data(buffer.data(offset)),
- m_size(length) {
+ m_length(length) {
DEBUG_ASSERT((buffer.size() - offset) >= length);
}
const CSAMPLE* data(SINT offset = 0) const {
DEBUG_ASSERT((m_data != nullptr) || (offset == 0));
DEBUG_ASSERT(0 <= offset);
// >=: allow access to one element behind allocated memory
- DEBUG_ASSERT(m_size >= offset);
+ DEBUG_ASSERT(m_length >= offset);
return m_data + offset;
}
- SINT size() const {
- return m_size;
+ SINT length() const {
+ return m_length;
}
bool empty() const {
- return (m_data == nullptr) || (m_size <= 0);
+ return (m_data == nullptr) || (m_length <= 0);
}
const CSAMPLE& operator[](SINT index) const {
return *data(index);
}
private:
const CSAMPLE* m_data;
- SINT m_size;
+ SINT m_length;
};
class WritableSlice {
public:
WritableSlice()
: m_data(nullptr),
- m_size(0) {
+ m_length(0) {
}
- WritableSlice(CSAMPLE* data, SINT size)
+ WritableSlice(CSAMPLE* data, SINT length)
: m_data(data),
- m_size(size) {
- DEBUG_ASSERT(size >= 0);
- DEBUG_ASSERT((size == 0) || (m_data != nullptr));
+ m_length(length) {
+ DEBUG_ASSERT(m_length >= 0);
+ DEBUG_ASSERT((m_length == 0) || (m_data != nullptr));
}
explicit WritableSlice(SampleBuffer& buffer)
: m_data(buffer.data()),
- m_size(buffer.size()) {
+ m_length(buffer.size()) {
}
WritableSlice(SampleBuffer& buffer, SINT offset, SINT length)
: m_data(buffer.data(offset)),
- m_size(length) {
+ m_length(length) {
DEBUG_ASSERT((buffer.size() - offset) >= length);
}
CSAMPLE* data(SINT offset = 0) const {
DEBUG_ASSERT((m_data != nullptr) || (offset == 0));
DEBUG_ASSERT(0 <= offset);
// >=: allow access to one element behind allocated memory
- DEBUG_ASSERT(m_size >= offset);
+ DEBUG_ASSERT(m_length >= offset);
return m_data + offset;
}
- SINT size() const {
- return m_size;
+ SINT length() const {
+ return m_length;
}
bool empty() const {
- return (m_data == nullptr) || (m_size <= 0);
+ return (m_data == nullptr) || (m_length <= 0);
}
CSAMPLE& operator[](SINT index) const {
return *data(index);
}
private:
CSAMPLE* m_data;
- SINT m_size;
+ SINT m_length;
};
private: