Skip to content

Commit

Permalink
Replace snd_set0{b,w} with memset
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Nov 11, 2024
1 parent a395ffa commit fefad32
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 35 deletions.
22 changes: 6 additions & 16 deletions libaesnd/aesndlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ static u8 __dspdram[DSP_DRAMSIZE] ATTRIBUTE_ALIGN(32);
static u8 mute_buffer[SND_BUFFERSIZE] ATTRIBUTE_ALIGN(32);
static u8 audio_buffer[2][SND_BUFFERSIZE] ATTRIBUTE_ALIGN(32);

static __inline__ void snd_set0b(char *p,int n)
{
while(n>0) { *p++ = 0; n--; }
}

static __inline__ void snd_set0w(int *p,int n)
{
while(n>0) { *p++ = 0; n--; }
}

static __inline__ void __aesndcopycommand(AESNDPB *dst,AESNDPB *src)
{
dst->buf_start = src->buf_start;
Expand Down Expand Up @@ -445,16 +435,16 @@ void AESND_Init(void)
#if defined(HW_DOL)
for(i=0;i<MAX_VOICES;i++) __aesndaramblocks[i] = AR_Alloc(DSP_STREAMBUFFER_SIZE*2);
#endif
snd_set0w((int*)mute_buffer,SND_BUFFERSIZE>>2);
snd_set0w((int*)audio_buffer[0],SND_BUFFERSIZE>>2);
snd_set0w((int*)audio_buffer[1],SND_BUFFERSIZE>>2);
memset(mute_buffer,0,SND_BUFFERSIZE);
memset(audio_buffer[0],0,SND_BUFFERSIZE);
memset(audio_buffer[1],0,SND_BUFFERSIZE);
DCFlushRange(mute_buffer,SND_BUFFERSIZE);
DCFlushRange(audio_buffer[0],SND_BUFFERSIZE);
DCFlushRange(audio_buffer[1],SND_BUFFERSIZE);

snd_set0w((int*)&__aesndcommand,sizeof(struct aesndpb_t)>>2);
memset(&__aesndcommand,0,sizeof(struct aesndpb_t));
for(i=0;i<MAX_VOICES;i++)
snd_set0w((int*)&__aesndvoicepb[i],sizeof(struct aesndpb_t)>>2);
memset(&__aesndvoicepb[i],0,sizeof(struct aesndpb_t));

__aesndloaddsptask(&__aesnddsptask,aesnddspmixer,aesnddspmixer_size,__dspdram,DSP_DRAMSIZE);
}
Expand Down Expand Up @@ -575,7 +565,7 @@ void AESND_FreeVoice(AESNDPB *pb)
if(pb==NULL) return;

_CPU_ISR_Disable(level);
snd_set0w((int*)pb,sizeof(struct aesndpb_t)>>2);
memset(pb,0,sizeof(struct aesndpb_t));
_CPU_ISR_Restore(level);
}

Expand Down
26 changes: 7 additions & 19 deletions libasnd/asndlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <stdio.h>
#include <unistd.h>

#include <string.h>
#include <ogcsys.h>
#include <gccore.h>
#include <ogc/timesupp.h>
Expand Down Expand Up @@ -95,20 +95,8 @@ static u32 asnd_inited = 0;
static t_sound_data sound_data[MAX_VOICES];

static t_sound_data sound_data_dma ATTRIBUTE_ALIGN(32);
static s16 mute_buf[SND_BUFFERSIZE] ATTRIBUTE_ALIGN(32);
static s16 audio_buf[2][SND_BUFFERSIZE] ATTRIBUTE_ALIGN(32);

static __inline__ char* snd_set0b( char *p, int n)
{
while(n>0) {*p++=0;n--;}
return p;
}

static __inline__ s32* snd_set0w( s32 *p, int n)
{
while(n>0) {*p++=0;n--;}
return p;
}
static u8 mute_buf[SND_BUFFERSIZE] ATTRIBUTE_ALIGN(32);
static u8 audio_buf[2][SND_BUFFERSIZE] ATTRIBUTE_ALIGN(32);

static void __dsp_initcallback(dsptask_t *task)
{
Expand Down Expand Up @@ -359,15 +347,15 @@ void ASND_Init(void)
dsp_complete = 0;
dsp_done = 0;

snd_set0w((s32*)mute_buf, SND_BUFFERSIZE>>2);
snd_set0w((s32*)audio_buf[0], SND_BUFFERSIZE>>2);
snd_set0w((s32*)audio_buf[1], SND_BUFFERSIZE>>2);
memset(mute_buf,0,SND_BUFFERSIZE);
memset(audio_buf[0],0,SND_BUFFERSIZE);
memset(audio_buf[1],0,SND_BUFFERSIZE);
DCFlushRange(mute_buf,SND_BUFFERSIZE);
DCFlushRange(audio_buf[0],SND_BUFFERSIZE);
DCFlushRange(audio_buf[1],SND_BUFFERSIZE);

for(i=0;i<MAX_VOICES;i++)
snd_set0w((s32*)&sound_data[i],sizeof(t_sound_data)/4);
memset(&sound_data[i],0,sizeof(t_sound_data));

dsp_task.prio = 255;
dsp_task.iram_maddr = (u16*)MEM_VIRTUAL_TO_PHYSICAL(asnd_dsp_mixer);
Expand Down

0 comments on commit fefad32

Please sign in to comment.