libobs: Clamp audio NaN to 0.0f

Add comparison check so that NaN is caught.
Comparisons with NaN always result in false.
NaNs cause problems later in audio encoder.

Note: may break with -ffast-math compiler flag.

Fixes #4885.
This commit is contained in:
Claude Heiland-Allen 2022-05-20 15:48:17 +01:00 committed by Richard Stanway
parent 56264befab
commit 06f66f3120

View File

@ -145,6 +145,7 @@ static inline void clamp_audio_output(struct audio_output *audio, size_t bytes)
while (mix_data < mix_end) {
float val = *mix_data;
val = (val == val) ? val : 0.0f;
val = (val > 1.0f) ? 1.0f : val;
val = (val < -1.0f) ? -1.0f : val;
*(mix_data++) = val;