feat(sound): sound player release function
This commit is contained in:
parent
a7c4e9402b
commit
52cbf0d1a6
|
|
@ -155,6 +155,11 @@ void SoundPlayer::StopAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoundPlayer::ReleaseSound(size_t id)
|
||||||
|
{
|
||||||
|
sound_cache_.erase(id);
|
||||||
|
}
|
||||||
|
|
||||||
void SoundPlayer::ClearCache()
|
void SoundPlayer::ClearCache()
|
||||||
{
|
{
|
||||||
sound_cache_.clear();
|
sound_cache_.clear();
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ KGE_DECLARE_SMART_PTR(SoundPlayer);
|
||||||
class KGE_API SoundPlayer : public ObjectBase
|
class KGE_API SoundPlayer : public ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using SoundMap = Map<size_t, SoundPtr>;
|
||||||
|
|
||||||
SoundPlayer();
|
SoundPlayer();
|
||||||
|
|
||||||
~SoundPlayer();
|
~SoundPlayer();
|
||||||
|
|
@ -120,6 +122,15 @@ public:
|
||||||
/// @brief 停止所有音频
|
/// @brief 停止所有音频
|
||||||
void StopAll();
|
void StopAll();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 释放音乐对象缓存
|
||||||
|
/// @param id 音频标识符
|
||||||
|
void ReleaseSound(size_t id);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取缓存
|
||||||
|
const SoundMap& GetCache() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 清除缓存
|
/// @brief 清除缓存
|
||||||
void ClearCache();
|
void ClearCache();
|
||||||
|
|
@ -127,10 +138,15 @@ public:
|
||||||
private:
|
private:
|
||||||
float volume_;
|
float volume_;
|
||||||
|
|
||||||
using SoundMap = Map<size_t, SoundPtr>;
|
|
||||||
SoundMap sound_cache_;
|
SoundMap sound_cache_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
inline const SoundPlayer::SoundMap& SoundPlayer::GetCache() const
|
||||||
|
{
|
||||||
|
return sound_cache_;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace audio
|
} // namespace audio
|
||||||
} // namespace kiwano
|
} // namespace kiwano
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue