Skip to content

Commit

Permalink
static allocation of intepolation data instead dynamic allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
newdigate committed Jan 14, 2024
1 parent 13d6115 commit 67dfc14
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 26 deletions.
1 change: 0 additions & 1 deletion src/ResamplingArrayReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ResamplingArrayReader : public ResamplingReader<int16_t, File> {
void close(void) override {
if (_playing) {
stop();
deleteInterpolationPoints();
}
}

Expand Down
1 change: 0 additions & 1 deletion src/ResamplingLfsReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class ResamplingLfsReader : public ResamplingReader< IndexableLittleFSFile<128,
delete [] _filename;
_filename = nullptr;
}
deleteInterpolationPoints();
}

IndexableLittleFSFile<128, 2>* createSourceBuffer() override {
Expand Down
23 changes: 1 addition & 22 deletions src/ResamplingReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,33 +674,12 @@ class ResamplingReader {

ResampleInterpolationType _interpolationType = ResampleInterpolationType::resampleinterpolation_none;
unsigned int _numInterpolationPoints[8] = {0};
InterpolationData **_interpolationPoints = nullptr;
InterpolationData _interpolationPoints[8][4] = {0};

void initializeInterpolationPoints(void) {
if (_numChannels < 0)
return;

deleteInterpolationPoints();
_interpolationPoints = new InterpolationData*[_numChannels];
for (int channel=0; channel < _numChannels; channel++) {
InterpolationData *interpolation = new InterpolationData[4];
interpolation[0].y = 0.0;
interpolation[1].y = 0.0;
interpolation[2].y = 0.0;
interpolation[3].y = 0.0;
_interpolationPoints[channel] = interpolation ;
}
_numInterpolationPointsChannels = _numChannels;
}

void deleteInterpolationPoints(void)
{
if (!_interpolationPoints) return;
for (int i=0; i<_numInterpolationPointsChannels; i++) {
delete [] _interpolationPoints[i];
}
delete [] _interpolationPoints;
_interpolationPoints = nullptr;
_numInterpolationPointsChannels = 0;
}

Expand Down
1 change: 0 additions & 1 deletion src/ResamplingSdReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class ResamplingSdReader : public ResamplingReader< IndexableSDFile<128, 4>, Fil
delete [] _filename;
_filename = nullptr;
}
deleteInterpolationPoints();
}

IndexableSDFile<128, 4>* createSourceBuffer() override {
Expand Down
1 change: 0 additions & 1 deletion src/ResamplingSerialFlashReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class ResamplingSerialFlashReader : public ResamplingReader< IndexableSerialFlas
delete [] _filename;
_filename = nullptr;
}
deleteInterpolationPoints();
}

IndexableSerialFlashFile<128, 2>* createSourceBuffer() override {
Expand Down

0 comments on commit 67dfc14

Please sign in to comment.