fix: small audio fragments evaluate to 0, multiply by zero earlier in the process

moved the multiplication by 1000 after the sample and channel divisions,
as those two are garunteed to evaluate to a whole number.
This commit is contained in:
2025-03-25 11:55:04 +01:00
parent df65ea5df4
commit 0f839d0803

View File

@@ -186,7 +186,7 @@ audiodata audio_wav_load(audiodevice const* dev, char const* fpath) {
} }
// calculate the time in miliseconds of the audio fragment // calculate the time in miliseconds of the audio fragment
audio.ms = 1000 * (((audio.len) / (SDL_AUDIO_BITSIZE(dev->fmt) / 8)) / spec.channels / dev->freq); audio.ms = ((((audio.len / (SDL_AUDIO_BITSIZE(dev->fmt) / 8)) / spec.channels) * 1000) / dev->freq);
return audio; return audio;
} }