13
0

Add API to update port resampler

Previously resampler ratio could only set when creating
an audio port. This is in preparation for setting resampler
quality when the session rate mismatches.

The session's rate is only known after basic session-setup
is performed. At this time Click-IO already exists.
This commit is contained in:
Robin Gareus 2023-01-30 23:17:29 +01:00
parent 2ff05d9e9d
commit 53cfbe9c7f
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 16 additions and 7 deletions

View File

@ -43,7 +43,7 @@ public:
void cycle_split ();
/* reset SRC, clear out any state */
void reinit ();
void reinit (bool with_ratio);
Buffer& get_buffer (pframes_t nframes) {
return get_audio_buffer (nframes);

View File

@ -121,7 +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 void reinit (bool) {}
virtual Buffer& get_buffer (pframes_t nframes) = 0;
virtual void flush_buffers (pframes_t /*nframes*/) {}
virtual void transport_stopped () {}

View File

@ -189,6 +189,9 @@ public:
void remove_all_ports ();
/** reset port-buffers. e.g. after freewheeling */
void reinit (bool with_ratio = false);
void clear_pending_port_deletions ();
virtual void add_pending_port_deletion (Port*) = 0;
@ -303,8 +306,6 @@ 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,8 +127,15 @@ AudioPort::cycle_split ()
}
void
AudioPort::reinit ()
AudioPort::reinit (bool with_ratio)
{
/* must not be called concurrently with processing */
if (with_ratio) {
/* Note: latency changes with quality, caller
* must take care of updating port latencies */
_src.setup (resampler_quality ());
_src.set_rrfilt (10);
}
_src.reset ();
}

View File

@ -1316,11 +1316,12 @@ PortManager::silence (pframes_t nframes, Session* s)
}
}
}
void
PortManager::reinit ()
PortManager::reinit (bool with_ratio)
{
for (auto const& p : *_ports.reader ()) {
p.second->reinit ();
p.second->reinit (with_ratio);
}
}