mirror of
https://github.com/zeldaret/mm.git
synced 2025-02-20 05:21:39 +00:00
AudioMgr cleanup (#1300)
* AudioMgr cleanup * Remove D_801D14F0 from variables.h
This commit is contained in:
parent
9c0fc94fe3
commit
c0ac061e6f
29
include/audiomgr.h
Normal file
29
include/audiomgr.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef AUDIOMGR_H
|
||||
#define AUDIOMGR_H
|
||||
|
||||
#include "ultra64.h"
|
||||
#include "unk.h"
|
||||
#include "irqmgr.h"
|
||||
#include "scheduler.h"
|
||||
#include "z64audio.h"
|
||||
|
||||
typedef struct {
|
||||
/* 0x000 */ IrqMgr* irqMgr;
|
||||
/* 0x004 */ SchedContext* sched;
|
||||
/* 0x008 */ OSScTask audioTask;
|
||||
/* 0x060 */ AudioTask* rspTask;
|
||||
/* 0x064 */ OSMesgQueue interruptQueue;
|
||||
/* 0x07C */ OSMesg interruptMsgBuf[30];
|
||||
/* 0x0F4 */ OSMesgQueue cmdQueue;
|
||||
/* 0x10C */ OSMesg cmdMsgBuf[1];
|
||||
/* 0x110 */ OSMesgQueue lockQueue;
|
||||
/* 0x128 */ OSMesg lockMsgBuf[1];
|
||||
/* 0x12C */ UNK_TYPE1 pad_12C[0x4];
|
||||
/* 0x130 */ OSThread thread;
|
||||
} AudioMgr; // size = 0x2E0
|
||||
|
||||
void AudioMgr_StopAllSfxExceptSystem(void);
|
||||
void AudioMgr_Unlock(AudioMgr* audioMgr);
|
||||
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr);
|
||||
|
||||
#endif
|
@ -1490,14 +1490,6 @@ void func_801720C4(PreRender* this);
|
||||
void func_801720FC(PreRenderParams* params, Gfx** gfxp);
|
||||
void Prerender_DrawBackground2D(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags);
|
||||
|
||||
void AudioMgr_StopAllSfxExceptSystem(void);
|
||||
void func_80172C30(AudioMgr* audioMgr);
|
||||
void AudioMgr_HandleRetrace(AudioMgr* audioMgr);
|
||||
void AudioMgr_HandlePRENMI(AudioMgr* audioMgr);
|
||||
void AudioMgr_ThreadEntry(void* arg);
|
||||
void AudioMgr_Unlock(AudioMgr* audioMgr);
|
||||
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr);
|
||||
|
||||
void GameAlloc_Log(GameAlloc* this);
|
||||
void* GameAlloc_Malloc(GameAlloc* this, size_t size);
|
||||
void GameAlloc_Free(GameAlloc* this, void* data);
|
||||
|
@ -658,7 +658,6 @@ extern s32 gDbgCamEnabled;
|
||||
extern Input* D_801D0D60;
|
||||
// extern UNK_TYPE2 sPlayerCsIdToCsCamId;
|
||||
// extern UNK_TYPE1 D_801D0D7A;
|
||||
// extern UNK_TYPE4 D_801D14F0;
|
||||
|
||||
extern u32 retryCount;
|
||||
extern u32 cfbIdx[3];
|
||||
|
@ -348,21 +348,6 @@ typedef struct {
|
||||
|
||||
struct PlayState;
|
||||
|
||||
typedef struct {
|
||||
/* 0x000 */ IrqMgr* irqMgr;
|
||||
/* 0x004 */ SchedContext* sched;
|
||||
/* 0x008 */ OSScTask audioTask;
|
||||
/* 0x060 */ AudioTask* rspTask;
|
||||
/* 0x064 */ OSMesgQueue interruptMsgQ;
|
||||
/* 0x07C */ OSMesg interruptMsgBuf[30];
|
||||
/* 0x0F4 */ OSMesgQueue cmdQ;
|
||||
/* 0x10C */ OSMesg cmdMsgBuf[1];
|
||||
/* 0x110 */ OSMesgQueue lockMsgQ;
|
||||
/* 0x128 */ OSMesg lockMsgBuf[1];
|
||||
/* 0x12C */ UNK_TYPE1 pad_12C[0x4];
|
||||
/* 0x130 */ OSThread thread;
|
||||
} AudioMgr; // size = 0x2E0
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ u8 seqId;
|
||||
/* 0x1 */ u8 ambienceId;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "audiomgr.h"
|
||||
|
||||
void func_80172C30(AudioMgr* audioMgr) {
|
||||
void AudioMgr_NotifyTaskDone(AudioMgr* audioMgr) {
|
||||
AudioTask* task = audioMgr->rspTask;
|
||||
|
||||
if (audioMgr->rspTask->taskQueue != NULL) {
|
||||
@ -9,7 +10,7 @@ void func_80172C30(AudioMgr* audioMgr) {
|
||||
}
|
||||
|
||||
void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
||||
static s32 retryCount = 10;
|
||||
static s32 sRetryCount = 10;
|
||||
AudioTask* rspTask;
|
||||
s32 timerMsgVal = 666;
|
||||
OSTimer timer;
|
||||
@ -19,8 +20,8 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
||||
audioMgr->rspTask = NULL;
|
||||
}
|
||||
|
||||
while (audioMgr->cmdQ.validCount != 0) {
|
||||
osRecvMesg(&audioMgr->cmdQ, NULL, OS_MESG_NOBLOCK);
|
||||
while (!MQ_IS_EMPTY(&audioMgr->cmdQueue)) {
|
||||
osRecvMesg(&audioMgr->cmdQueue, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
if (audioMgr->rspTask != NULL) {
|
||||
@ -29,7 +30,7 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
||||
audioMgr->audioTask.framebuffer = NULL;
|
||||
|
||||
audioMgr->audioTask.list = audioMgr->rspTask->task;
|
||||
audioMgr->audioTask.msgQ = &audioMgr->cmdQ;
|
||||
audioMgr->audioTask.msgQ = &audioMgr->cmdQueue;
|
||||
|
||||
audioMgr->audioTask.msg = NULL;
|
||||
osSendMesg(&audioMgr->sched->cmdQ, &audioMgr->audioTask, OS_MESG_BLOCK);
|
||||
@ -44,13 +45,13 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
||||
|
||||
if (audioMgr->rspTask != NULL) {
|
||||
while (true) {
|
||||
osSetTimer(&timer, OS_USEC_TO_CYCLES(32000), 0, &audioMgr->cmdQ, (OSMesg)timerMsgVal);
|
||||
osRecvMesg(&audioMgr->cmdQ, (OSMesg*)&msg, OS_MESG_BLOCK);
|
||||
osSetTimer(&timer, OS_USEC_TO_CYCLES(32000), 0, &audioMgr->cmdQueue, (OSMesg)timerMsgVal);
|
||||
osRecvMesg(&audioMgr->cmdQueue, (OSMesg*)&msg, OS_MESG_BLOCK);
|
||||
osStopTimer(&timer);
|
||||
if (msg == timerMsgVal) {
|
||||
osSyncPrintf("AUDIO SP TIMEOUT %08x %08x\n", audioMgr->rspTask, audioMgr->rspTask->task);
|
||||
if (retryCount >= 0) {
|
||||
retryCount--;
|
||||
if (sRetryCount >= 0) {
|
||||
sRetryCount--;
|
||||
Sched_SendAudioCancelMsg(audioMgr->sched);
|
||||
} else {
|
||||
osSyncPrintf("audioMgr.c:もうダメ!死ぬ!\n");
|
||||
@ -62,13 +63,13 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
||||
}
|
||||
}
|
||||
|
||||
func_80172C30(audioMgr);
|
||||
AudioMgr_NotifyTaskDone(audioMgr);
|
||||
}
|
||||
|
||||
audioMgr->rspTask = rspTask;
|
||||
}
|
||||
|
||||
void AudioMgr_HandlePRENMI(AudioMgr* audioMgr) {
|
||||
void AudioMgr_HandlePreNMI(AudioMgr* audioMgr) {
|
||||
Audio_PreNMI();
|
||||
}
|
||||
|
||||
@ -81,32 +82,36 @@ void AudioMgr_ThreadEntry(void* arg) {
|
||||
Audio_Init();
|
||||
AudioLoad_SetDmaHandler(DmaMgr_DmaHandler);
|
||||
Audio_InitSound();
|
||||
osSendMesg(&audioMgr->lockMsgQ, NULL, OS_MESG_BLOCK);
|
||||
IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptMsgQ);
|
||||
osSendMesg(&audioMgr->lockQueue, NULL, OS_MESG_BLOCK);
|
||||
IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptQueue);
|
||||
|
||||
exit = false;
|
||||
while (!exit) {
|
||||
osRecvMesg(&audioMgr->interruptMsgQ, (OSMesg*)&msg, OS_MESG_BLOCK);
|
||||
osRecvMesg(&audioMgr->interruptQueue, (OSMesg*)&msg, OS_MESG_BLOCK);
|
||||
switch (*msg) {
|
||||
case OS_SC_RETRACE_MSG:
|
||||
AudioMgr_HandleRetrace(audioMgr);
|
||||
while (audioMgr->interruptMsgQ.validCount != 0) {
|
||||
osRecvMesg(&audioMgr->interruptMsgQ, (OSMesg*)&msg, OS_MESG_BLOCK);
|
||||
while (!MQ_IS_EMPTY(&audioMgr->interruptQueue)) {
|
||||
osRecvMesg(&audioMgr->interruptQueue, (OSMesg*)&msg, OS_MESG_BLOCK);
|
||||
switch (*msg) {
|
||||
case OS_SC_RETRACE_MSG:
|
||||
break;
|
||||
|
||||
case OS_SC_PRE_NMI_MSG:
|
||||
AudioMgr_HandlePRENMI(audioMgr);
|
||||
AudioMgr_HandlePreNMI(audioMgr);
|
||||
break;
|
||||
|
||||
case OS_SC_NMI_MSG:
|
||||
exit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case OS_SC_PRE_NMI_MSG:
|
||||
AudioMgr_HandlePRENMI(audioMgr);
|
||||
AudioMgr_HandlePreNMI(audioMgr);
|
||||
break;
|
||||
|
||||
case OS_SC_NMI_MSG:
|
||||
exit = true;
|
||||
break;
|
||||
@ -117,7 +122,7 @@ void AudioMgr_ThreadEntry(void* arg) {
|
||||
}
|
||||
|
||||
void AudioMgr_Unlock(AudioMgr* audioMgr) {
|
||||
osRecvMesg(&audioMgr->lockMsgQ, NULL, OS_MESG_BLOCK);
|
||||
osRecvMesg(&audioMgr->lockQueue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr) {
|
||||
@ -127,9 +132,9 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon
|
||||
audioMgr->irqMgr = irqMgr;
|
||||
audioMgr->rspTask = NULL;
|
||||
|
||||
osCreateMesgQueue(&audioMgr->cmdQ, audioMgr->cmdMsgBuf, ARRAY_COUNT(audioMgr->cmdMsgBuf));
|
||||
osCreateMesgQueue(&audioMgr->interruptMsgQ, audioMgr->interruptMsgBuf, ARRAY_COUNT(audioMgr->interruptMsgBuf));
|
||||
osCreateMesgQueue(&audioMgr->lockMsgQ, audioMgr->lockMsgBuf, ARRAY_COUNT(audioMgr->lockMsgBuf));
|
||||
osCreateMesgQueue(&audioMgr->cmdQueue, audioMgr->cmdMsgBuf, ARRAY_COUNT(audioMgr->cmdMsgBuf));
|
||||
osCreateMesgQueue(&audioMgr->interruptQueue, audioMgr->interruptMsgBuf, ARRAY_COUNT(audioMgr->interruptMsgBuf));
|
||||
osCreateMesgQueue(&audioMgr->lockQueue, audioMgr->lockMsgBuf, ARRAY_COUNT(audioMgr->lockMsgBuf));
|
||||
|
||||
osCreateThread(&audioMgr->thread, id, AudioMgr_ThreadEntry, audioMgr, stack, pri);
|
||||
osStartThread(&audioMgr->thread);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "audiomgr.h"
|
||||
#include "system_malloc.h"
|
||||
#include "z64debug_text.h"
|
||||
#include "z64rumble.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "audiomgr.h"
|
||||
#include "buffers.h"
|
||||
#include "stack.h"
|
||||
#include "stackcheck.h"
|
||||
@ -80,7 +81,7 @@ void Main(void* arg) {
|
||||
|
||||
while (!exit) {
|
||||
msg = NULL;
|
||||
osRecvMesg(&irqMgrMsgQ, (OSMesg)&msg, OS_MESG_BLOCK);
|
||||
osRecvMesg(&irqMgrMsgQ, (OSMesg*)&msg, OS_MESG_BLOCK);
|
||||
if (msg == NULL) {
|
||||
break;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx) {
|
||||
jpegCtx->scTask.framebuffer = NULL;
|
||||
jpegCtx->scTask.list.t = sJpegTask;
|
||||
|
||||
osSendMesg(&gSchedContext.cmdQ, (OSMesg)&jpegCtx->scTask, OS_MESG_BLOCK);
|
||||
osSendMesg(&gSchedContext.cmdQ, (OSMesg*)&jpegCtx->scTask, OS_MESG_BLOCK);
|
||||
Sched_SendEntryMsg(&gSchedContext); // osScKickEntryMsg
|
||||
osRecvMesg(&jpegCtx->mq, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ void __osDevMgrMain(void* arg) {
|
||||
ret = 0;
|
||||
|
||||
while (true) {
|
||||
osRecvMesg(devMgr->cmdQueue, (OSMesg)&ioMesg, OS_MESG_BLOCK);
|
||||
osRecvMesg(devMgr->cmdQueue, (OSMesg*)&ioMesg, OS_MESG_BLOCK);
|
||||
if ((ioMesg->piHandle != NULL) && (ioMesg->piHandle->type == 2) &&
|
||||
((ioMesg->piHandle->transferInfo.cmdType == OS_READ) ||
|
||||
(ioMesg->piHandle->transferInfo.cmdType == OS_WRITE))) {
|
||||
|
@ -72,7 +72,7 @@ void viMgrMain(void* vargs) {
|
||||
args = (OSMgrArgs*)vargs;
|
||||
|
||||
while (true) {
|
||||
osRecvMesg(args->eventQueue, (OSMesg)&mesg, OS_MESG_BLOCK);
|
||||
osRecvMesg(args->eventQueue, (OSMesg*)&mesg, OS_MESG_BLOCK);
|
||||
switch (mesg->hdr.type) {
|
||||
case OS_MESG_TYPE_VRETRACE:
|
||||
__osViSwapContext();
|
||||
|
@ -3110,9 +3110,9 @@
|
||||
0x80172B58:("THA_Init",),
|
||||
0x80172B9C:("THA_Destroy",),
|
||||
0x80172BC0:("AudioMgr_StopAllSfxExceptSystem",),
|
||||
0x80172C30:("func_80172C30",),
|
||||
0x80172C30:("AudioMgr_NotifyTaskDone",),
|
||||
0x80172C68:("AudioMgr_HandleRetrace",),
|
||||
0x80172EAC:("AudioMgr_HandlePRENMI",),
|
||||
0x80172EAC:("AudioMgr_HandlePreNMI",),
|
||||
0x80172ED0:("AudioMgr_ThreadEntry",),
|
||||
0x80173048:("AudioMgr_Unlock",),
|
||||
0x80173074:("AudioMgr_Init",),
|
||||
|
@ -2624,9 +2624,9 @@ asm/non_matchings/code/TwoHeadArena/THA_Reset.s,THA_Reset,0x80172B3C,0x7
|
||||
asm/non_matchings/code/TwoHeadArena/THA_Init.s,THA_Init,0x80172B58,0x11
|
||||
asm/non_matchings/code/TwoHeadArena/THA_Destroy.s,THA_Destroy,0x80172B9C,0x9
|
||||
asm/non_matchings/code/audio_stop_all_sfx/AudioMgr_StopAllSfxExceptSystem.s,AudioMgr_StopAllSfxExceptSystem,0x80172BC0,0x1C
|
||||
asm/non_matchings/code/audio_thread_manager/func_80172C30.s,func_80172C30,0x80172C30,0xE
|
||||
asm/non_matchings/code/audio_thread_manager/AudioMgr_NotifyTaskDone.s,AudioMgr_NotifyTaskDone,0x80172C30,0xE
|
||||
asm/non_matchings/code/audio_thread_manager/AudioMgr_HandleRetrace.s,AudioMgr_HandleRetrace,0x80172C68,0x91
|
||||
asm/non_matchings/code/audio_thread_manager/AudioMgr_HandlePRENMI.s,AudioMgr_HandlePRENMI,0x80172EAC,0x9
|
||||
asm/non_matchings/code/audio_thread_manager/AudioMgr_HandlePreNMI.s,AudioMgr_HandlePreNMI,0x80172EAC,0x9
|
||||
asm/non_matchings/code/audio_thread_manager/AudioMgr_ThreadEntry.s,AudioMgr_ThreadEntry,0x80172ED0,0x5E
|
||||
asm/non_matchings/code/audio_thread_manager/AudioMgr_Unlock.s,AudioMgr_Unlock,0x80173048,0xB
|
||||
asm/non_matchings/code/audio_thread_manager/AudioMgr_Init.s,AudioMgr_Init,0x80173074,0x2F
|
||||
|
|
Loading…
x
Reference in New Issue
Block a user