NW4F Snd
Loading...
Searching...
No Matches
snd_SoundHeap.h
Go to the documentation of this file.
1#ifndef NW_SND_SOUND_HEAP_H_
2#define NW_SND_SOUND_HEAP_H_
3
4#include <nw/snd/snd_FrameHeap.h>
5#include <nw/snd/snd_SoundMemoryAllocatable.h>
6#include <nw/ut/os/ut_CriticalSection.h>
7
8namespace nw { namespace snd {
9
10class SoundArchive;
11class SoundDataManager;
12
14{
15public:
16 typedef void (*DisposeCallback)(void* mem, unsigned long size, void* userArg);
17
18
19public:
21 virtual ~SoundHeap();
22
23 bool Create(void* startAddress, size_t size);
24 void Destroy();
25
26 virtual void* Alloc(size_t size);
27 void* Alloc(size_t size, DisposeCallback callback, void* callbackArg);
28 void Clear();
29
30 bool IsValid() const { return m_FrameHeap.IsValid(); }
31
32 int SaveState();
33 void LoadState(int level);
34
35 int GetCurrentLevel() const
36 {
37 ut::ScopedLock<ut::CriticalSection> lock(m_CriticalSection);
38 return m_FrameHeap.GetCurrentLevel();
39 }
40
42 {
43 ut::ScopedLock<ut::CriticalSection> lock(m_CriticalSection);
44 return m_FrameHeap.GetSize();
45 }
46
48 {
49 ut::ScopedLock<ut::CriticalSection> lock(m_CriticalSection);
50 return m_FrameHeap.GetFreeSize();
51 }
52
53 void Dump(nw::snd::SoundDataManager& mgr, nw::snd::SoundArchive& arc) const
54 {
55 ut::ScopedLock<ut::CriticalSection> lock(m_CriticalSection);
56 m_FrameHeap.Dump(mgr, arc);
57 }
58
59private:
60 static void DisposeCallbackFunc(void* mem, unsigned long size, void* arg);
61
62private:
65};
66static_assert(sizeof(SoundHeap) == 0x44);
67
68} } // namespace nw::snd
69
70#endif // NW_SND_SOUND_HEAP_H_
Definition snd_SoundArchive.h:11
Definition snd_SoundHeap.h:14
void Dump(nw::snd::SoundDataManager &mgr, nw::snd::SoundArchive &arc) const
Definition snd_SoundHeap.h:53
void(* DisposeCallback)(void *mem, unsigned long size, void *userArg)
Definition snd_SoundHeap.h:16
bool IsValid() const
Definition snd_SoundHeap.h:30
static void DisposeCallbackFunc(void *mem, unsigned long size, void *arg)
virtual void * Alloc(size_t size)
size_t GetFreeSize() const
Definition snd_SoundHeap.h:47
size_t GetSize() const
Definition snd_SoundHeap.h:41
bool Create(void *startAddress, size_t size)
int GetCurrentLevel() const
Definition snd_SoundHeap.h:35
void LoadState(int level)
void * Alloc(size_t size, DisposeCallback callback, void *callbackArg)
virtual ~SoundHeap()
ut::CriticalSection m_CriticalSection
Definition snd_SoundHeap.h:63
internal::FrameHeap m_FrameHeap
Definition snd_SoundHeap.h:64
Definition snd_SoundMemoryAllocatable.h:9
Definition snd_FrameHeap.h:14
Definition snd_BasicSound.cpp:3
Definition snd_BasicSound.cpp:3