mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Apply suggestions from code review
Co-authored-by: Ivan Savenko <saven.ivan@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
@@ -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<std::unique_ptr<ui8 []>, si64> & data, int repeats=0, bool cache=false);
|
||||
|
Reference in New Issue
Block a user