forked from metin-server/m2dev-client-src
Merge pull request #12 from sndth/fix-audio-casting-warnings
Fix potential casting warnings inside AudioLib
This commit is contained in:
@@ -70,8 +70,8 @@ void MaSoundInstance::Destroy()
|
||||
}
|
||||
m_Initialized = false;
|
||||
m_Identity = "";
|
||||
m_FadeTargetVolume = 0;
|
||||
m_FadeRatePerFrame = 0;
|
||||
m_FadeTargetVolume = 0.0f;
|
||||
m_FadeRatePerFrame = 0.0f;
|
||||
}
|
||||
|
||||
bool MaSoundInstance::IsInitialized() const
|
||||
@@ -149,21 +149,21 @@ void MaSoundInstance::Fade(float toVolume, float secDurationFromMinMax)
|
||||
|
||||
void MaSoundInstance::StopFading()
|
||||
{
|
||||
m_FadeRatePerFrame = 0;
|
||||
m_FadeRatePerFrame = 0.0f;
|
||||
}
|
||||
|
||||
bool MaSoundInstance::IsFading() const
|
||||
{
|
||||
return m_FadeRatePerFrame != 0;
|
||||
return m_FadeRatePerFrame != 0.0f;
|
||||
}
|
||||
|
||||
void MaSoundInstance::Update(float volumeFactor) // volume factor is the user's volume
|
||||
{
|
||||
if (m_FadeRatePerFrame != 0)
|
||||
if (m_FadeRatePerFrame != 0.0f)
|
||||
{
|
||||
float targetVolume = std::clamp<float>(m_FadeTargetVolume * volumeFactor, 0.0f, 1.0f);
|
||||
float volume = std::clamp<float>(GetVolume() + (m_FadeRatePerFrame * volumeFactor), 0.0f, 1.0f);
|
||||
if ((m_FadeRatePerFrame > 0 && volume >= targetVolume) || (m_FadeRatePerFrame < 0 && volume <= targetVolume))
|
||||
if ((m_FadeRatePerFrame > 0.0f && volume >= targetVolume) || (m_FadeRatePerFrame < 0.0f && volume <= targetVolume))
|
||||
{
|
||||
volume = m_FadeTargetVolume * volumeFactor;
|
||||
m_FadeRatePerFrame = 0.0f;
|
||||
|
||||
@@ -171,7 +171,7 @@ void SoundEngine::SaveVolume(bool isMinimized)
|
||||
if (m_MasterVolume <= outOfFocusVolume)
|
||||
outOfFocusVolume = m_MasterVolume;
|
||||
|
||||
m_MasterVolumeFadeTarget = isMinimized ? 0 : outOfFocusVolume;
|
||||
m_MasterVolumeFadeTarget = isMinimized ? 0.0f : outOfFocusVolume;
|
||||
m_MasterVolumeFadeRatePerFrame = -ratePerSecond / durationOnFullVolume;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ void SoundEngine::Update()
|
||||
if (m_MasterVolumeFadeRatePerFrame)
|
||||
{
|
||||
float volume = ma_engine_get_volume(&m_Engine) + m_MasterVolumeFadeRatePerFrame;
|
||||
if ((m_MasterVolumeFadeRatePerFrame > 0 && volume >= m_MasterVolumeFadeTarget) || (m_MasterVolumeFadeRatePerFrame < 0 && volume <= m_MasterVolumeFadeTarget))
|
||||
if ((m_MasterVolumeFadeRatePerFrame > 0.0f && volume >= m_MasterVolumeFadeTarget) || (m_MasterVolumeFadeRatePerFrame < 0.0f && volume <= m_MasterVolumeFadeTarget))
|
||||
{
|
||||
volume = m_MasterVolumeFadeTarget;
|
||||
m_MasterVolumeFadeRatePerFrame = 0.0f;
|
||||
|
||||
@@ -89,10 +89,10 @@ private:
|
||||
// One song at a time, but holding both current and previous for graceful fading
|
||||
std::array<MaSoundInstance, 2> m_Music;
|
||||
int m_CurrentMusicIndex{};
|
||||
float m_MusicVolume{ 1.0 };
|
||||
float m_SoundVolume{ 1.0 };
|
||||
float m_MusicVolume{ 1.0f };
|
||||
float m_SoundVolume{ 1.0f };
|
||||
|
||||
float m_MasterVolume{ 1.0 };
|
||||
float m_MasterVolume{ 1.0f };
|
||||
float m_MasterVolumeFadeTarget{};
|
||||
float m_MasterVolumeFadeRatePerFrame{};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user