Reset port resampler after freewheeling

This clears out any data potently left there by export processing.
Previously this could cause an audible click.
This commit is contained in:
Robin Gareus 2022-05-10 05:38:38 +02:00
parent b26f0b3e85
commit 1809b6ae9a
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
6 changed files with 23 additions and 0 deletions

View File

@ -42,6 +42,9 @@ public:
void cycle_end (pframes_t);
void cycle_split ();
/* reset SRC, clear out any state */
void reinit ();
Buffer& get_buffer (pframes_t nframes) {
return get_audio_buffer (nframes);
}
@ -53,6 +56,7 @@ protected:
friend class PortManager;
AudioPort (std::string const &, PortFlags);
/* special access for PortManager only (hah, C++) */
Sample* engine_get_whole_audio_buffer ();

View File

@ -121,6 +121,7 @@ public:
virtual void cycle_start (pframes_t);
virtual void cycle_end (pframes_t) = 0;
virtual void cycle_split () = 0;
virtual void reinit () {}
virtual Buffer& get_buffer (pframes_t nframes) = 0;
virtual void flush_buffers (pframes_t /*nframes*/) {}
virtual void transport_stopped () {}

View File

@ -293,6 +293,8 @@ protected:
*/
void cycle_end (pframes_t nframes, Session* s = 0);
void reinit ();
void cycle_end_fade_out (gain_t, gain_t, pframes_t, Session* s = 0);
static std::string port_info_file ();

View File

@ -127,6 +127,12 @@ AudioPort::cycle_split ()
{
}
void
AudioPort::reinit ()
{
_src.reset ();
}
AudioBuffer&
AudioPort::get_audio_buffer (pframes_t nframes)
{

View File

@ -1483,6 +1483,9 @@ AudioEngine::freewheel_callback (bool onoff)
{
DEBUG_TRACE (DEBUG::BackendCallbacks, string_compose (X_("freewheel callback onoff %1\n"), onoff));
_freewheeling = onoff;
if (!_freewheeling) {
PortManager::reinit ();
}
}
void

View File

@ -1183,6 +1183,13 @@ PortManager::silence (pframes_t nframes, Session* s)
}
}
}
void
PortManager::reinit ()
{
for (auto const& p : *_ports.reader ()) {
p.second->reinit ();
}
}
void
PortManager::silence_outputs (pframes_t nframes)