//
// MusicDownloadManager::isSongDownloaded from 0x82fb94 to 0x82fd40 (428 bytes)
//
// 11 xrefs:
// > GJSongBrowser::loadPage @ 0x5beef4
// > GameManager::getMenuMusicFile @ 0x5e8a08
// > GameManager::getPracticeMusicFile @ 0x5e8b4c
// > LevelInfoLayer::onPlay @ 0x6d8ae0
// > CustomSongWidget::updateSongInfo @ 0x744ad8
// > CustomSongWidget::updateWithMultiAssets @ 0x7487a8
// > MusicDownloadManager::getDownloadedSongs @ 0x82fd7c
// > MusicDownloadManager::getDownloadedSongs @ 0x82fda0
// > MusicDownloadManager::clearUnusedSongs @ 0x8300f4
// > AudioAssetsBrowser::onInfo @ 0xa8ec24
// > ??> @ 0x50550
//
// 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
//
bool MusicDownloadManager::isSongDownloaded(MusicDownloadManager *a1, int a2)
{
char isResourceSong; // w20
cocos2d::CCFileUtils *v6; // x20
MusicDownloadManager *v7; // x0
bool (__fastcall *isPopupNotify)(cocos2d::CCFileUtils *__hidden); // x21
void *v9; // x0
char *v10; // x0
unsigned int *v11; // x1
int v12; // w2
unsigned int *v13; // x1
int v14; // w2
char *v15; // [xsp+48h] [xbp+48h] BYREF
__int64 v16; // [xsp+50h] [xbp+50h] BYREF
isResourceSong = MusicDownloadManager::isResourceSong(a1, a2);
if ( !isResourceSong )
{
v6 = cocos2d::CCFileUtils::sharedFileUtils();
v7 = a1;
isPopupNotify = v6->isPopupNotify;
MusicDownloadManager::pathForSong((__int64 *)&v15, v7, a2);
sub_D153B8((int)&v16, v15);
isResourceSong = ((__int64 (__fastcall *)(cocos2d::CCFileUtils *, __int64 *))isPopupNotify)(v6, &v16);
v9 = (void *)(v16 - 24);
if ( (__int64 *)(v16 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v16 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *(_DWORD *)(v16 - 8);
*(_DWORD *)(v16 - 8) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v9);
}
v10 = v15 - 24;
if ( v15 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v15 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *((_DWORD *)v15 - 2);
*((_DWORD *)v15 - 2) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v10);
}
}
return isResourceSong;
}