NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_SoundThread.h
1#ifndef NW4R_SND_SOUND_THREAD_H
2#define NW4R_SND_SOUND_THREAD_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10#include "nw4r/snd/snd_AxManager.h"
11
12#include "nw4r/ut/ut_algorithm.h" // ut::NonCopyable
13#include "nw4r/ut/ut_LinkList.h"
14
15#include <revolution/OS/OSMessage.h>
16#include <revolution/OS/OSMutex.h>
17#include <revolution/OS/OSThread.h>
18
19/*******************************************************************************
20 * classes
21 */
22
23namespace nw4r { namespace snd { namespace detail
24{
25 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2bc156
26 class SoundThread
27 {
28 // nested types
29 public:
30 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2bbe45
31 class AutoLock : private ut::NonCopyable
32 {
33 // methods
34 public:
35 // cdtors
36 AutoLock() { SoundThread::GetInstance().Lock(); }
37 ~AutoLock() { SoundThread::GetInstance().Unlock(); }
38 }; // size 0x01 (0x00 for inheritance)
39
40 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2bc03f
42 {
43 // typedefs
44 public:
46
47 // members
48 private:
49 ut::LinkListNode mLink; // size 0x08, offset 0x00
50 /* vtable */ // size 0x04, offset 0x08
51
52 // late virtual methods
53 public:
54 virtual void at_0x08();
55 virtual void at_0x0c();
56 virtual void at_0x10();
57 }; // size 0x0c
58
59 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2cc6f
61 {
62 // typedefs
63 public:
65
66 // members
67 private:
68 ut::LinkListNode mLink; // size 0x08, offset 0x00
69 /* vtable */ // size 0x04, offset 0x08
70
71 // late virtual methods
72 public:
73 virtual ~PlayerCallback() {}
74 virtual void OnUpdateFrameSoundThread() {}
75 virtual void OnUpdateVoiceSoundThread() {}
76 virtual void OnShutdownSoundThread() {}
77 }; // size 0x0c
78
79 // methods
80 public:
81 // instance accessors
82 static SoundThread &GetInstance();
83
84 // methods
85 bool Create(s32 priority, void *stack, ulong stackSize);
86 void Shutdown();
87
88 void Lock() { OSLockMutex(&mMutex); }
89 void Unlock() { OSUnlockMutex(&mMutex); }
90
91 void RegisterPlayerCallback(PlayerCallback *callback);
92 void UnregisterPlayerCallback(PlayerCallback *callback);
93
94 private:
95 // cdtors
96 SoundThread();
97
98 // fibers, callbacks, and procedures
99 static void AxCallbackFunc();
100 void AxCallbackProc();
101
102 static void *SoundThreadFunc(void *arg);
103 void SoundThreadProc();
104 void FrameProcess();
105
106 // static members
107 private:
108 static int const MESSAGE_SHUTDOWN = 1 << 1;
109 static int const MESSAGE_AX_CALLBACK = 1 << 0;
110 static int const THREAD_MESSAGE_BUFSIZE = 4;
111
112 // members
113 private:
114 OSThread mThread; // size 0x318, offset 0x000
115 OSThreadQueue mThreadQueue; // size 0x008, offset 0x318
116 OSMessageQueue mMsgQueue; // size 0x020, offset 0x320
117 OSMessage mMsgBuffer[THREAD_MESSAGE_BUFSIZE]; // size 0x010, offset 0x340
118 ulong *mStackEnd; // size 0x004, offset 0x350
119 OSMutex mMutex; // size 0x018, offset 0x354
120 AxManager::CallbackListNode mAxCallbackNode; // size 0x00c, offset 0x36c
121 SoundFrameCallback::LinkList mSoundFrameCallbackList; // size 0x00c, offset 0x378
122 PlayerCallback::LinkList mPlayerCallbackList; // size 0x00c, offset 0x384
123 ulong mProcessTick; // size 0x004, offset 0x390
124 bool mCreateFlag; // size 0x001, offset 0x394
125 bool field_0x395; // size 0x001, offset 0x395
126 /* 3 bytes padding */
127 }; // size 0x398
128}}} // namespace nw4r::snd::detail
129
130#endif // NW4R_SND_SOUND_THREAD_H