//
// MusicSearchResult::updateObjects from 0x832d40 to 0x832f2c (492 bytes)
//
// 2 xrefs:
// > ??> @ 0xab438
// > ??> @ 0x118a0a0
//
// 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 MusicSearchResult::updateObjects(MusicSearchResult *a1, AudioSortType a2)
{
MusicDownloadManager *v4; // x0
cocos2d::CCArray *AllMusicObjects; // x23
cocos2d::CCArray *FilesMatchingSearch; // x20
void *v7; // x0
cocos2d::CCArray *v8; // x0
cocos2d::CCArray *v9; // x20
cocos2d::ccArray *data; // x1
cocos2d::CCObject **arr; // x0
size_t num; // x1
cocos2d::CCArray *m_filterObjects; // x0
unsigned int *v14; // x2
int v15; // w1
__int64 v16; // [xsp+60h] [xbp+60h] BYREF
a1->m_sortType = a2;
v4 = MusicDownloadManager::sharedState();
AllMusicObjects = MusicDownloadManager::getAllMusicObjects(v4, a1->m_songType);
MusicSearchResult::createTagFilterObjects(a1);
MusicSearchResult::createArtistFilterObjects(a1);
if ( *((_QWORD *)a1->m_searchQuery.m_data.m_data - 3) )
{
sub_D18D28(&v16);
FilesMatchingSearch = MusicSearchResult::getFilesMatchingSearch(
(__int64)a1,
(__int64)AllMusicObjects,
(__int64)&v16);
v7 = (void *)(v16 - 24);
if ( (__int64 *)(v16 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)(v16 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *(_DWORD *)(v16 - 8);
*(_DWORD *)(v16 - 8) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v7);
}
}
else
{
FilesMatchingSearch = AllMusicObjects;
}
v8 = MusicSearchResult::applyArtistFilters(a1, FilesMatchingSearch);
v9 = MusicSearchResult::applyTagFilters(a1, v8);
MusicSearchResult::updateFutureCount(a1, v9, AllMusicObjects);
if ( (unsigned int)cocos2d::CCArray::count(v9) > 1 )
{
data = v9->data;
arr = data->arr;
num = data->num;
if ( a2 )
{
if ( a2 == SongOrder )
qsort(arr, num, 8u, (int (*)(const void *, const void *))songOrderCompare);
else
qsort(arr, num, 8u, (int (*)(const void *, const void *))songIDCompare);
}
else
{
qsort(arr, num, 8u, (int (*)(const void *, const void *))songNameCompare);
}
}
m_filterObjects = a1->m_filterObjects;
if ( v9 != m_filterObjects )
{
if ( v9 )
{
cocos2d::CCObject::retain(v9);
m_filterObjects = a1->m_filterObjects;
}
if ( m_filterObjects )
cocos2d::CCObject::release(m_filterObjects);
a1->m_filterObjects = v9;
}
}