Skip to content

Commit

Permalink
fix memory leak in AudioFormatInputSource
Browse files Browse the repository at this point in the history
  • Loading branch information
CrSjimo committed Jan 21, 2024
1 parent 2735138 commit 421959e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/format/AudioFormatInputSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ namespace talcs {
return false;
if (d->io->open(QIODevice::ReadOnly)) {
d->ratio = sampleRate / d->io->sampleRate();
d->resampler = new AudioFormatInputSourcePrivate::AudioFormatInputResampler(d->ratio, bufferSize,
d->io->channelCount(), d);
d->resampler.reset(new AudioFormatInputSourcePrivate::AudioFormatInputResampler(d->ratio, bufferSize,
d->io->channelCount(), d));
d->io->seek(outPositionToIn(d->position, d->ratio));
return AudioStreamBase::open(bufferSize, sampleRate);
} else
Expand All @@ -138,8 +138,7 @@ namespace talcs {
return;
d->io->close();
d->ratio = 0;
delete d->resampler;
d->resampler = nullptr;
d->resampler.reset();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/format/AudioFormatInputSource_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace talcs {
QVector<float> tmpBuf;
};

AudioFormatInputResampler *resampler = nullptr;
QScopedPointer<AudioFormatInputResampler> resampler;

qint64 inPosition = 0;

Expand Down

0 comments on commit 421959e

Please sign in to comment.