瀏覽代碼

code review

Laserlicht 1 年之前
父節點
當前提交
3f59942b04
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      client/media/CSoundHandler.cpp

+ 5 - 4
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);