summaryrefslogtreecommitdiff
path: root/include/nw4r/snd/snd_StrmChannel.h
blob: 65fa2622ebf06d83215e9a123fc3902535a2ae92 (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
66
#ifndef NW4R_SND_STRM_CHANNEL_H
#define NW4R_SND_STRM_CHANNEL_H

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

#include <climits> // CHAR_BIT

#include "common.h"

#include "nw4r/snd/snd_adpcm.h"

/*******************************************************************************
 * types
 */

namespace nw4r { namespace snd { namespace detail
{
	// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2f927
	struct StrmChannel
	{
		void			*bufferAddress;	// size 0x04, offset 0x00
		AdpcmParam		adpcmParam;		// size 0x28, offset 0x04
		AdpcmLoopParam	adpcmLoopParam;	// size 0x06, offset 0x2c
		u16				adpcmPredScale;	// size 0x02, offset 0x32
	}; // size 0x34
}}} // namespace nw4r::snd::detail

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

namespace nw4r { namespace snd { namespace detail
{
	// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2f7c6
	class StrmBufferPool
	{
	// methods
	public:
		// methods
		void Setup(void *buffer, u32 size, int blockCount);
		void Shutdown();

		u32 GetBlockSize() const { return mBlockSize; }

		void *Alloc();
		void Free(void *p);

	// static members
	private:
		static int const BIT_PER_BYTE = CHAR_BIT; // uhhh ok
		static int const BLOCK_MAX = 32;

	// members
	private:
		void	*mBuffer;														// size 0x04, offset 0x00
		u32		mBufferSize;													// size 0x04, offset 0x04
		u32		mBlockSize;														// size 0x04, offset 0x08
		int		mBlockCount;													// size 0x04, offset 0x0c
		int		mAllocCount;													// size 0x04, offset 0x10
		byte_t	mAllocFlags[ROUND_UP(BLOCK_MAX, BIT_PER_BYTE) / BIT_PER_BYTE];	// size 0x04, offset 0x14
	}; // size 0x18
}}} // namespace nw4r::snd::detail

#endif // NW4R_SND_STRM_CHANNEL_H