//
// MusicDownloadManager::onDownloadMusicLibraryCompleted from 0x83a0bc to 0x83a294 (472 bytes)
//
// 3 xrefs:
// > ??> @ 0xaea68
// > MusicDownloadManager::downloadMusicLibrary @ 0x82c3cc
// > ??> @ 0x122e090
//
// 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 MusicDownloadManager::onDownloadMusicLibraryCompleted(
MusicDownloadManager *a1,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
FILE *v5; // x22
char *v6; // x2
char *v7; // x0
unsigned int *v8; // x2
int v9; // w1
unsigned int *v10; // x2
char *filename; // [xsp+40h] [xbp+40h] BYREF
MusicDownloadManager::removeDLFromActive(a1, "dl_music_l");
if ( !a3 || !a3->_succeed )
{
MusicDownloadManager::musicActionFailed(a1, UpdateMusicLibrary|0x1);
return;
}
MusicDownloadManager::pathForSongFolder(a1, 0, (__int64)&filename);
sub_D15FD4(&filename, "musiclibrary.dat", 16);
v5 = fopen(filename, "wb");
if ( !v5 )
{
MusicDownloadManager::musicActionFailed(a1, UpdateMusicLibrary|0x1);
v6 = filename;
v7 = filename - 24;
if ( filename - 24 == (char *)&qword_124B6B0 )
return;
if ( &pthread_create )
{
v10 = (unsigned int *)(filename - 8);
do
v9 = __ldaxr(v10);
while ( __stlxr(v9 - 1, v10) );
goto LABEL_12;
}
goto LABEL_20;
}
fwrite(a3->_responseData.m_start, 1u, a3->_responseData.m_finish - a3->_responseData.m_start, v5);
fclose(v5);
MusicDownloadManager::parseMusicLibrary(a1);
if ( MusicDownloadManager::isMusicLibraryLoaded(a1) )
MusicDownloadManager::musicActionFinished(a1, UpdateMusicLibrary|0x1);
else
MusicDownloadManager::musicActionFailed(a1, UpdateMusicLibrary|0x1);
v6 = filename;
v7 = filename - 24;
if ( filename - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)(filename - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
goto LABEL_12;
}
LABEL_20:
v9 = *((_DWORD *)v6 - 2);
*((_DWORD *)v6 - 2) = v9 - 1;
LABEL_12:
if ( v9 <= 0 )
operator delete(v7);
}
}