Browse Source

Fix for +1 frame offset in libsndfile

tags/v1.9.11
falkTX 6 years ago
parent
commit
4458590275
3 changed files with 13 additions and 3 deletions
  1. +7
    -2
      source/modules/sfzero/sfzero/SFZSample.cpp
  2. +4
    -0
      source/native-plugins/audio-base.hpp
  3. +2
    -1
      source/native-plugins/midi-base.hpp

+ 7
- 2
source/modules/sfzero/sfzero/SFZSample.cpp View File

@@ -84,10 +84,15 @@ bool Sample::load()
return false;
}

// Fix for misinformation using libsndfile
if (info.frames % info.channels)
--info.frames;

const ssize_t r = ad_read(handle, rbuffer, info.frames);
if (r+1 < info.frames)
if (r != info.frames)
{
carla_stderr2("sfzero::Sample::load() - failed to read complete file: " P_SSIZE " vs " P_INT64, r, info.frames);
if (r != 0)
carla_stderr2("sfzero::Sample::load() - failed to read complete file: " P_SSIZE " vs " P_INT64, r, info.frames);
ad_close(handle);
return false;
}


+ 4
- 0
source/native-plugins/audio-base.hpp View File

@@ -199,6 +199,10 @@ public:
if (fFileNfo.frames == 0)
carla_stderr("L: filename \"%s\" has 0 frames", filename);

// Fix for misinformation using libsndfile
if (fFileNfo.frames % fFileNfo.channels)
--fFileNfo.frames;

if ((fFileNfo.channels == 1 || fFileNfo.channels == 2) && fFileNfo.frames > 0)
{
// valid


+ 2
- 1
source/native-plugins/midi-base.hpp View File

@@ -350,7 +350,8 @@ public:
carla_zeroStruct(midiEvent);

tmpSize = needle - dataRead;
CARLA_SAFE_ASSERT_RETURN(tmpSize > 0 && tmpSize < 24,);
CARLA_SAFE_ASSERT_RETURN(tmpSize > 0,);
CARLA_SAFE_ASSERT_RETURN(tmpSize < 24,);

std::strncpy(tmpBuf, dataRead, static_cast<size_t>(tmpSize));
tmpBuf[tmpSize] = '\0';


Loading…
Cancel
Save