//
// CustomSongWidget::onPlayback from 0x1400caec0 to 0x1400cb2a0 (992 bytes)
//
// 2 xrefs:
// > CustomSongWidget::init @ 0x1400c89df
// > ??> @ 0x1406c831c
//
// 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
//
// Hidden C++ exception states: #wind=12
void CustomSongWidget::onPlayback(CustomSongWidget *a1, cocos2d::CCObject *a2)
{
SongPlaybackDelegate *m_playbackDelegate; // rcx
SongInfoObject *m_songInfoObject; // rbx
MusicDownloadManager *v5; // rax
FMODAudioEngine *v6; // rcx
__int64 v7; // rdx
__int64 v8; // rcx
__int64 v9; // r8
__int64 v10; // r9
void **v11; // r14
unsigned __int64 v12; // rdi
__int64 v13; // rbx
FMODAudioEngine *v14; // rcx
__int64 v15; // rbx
FMODAudioEngine *v16; // rcx
__int64 v17; // rbx
SongInfoObject *v18; // rbx
MusicDownloadManager *v19; // rax
_QWORD *v20; // rax
size_t v21; // r8
FMODAudioEngine *v22; // rcx
MusicDownloadManager *v23; // rax
FMODAudioEngine *v24; // [rsp+30h] [rbp-39h]
FMODAudioEngine *v25; // [rsp+30h] [rbp-39h]
FMODAudioEngine *v26; // [rsp+30h] [rbp-39h]
FMODAudioEngine *v27; // [rsp+30h] [rbp-39h]
__int128 v28; // [rsp+38h] [rbp-31h] BYREF
unsigned __int64 v29; // [rsp+48h] [rbp-21h]
__int64 v30; // [rsp+50h] [rbp-19h]
FMODAudioEngine *v31; // [rsp+58h] [rbp-11h]
void *Src[2]; // [rsp+60h] [rbp-9h] BYREF
unsigned __int64 v33; // [rsp+70h] [rbp+7h]
unsigned __int64 v34; // [rsp+78h] [rbp+Fh]
_BYTE v35[32]; // [rsp+80h] [rbp+17h] BYREF
m_playbackDelegate = a1->m_playbackDelegate;
if ( m_playbackDelegate )
{
m_playbackDelegate->onPlayback(m_playbackDelegate, a1->m_songInfoObject);
}
else
{
m_songInfoObject = a1->m_songInfoObject;
if ( m_songInfoObject )
{
v5 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSong(v5, Src, (unsigned int)m_songInfoObject->m_songID);
v6 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v31 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v6 = (FMODAudioEngine *)qword_1406C2E88;
}
if ( FMODAudioEngine::isMusicPlaying_1(v6, 0) )
{
v31 = (FMODAudioEngine *)&v28;
v28 = 0;
v29 = 0;
v30 = 0;
v11 = Src;
if ( v34 > 0xF )
v11 = (void **)Src[0];
v12 = v33;
v13 = 0x7FFFFFFFFFFFFFFFLL;
if ( v33 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v8, v7, v9, v10);
v30 = 15;
if ( v33 > 0xF )
{
if ( (v33 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v13 = v33 | 0xF;
if ( (v33 | 0xF) < 0x16 )
v13 = 22;
}
*(_QWORD *)&v28 = sub_14003AA10(v13 + 1);
v29 = v12;
v30 = v13;
memcpy((void *)v28, v11, v12 + 1);
}
else
{
v29 = v33;
v28 = *(_OWORD *)v11;
}
v14 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v24 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v14 = (FMODAudioEngine *)qword_1406C2E88;
}
if ( !FMODAudioEngine::isMusicPlaying(v14, &v28) )
{
v15 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v25 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v15 = qword_1406C2E88;
}
if ( *(_QWORD *)(v15 + 552) )
FMOD::ChannelControl::stop(*(FMOD::ChannelControl **)(v15 + 552));
sub_14005E0D0((_QWORD *)(v15 + 1064));
sub_14005E0D0((_QWORD *)(v15 + 1128));
sub_14005E0D0((_QWORD *)(v15 + 1192));
}
}
v16 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v26 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v16 = (FMODAudioEngine *)qword_1406C2E88;
}
if ( FMODAudioEngine::isMusicPlaying_1(v16, 0) )
{
v17 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v27 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v17 = qword_1406C2E88;
}
if ( *(_QWORD *)(v17 + 552) )
FMOD::ChannelControl::stop(*(FMOD::ChannelControl **)(v17 + 552));
sub_14005E0D0((_QWORD *)(v17 + 1064));
sub_14005E0D0((_QWORD *)(v17 + 1128));
sub_14005E0D0((_QWORD *)(v17 + 1192));
}
else
{
v18 = a1->m_songInfoObject;
if ( v18 )
{
v19 = MusicDownloadManager::sharedState();
v20 = (_QWORD *)MusicDownloadManager::pathForSong(v19, v35, (unsigned int)v18->m_songID);
if ( v20[3] > 0xFu )
v20 = (_QWORD *)*v20;
v28 = 0;
v29 = 0;
v30 = 0;
v21 = -1;
do
++v21;
while ( *((_BYTE *)v20 + v21) );
sub_14003A930(&v28, v20, v21);
v22 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v31 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v22 = (FMODAudioEngine *)qword_1406C2E88;
}
FMODAudioEngine::playMusic(v22, (__int64)&v28, 0, 0.0);
sub_14003A830((__int64)v35);
}
}
v23 = MusicDownloadManager::sharedState();
MusicDownloadManager::songStateChanged(v23);
sub_14003A830((__int64)Src);
}
}
}