//
// FMODAudioEngine::stopChannel from 0x3f08ac to 0x3f0b18 (620 bytes)
//
// 2 xrefs:
// > FMODAudioEngine::stopChannel @ 0x3f0be4
// > FMODAudioEngine::stopChannel @ 0x3f0c36
//
// 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:13 +0000
//
void __fastcall FMODAudioEngine::stopChannel(FMODAudioEngine *this, unsigned int a2, int a3, float a4)
{
int v4; // r7
unsigned int v10; // r4
unsigned int v11; // r10
unsigned int v12; // r6
_DWORD *v13; // r3
unsigned int v14; // r0
int v15; // r1
_DWORD *v16; // r0
_DWORD *v17; // r6
float v18; // s13
float v19; // s15
bool v20; // r7
unsigned int v21; // r7
unsigned int v22; // r1
_DWORD *v23; // r3
int v24; // r3
unsigned int v25; // r0
int v26; // r1
float Fade; // r4
int v28; // r0
unsigned __int64 v29; // r2
unsigned __int64 v30; // [sp+18h] [bp-14h] BYREF
if ( !a2 )
return;
if ( !a3 && a4 <= 0.0 )
{
FMOD::ChannelControl::stop((FMOD::ChannelControl *)a2);
return;
}
getChannelID((FMOD::Channel *)a2, (void *)a2);
v10 = *((_DWORD *)this + 198);
v11 = a2;
if ( v10 )
{
v12 = v10 - 1;
v4 = ((v10 - 1) & v10) != 0 ? a2 % v10 : a2 & v12;
v13 = *(_DWORD **)(*((_DWORD *)this + 197) + 4 * v4);
if ( v13 )
{
while ( 1 )
{
v13 = (_DWORD *)*v13;
if ( !v13 )
break;
v14 = v13[1];
v15 = ((v10 - 1) & v10) != 0 ? v14 % v10 : v12 & v14;
if ( v15 != v4 )
break;
if ( v13[2] == v11 )
goto LABEL_31;
}
}
}
v16 = (_DWORD *)operator new(0xCu);
v16[2] = v11;
v17 = v16;
v16[1] = v11;
*v16 = 0;
v18 = *((float *)this + 201);
v19 = (float)(unsigned int)(*((_DWORD *)this + 200) + 1);
if ( v19 > (float)((float)v10 * v18) )
{
v20 = v10 > 2 && ((v10 - 1) & v10) == 0;
}
else
{
if ( v10 )
goto LABEL_23;
v20 = 0;
}
v21 = 2 * v10 + !v20;
v22 = (unsigned int)ceilf(v19 / v18);
if ( v22 < v21 )
v22 = v21;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)this + 788, v22);
v10 = *((_DWORD *)this + 198);
if ( ((v10 - 1) & v10) != 0 )
v4 = v11 % v10;
else
v4 = v11 & (v10 - 1);
LABEL_23:
v23 = *(_DWORD **)(*((_DWORD *)this + 197) + 4 * v4);
if ( v23 )
{
*v17 = *v23;
*v23 = v17;
}
else
{
*v17 = *((_DWORD *)this + 199);
v24 = *((_DWORD *)this + 197);
*((_DWORD *)this + 199) = v17;
*(_DWORD *)(v24 + 4 * v4) = (char *)this + 796;
if ( *v17 )
{
v25 = *(_DWORD *)(*v17 + 4);
if ( ((v10 - 1) & v10) != 0 )
v26 = v25 % v10;
else
v26 = (v10 - 1) & v25;
*(_DWORD *)(*((_DWORD *)this + 197) + 4 * v26) = v17;
}
}
++*((_DWORD *)this + 200);
LABEL_31:
if ( a3 )
FMOD::Channel::setLoopCount((FMOD::Channel *)a2, 0);
if ( a4 > 0.0 )
{
*((_DWORD *)this + 97) = FMOD::ChannelControl::getDSPClock((FMOD::ChannelControl *)a2, nullptr, &v30);
Fade = FMODAudioEngine::stopAndGetFade(this, (FMOD::Channel *)a2);
v28 = FMOD::ChannelControl::setDelay(
(FMOD::ChannelControl *)a2,
0,
(unsigned __int64)(float)((float)v30 + (float)((float)*((int *)this + 98) * a4)),
1);
v29 = v30;
*((_DWORD *)this + 97) = v28;
*((_DWORD *)this + 97) = FMOD::ChannelControl::addFadePoint((FMOD::ChannelControl *)a2, v29, Fade);
ERRCHECK_fn();
*((_DWORD *)this + 97) = FMOD::ChannelControl::addFadePoint(
(FMOD::ChannelControl *)a2,
(unsigned __int64)(float)((float)v30 + (float)((float)*((int *)this + 98) * a4)),
0.0);
ERRCHECK_fn();
}
}