Prevent crash when running unconfigured meter processor

If Route::configure_processors fails at session start,
meters are not configured (#9106), leading to a crash when
::run() is called (insufficient peak/max/midi buffers).
This commit is contained in:
Robin Gareus 2022-11-20 15:01:08 +01:00
parent 8468607a37
commit 4448b3a2a9
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 20 additions and 0 deletions

View File

@ -99,6 +99,7 @@ private:
* as it can be altered outside a \ref configure_io by \ref reflect_inputs .
*/
ChanCount current_meters;
ChanCount _max_n_meters;
GATOMIC_QUAL gint _reset_dpm;
GATOMIC_QUAL gint _reset_max;

View File

@ -269,6 +269,23 @@ PeakMeter::configure_io (ChanCount in, ChanCount out)
void
PeakMeter::reflect_inputs (const ChanCount& in)
{
if (!_configured || in > _max_n_meters) {
/* meter has to be configured at least once, and
* Route has to call ::set_max_channels after successful
* configure_processors.
*/
return;
}
/* In theory this cannot happen. After an initial successful
* configuration, Route::configure_processors_unlocked will revert
* to a prior config in case of an error.
*/
assert (in <= _max_n_meters);
if (in > _max_n_meters) {
return;
}
reset ();
current_meters = in;
reset_max ();
@ -283,6 +300,8 @@ PeakMeter::emit_configuration_changed ()
void
PeakMeter::set_max_channels (const ChanCount& chn)
{
_max_n_meters = chn;
uint32_t const limit = chn.n_total ();
const size_t n_audio = chn.n_audio ();