summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-05-26 00:42:57 +0200
committerrobojumper <robojumper@gmail.com>2025-05-26 00:42:57 +0200
commita9da90bbb2c8dddbaffec4c82e03b92eb97f2690 (patch)
tree9099bd67a1e1fbed18e8a4db86a568926db302b8
parent83a7f21b96da09bfa8487a51230e91e606315f7b (diff)
snd_SoundThread OK
-rw-r--r--config/SOUE01/splits.txt2
-rw-r--r--config/SOUE01/symbols.txt10
-rw-r--r--configure.py2
-rw-r--r--include/nw4r/snd/snd_SoundThread.h2
-rw-r--r--src/nw4r/snd/snd_SoundThread.cpp82
5 files changed, 56 insertions, 42 deletions
diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt
index 79f7fd9e..51606d7b 100644
--- a/config/SOUE01/splits.txt
+++ b/config/SOUE01/splits.txt
@@ -3063,6 +3063,8 @@ nw4r/snd/snd_SoundSystem.cpp:
nw4r/snd/snd_SoundThread.cpp:
.text start:0x8047C710 end:0x8047CD10 align:16
+ .sbss start:0x805766C0 end:0x805766C8
+ .bss start:0x8066F660 end:0x8066FA20
nw4r/snd/snd_StrmChannel.cpp:
.text start:0x8047CD10 end:0x8047CF50 align:16
diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt
index bfde946f..8265b693 100644
--- a/config/SOUE01/symbols.txt
+++ b/config/SOUE01/symbols.txt
@@ -25629,7 +25629,7 @@ IsInitializedSoundSystem__Q34nw4r3snd11SoundSystemFv = .text:0x8047C630; // type
WaitForResetReady__Q34nw4r3snd11SoundSystemFv = .text:0x8047C640; // type:function size:0x74
__sinit_\snd_SoundSystem_cpp = .text:0x8047C6C0; // type:function size:0x48 scope:local
GetInstance__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C710; // type:function size:0xB8
-__dt__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C7D0; // type:function size:0x70
+__dt__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C7D0; // type:function size:0x70 scope:weak
Create__Q44nw4r3snd6detail11SoundThreadFlPvUl = .text:0x8047C840; // type:function size:0x12C
AxCallbackFunc__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C970; // type:function size:0x10C
SoundThreadFunc__Q44nw4r3snd6detail11SoundThreadFPv = .text:0x8047CA80; // type:function size:0xB8
@@ -42435,7 +42435,7 @@ lbl_805766A8 = .sbss:0x805766A8; // type:object size:0x8 data:4byte
lbl_805766B0 = .sbss:0x805766B0; // type:object size:0x8 data:byte
isSoundSystemInit = .sbss:0x805766B8; // type:object size:0x1 data:byte
lbl_805766BC = .sbss:0x805766BC; // type:object size:0x4 data:4byte
-lbl_805766C0 = .sbss:0x805766C0; // type:object size:0x8 data:byte
+@GUARD@GetInstance__Q44nw4r3snd6detail11SoundThreadFv@instance = .sbss:0x805766C0; // type:object size:0x1 scope:weak data:byte
lbl_805766C8 = .sbss:0x805766C8; // type:object size:0x8 data:byte
lbl_805766D0 = .sbss:0x805766D0; // type:object size:0x8 data:4byte
@GUARD@GetInstance__Q44nw4r3snd6detail11TaskManagerFv@instance = .sbss:0x805766D8; // type:object size:0x1 scope:weak data:byte
@@ -51947,9 +51947,9 @@ lbl_80659730 = .bss:0x80659730; // type:object size:0x610 data:4byte
lbl_80659D40 = .bss:0x80659D40; // type:object size:0x10
lbl_80659D50 = .bss:0x80659D50; // type:object size:0x330
lbl_8065A080 = .bss:0x8065A080; // type:object size:0x155E0
-lbl_8066F660 = .bss:0x8066F660; // type:object size:0x10
-lbl_8066F670 = .bss:0x8066F670; // type:object size:0x3B0
-lbl_8066FA20 = .bss:0x8066FA20; // type:object size:0x4000
+@1941 = .bss:0x8066F660; // type:object size:0xC scope:local
+@LOCAL@GetInstance__Q44nw4r3snd6detail11SoundThreadFv@instance = .bss:0x8066F670; // type:object size:0x398 scope:weak
+lbl_8066FA20 = .bss:0x8066FA20; // type:object size:0x4000 align:32
lbl_80673A20 = .bss:0x80673A20; // type:object size:0x18
@886 = .bss:0x80673A38; // type:object size:0xC scope:local
@LOCAL@GetInstance__Q44nw4r3snd6detail11TaskManagerFv@instance = .bss:0x80673A44; // type:object size:0x3C scope:weak
diff --git a/configure.py b/configure.py
index 445359da..aecb61a3 100644
--- a/configure.py
+++ b/configure.py
@@ -1067,7 +1067,7 @@ config.libs = [
Object(NonMatching, "nw4r/snd/snd_SoundPlayer.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundStartable.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundSystem.cpp"),
- Object(NonMatching, "nw4r/snd/snd_SoundThread.cpp"),
+ Object(Matching, "nw4r/snd/snd_SoundThread.cpp"),
Object(Matching, "nw4r/snd/snd_StrmChannel.cpp"),
Object(Matching, "nw4r/snd/snd_StrmFile.cpp"),
Object(NonMatching, "nw4r/snd/snd_StrmPlayer.cpp"),
diff --git a/include/nw4r/snd/snd_SoundThread.h b/include/nw4r/snd/snd_SoundThread.h
index 42d4a10f..7d250496 100644
--- a/include/nw4r/snd/snd_SoundThread.h
+++ b/include/nw4r/snd/snd_SoundThread.h
@@ -101,6 +101,7 @@ namespace nw4r { namespace snd { namespace detail
static void *SoundThreadFunc(void *arg);
void SoundThreadProc();
+ void FrameProcess();
// static members
private:
@@ -121,6 +122,7 @@ namespace nw4r { namespace snd { namespace detail
PlayerCallback::LinkList mPlayerCallbackList; // size 0x00c, offset 0x384
u32 mProcessTick; // size 0x004, offset 0x390
bool mCreateFlag; // size 0x001, offset 0x394
+ bool field_0x395; // size 0x001, offset 0x395
/* 3 bytes padding */
}; // size 0x398
}}} // namespace nw4r::snd::detail
diff --git a/src/nw4r/snd/snd_SoundThread.cpp b/src/nw4r/snd/snd_SoundThread.cpp
index 2a8ca309..153d3492 100644
--- a/src/nw4r/snd/snd_SoundThread.cpp
+++ b/src/nw4r/snd/snd_SoundThread.cpp
@@ -35,7 +35,8 @@ namespace nw4r { namespace snd { namespace detail {
SoundThread::SoundThread() :
mStackEnd (nullptr),
- mCreateFlag (false)
+ mCreateFlag (false),
+ field_0x395 (false)
{
OSInitMessageQueue(&mMsgQueue, mMsgBuffer, THREAD_MESSAGE_BUFSIZE);
OSInitThreadQueue(&mThreadQueue);
@@ -96,8 +97,10 @@ void SoundThread::AxCallbackFunc()
void SoundThread::AxCallbackProc()
{
- BOOL result ATTR_UNUSED =
- OSSendMessageAny(&mMsgQueue, MESSAGE_AX_CALLBACK, OS_MESSAGE_NO_FLAGS);
+ if (!field_0x395) {
+ BOOL result ATTR_UNUSED =
+ OSSendMessageAny(&mMsgQueue, MESSAGE_AX_CALLBACK, OS_MESSAGE_NO_FLAGS);
+ }
NW4R_RANGE_FOR_NO_AUTO_INC(itr, mPlayerCallbackList)
{
@@ -123,6 +126,7 @@ void *SoundThread::SoundThreadFunc(void *arg)
return nullptr;
}
+#ifdef DEBUG
/* SoundThread::RegisterSoundFrameCallback
* ([R89JEL]:/bin/RVL/Debug/mainD.MAP:14509)
*/
@@ -134,6 +138,7 @@ DECOMP_FORCE_CLASS_METHOD(SoundThread::SoundFrameCallback::LinkList,
*/
DECOMP_FORCE_CLASS_METHOD(SoundThread::SoundFrameCallback::LinkList,
Erase(nullptr));
+#endif
void SoundThread::RegisterPlayerCallback(PlayerCallback *callback)
{
@@ -159,56 +164,61 @@ void SoundThread::SoundThreadProc()
if (reinterpret_cast<u32>(message) == MESSAGE_AX_CALLBACK)
{
- ut::detail::AutoLock<OSMutex> lock(mMutex);
-
- NW4R_RANGE_FOR_NO_AUTO_INC(itr, mSoundFrameCallbackList)
- {
- decltype(itr) curItr = itr++;
+ FrameProcess();
+ }
+ else if (reinterpret_cast<u32>(message) == MESSAGE_SHUTDOWN)
+ {
+ break;
+ }
- curItr->at_0x0c();
- }
+ NW4RAssert_Line(313, *mStackEnd == OS_THREAD_STACK_MAGIC);
+ }
- OSTick tick = OSGetTick();
+ NW4R_RANGE_FOR_NO_AUTO_INC(itr, mPlayerCallbackList)
+ {
+ decltype(itr) curItr = itr++;
- {
- // Sound frame
- AxVoiceManager::GetInstance().FreeAllReservedAxVoice();
- AxManager::GetInstance().Update();
+ curItr->OnShutdownSoundThread();
+ }
+}
- NW4R_RANGE_FOR_NO_AUTO_INC(itr, mPlayerCallbackList)
- {
- decltype(itr) curItr = itr++;
+void SoundThread::FrameProcess()
+{
+ ut::detail::AutoLock<OSMutex> lock(mMutex);
- curItr->OnUpdateFrameSoundThread();
- }
+ NW4R_RANGE_FOR_NO_AUTO_INC(itr, mSoundFrameCallbackList)
+ {
+ decltype(itr) curItr = itr++;
- ChannelManager::GetInstance().UpdateAllChannel();
- (void)Util::CalcRandom(); // ?
- VoiceManager::GetInstance().UpdateAllVoices();
- }
+ curItr->at_0x0c();
+ }
- mProcessTick = OSGetTick() - tick;
+ OSTick tick = OSGetTick();
- NW4R_RANGE_FOR_NO_AUTO_INC(itr, mSoundFrameCallbackList)
- {
- decltype(itr) curItr = itr++;
+ {
+ // Sound frame
+ AxVoiceManager::GetInstance().FreeAllReservedAxVoice();
+ AxManager::GetInstance().Update();
- curItr->at_0x10();
- }
- }
- else if (reinterpret_cast<u32>(message) == MESSAGE_SHUTDOWN)
+ NW4R_RANGE_FOR_NO_AUTO_INC(itr, mPlayerCallbackList)
{
- break;
+ decltype(itr) curItr = itr++;
+
+ curItr->OnUpdateFrameSoundThread();
}
- NW4RAssert_Line(313, *mStackEnd == OS_THREAD_STACK_MAGIC);
+ ChannelManager::GetInstance().UpdateAllChannel();
+ (void)Util::CalcRandom(); // ?
+ VoiceManager::GetInstance().UpdateAllVoices();
}
- NW4R_RANGE_FOR_NO_AUTO_INC(itr, mPlayerCallbackList)
+ mProcessTick = OSGetTick() - tick;
+
+ NW4R_RANGE_FOR_NO_AUTO_INC(itr, mSoundFrameCallbackList)
{
decltype(itr) curItr = itr++;
- curItr->OnShutdownSoundThread();
+ curItr->at_0x10();
}
}