summaryrefslogtreecommitdiff
path: root/src/JSystem/JAudio2/JASAudioThread.cpp
diff options
context:
space:
mode:
authorLuke Street <luke@street.dev>2026-03-01 15:35:36 -0700
committerGitHub <noreply@github.com>2026-03-01 14:35:36 -0800
commit9649319ec4926457ef85e6094f8207474c977c2d (patch)
tree1c5cd4c7cc4c1aee03f28921213da47f2775444d /src/JSystem/JAudio2/JASAudioThread.cpp
parent6e149819e13b1f70ecbf8a4c66b030c17ffed2bb (diff)
Reorganize library code into `libs/` (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN} * Update configure.py and project.py for new libs structure * Refactor `#include <dolphin/x.h>` -> `<x.h>` * Remove `__REVOLUTION_SDK__` forwards from dolphin * Fix dolphin/ references in revolution * Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__` * Always build TRK against dolphin headers * Resolve revolution SDK header resolution issues
Diffstat (limited to 'src/JSystem/JAudio2/JASAudioThread.cpp')
-rw-r--r--src/JSystem/JAudio2/JASAudioThread.cpp140
1 files changed, 0 insertions, 140 deletions
diff --git a/src/JSystem/JAudio2/JASAudioThread.cpp b/src/JSystem/JAudio2/JASAudioThread.cpp
deleted file mode 100644
index 0277f00804..0000000000
--- a/src/JSystem/JAudio2/JASAudioThread.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-#include "JSystem/JSystem.h" // IWYU pragma: keep
-
-#include "JSystem/JAudio2/JASAudioThread.h"
-#include "JSystem/JAudio2/JASAiCtrl.h"
-#include "JSystem/JAudio2/JASDriverIF.h"
-#include "JSystem/JAudio2/JASDSPChannel.h"
-#include "JSystem/JAudio2/JASDSPInterface.h"
-#include "JSystem/JAudio2/JASHeapCtrl.h"
-#include "JSystem/JAudio2/JASProbe.h"
-#include "JSystem/JAudio2/JASReport.h"
-#include "JSystem/JKernel/JKRSolidHeap.h"
-#include <dolphin/dsp.h>
-#include <stdint.h>
-
-JASAudioThread::JASAudioThread(int stackSize, int msgCount, u32 threadPriority)
- :
- JKRThread(JASDram, threadPriority, msgCount, stackSize),
- JASGlobalInstance<JASAudioThread>(true)
-{
- sbPauseFlag = false;
- OSInitThreadQueue(&sThreadQueue);
-}
-
-void JASAudioThread::create(s32 threadPriority) {
-#if PLATFORM_GCN
- const int size = 0x1400;
-#else
- const int size = 0x2800;
-#endif
- JASAudioThread* pAudioThread = new (JASDram, 0) JASAudioThread(threadPriority, 0x10, size);
- JUT_ASSERT(46, pAudioThread);
- JKRHeap* pCurrentHeap = JKRGetSystemHeap();
- JUT_ASSERT(48, pCurrentHeap);
- pAudioThread->setCurrentHeap(pCurrentHeap);
- pAudioThread->resume();
-}
-
-void JASAudioThread::stop() {
- jamMessageBlock((void*)2);
-}
-
-volatile int JASAudioThread::snIntCount;
-
-class Lock {
-public:
- Lock() {
- mInterrupts = OSDisableInterrupts();
- }
- ~Lock() {
- OSRestoreInterrupts(mInterrupts);
- }
-private:
- BOOL mInterrupts;
-};
-
-class JASChannel {
- u8 filler[0x108];
-};
-
-// NONMATCHING location of JASPoolAllocObject_MultiThreaded<JASChannel>
-void* JASAudioThread::run() {
- OSInitFastCast();
- JASDriver::initAI(DMACallback);
- JASDsp::boot(DSPCallback);
- JASDsp::initBuffer();
- JASDSPChannel::initAll();
-
- JASPoolAllocObject_MultiThreaded<JASChannel>::newMemPool(0x48);
- JASDriver::startDMA();
-
- OSMessage msg;
- while (true) {
- msg = waitMessageBlock();
- switch ((intptr_t)msg) {
- case AUDIOMSG_DMA:
- if (sbPauseFlag) {
- JUT_PANIC(107, "AUDIO THREAD PAUSED\n");
- JASDriver::stopDMA();
- OSSleepThread(&sThreadQueue);
- }
-#if DEBUG
- if (snIntCount != 0) {
- JASReport("DSP process is over.");
- }
-#endif
- JASDriver::updateDac();
- JASDriver::updateDacCallback();
- continue;
-
- case AUDIOMSG_DSP:
- JUT_ASSERT(125, snIntCount != 0);
- snIntCount--;
- if (snIntCount == 0) {
- JASProbe::stop(7);
- JASDriver::finishDSPFrame();
- } else {
- JASProbe::start(2, "SFR_DSP");
- JASDriver::updateDSP();
- JASProbe::stop(2);
- }
- continue;
-
- case AUDIOMSG_STOP:
- JASDriver::stopDMA();
- OSExitThread(NULL);
- continue;
- default:
- JUT_PANIC(152, "AUDIO THREAD INVALID MESSAGE\n");
- }
- }
-}
-
-void JASAudioThread::DMACallback() {
- JASAudioThread* pAudioThread = getInstance();
- JUT_ASSERT(167, pAudioThread);
- JASProbe::stop(4);
- JASProbe::start(4, "UPDATE-DAC");
- if (!pAudioThread->sendMessage((void*)AUDIOMSG_DMA)) {
- JUT_WARN_DEVICE(173, 1, "%s","----- DMACallback : Can\'t send DAC_SYNC message\n");
- }
-}
-
-void JASAudioThread::DSPCallback(void*) {
- JASAudioThread* pAudioThread = getInstance();
- JUT_ASSERT(184, pAudioThread);
- while (DSPCheckMailFromDSP() == 0) { }
-
- u32 mail = DSPReadMailFromDSP();
- if (mail >> 0x10 != 0xF355) {
- JUT_WARN(196, "DSP Mail format error %x\n", mail);
- } else {
- if ((mail & 0xFF00) == 0xFF00) {
- if (!pAudioThread->sendMessage((void*)AUDIOMSG_DSP)) {
- JUT_WARN_DEVICE(204, 1, "%s", "----- syncDSP : Send Miss\n");
- }
- } else {
- JASDsp::finishWork(mail);
- }
- }
-}