Browse Source

Fix audio file buffering with files that align perfectly in buffer

Signed-off-by: falkTX <falktx@falktx.com>
pull/1811/head
falkTX 1 year ago
parent
commit
9317df5970
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 10 additions and 9 deletions
  1. +8
    -7
      source/native-plugins/audio-base.hpp
  2. +2
    -2
      source/utils/CarlaRingBuffer.hpp

+ 8
- 7
source/native-plugins/audio-base.hpp View File

@@ -362,10 +362,11 @@ public:
}

// within bounds, skip frames until we reach the end of the memory pool
if (fRingBufferR.getReadableDataSize() >= numPoolFrames * sizeof(float))
const uint32_t framesUpToPoolEnd = numPoolFrames - fRingBufferFramePos;
if (fRingBufferR.getReadableDataSize() / sizeof(float) >= framesUpToPoolEnd)
{
fRingBufferL.skipRead(numPoolFrames * sizeof(float));
fRingBufferR.skipRead(numPoolFrames * sizeof(float));
fRingBufferL.skipRead(framesUpToPoolEnd * sizeof(float));
fRingBufferR.skipRead(framesUpToPoolEnd * sizeof(float));
fRingBufferFramePos = numPoolFrames;
}

@@ -383,9 +384,9 @@ public:
carla_zeroFloats(outR, frames);
carla_zeroFloats(playCV, frames);

// wait until there previous relocation is done
// wait until the previous relocation is done
if (fNextFileReadPos == -1)
fNextFileReadPos = framePos;
fNextFileReadPos = framePos - frames;

return true;
}
@@ -408,8 +409,8 @@ public:
return framePos < fTotalResampledFrames;
}

fRingBufferL.readCustomData(outL, sizeof(float) * usableFrames);
fRingBufferR.readCustomData(outR, sizeof(float) * usableFrames);
fRingBufferL.readCustomData(outL, usableFrames * sizeof(float));
fRingBufferR.readCustomData(outR, usableFrames * sizeof(float));
carla_fillFloatsWithSingleValue(playCV, 10.f, usableFrames);

fRingBufferFramePos += usableFrames;


+ 2
- 2
source/utils/CarlaRingBuffer.hpp View File

@@ -172,7 +172,7 @@ public:

const uint32_t wrap = fBuffer->tail > fBuffer->wrtn ? 0 : fBuffer->size;

return wrap + fBuffer->tail - fBuffer->wrtn;
return wrap + fBuffer->tail - fBuffer->wrtn - 1;
}

// ----------------------------------------------------------------------------------------------------------------
@@ -448,7 +448,7 @@ protected:
const uint32_t wrtn = fBuffer->wrtn;
const uint32_t wrap = tail > wrtn ? 0 : fBuffer->size;

if (size > wrap + tail - wrtn)
if (size >= wrap + tail - wrtn)
{
if (! fErrorWriting)
{


Loading…
Cancel
Save