Cache BundleChannel nchannels, allow lock-free calls

This commit is contained in:
Robin Gareus 2025-07-01 17:26:13 +02:00
parent 9897074fcc
commit a0ba6e3dfb
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -174,8 +174,18 @@ public:
return bundle != other.bundle || channel != other.channel;
}
ChanCount nchannels () const {
if (!_nchannels) {
_nchannels = bundle->nchannels ();
}
return _nchannels.value ();
}
std::shared_ptr<Bundle> bundle;
int channel; ///< channel index, or -1 for "all"
private:
mutable std::optional<ChanCount> _nchannels;
};
}