mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-21 16:37:12 +01:00
commit a large patch by Maarten Baert maarten-baert<at>hotmail<dot>com to fix and improve time track support. Several fix-me issues remain but none are new with this patch.
This commit is contained in:
@@ -168,6 +168,12 @@
|
||||
: Resample(useBestMethod)
|
||||
{
|
||||
mHandle = resample_open(mMethod, dMinFactor, dMaxFactor);
|
||||
if(mHandle == NULL) {
|
||||
fprintf(stderr, "libresample doesn't support range %f .. %f.\n", dMinFactor, dMaxFactor);
|
||||
// FIX-ME: Audacity will hang after this if branch.
|
||||
mHandle = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VarRateResample::~VarRateResample()
|
||||
@@ -240,6 +246,8 @@
|
||||
int err;
|
||||
SRC_STATE *state = src_new(mMethod, 1, &err);
|
||||
mHandle = (void *)state;
|
||||
mShouldReset = false;
|
||||
mSamplesLeft = 0;
|
||||
}
|
||||
|
||||
VarRateResample::~VarRateResample()
|
||||
@@ -299,6 +307,15 @@
|
||||
src_set_ratio((SRC_STATE *)mHandle, factor);
|
||||
|
||||
SRC_DATA data;
|
||||
|
||||
if(mShouldReset) {
|
||||
if(inBufferLen > mSamplesLeft) {
|
||||
mShouldReset = false;
|
||||
src_reset((SRC_STATE *)mHandle);
|
||||
} else {
|
||||
mSamplesLeft -= inBufferLen;
|
||||
}
|
||||
}
|
||||
|
||||
data.data_in = inBuffer;
|
||||
data.data_out = outBuffer;
|
||||
@@ -314,6 +331,11 @@
|
||||
wxFprintf(stderr, _("Libsamplerate error: %d\n"), err);
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user