Prevent crash in SoundOutputProvider due to negative sample count being computed

In practice this doesn't occur ever except with subframe core abuse with tiny sample counts being spammed
This commit is contained in:
CasualPokePlayer 2025-03-28 16:47:39 -07:00
parent 60d7ddbffc
commit 5a020c1e9e
1 changed files with 5 additions and 1 deletions

View File

@ -263,7 +263,11 @@ namespace BizHawk.Client.Common
// would drift by ~22 milliseconds per minute.
_resampleLengthRoundingError = newCountExact - count;
AddSamplesToBuffer(samples, count);
if (count > 0)
{
// in rare cases (with subframe core tiny sample spam) count can be negative, somehow
AddSamplesToBuffer(samples, count);
}
}
private static double CalculatePowerMean(IEnumerable<int> values, double power)