summaryrefslogtreecommitdiff
path: root/include/nw4r/snd/snd_AxVoiceManager.h
blob: 5165e8efb03c7e4dbceb856cbf36be2a928cd05a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef NW4R_SND_AX_VOICE_MANAGER_H
#define NW4R_SND_AX_VOICE_MANAGER_H

/*******************************************************************************
 * headers
 */

#include "common.h" // u32

#include "nw4r/snd/snd_AxVoice.h"

/*******************************************************************************
 * classes and functions
 */

namespace nw4r { namespace snd { namespace detail
{
	// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2adb3b
	class AxVoiceManager
	{
	// methods
	public:
		// instance accessors
		static AxVoiceManager &GetInstance();

		// methods
		void Setup(void *mem, u32 memSize);
		void Shutdown();

		u32 GetRequiredMemSize(int axVoiceCount);

		AxVoice *AcquireAxVoice(u32 priority, AxVoice::Callback *callback,
		                        void *callbackData);
		void ReserveForFreeAxVoice(AxVoice *voice);
		void FreeAxVoice(AxVoice *voice);
		void FreeAllReservedAxVoice();

	private:
		// cdtors
		AxVoiceManager();

		// methods
		AxVoice *Alloc();
		void ReserveForFree(AxVoice *voice);
		void Free(AxVoice *voice);

	// static members
	public:
		static int const VOICE_COUNT_MARGIN = 16;
		static const int VOICE_MARGIN = 16;
		static const int VOICE_MAX = AX_VOICE_MAX + VOICE_MARGIN;
		static const int WORK_SIZE_MAX = VOICE_MAX * sizeof(AxVoice);

	// members
	private:
		AxVoice::LinkList	mActiveVoiceList;		// size 0x0c, offset 0x00
		AxVoice::LinkList	mFreeVoiceList;			// size 0x0c, offset 0x0c
		AxVoice::LinkList	mFreeReservedVoiceList;	// size 0x0c, offset 0x18
		bool				mInitialized;			// size 0x01, offset 0x24
		/* 3 bytes padding */
		int					mVoiceCount;			// size 0x04, offset 0x28
	}; // size 0x2c
}}} // namespace nw4r::snd::detail

#endif // NW4R_SND_AX_VOICE_MANAGER_H