Merge pull request #91 from lioncash/string

CAudioSys: Minor cleanup
This commit is contained in:
Phillip Stephens 2019-10-01 06:44:26 -07:00 committed by GitHub
commit 60ecede3fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 12 deletions

View File

@ -3,11 +3,19 @@
#include "CAudioGroupSet.hpp"
namespace urde {
namespace {
std::unordered_map<std::string, TLockedToken<CAudioGroupSet>> mpGroupSetDB;
std::unordered_map<CAssetId, std::string> mpGroupSetResNameDB;
constexpr std::string_view mpDefaultInvalidString = "NULL";
float s_MasterVol = 1.f;
float s_SfxVol = 1.f;
s16 s_VolumeScale = 0x7f;
s16 s_DefaultVolumeScale = 0x7f;
} // Anonymous namespace
CAudioSys* CAudioSys::g_SharedSys = nullptr;
static std::unordered_map<std::string, TLockedToken<CAudioGroupSet>> mpGroupSetDB;
static std::unordered_map<CAssetId, std::string> mpGroupSetResNameDB;
static const std::string mpDefaultInvalidString = "NULL";
TLockedToken<CAudioGroupSet> CAudioSys::FindGroupSet(std::string_view name) {
auto search = mpGroupSetDB.find(name.data());
@ -26,8 +34,8 @@ std::string_view CAudioSys::SysGetGroupSetName(CAssetId id) {
bool CAudioSys::SysLoadGroupSet(CSimplePool* pool, CAssetId id) {
if (!FindGroupSet(SysGetGroupSetName(id))) {
TLockedToken<CAudioGroupSet> set = pool->GetObj(SObjectTag{FOURCC('AGSC'), id});
mpGroupSetDB.emplace(std::make_pair(set->GetName(), set));
mpGroupSetResNameDB.emplace(std::make_pair(id, set->GetName()));
mpGroupSetDB.emplace(set->GetName(), set);
mpGroupSetResNameDB.emplace(id, set->GetName());
return false;
} else {
return true;
@ -36,8 +44,8 @@ bool CAudioSys::SysLoadGroupSet(CSimplePool* pool, CAssetId id) {
bool CAudioSys::SysLoadGroupSet(const TLockedToken<CAudioGroupSet>& set, std::string_view name, CAssetId id) {
if (!FindGroupSet(name)) {
mpGroupSetDB.emplace(std::make_pair(set->GetName(), set));
mpGroupSetResNameDB.emplace(std::make_pair(id, set->GetName()));
mpGroupSetDB.emplace(set->GetName(), set);
mpGroupSetResNameDB.emplace(id, set->GetName());
return false;
} else {
return true;
@ -65,8 +73,6 @@ void CAudioSys::SysRemoveGroupFromAmuse(std::string_view name) {
RemoveAudioGroup(set->GetAudioGroupData());
}
static float s_MasterVol = 1.f;
static float s_SfxVol = 1.f;
void CAudioSys::_UpdateVolume() { GetAmuseEngine().setVolume(s_MasterVol * s_SfxVol); }
void CAudioSys::SysSetVolume(u8 volume) {
@ -79,9 +85,6 @@ void CAudioSys::SysSetSfxVolume(u8 volume, u16 time, bool music, bool fx) {
_UpdateVolume();
}
static s16 s_VolumeScale = 0x7f;
static s16 s_DefaultVolumeScale = 0x7f;
s16 CAudioSys::GetDefaultVolumeScale() { return s_DefaultVolumeScale; }
void CAudioSys::SetDefaultVolumeScale(s16 scale) { s_DefaultVolumeScale = scale; }