Files
isaac-port/generated-src/sound_manager.cpp
T
shweetandClaude Opus 5.5 9d4d4f5c64 Build 29: zero-length placeholder structs, generated-src with standard types
--check: 938/3256 method bodies compile for x86_64 (28.8%), 32-bit layout asserts hold; boot path 3/626 curated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:41:34 -05:00

244 lines
8.8 KiB
C++

#include "classes.h"
// 00a2b1e0
void * SoundManager::load_sound(void *outSound, uint8_t *path, void *fileSource, uint8_t isStream)
{
void *pvVar1;
char cVar2;
uint32_t uVar3;
ReferenceCountBase *emptySourceRef;
char *pcVar4;
uint32_t *newSource;
uint8_t *pathEnd;
undefined3 in_stack_00000011;
int pathHash;
uint8_t local_28 [4];
int *local_24;
int *sourcePtr;
int *local_1c;
void *local_18;
uint32_t local_14;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
code *mutexInitFn;
uint8_t pathChar;
int *soundSource;
pvVar1 = fileSource;
local_8 = 0xffffffff;
puStack_c = &LAB_00b12184;
local_10 = ExceptionList;
uVar3 = __security_cookie ^ GHIDRA_UINT((local_28 + 0x24));
ExceptionList = &local_10;
local_14 = 0;
local_18 = this;
if (((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 4)) & 1) == 0) &&
(KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Sound manager has not been initialized\n")),
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 4)) & 1) == 0)) {
*GHIDRA_CAST<uint32_t *>(outSound) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(outSound) + 4)) = 0;
emptySourceRef = operator_new(0x18);
local_8 = 1;
_isStream = emptySourceRef;
if (emptySourceRef == GHIDRA_CAST<ReferenceCountBase *>(0x0)) {
emptySourceRef = GHIDRA_CAST<ReferenceCountBase *>(0x0);
}
else {
(GHIDRA_CAST<ReferenceCountBase *>((emptySourceRef)))->ReferenceCountBase::ReferenceCountBase();
*GHIDRA_CAST<uint8_t ***>(emptySourceRef) = ReferenceCount<KAGE::Sound::SoundSourceBase>::vftable;
*GHIDRA_CAST<uint32_t *>((emptySourceRef + 0x14)) = 0;
}
local_8 = local_8 & 0xffffff00;
if (((*GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(outSound) + 4)) != GHIDRA_CAST<int *>(0x0)) &&
(cVar2 = (**(code **)(**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(outSound) + 4)) + 0xc))(), cVar2 != '\0')) &&
(g_soundReleaseFn != (void *)0x0)) {
(*g_soundReleaseFn)(outSound);
}
*GHIDRA_CAST<ReferenceCountBase **>((GHIDRA_CAST<char *>(outSound) + 4)) = emptySourceRef;
*GHIDRA_CAST<uint32_t *>(outSound) = 0;
ExceptionList = local_10;
return outSound;
}
(**(code **)(*GHIDRA_CAST<int *>(this) + 0x28))(&sourcePtr,path,fileSource,uVar3);
local_8 = 2;
fileSource = sourcePtr;
if (sourcePtr == GHIDRA_CAST<int *>(0x0)) {
fileSource = (void *)0x0;
}
else if (isStream == 0) {
FUN_008f2d20(&sourcePtr);
local_14 = 1;
local_8 = 3;
if (local_1c == GHIDRA_CAST<int *>(0x0)) {
ExceptionList = local_10;
return outSound;
}
cVar2 = (**(code **)(*local_1c + 0xc))();
if (cVar2 == '\0') {
ExceptionList = local_10;
return outSound;
}
if (g_soundReleaseFn == (void *)0x0) {
ExceptionList = local_10;
return outSound;
}
(*g_soundReleaseFn)(&sourcePtr);
ExceptionList = local_10;
return outSound;
}
pcVar4 = strstr(GHIDRA_CAST<char *>(path),".wav");
if (pcVar4 == GHIDRA_CAST<char *>(0x0)) {
pcVar4 = strstr(GHIDRA_CAST<char *>(path),".ogg");
if (pcVar4 == GHIDRA_CAST<char *>(0x0)) {
pcVar4 = strstr(GHIDRA_CAST<char *>(path),".org");
if (pcVar4 == GHIDRA_CAST<char *>(0x0)) {
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("Failed to load sound \'%s\'. Unknown sound source type\n"));
FUN_008f2d20(&sourcePtr);
FUN_007e2740();
ExceptionList = local_10;
return outSound;
}
if (pvVar1 == (void *)0x0) {
newSource = operator_new(0x4c);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 0xb;
if (newSource == GHIDRA_CAST<uint32_t *>(0x0)) goto LAB_00a2b5b3;
FUN_00a9fa20();
newSource[0x11] = 0;
newSource[0x12] = 0;
*newSource = KAGE::Sound::SampleSourceOrg::vftable;
}
else {
if (pvVar1 != (void *)0x1) goto LAB_00a2b5c2;
newSource = operator_new(0x20740);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 0xc;
if (newSource == GHIDRA_CAST<uint32_t *>(0x0)) goto LAB_00a2b5b3;
FUN_00aa0110();
*newSource = KAGE::Sound::StreamSourceOrg::vftable;
newSource[0x81cc] = 0;
newSource[0x81cd] = 0;
memset(newSource + 0x25,0,0x2069c);
newSource[0x81ce] = 0;
newSource[0x81cf] = 0;
}
}
else if (pvVar1 == (void *)0x0) {
newSource = operator_new(0x58);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 6;
if (newSource == GHIDRA_CAST<uint32_t *>(0x0)) goto LAB_00a2b5b3;
FUN_00a9fa20();
newSource[0x11] = 0;
newSource[0x12] = 0;
*newSource = KAGE::Sound::SampleSourceOgg::vftable;
}
else {
if (pvVar1 != (void *)0x1) goto LAB_00a2b5c2;
newSource = operator_new(0xc4);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 7;
if (newSource == GHIDRA_CAST<uint32_t *>(0x0)) goto LAB_00a2b5b3;
FUN_00aa0110();
*newSource = KAGE::Sound::StreamSourceOgg::vftable;
newSource[0x25] = 0;
*GHIDRA_CAST<uint8_t *>((newSource + 0x29)) = 0;
newSource[0x28] = KAGE::Mutex::vftable;
newSource[0x2a] = 0;
newSource[0x2b] = 0;
newSource[0x2f] = 0;
newSource[0x30] = 0xf;
*GHIDRA_CAST<uint8_t *>((newSource + 0x2b)) = 0;
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 10;
mutexInitFn = *(code **)(newSource[0x28] + 4);
if (mutexInitFn == FUN_00a15770) {
FUN_00a15770();
newSource[0x26] = 0;
}
else {
(*mutexInitFn)();
newSource[0x26] = 0;
}
}
}
else if (pvVar1 == (void *)0x0) {
newSource = operator_new(100);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 4;
if (newSource == GHIDRA_CAST<uint32_t *>(0x0)) {
LAB_00a2b5b3:
newSource = GHIDRA_CAST<uint32_t *>(0x0);
}
else {
FUN_00a9fa20();
newSource[0x11] = 0;
newSource[0x12] = 0;
*newSource = KAGE::Sound::SampleSourceWav::vftable;
newSource[0x14] = 0;
newSource[0x13] = 0;
}
}
else {
if (pvVar1 != (void *)0x1) goto LAB_00a2b5c2;
newSource = operator_new(0xa8);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 5;
if (newSource == GHIDRA_CAST<uint32_t *>(0x0)) goto LAB_00a2b5b3;
FUN_00aa0110();
*newSource = KAGE::Sound::StreamSourceWav::vftable;
}
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),2);
KAGE::SmartPointer<SoundSourceBase>::reset(newSource);
LAB_00a2b5c2:
if ((((isStream == 0) || (fileSource == (void *)0x0)) ||
((pvVar1 != (void *)0x0 ||
(cVar2 = (**(code **)(*GHIDRA_CAST<int *>(fileSource) + 0x20))(sourcePtr), cVar2 == '\0')))) &&
(cVar2 = (**(code **)(*sourcePtr + 0x1c))(path), cVar2 == '\0')) {
KAGE::SmartPointer<SoundSourceBase>::reset(0);
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Failed to open %s \")%s\"\n");
}
else {
sourcePtr[1] = GHIDRA_INT(pvVar1);
if (path == GHIDRA_CAST<uint8_t *>(0x0)) {
pcVar4 = GHIDRA_CAST<char *>(0x0);
}
else {
pathEnd = path;
do {
pathChar = *pathEnd;
pathEnd = pathEnd + 1;
} while (pathChar != 0);
pcVar4 = operator_new_tracked(GHIDRA_UINT((pathEnd + (1 - GHIDRA_INT((path + 1))))));
pathEnd = path;
do {
pathChar = *pathEnd;
pathEnd = pathEnd + 1;
} while (pathChar != 0);
strncpy(pcVar4,GHIDRA_CAST<char *>(path),(size_t)(pathEnd + (1 - GHIDRA_INT((path + 1)))));
}
soundSource = sourcePtr;
sourcePtr[3] = GHIDRA_INT(pcVar4);
uVar3 = KAGE_Filesys_FileManager::GetPrimaryFilePathHash(GHIDRA_CAST<uint8_t *>(sourcePtr[3]));
pvVar1 = local_18;
soundSource[4] = uVar3;
(**(code **)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_18) + 0x10)) + 0xc))(0xffffffff);
pathHash = sourcePtr[4];
FUN_008f2d20(&sourcePtr);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 0xd;
FUN_00a2bd60(&isStream,&pathHash);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 0xe;
if (((local_24 != GHIDRA_CAST<int *>(0x0)) && (cVar2 = (**(code **)(*local_24 + 0xc))(), cVar2 != '\0')) &&
(g_soundReleaseFn != (void *)0x0)) {
(*g_soundReleaseFn)(local_28);
}
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),2);
(**(code **)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x10)) + 0x10))();
}
FUN_008f2d20(&sourcePtr);
local_14 = 1;
local_8 = 0xf;
if (((local_1c == GHIDRA_CAST<int *>(0x0)) || (cVar2 = (**(code **)(*local_1c + 0xc))(), cVar2 == '\0')) ||
(g_soundReleaseFn == (void *)0x0)) {
ExceptionList = local_10;
return outSound;
}
(*g_soundReleaseFn)(&sourcePtr);
ExceptionList = local_10;
return outSound;
}