From 3f59942b04ffe8d85fd03c27663bbde564fb2fa3 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:28:38 +0200 Subject: [PATCH] code review --- client/media/CSoundHandler.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/media/CSoundHandler.cpp b/client/media/CSoundHandler.cpp index a0b5e6301..adfb1a2f7 100644 --- a/client/media/CSoundHandler.cpp +++ b/client/media/CSoundHandler.cpp @@ -153,14 +153,15 @@ uint32_t CSoundHandler::getSoundDurationMilliseconds(const AudioPath & sound) int freq = 0; Uint16 fmt = 0; - int chans = 0; - if(!Mix_QuerySpec(&freq, &fmt, &chans)) + int channels = 0; + if(!Mix_QuerySpec(&freq, &fmt, &channels)) return 0; if(chunk != nullptr) { - Uint32 points = (chunk->alen / ((fmt & 0xFF) / 8)); - Uint32 frames = (points / chans); + Uint32 sampleSizeBytes = (fmt & 0xFF) / 8; + Uint32 samples = (chunk->alen / sampleSizeBytes); + Uint32 frames = (samples / channels); milliseconds = ((frames * 1000) / freq); Mix_FreeChunk(chunk);