]> Chaos Git - corbenik/ctrulib.git/commitdiff
CSND: move waiting code to csndExecChnCmds()
authorfincs <fincs.alt1@gmail.com>
Thu, 1 Jan 2015 15:23:09 +0000 (16:23 +0100)
committerfincs <fincs.alt1@gmail.com>
Tue, 20 Jan 2015 16:53:52 +0000 (17:53 +0100)
libctru/include/3ds/services/csnd.h
libctru/source/services/csnd.c

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