Adding Music Playback

This commit is contained in:
IlyaShurupov 2023-11-29 19:42:17 +03:00
parent 7b325244c5
commit 231b30b2cb
12 changed files with 1840 additions and 149 deletions

View file

@ -1,12 +1,22 @@
#include "Allocators.hpp"
#include "HeapAllocatorGlobal.hpp"
#include <cstdlib>
#include <stdio.h>
static bool init(const tp::ModuleManifest* self) {
tp::HeapAllocGlobal::stopIgnore();
if (tp::HeapAllocGlobal::getNAllocations()) {
printf("Warning : Operator new was called outside module initialization!!\n\n");
}
return true;
}
static void deinit(const tp::ModuleManifest* self) { tp::HeapAllocGlobal::checkLeaks(); }
static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleUtils, nullptr };
tp::ModuleManifest tp::gModuleAllocators = ModuleManifest("Allocators", nullptr, deinit, sModuleDependencies);
tp::ModuleManifest tp::gModuleAllocators = ModuleManifest("Allocators", init, deinit, sModuleDependencies);
void* operator new(size_t aSize) { return tp::HeapAllocGlobal::allocate(aSize); }
void* operator new[](size_t aSize) { return tp::HeapAllocGlobal::allocate(aSize); }

View file

@ -21,13 +21,14 @@ HeapAllocGlobal::~HeapAllocGlobal() = default;
bool HeapAllocGlobal::checkLeaks() { return false; }
void HeapAllocGlobal::startIgnore() {}
void HeapAllocGlobal::stopIgnore() {}
ualni HeapAllocGlobal::getNAllocations() { return 0; }
#else
tp::MemHead* tp::HeapAllocGlobal::mEntry = nullptr;
tp::ualni tp::HeapAllocGlobal::mNumAllocations = 0;
tp::Mutex tp::HeapAllocGlobal::mMutex;
bool tp::HeapAllocGlobal::mIgnore;
bool tp::HeapAllocGlobal::mIgnore = true;
// ----------------------- Debug Implementation ---------------------------- //
// |----------------|
@ -100,7 +101,9 @@ ALLOCATE:
// 3) Trace the stack
#ifdef MEM_STACK_TRACE
head->mCallStack = gCSCapture->getSnapshot();
// check if somewhat decides to call new within static variable initialization
if (gCSCapture) head->mCallStack = gCSCapture->getSnapshot();
else head->mCallStack = nullptr;
#endif
mMutex.unlock();
@ -194,6 +197,10 @@ void HeapAllocGlobal::stopIgnore() {
mMutex.unlock();
}
ualni HeapAllocGlobal::getNAllocations() {
return mNumAllocations;
}
HeapAllocGlobal::~HeapAllocGlobal() = default;
#endif

View file

@ -25,7 +25,8 @@ namespace tp {
static bool checkLeaks();
static void startIgnore();
static void stopIgnore();
static ualni getNAllocations();
public:
[[nodiscard]] bool checkWrap() const { return false; }
void checkValid() {}