mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
code review
This commit is contained in:
parent
d43997f5ba
commit
3f59942b04
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user