mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Library/Audio: Implement AudioAddonSoundArchiveInfo and al::createAudioInfoList (#890)
This commit is contained in:
parent
b5332923c2
commit
ee3a42d98c
|
|
@ -224035,7 +224035,7 @@ Library/Audio/AudioEventController.o:
|
|||
label:
|
||||
- _ZN2al26AudioAddonSoundArchiveInfoC1Ev
|
||||
- _ZN2al26AudioAddonSoundArchiveInfoC2Ev
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8118fc
|
||||
size: 8
|
||||
label:
|
||||
|
|
@ -224051,7 +224051,7 @@ Library/Audio/AudioEventController.o:
|
|||
- offset: 0x81190c
|
||||
size: 72
|
||||
label: _ZN2al26AudioAddonSoundArchiveInfo10createInfoERKNS_9ByamlIterE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x811954
|
||||
size: 108
|
||||
label: _ZN2al21AudioSoundArchiveInfo10createInfoERKNS_9ByamlIterE
|
||||
|
|
@ -224068,7 +224068,7 @@ Library/Audio/AudioEventController.o:
|
|||
- offset: 0x811c64
|
||||
size: 12
|
||||
label: _ZN2al26AudioAddonSoundArchiveInfo11compareInfoEPKS0_S2_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x811c70
|
||||
size: 104
|
||||
label: _ZN2al26AudioInfoListCreateFunctorINS_26AudioAddonSoundArchiveInfoEE30tryCreateAudioInfoAndSetToListERKNS_9ByamlIterE
|
||||
|
|
|
|||
23
lib/al/Library/Audio/AudioEventController.cpp
Normal file
23
lib/al/Library/Audio/AudioEventController.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include "Library/Audio/AudioEventController.h"
|
||||
|
||||
#include "Library/Yaml/ByamlIter.h"
|
||||
|
||||
namespace al {
|
||||
|
||||
AudioAddonSoundArchiveInfo::AudioAddonSoundArchiveInfo() = default;
|
||||
|
||||
AudioAddonSoundArchiveInfo* AudioAddonSoundArchiveInfo::createInfo(const ByamlIter& iter) {
|
||||
AudioAddonSoundArchiveInfo* info = new AudioAddonSoundArchiveInfo();
|
||||
|
||||
if (!iter.tryGetStringByKey(&info->name, "Name"))
|
||||
return nullptr;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
s32 AudioAddonSoundArchiveInfo::compareInfo(const AudioAddonSoundArchiveInfo* lhs,
|
||||
const AudioAddonSoundArchiveInfo* rhs) {
|
||||
return strcmp(lhs->name, rhs->name);
|
||||
}
|
||||
|
||||
} // namespace al
|
||||
20
lib/al/Library/Audio/AudioEventController.h
Normal file
20
lib/al/Library/Audio/AudioEventController.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
|
||||
namespace al {
|
||||
class ByamlIter;
|
||||
|
||||
struct AudioAddonSoundArchiveInfo {
|
||||
AudioAddonSoundArchiveInfo();
|
||||
|
||||
static AudioAddonSoundArchiveInfo* createInfo(const ByamlIter& iter);
|
||||
static s32 compareInfo(const AudioAddonSoundArchiveInfo* lhs,
|
||||
const AudioAddonSoundArchiveInfo* rhs);
|
||||
|
||||
const char* name = nullptr;
|
||||
};
|
||||
|
||||
static_assert(sizeof(AudioAddonSoundArchiveInfo) == 0x8);
|
||||
|
||||
} // namespace al
|
||||
100
lib/al/Library/Audio/AudioInfo.h
Normal file
100
lib/al/Library/Audio/AudioInfo.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
#include <container/seadPtrArray.h>
|
||||
|
||||
#include "Library/Audio/System/System.h"
|
||||
|
||||
namespace al {
|
||||
class ByamlIter;
|
||||
class AudioInfoListCreateFunctorBase;
|
||||
|
||||
template <typename T>
|
||||
struct AudioInfoList;
|
||||
|
||||
class AudioInfoListCreateFunctorBase {
|
||||
public:
|
||||
AudioInfoListCreateFunctorBase() = default;
|
||||
|
||||
virtual bool tryCreateAudioInfoAndSetToList(const ByamlIter&) = 0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class AudioInfoListCreateFunctor : public AudioInfoListCreateFunctorBase {
|
||||
public:
|
||||
using CreateInfoFunc = T* (*)(const ByamlIter&);
|
||||
|
||||
AudioInfoListCreateFunctor(AudioInfoList<T>* list, CreateInfoFunc fun)
|
||||
: mCreateInfoFunc(fun), mAudioInfoList(list) {}
|
||||
|
||||
bool tryCreateAudioInfoAndSetToList(const ByamlIter& iter) override {
|
||||
T* info = mCreateInfoFunc(iter);
|
||||
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
return mAudioInfoList->list->pushBack(info);
|
||||
}
|
||||
|
||||
private:
|
||||
CreateInfoFunc mCreateInfoFunc;
|
||||
AudioInfoList<T>* mAudioInfoList;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct AudioInfoList {
|
||||
static s32 compareInfoAndKey(const T* info, const char* key) { return strcmp(info->name, key); }
|
||||
|
||||
sead::PtrArray<T>* list;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct AudioInfoListWithParts : public AudioInfoList<T> {
|
||||
s32 tryGetInfoIndex(const char*) const;
|
||||
T* tryFindInfo(const char*) const;
|
||||
|
||||
s32 getPartsSize() const {
|
||||
if (!parts)
|
||||
return 0;
|
||||
return parts->size();
|
||||
}
|
||||
|
||||
bool _8;
|
||||
sead::PtrArray<AudioInfoList<T>>* parts;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
AudioInfoListWithParts<T>* createAudioInfoList(const ByamlIter& iter, s32 maxNumParts) {
|
||||
AudioInfoListWithParts<T>* audioInfoList = new AudioInfoListWithParts<T>;
|
||||
|
||||
s32 listSize = alAudioInfoListFunction::getCreateAudioInfoListSize(iter, 0);
|
||||
audioInfoList->_8 = false;
|
||||
|
||||
audioInfoList->list = new sead::PtrArray<T>();
|
||||
audioInfoList->list->allocBuffer((listSize == 0) ? 1 : listSize, nullptr);
|
||||
|
||||
audioInfoList->parts = nullptr;
|
||||
if (maxNumParts != 0) {
|
||||
audioInfoList->parts = new sead::PtrArray<AudioInfoList<T>>();
|
||||
audioInfoList->parts->allocBuffer(maxNumParts, nullptr);
|
||||
}
|
||||
|
||||
AudioInfoListCreateFunctor<T> functor(audioInfoList, T::createInfo);
|
||||
alAudioInfoListFunction::createAudioInfoAndSetToList(&functor, iter);
|
||||
|
||||
if (audioInfoList->list->size() >= 10)
|
||||
audioInfoList->list->heapSort(T::compareInfo);
|
||||
else
|
||||
audioInfoList->list->sort(T::compareInfo);
|
||||
|
||||
for (s32 i = 0; i < audioInfoList->getPartsSize(); i++) {
|
||||
sead::PtrArray<T>* partsList = audioInfoList->parts->at(i)->list;
|
||||
if (partsList->size() >= 10)
|
||||
partsList->heapSort(T::compareInfo);
|
||||
else
|
||||
partsList->sort(T::compareInfo);
|
||||
}
|
||||
return audioInfoList;
|
||||
}
|
||||
|
||||
} // namespace al
|
||||
14
lib/al/Library/Audio/System/System.h
Normal file
14
lib/al/Library/Audio/System/System.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
|
||||
namespace al {
|
||||
class ByamlIter;
|
||||
class AudioInfoListCreateFunctorBase;
|
||||
} // namespace al
|
||||
|
||||
namespace alAudioInfoListFunction {
|
||||
s32 getCreateAudioInfoListSize(const al::ByamlIter&, s32);
|
||||
s32 getCreateAudioInfoListSize(const al::ByamlIter&, const al::ByamlIter&);
|
||||
void createAudioInfoAndSetToList(al::AudioInfoListCreateFunctorBase*, const al::ByamlIter&);
|
||||
} // namespace alAudioInfoListFunction
|
||||
Loading…
Reference in a new issue