//
// CustomSFXWidget::onPlayback from 0xa3161c to 0xa317dc (448 bytes)
//
// 4 xrefs:
// > CustomSFXWidget::downloadSFXFinished @ 0xa3395c
// > ??> @ 0x698a0
// > CustomSFXWidget::init @ 0xa32cb0
// > ??> @ 0x122b6e8
//
// 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
//
void CustomSFXWidget::onPlayback(CustomSFXWidget *a1, cocos2d::CCObject *a2)
{
FMODAudioEngine *v3; // x0
CustomSFXDelegate *m_delegate; // x0
FMODAudioEngine *v5; // x22
MusicDownloadManager *v6; // x0
void *v7; // x0
char *v8; // x0
unsigned int *v9; // x1
int v10; // w2
unsigned int *v11; // x1
int v12; // w2
char *v13; // [xsp+48h] [xbp+48h] BYREF
__int64 v14; // [xsp+50h] [xbp+50h] BYREF
if ( a1->m_sfxObject )
{
v3 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopAllEffects(v3);
m_delegate = a1->m_delegate;
if ( !m_delegate || !m_delegate->overridePlaySFX(m_delegate, a1->m_sfxObject) )
{
v5 = FMODAudioEngine::sharedEngine();
v6 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSFX((__int64 *)&v13, v6, a1->m_sfxObject->m_sfxID);
sub_D153B8((int)&v14, v13);
FMODAudioEngine::playEffectAsync((__int64)v5, (__int64)&v14);
v7 = (void *)(v14 - 24);
if ( (__int64 *)(v14 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v14 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *(_DWORD *)(v14 - 8);
*(_DWORD *)(v14 - 8) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v7);
}
v8 = v13 - 24;
if ( v13 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v9 = (unsigned int *)(v13 - 8);
do
v10 = __ldaxr(v9);
while ( __stlxr(v10 - 1, v9) );
}
else
{
v10 = *((_DWORD *)v13 - 2);
*((_DWORD *)v13 - 2) = v10 - 1;
}
if ( v10 <= 0 )
operator delete(v8);
}
}
}
}