Tiny follow-up to #3397 (merged as 204585b).
AudioFormatNegotiator::primaryRateOrder() (src/core/AudioFormatNegotiator.cpp:19-47) has two per-direction switches over TargetOs, then a return {internalRate} fallback after both switches. The fallback is only reachable if a new TargetOs enum value is added later without updating one of the inner switches.
Flagged in the @aethersdr-agent bot review as a non-blocking nit. The current shape is correct; this is documentation polish for future contributors.
Suggested change
Replace the trailing fallback with Q_UNREACHABLE() so the invariant ("every TargetOs value is handled in both directions") is enforced by the compiler / runtime instead of papered over with a silent default:
QList<int> primaryRateOrder(TargetOs os, Direction dir, int internalRate)
{
if (dir == Direction::Output) {
switch (os) {
case TargetOs::Windows: return {48000, internalRate};
case TargetOs::MacOS: return {48000, internalRate};
case TargetOs::Linux: return {internalRate, 48000};
}
} else {
switch (os) {
case TargetOs::Windows: return {48000, 44100, internalRate, 16000};
case TargetOs::MacOS: return {48000, 44100, internalRate, 16000};
case TargetOs::Linux: return {internalRate, 48000, 44100};
}
}
Q_UNREACHABLE(); // every TargetOs value is covered above
}
When
Cheap enough to roll into the next audio-sink-factory PR (the live Qt wrapper, currently open as #3398) rather than landing as a standalone change.
Refs #3306 #3397
Tiny follow-up to #3397 (merged as 204585b).
AudioFormatNegotiator::primaryRateOrder()(src/core/AudioFormatNegotiator.cpp:19-47) has two per-direction switches overTargetOs, then areturn {internalRate}fallback after both switches. The fallback is only reachable if a newTargetOsenum value is added later without updating one of the inner switches.Flagged in the @aethersdr-agent bot review as a non-blocking nit. The current shape is correct; this is documentation polish for future contributors.
Suggested change
Replace the trailing fallback with
Q_UNREACHABLE()so the invariant ("everyTargetOsvalue is handled in both directions") is enforced by the compiler / runtime instead of papered over with a silent default:When
Cheap enough to roll into the next audio-sink-factory PR (the live Qt wrapper, currently open as #3398) rather than landing as a standalone change.
Refs #3306 #3397