//
// CustomSongWidget::onPlayback from 0x14016bcd0 to 0x14016c158 (1160 bytes)
//
// 2 xrefs:
// > CustomSongWidget::init @ 0x1401698c5
// > ??> @ 0x14091814c
//
// This function is hookable on this platform (idp: pc, 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 11:27:29 +0000
//
// Hidden C++ exception states: #wind=15
void __fastcall CustomSongWidget::onPlayback(__int64 a1)
{
void (__fastcall ***v2)(_QWORD, _QWORD); // rcx
__int64 v3; // rcx
_QWORD *v4; // rcx
__int64 v5; // rcx
void **v6; // r14
unsigned __int64 v7; // rsi
__int64 v8; // rbx
_QWORD *v9; // rcx
_QWORD *v10; // rbx
__int64 v11; // rcx
_QWORD *v12; // rcx
_QWORD *v13; // rbx
__int64 v14; // rcx
__int64 v15; // rcx
_QWORD *v16; // rax
size_t v17; // r8
_QWORD *v18; // rcx
void *v19; // [rsp+30h] [rbp-39h]
void *v20; // [rsp+30h] [rbp-39h]
void *v21; // [rsp+30h] [rbp-39h]
void *v22; // [rsp+30h] [rbp-39h]
void *v23; // [rsp+30h] [rbp-39h]
void *v24; // [rsp+38h] [rbp-31h]
void *v25; // [rsp+38h] [rbp-31h]
void *v26; // [rsp+38h] [rbp-31h]
void *v27; // [rsp+38h] [rbp-31h]
__int128 v28; // [rsp+40h] [rbp-29h] BYREF
unsigned __int64 v29; // [rsp+50h] [rbp-19h]
__int64 v30; // [rsp+58h] [rbp-11h]
void *Src[2]; // [rsp+60h] [rbp-9h] BYREF
unsigned __int64 v32; // [rsp+70h] [rbp+7h]
unsigned __int64 v33; // [rsp+78h] [rbp+Fh]
_BYTE v34[32]; // [rsp+80h] [rbp+17h] BYREF
v2 = *(void (__fastcall ****)(_QWORD, _QWORD))(a1 + 520);
if ( v2 )
{
(**v2)(v2, *(_QWORD *)(a1 + 336));
}
else if ( *(_QWORD *)(a1 + 336) )
{
v3 = qword_14090C070;
if ( !qword_14090C070 )
{
v24 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager(v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
v3 = qword_14090C070;
}
MusicDownloadManager::pathForSong(v3, Src, *(unsigned int *)(*(_QWORD *)(a1 + 336) + 320LL));
v4 = (_QWORD *)qword_14090BF60;
if ( !qword_14090BF60 )
{
v25 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v4 = (_QWORD *)qword_14090BF60;
}
if ( FMODAudioEngine::isMusicPlaying_1(v4, 0) )
{
v28 = 0;
v29 = 0;
v30 = 0;
v6 = Src;
if ( v33 > 0xF )
v6 = (void **)Src[0];
v7 = v32;
v8 = 0x7FFFFFFFFFFFFFFFLL;
if ( v32 > 0x7FFFFFFFFFFFFFFFLL )
sub_140009D90(v5);
if ( v32 > 0xF )
{
if ( (v32 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v8 = v32 | 0xF;
if ( (v32 | 0xF) < 0x16 )
v8 = 22;
}
*(_QWORD *)&v28 = sub_14003D460(v8 + 1);
v29 = v7;
v30 = v8;
memcpy((void *)v28, v6, v7 + 1);
}
else
{
v29 = v32;
v30 = 15;
v28 = *(_OWORD *)v6;
}
v9 = (_QWORD *)qword_14090BF60;
if ( !qword_14090BF60 )
{
v19 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v19);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v9 = (_QWORD *)qword_14090BF60;
}
if ( !FMODAudioEngine::isMusicPlaying(v9, &v28) )
{
v10 = (_QWORD *)qword_14090BF60;
if ( !qword_14090BF60 )
{
v20 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v20);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v10 = (_QWORD *)qword_14090BF60;
}
v11 = v10[69];
if ( v11 )
FMOD::ChannelControl::stop(v11);
sub_14003EB60(v10 + 137);
sub_14003EB60(v10 + 145);
sub_14003EB60(v10 + 153);
}
}
v12 = (_QWORD *)qword_14090BF60;
if ( !qword_14090BF60 )
{
v21 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v21);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v12 = (_QWORD *)qword_14090BF60;
}
if ( FMODAudioEngine::isMusicPlaying_1(v12, 0) )
{
v13 = (_QWORD *)qword_14090BF60;
if ( !qword_14090BF60 )
{
v22 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v13 = (_QWORD *)qword_14090BF60;
}
v14 = v13[69];
if ( v14 )
FMOD::ChannelControl::stop(v14);
sub_14003EB60(v13 + 137);
sub_14003EB60(v13 + 145);
sub_14003EB60(v13 + 153);
}
else if ( *(_QWORD *)(a1 + 336) )
{
v15 = qword_14090C070;
if ( !qword_14090C070 )
{
v26 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager(v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
v15 = qword_14090C070;
}
v16 = (_QWORD *)MusicDownloadManager::pathForSong(v15, v34, *(unsigned int *)(*(_QWORD *)(a1 + 336) + 320LL));
if ( v16[3] > 0xFu )
v16 = (_QWORD *)*v16;
v28 = 0;
v29 = 0;
v30 = 0;
v17 = -1;
do
++v17;
while ( *((_BYTE *)v16 + v17) );
sub_14003D230(&v28, v16, v17);
v18 = (_QWORD *)qword_14090BF60;
if ( !qword_14090BF60 )
{
v27 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v18 = (_QWORD *)qword_14090BF60;
}
FMODAudioEngine::playMusic(v18, (__int64)&v28, 0, 0.0);
sub_14003D310((__int64)v34);
}
if ( !qword_14090C070 )
{
v23 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager(v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
}
MusicDownloadManager::songStateChanged();
sub_14003D310((__int64)Src);
}
}