//
// FMODAudioEngine::channelStopped from 0x3ed9f0 to 0x3edb28 (312 bytes)
//
// 2 xrefs:
// > sub_3EDB2C @ 0x3edb3e
// > sub_3EDB46 @ 0x3edb56
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:47:10 +0000
//
unsigned int __fastcall FMODAudioEngine::channelStopped(FMODAudioEngine *this, FMOD::Channel *a2, int a3)
{
int v6; // r5
unsigned int v7; // r7
unsigned int v8; // r6
unsigned int v9; // r10
int v10; // r11
int ***v11; // r1
int **i; // r5
int *v13; // r0
int v14; // r1
FMOD::DSP *v15; // r11
unsigned int result; // r0
_DWORD *j; // r5
int v18; // r2
_DWORD *v19; // r3
int v21; // [sp+14h] [bp-4h] BYREF
FMOD::DSP *v22; // [sp+18h] [bp+0h] BYREF
v6 = 0;
getChannelID(a2, a2);
v21 = 0;
v7 = (unsigned int)a2;
FMOD::ChannelControl::getNumDSPs(a2, &v21);
while ( v6 < v21 )
{
v22 = nullptr;
FMOD::ChannelControl::getDSP(a2, v6, &v22);
if ( v22 )
{
FMOD::ChannelControl::removeDSP(a2, v22);
FMOD::DSP::release(v22);
}
++v6;
}
v8 = *((_DWORD *)this + 188);
if ( v8 )
{
v9 = v8 - 1;
v10 = ((v8 - 1) & v8) != 0 ? v7 % v8 : v7 & v9;
v11 = *(int ****)(*((_DWORD *)this + 187) + 4 * v10);
if ( v11 )
{
for ( i = *v11; i; i = (int **)*i )
{
v13 = i[1];
v14 = ((v8 - 1) & v8) != 0 ? (unsigned int)v13 % v8 : v9 & (unsigned int)v13;
if ( v14 != v10 )
break;
if ( i[2] == (int *)v7 )
{
v15 = (FMOD::DSP *)i[3];
if ( v15 )
{
FMOD::ChannelControl::removeDSP(a2, (FMOD::DSP *)i[3]);
FMOD::DSP::release(v15);
}
std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::erase(
(_DWORD *)this + 187,
i);
break;
}
}
}
}
result = FMODAudioEngine::unregisterChannel(this, v7);
if ( a3 )
{
for ( j = *((_DWORD **)this + 68); j; j = (_DWORD *)*j )
{
if ( j[3] == v7 )
{
v18 = j[4];
if ( v18 )
{
v19 = *((_DWORD **)this + 185);
if ( v19 == *((_DWORD **)this + 186) )
{
std::vector::__push_back_slow_path((int)this + 736, j + 4);
}
else
{
if ( v19 )
*v19 = v18;
*((_DWORD *)this + 185) += 4;
}
}
return std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::erase(
(_DWORD *)this + 66,
j);
}
}
}
return result;
}