mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
code review
This commit is contained in:
@@ -153,14 +153,15 @@ uint32_t CSoundHandler::getSoundDurationMilliseconds(const AudioPath & sound)
|
|||||||
|
|
||||||
int freq = 0;
|
int freq = 0;
|
||||||
Uint16 fmt = 0;
|
Uint16 fmt = 0;
|
||||||
int chans = 0;
|
int channels = 0;
|
||||||
if(!Mix_QuerySpec(&freq, &fmt, &chans))
|
if(!Mix_QuerySpec(&freq, &fmt, &channels))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(chunk != nullptr)
|
if(chunk != nullptr)
|
||||||
{
|
{
|
||||||
Uint32 points = (chunk->alen / ((fmt & 0xFF) / 8));
|
Uint32 sampleSizeBytes = (fmt & 0xFF) / 8;
|
||||||
Uint32 frames = (points / chans);
|
Uint32 samples = (chunk->alen / sampleSizeBytes);
|
||||||
|
Uint32 frames = (samples / channels);
|
||||||
milliseconds = ((frames * 1000) / freq);
|
milliseconds = ((frames * 1000) / freq);
|
||||||
|
|
||||||
Mix_FreeChunk(chunk);
|
Mix_FreeChunk(chunk);
|
||||||
|
|||||||
Reference in New Issue
Block a user