//
// FMODAudioEngine::saveAudioState from 0x100139888 to 0x1001399d4 (332 bytes)
//
// 1 xrefs:
// > PlayLayer::createCheckpoint @ 0x10011f9e4
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall FMODAudioEngine::saveAudioState(FMODAudioEngine *a1, FMODAudioState *a2)
{
std::__hash_node_base, void *> *>::__next_pointer i; // x24
__int64 v5; // x0
__int64 v6; // x22
FMOD::Channel *v7; // x0
FMOD::Channel *v8; // x23
int next; // [xsp+0h] [xbp-50h] BYREF
char v10; // [xsp+7h] [xbp-49h] BYREF
int *p_next; // [xsp+8h] [xbp-48h] BYREF
sub_100452E0C(a1->m_system);
for ( i = a1->m_channelIDToChannel.__table_.__p1_.__value_.__next_; i; i = i->__next_ )
{
next = (int)i[2].__next_;
if ( sub_100018814(&a1->m_audioState.m_soundStateForChannels.__table_.__bucket_list_.__ptr_.__value_, &next) )
{
p_next = &next;
v5 = sub_10013F980(&a1->m_audioState.m_soundStateForChannels, &next, &unk_100637FD3, &p_next, &v10);
if ( (*(_BYTE *)(v5 + 196) & 1) == 0 )
{
v6 = v5;
v7 = FMODAudioEngine::channelForChannelID(a1, next);
if ( v7 )
{
v8 = v7;
FMOD::Channel::getLoopPoints(v7, (unsigned int *)(v6 + 136), 1u, (unsigned int *)(v6 + 140), 1u);
FMOD::ChannelControl::getDSPClock(v8, nullptr, (unsigned __int64 *)(v6 + 128));
FMOD::Channel::getPosition(v8, (unsigned int *)(v6 + 144), 1u);
sub_1004535A8(v8, v6 + 72, 0, 0);
if ( *(_DWORD *)(v6 + 72) )
sub_1004535A8(v8, v6 + 72, v6 + 96, v6 + 76);
sub_100453534(v8, v6 + 152, v6 + 160, v6 + 168);
}
}
}
}
sub_100139A34(a2, &a1->m_audioState);
sub_10013FBD4(&a2->m_queuedMusicForChannels1);
sub_100452E1C(a1->m_system);
}