diff --git a/client/CMusicHandler.cpp b/client/CMusicHandler.cpp index eb5903ec6..11325e0ac 100644 --- a/client/CMusicHandler.cpp +++ b/client/CMusicHandler.cpp @@ -193,7 +193,7 @@ double CSoundHandler::getSoundDuration(const AudioPath & sound) SDL_AudioSpec spec; uint32_t audioLen; uint8_t *audioBuf; - double seconds = 0.0; + uint32_t miliseconds = 0; if(SDL_LoadWAV_RW(SDL_RWFromMem(data.first.get(), (int)data.second), 1, &spec, &audioBuf, &audioLen) != nullptr) { @@ -201,10 +201,10 @@ double CSoundHandler::getSoundDuration(const AudioPath & sound) uint32_t sampleSize = SDL_AUDIO_BITSIZE(spec.format) / 8; uint32_t sampleCount = audioLen / sampleSize; uint32_t sampleLen = sampleCount / spec.channels; - seconds = (double)sampleLen / (double)spec.freq; + miliseconds = 1000 * sampleLen / spec.freq; } - return seconds; + return miliseconds ; } // Plays a sound, and return its channel so we can fade it out later diff --git a/client/CMusicHandler.h b/client/CMusicHandler.h index 514a16834..31db7a416 100644 --- a/client/CMusicHandler.h +++ b/client/CMusicHandler.h @@ -77,7 +77,7 @@ public: void setChannelVolume(int channel, ui32 percent); // Sounds - double getSoundDuration(const AudioPath & sound); + uint32_t getSoundDurationMilliseconds(const AudioPath & sound); int playSound(soundBase::soundID soundID, int repeats=0); int playSound(const AudioPath & sound, int repeats=0, bool cache=false); int playSound(std::pair, si64> & data, int repeats=0, bool cache=false);