diff --git a/configure.py b/configure.py index 317dd967cad..74e7b85029d 100755 --- a/configure.py +++ b/configure.py @@ -944,7 +944,7 @@ config.libs = [ Object(NonMatching, "JSystem/JAudio2/JASTaskThread.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JASDvdThread.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JASCallback.cpp"), - Object(NonMatching, "JSystem/JAudio2/JASHeapCtrl.cpp"), + Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JASHeapCtrl.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JASResArcLoader.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JASProbe.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JASReport.cpp"), diff --git a/include/JSystem/JAudio2/JASHeapCtrl.h b/include/JSystem/JAudio2/JASHeapCtrl.h index db26f57f8ee..49e579c4037 100644 --- a/include/JSystem/JAudio2/JASHeapCtrl.h +++ b/include/JSystem/JAudio2/JASHeapCtrl.h @@ -26,7 +26,6 @@ public: /* 802906F0 */ JASHeap* getTailHeap(); /* 8029077C */ u32 getTailOffset(); /* 802907E0 */ u32 getCurOffset(); - /* 80290B54 */ ~JASHeap() {} void* getBase() { return mBase; } bool isAllocated() { return mBase; } @@ -70,7 +69,11 @@ namespace JASThreadingModel { }; template - struct ObjectLevelLockable { + struct ObjectLevelLockable : public OSMutex { + ObjectLevelLockable() { + OSInitMutex(this); + } + struct Lock { Lock(A0 const& mutex) { mMutex = (A0*)&mutex; @@ -84,7 +87,7 @@ namespace JASThreadingModel { A0* mMutex; }; }; -}; +}; // namespace JASThreadingModel /** * @ingroup jsystem-jaudio @@ -113,7 +116,7 @@ namespace JASKernel { JKRHeap* getSystemHeap(); }; * */ template class T> -class JASMemChunkPool : public OSMutex { +class JASMemChunkPool : public T >::ObjectLevelLockable { struct MemoryChunk { MemoryChunk(MemoryChunk* nextChunk) { mNextChunk = nextChunk; @@ -163,9 +166,9 @@ class JASMemChunkPool : public OSMutex { }; public: JASMemChunkPool() { - OSInitMutex(this); field_0x18 = NULL; - createNewChunk(); + bool ret = createNewChunk(); + JUT_ASSERT(320, ret); } bool createNewChunk() { @@ -179,6 +182,7 @@ public: if (field_0x18 != NULL) { uVar2 = 1; } else { + JUT_WARN(428, "%s", "Not enough JASSystemHeap"); field_0x18 = new (JKRHeap::getSystemHeap(), 0) MemoryChunk(pMVar4); if (field_0x18 != NULL) { uVar2 = 1; @@ -193,7 +197,8 @@ public: void* alloc(u32 size) { typename T >::Lock lock(*this); - if (field_0x18->getFreeSize() < size) { + u32 freeSize = field_0x18->getFreeSize(); + if (freeSize < size) { if (ChunkSize < size) { return NULL; } diff --git a/include/JSystem/JAudio2/JASMutex.h b/include/JSystem/JAudio2/JASMutex.h index 51345343616..3155f462c24 100644 --- a/include/JSystem/JAudio2/JASMutex.h +++ b/include/JSystem/JAudio2/JASMutex.h @@ -10,7 +10,7 @@ struct JASMutexLock { JASMutexLock(OSMutex* mutex) { mMutex = mutex; - OSLockMutex(mMutex); + OSLockMutex(mutex); } ~JASMutexLock() { OSUnlockMutex(mMutex); } diff --git a/include/JSystem/JSupport/JSUList.h b/include/JSystem/JSupport/JSUList.h index 75c18bb8d56..06ccfd0f181 100644 --- a/include/JSystem/JSupport/JSUList.h +++ b/include/JSystem/JSupport/JSUList.h @@ -196,19 +196,19 @@ public: JSUTree* getEndChild() const { return NULL; } - JSUTree* getFirstChild() const { return (JSUTree*)this->getFirst(); } + JSUTree* getFirstChild() const { return (JSUTree*)this->getFirstLink(); } - JSUTree* getLastChild() const { return (JSUTree*)this->getLast(); } + JSUTree* getLastChild() const { return (JSUTree*)this->getLastLink(); } - JSUTree* getNextChild() const { return (JSUTree*)this->getNext(); } + JSUTree* getNextChild() const { return (JSUTree*)JSUPtrLink::mNext; } - JSUTree* getPrevChild() const { return (JSUTree*)this->getPrev(); } + JSUTree* getPrevChild() const { return (JSUTree*)JSUPtrLink::mPrev; } u32 getNumChildren() const { return this->getNumLinks(); } - T* getObject() const { return (T*)this->getObjectPtr(); } + T* getObject() const { return (T*)JSUPtrLink::mObject; } - JSUTree* getParent() const { return (JSUTree*)this->getList(); } + JSUTree* getParent() const { return (JSUTree*)JSUPtrLink::mList; } }; /** diff --git a/src/JSystem/JAudio2/JASHeapCtrl.cpp b/src/JSystem/JAudio2/JASHeapCtrl.cpp index 66b8a40d031..0a3063dcf76 100644 --- a/src/JSystem/JAudio2/JASHeapCtrl.cpp +++ b/src/JSystem/JAudio2/JASHeapCtrl.cpp @@ -104,7 +104,6 @@ bool JASHeap::allocTail(JASHeap* mother, u32 size) { } /* 802904E4-80290608 28AE24 0124+00 0/0 4/4 0/0 .text free__7JASHeapFv */ -// NONMATCHING regswap bool JASHeap::free() { JASMutexLock lock(&mMutex); if (!isAllocated()) { @@ -140,10 +139,9 @@ bool JASHeap::free() { /* 80290608-802906F0 28AF48 00E8+00 2/2 0/0 0/0 .text * insertChild__7JASHeapFP7JASHeapP7JASHeapPvUlb */ -// NONMATCHING regalloc void JASHeap::insertChild(JASHeap* heap, JASHeap* next, void* param_2, u32 param_3, bool param_4) { - JUT_ASSERT(537, heap != NULL); - JUT_ASSERT(538, next == NULL || &mTree == next->mTree.getParent()); + JUT_ASSERT(513, heap != NULL); + JUT_ASSERT(514, next == NULL || &mTree == next->mTree.getParent()); JASMutexLock lock(&mMutex); if (!param_4) { JSUTreeIterator it;