//
// FMODAudioEngine::stopChannel from 0x6da00c to 0x6da350 (836 bytes)
//
// 3 xrefs:
// > FMODAudioEngine::stopChannel @ 0x6da3bc
// > FMODAudioEngine::stopChannel @ 0x6da510
// > ??> @ 0xecf80
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 12:51:33 +0000
//
__int64 __fastcall FMODAudioEngine::stopChannel(FMODAudioEngine *this, FMOD::Channel *a2, unsigned __int8 a3, float a4)
{
int ChannelID; // w0
unsigned __int64 v8; // x27
unsigned __int64 v9; // x21
int v10; // w28
unsigned __int64 v11; // x23
__int64 v12; // x22
unsigned __int64 v13; // x5
__int64 *v14; // x0
unsigned __int64 v15; // x2
unsigned __int64 v16; // x2
char *v17; // x26
__int64 v18; // x0
__int64 v19; // x20
float v20; // s2
float v21; // s0
_BOOL8 v22; // x2
__int64 v23; // x1
unsigned __int64 v24; // x1
unsigned __int64 v25; // x22
__int64 *v26; // x0
float v27; // s0
unsigned __int64 v29; // x2
unsigned __int64 v30; // x1
__int64 v31; // [xsp+78h] [xbp+78h]
int v32; // [xsp+80h] [xbp+80h]
float v33; // [xsp+80h] [xbp+80h]
unsigned __int64 v34; // [xsp+90h] [xbp+90h] BYREF
v32 = a3;
if ( !a2 )
return _stack_chk_guard;
if ( (a4 <= 0.0) > (unsigned int)a3 )
{
FMOD::ChannelControl::stop(a2);
return _stack_chk_guard;
}
ChannelID = getChannelID(a2);
v8 = *((_QWORD *)this + 163);
v9 = ChannelID;
v10 = ChannelID;
if ( v8 )
{
v11 = v8 - 1;
v12 = (v8 - 1) & v8;
v13 = ChannelID & (v8 - 1);
if ( v12 )
v13 = ChannelID % v8;
v31 = 8 * v13;
v14 = *(__int64 **)(*((_QWORD *)this + 162) + 8 * v13);
if ( v14 )
{
while ( 1 )
{
v14 = (__int64 *)*v14;
if ( !v14 )
break;
v15 = v14[1];
v16 = v12 ? v15 % v8 : v11 & v15;
if ( v13 != v16 )
break;
if ( v10 == *((_DWORD *)v14 + 4) )
{
if ( !v32 )
goto LABEL_21;
goto LABEL_26;
}
}
}
v17 = (char *)this + 1312;
v18 = operator new(0x18u);
*(_DWORD *)(v18 + 16) = v10;
*(_QWORD *)(v18 + 8) = v9;
v19 = v18;
*(_QWORD *)v18 = 0;
v20 = *((float *)this + 332);
v21 = (float)(unsigned __int64)(*((_QWORD *)this + 165) + 1LL);
if ( (float)((float)v8 * v20) >= v21 )
goto LABEL_18;
v22 = 1;
v23 = 2 * v8;
if ( v8 > 2 )
v22 = v12 != 0;
}
else
{
v17 = (char *)this + 1312;
v19 = operator new(0x18u);
v22 = 1;
v23 = 0;
*(_DWORD *)(v19 + 16) = v9;
*(_QWORD *)(v19 + 8) = v9;
*(_QWORD *)v19 = 0;
v20 = *((float *)this + 332);
v21 = (float)(unsigned __int64)(*((_QWORD *)this + 165) + 1LL);
}
v24 = v22 + v23;
v25 = vcvtps_u32_f32(v21 / v20);
if ( v25 >= v24 )
v24 = v25;
std::__hash_table,std::equal_to,std::allocator>::rehash(
(unsigned __int64)this + 1296,
v24);
v8 = *((_QWORD *)this + 163);
v11 = v8 - 1;
if ( ((v8 - 1) & v8) != 0 )
v31 = 8 * (v9 % v8);
else
v31 = 8 * (v9 & v11);
LABEL_18:
v26 = *(__int64 **)(*((_QWORD *)this + 162) + v31);
if ( v26 )
{
*(_QWORD *)v19 = *v26;
*v26 = v19;
}
else
{
*(_QWORD *)v19 = *((_QWORD *)this + 164);
*((_QWORD *)this + 164) = v19;
*(_QWORD *)(*((_QWORD *)this + 162) + v31) = v17;
if ( *(_QWORD *)v19 )
{
v29 = *(_QWORD *)(*(_QWORD *)v19 + 8LL);
if ( (v11 & v8) != 0 )
v30 = v29 % v8;
else
v30 = v11 & v29;
*(_QWORD *)(*((_QWORD *)this + 162) + 8 * v30) = v19;
}
}
++*((_QWORD *)this + 165);
if ( v32 )
LABEL_26:
FMOD::Channel::setLoopCount(a2, 0);
LABEL_21:
if ( a4 > 0.0 )
{
*((_DWORD *)this + 134) = FMOD::ChannelControl::getDSPClock(a2, nullptr, &v34);
FMODAudioEngine::stopAndGetFade(this, a2);
v33 = v27;
*((_DWORD *)this + 134) = FMOD::ChannelControl::setDelay(
a2,
0,
(unsigned __int64)(float)((float)v34 + (float)((float)*((int *)this + 135) * a4)),
1);
*((_DWORD *)this + 134) = FMOD::ChannelControl::addFadePoint(a2, v34, v33);
ERRCHECK_fn();
*((_DWORD *)this + 134) = FMOD::ChannelControl::addFadePoint(
a2,
(unsigned __int64)(float)((float)v34 + (float)((float)*((int *)this + 135) * a4)),
0.0);
ERRCHECK_fn();
}
return _stack_chk_guard;
}