]> Chaos Git - corbenik/ctrulib.git/commitdiff
use struct for channel status array
authorDave Murphy <davem@devkitpro.org>
Fri, 2 Jan 2015 22:41:48 +0000 (22:41 +0000)
committerDave Murphy <davem@devkitpro.org>
Fri, 2 Jan 2015 22:42:12 +0000 (22:42 +0000)
libctru/include/3ds/services/csnd.h
libctru/source/services/csnd.c

index f60795518b3c7e87a49d9273bd9b96dcfe264514..84201c943063b7a1f2d1a1c3d965b28f7e1452b7 100644 (file)
@@ -1,30 +1,40 @@
 #pragma once
 
+#include <3ds/types.h>
+
 #define CSND_SHAREDMEM_DEFAULT 0x10004000
 
 typedef enum{
-    CSND_LOOP_DISABLE,
-    CSND_LOOP_ENABLE
+       CSND_LOOP_DISABLE,
+       CSND_LOOP_ENABLE
 } CSND_LOOPING;
 
 typedef enum{
-    CSND_ENCODING_PCM8,
-    CSND_ENCODING_PCM16,
-    CSND_ENCODING_IMA_ADPCM,
-    CSND_ENCODING_PSG//"3 = PSG, similar to DS?"
+       CSND_ENCODING_PCM8,
+       CSND_ENCODING_PCM16,
+       CSND_ENCODING_IMA_ADPCM,
+       CSND_ENCODING_PSG//"3 = PSG, similar to DS?"
 } CSND_ENCODING;
 
+struct  CSND_CHANNEL_STATUS {
+       u8  state;
+       u8  pad[3];
+       u32 unknown;
+       u32 position;
+} ALIGN(4);
+
 
 //See here regarding CSND shared-mem commands, etc: http://3dbrew.org/wiki/CSND_Shared_Memory
 
 Result CSND_initialize(u32* sharedMem);
 Result CSND_shutdown();
 
+u32 CSND_convertsamplerate(u32 samplerate);
 Result CSND_playsound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u32 *vaddr0, u32 *vaddr1, u32 totalbytesize, u32 unk0, u32 unk1);
 void CSND_setchannel_playbackstate(u32 channel, u32 value);
 void CSND_sharedmemtype0_cmd0(u32 channel, u32 value);
 void CSND_writesharedmem_cmdtype0(u16 cmdid, u8 *cmdparams);
 Result CSND_sharedmemtype0_cmdupdatestate(int waitdone);
 
-Result CSND_getchannelstate(u32 entryindex, u32 *out);
+Result CSND_getchannelstate(u32 entryindex, struct CSND_CHANNEL_STATUS *out);
 Result CSND_getchannelstate_isplaying(u32 entryindex, u8 *status);
index 52f95ec5f9b9e8cbb259241fe1656d37b28edb34..d118329e64008126b03fc3146a51d7b02f3a4b2f 100644 (file)
@@ -301,14 +301,14 @@ Result CSND_playsound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u3
        return CSND_sharedmemtype0_cmdupdatestate(0);
 }
 
-Result CSND_getchannelstate(u32 entryindex, u32 *out)
+Result CSND_getchannelstate(u32 entryindex, struct CSND_CHANNEL_STATUS *out)
 {
        Result ret=0;
 
        if((ret = CSND_sharedmemtype0_cmdupdatestate(1))!=0)return ret;
 
        memcpy(out, &CSND_sharedmem[(CSND_sharedmem_cmdblocksize+8 + entryindex*0xc) >> 2], 0xc);
-       out[2] -= 0x0c000000;
+       out->position -= 0x0c000000;
 
        return 0;
 }
@@ -316,12 +316,12 @@ Result CSND_getchannelstate(u32 entryindex, u32 *out)
 Result CSND_getchannelstate_isplaying(u32 entryindex, u8 *status)
 {
        Result ret;
-       u32 entry[0xc>>2];
+       struct CSND_CHANNEL_STATUS entry;
 
-       ret = CSND_getchannelstate(entryindex, entry);
+       ret = CSND_getchannelstate(entryindex, &entry);
        if(ret!=0)return ret;
 
-       *status = entry[0] & 0xff;
+       *status = entry.state;
 
        return 0;
 }