mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-26 15:23:48 +01:00
Fix problems introduced in r12170.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
\class Resample
|
||||
\brief Combined interface to libresample, libsamplerate, and libsoxr.
|
||||
|
||||
This class abstracts the interface to three different resampling libraries:
|
||||
This class abstracts the interface to different resampling libraries:
|
||||
|
||||
libresample, written by Dominic Mazzoni based on Resample-1.7
|
||||
by Julius Smith. LGPL.
|
||||
@@ -55,6 +55,11 @@
|
||||
{
|
||||
this->SetMethod(useBestMethod);
|
||||
mHandle = resample_open(mMethod, dFactor, dFactor);
|
||||
if(mHandle == NULL) {
|
||||
fprintf(stderr, "libresample doesn't support factor %f.\n", dFactor);
|
||||
// FIX-ME: Audacity will hang after this if branch.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ConstRateResample::~ConstRateResample()
|
||||
@@ -112,7 +117,8 @@
|
||||
: Resample()
|
||||
{
|
||||
this->SetMethod(useBestMethod);
|
||||
if (!src_is_valid_ratio (dFactor) || !src_is_valid_ratio (dFactor)) {
|
||||
if (!src_is_valid_ratio(dFactor))
|
||||
{
|
||||
fprintf(stderr, "libsamplerate supports only resampling factors between 1/SRC_MAX_RATIO and SRC_MAX_RATIO.\n");
|
||||
// FIX-ME: Audacity will hang after this if branch.
|
||||
mHandle = NULL;
|
||||
@@ -181,9 +187,15 @@
|
||||
float *outBuffer,
|
||||
int outBufferLen)
|
||||
{
|
||||
if (mInitial) {
|
||||
src_set_ratio((SRC_STATE *)mHandle, factor);
|
||||
mInitial = false;
|
||||
|
||||
if(mShouldReset) {
|
||||
if(inBufferLen > mSamplesLeft) {
|
||||
mShouldReset = false;
|
||||
src_reset((SRC_STATE *)mHandle);
|
||||
} else {
|
||||
mSamplesLeft -= inBufferLen;
|
||||
}
|
||||
}
|
||||
|
||||
SRC_DATA data;
|
||||
@@ -203,12 +215,17 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(lastFlag) {
|
||||
mShouldReset = true;
|
||||
mSamplesLeft = inBufferLen - (int)data.input_frames_used;
|
||||
}
|
||||
|
||||
*inBufferUsed = (int)data.input_frames_used;
|
||||
return (int)data.output_frames_gen;
|
||||
}
|
||||
|
||||
|
||||
#elif USE_LIBSOXR
|
||||
|
||||
#include <soxr.h>
|
||||
|
||||
ConstRateResample::ConstRateResample(const bool useBestMethod, const double dFactor)
|
||||
@@ -283,7 +300,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
// variable-rate resampler(s)
|
||||
// variable-rate resamplers
|
||||
#if USE_LIBRESAMPLE
|
||||
|
||||
#include "libresample.h"
|
||||
@@ -294,9 +311,8 @@
|
||||
this->SetMethod(useBestMethod);
|
||||
mHandle = resample_open(mMethod, dMinFactor, dMaxFactor);
|
||||
if(mHandle == NULL) {
|
||||
fprintf(stderr, "libresample doesn't support range %f .. %f.\n", dMinFactor, dMaxFactor);
|
||||
fprintf(stderr, "libresample doesn't support range of factors %f to %f.\n", dMinFactor, dMaxFactor);
|
||||
// FIX-ME: Audacity will hang after this if branch.
|
||||
mHandle = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -333,15 +349,8 @@
|
||||
return wxT("/Quality/LibresampleHQSampleRateConverter");
|
||||
}
|
||||
|
||||
int VarRateResample::GetFastMethodDefault()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VarRateResample::GetBestMethodDefault()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int VarRateResample::GetFastMethodDefault() { return 0; }
|
||||
int VarRateResample::GetBestMethodDefault() { return 1; }
|
||||
|
||||
int VarRateResample::Process(double factor,
|
||||
float *inBuffer,
|
||||
|
||||
@@ -143,8 +143,6 @@ class ConstRateResample : public Resample
|
||||
else
|
||||
mMethod = gPrefs->Read(GetFastMethodKey(), GetFastMethodDefault());
|
||||
};
|
||||
private:
|
||||
bool mInitial;
|
||||
};
|
||||
|
||||
class VarRateResample : public Resample
|
||||
|
||||
Reference in New Issue
Block a user