Make resampler reset idempotent

This commit is contained in:
Robin Gareus 2022-05-22 18:21:16 +02:00
parent 83b5be1add
commit f02e8d34e3
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 7 additions and 1 deletions

View File

@ -69,7 +69,6 @@ AudioPort::cycle_start (pframes_t nframes)
_buffer->prepare ();
} else if (!externally_connected ()) {
/* ardour internal port, just silence input, don't resample */
// TODO reset resampler only once
_src.reset ();
memset (_data, 0, _cycle_nframes * sizeof (float));
} else {

View File

@ -33,6 +33,7 @@ VMResampler::VMResampler (void)
, _buff (0)
, _c1 (0)
, _c2 (0)
, _reset (false)
{
reset ();
}
@ -91,6 +92,7 @@ VMResampler::clear (void)
_pstep = 0;
_qstep = 0;
_wstep = 1;
_reset = false;
reset ();
}
@ -144,6 +146,7 @@ int
VMResampler::reset (void)
{
if (!_table) return 1;
if (_reset) return 0;
inp_count = 0;
out_count = 0;
@ -155,6 +158,7 @@ VMResampler::reset (void)
memset (_buff, 0, sizeof(float) * (_nread + 249));
_nread -= _table->_hl - 1;
_reset = true;
return 0;
}
@ -175,6 +179,8 @@ VMResampler::process (void)
dp = _pstep;
n = 2 * hl - nr;
_reset = false;
#if 1
/* optimized full-cycle no-resampling */
if (dp == np && _qstep == np && nr == 1 && inp_count == out_count) {

View File

@ -66,6 +66,7 @@ private:
float *_buff;
float *_c1;
float *_c2;
bool _reset;
};
};