Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/spectrum-analyzer' into devel
Browse files Browse the repository at this point in the history
* Fixed memory corruption bug in Analyzer core module that could crash the system on
  non-power-of-two buffer sizes. Affected plugins: Parametric Equalizer, Graphic Equalizer,
  Spectrum Analyzer, Multiband Compressor.
  • Loading branch information
sadko4u committed Sep 2, 2019
1 parent 1e3a218 commit 6824c2a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
=== 1.1.11 ===

* Build fixes for Aarch64 architecture related to CPU feature detection.
* Fixed memory corruption bug in Analyzer core module that could crash the system on
non-power-of-two buffer sizes. Affected plugins: Parametric Equalizer, Graphic Equalizer,
Spectrum Analyzer, Multiband Compressor.
- Decomposition of core modules into submodules.
- Additional code updates to get compatibility with WindowsNT platform.
- Research the work of plugins under Audacity.
Expand Down
4 changes: 2 additions & 2 deletions include/core/util/Analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace lsp
{
float *vBuffer; // FFT buffer
float *vAmp; // FFT amplitude
size_t nCounter; // FFT trigger counter
ssize_t nCounter; // FFT trigger counter
bool bFreeze; // Freeze analysis
bool bActive; // Enable analysis
} channel_t;
Expand All @@ -64,7 +64,7 @@ namespace lsp
size_t nRank;
size_t nSampleRate;
size_t nBufSize;
size_t nFftPeriod;
ssize_t nFftPeriod;
float fReactivity;
float fTau;
float fRate;
Expand Down
5 changes: 4 additions & 1 deletion src/core/util/Analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,15 @@ namespace lsp
// Limit number of samples to be processed
if (to_process > ssize_t(samples))
to_process = samples;
// Add limitation of processed data according to the FFT window size
if (to_process > ssize_t(fft_size))
to_process = fft_size;

// Move data in the buffer
dsp::move(c->vBuffer, &c->vBuffer[to_process], fft_size - to_process);
dsp::copy(&c->vBuffer[fft_size - to_process], in, to_process);

// Update counters
// Update counter and pointers
c->nCounter += to_process;
in += to_process;
samples -= to_process;
Expand Down
2 changes: 1 addition & 1 deletion src/core/util/Counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace lsp

bool Counter::submit(size_t samples)
{
ssize_t left = ssize_t(nCurrent) - samples;
ssize_t left = ssize_t(nCurrent) - ssize_t(samples);
if (left <= 0)
{
nCurrent = nInitial + (left % ssize_t(nInitial));
Expand Down

0 comments on commit 6824c2a

Please sign in to comment.