CSND: move waiting code to csndExecChnCmds()

This commit is contained in:
fincs 2015-01-01 16:23:09 +01:00
parent b15eb566dd
commit e943b25bc5
2 changed files with 10 additions and 17 deletions

View File

@ -24,7 +24,7 @@ Result csndInit(void);
Result csndExit(void); Result csndExit(void);
void csndWriteChnCmd(int cmdid, u8 *cmdparams); void csndWriteChnCmd(int cmdid, u8 *cmdparams);
Result csndExecChnCmds(void); Result csndExecChnCmds(bool waitDone);
void CSND_ChnSetPlayStateR(u32 channel, u32 value); void CSND_ChnSetPlayStateR(u32 channel, u32 value);
void CSND_ChnSetPlayState(u32 channel, u32 value); void CSND_ChnSetPlayState(u32 channel, u32 value);
@ -33,7 +33,7 @@ void CSND_ChnSetVol(u32 channel, u16 left, u16 right);
void CSND_ChnSetTimer(u32 channel, u32 timer); void CSND_ChnSetTimer(u32 channel, u32 timer);
void CSND_ChnConfig(u32 channel, u32 looping, u32 encoding, u32 timer, u32 unk0, u32 unk1, u32 physaddr0, u32 physaddr1, u32 totalbytesize); void CSND_ChnConfig(u32 channel, u32 looping, u32 encoding, u32 timer, u32 unk0, u32 unk1, u32 physaddr0, u32 physaddr1, u32 totalbytesize);
Result CSND_UpdateChnInfo(bool waitdone); Result CSND_UpdateChnInfo(bool waitDone);
Result csndChnPlaySound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u32 *vaddr0, u32 *vaddr1, u32 totalbytesize, u32 unk0, u32 unk1); Result csndChnPlaySound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u32 *vaddr0, u32 *vaddr1, u32 totalbytesize, u32 unk0, u32 unk1);

View File

@ -149,7 +149,7 @@ void csndWriteChnCmd(int cmdid, u8 *cmdparams)
svcReleaseMutex(csndMutex); svcReleaseMutex(csndMutex);
} }
Result csndExecChnCmds(void) Result csndExecChnCmds(bool waitDone)
{ {
Result ret=0; Result ret=0;
@ -157,9 +157,14 @@ Result csndExecChnCmds(void)
if (csndCmdStartOff == csndCmdCurOff) if (csndCmdStartOff == csndCmdCurOff)
return 0; return 0;
vu8* flag = (vu8*)&csndSharedMem[csndCmdStartOff>>2];
ret = CSND_ExecChnCmds(csndCmdStartOff); ret = CSND_ExecChnCmds(csndCmdStartOff);
csndCmdStartOff = csndCmdCurOff; csndCmdStartOff = csndCmdCurOff;
// FIXME: This is a really ugly busy waiting loop!
while (waitDone && *flag == 0);
return ret; return ret;
} }
@ -248,26 +253,14 @@ void CSND_ChnConfig(u32 channel, u32 looping, u32 encoding, u32 timer, u32 unk0,
csndWriteChnCmd(0xe, (u8*)&cmdparams); csndWriteChnCmd(0xe, (u8*)&cmdparams);
} }
Result CSND_UpdateChnInfo(bool waitdone) Result CSND_UpdateChnInfo(bool waitDone)
{ {
u8 *ptr;
int ret=0;
u32 cmdparams[0x18>>2]; u32 cmdparams[0x18>>2];
memset(cmdparams, 0, 0x18); memset(cmdparams, 0, 0x18);
ptr = (u8*)&csndSharedMem[csndCmdStartOff>>2];
csndWriteChnCmd(0x300, (u8*)&cmdparams); csndWriteChnCmd(0x300, (u8*)&cmdparams);
return csndExecChnCmds(waitDone);
ret = csndExecChnCmds();
if (ret != 0) return ret;
// This is bad! Busy loops are bad!
while (waitdone && *ptr == 0);
return 0;
} }
Result csndChnPlaySound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u32 *vaddr0, u32 *vaddr1, u32 totalbytesize, u32 unk0, u32 unk1) Result csndChnPlaySound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u32 *vaddr0, u32 *vaddr1, u32 totalbytesize, u32 unk0, u32 unk1)