Here is the code:
Code: Select all
strcpy(str,"pgasnd0");
for (i=0; i<PGA_CHANNELS; i++) {
str[6]='0'+i;
pga_threadhandle[i]=sceKernelCreateThread(str,&pga_channel_thread,0x12,0x10000,0,NULL);
if (pga_threadhandle[i]<0) {
pga_threadhandle[i]=-1;
failed=1;
break;
}
ret=sceKernelStartThread(pga_threadhandle[i],sizeof(i),&i);
if (ret!=0) {
failed=1;
break;
}
}
Code: Select all
static int pga_channel_thread(SceSize args, void *argp)
{
volatile int bufidx=0;
int channel=*(int *)argp;
while (pga_terminate==0) {
void *bufptr=&pga_sndbuf[channel][bufidx];
void (*callback)(void *buf, unsigned long reqn);
callback=pga_channel_callback[channel];
if (callback) {
callback(bufptr,PGA_SAMPLES);
} else {
unsigned long *ptr=bufptr;
int i;
for (i=0; i<PGA_SAMPLES; ++i) *(ptr++)=0;
}
pgaOutBlocking(channel,0x8000,0x8000,bufptr);
bufidx=(bufidx?0:1);
}
sceKernelExitThread(0);
return 0;
}
void pga_channel_thread_callback(int channel, void *buf, unsigned long reqn)
{
void (*callback)(void *buf, unsigned long reqn);
callback=pga_channel_callback[channel];
}
Code: Select all
PSP_MODULE_INFO("fMSX 0.62", 0, 6, 2);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER | PSP_THREAD_ATTR_VFPU);