 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Snatcher
Joined: 19 Jul 2005 Posts: 9
|
Posted: Tue Aug 09, 2005 3:04 am Post subject: Problems with sceKernelStartThread |
|
|
Hello, I am trying to "port" fMSX to the PSP SDK, and have completed almost everything succesfully. The only problem I have right now is with the Audio threads, since the thing hangs when calling sceKernelStartThread after a successful sceKernelCreateThread.
Here is the code:
| Code: |
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;
}
}
|
the thread callback is:
| Code: |
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];
}
|
Any ideas? I am using the following:
| Code: |
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);
|
|
|
| Back to top |
|
 |
matkeupon
Joined: 02 Jul 2005 Posts: 26
|
Posted: Tue Aug 09, 2005 10:14 pm Post subject: |
|
|
This looks like the sdk's libpspaudio... So I guess you should just include it, it works fine, and without glitches. I also tried to adapt this initialisation for my game (using mono samples, and only one hardware channel), it won't hang, but it looks like the thread is not triggered when it should, so I switched back to libpspaudio.
Little hint there: libpspaudio always uses 8 hardware channels, even if you need only one. So put your callback threads on the channels you need, for the others just set up a callback function that does nothing, this will avoid having the psp filling 7 buffers with zeros all the time... |
|
| Back to top |
|
 |
Snatcher
Joined: 19 Jul 2005 Posts: 9
|
Posted: Wed Aug 10, 2005 10:41 am Post subject: |
|
|
Thanks man, I found the real problem though, thanks to aprevious post of yours (http://forums.ps2dev.org/viewtopic.php?t=2862&highlight=)
The solution was changing it to:
| Code: |
#define PGA_CHANNELS 3
#define PGA_SAMPLES PSP_AUDIO_SAMPLE_ALIGN(256)
#define MAXVOLUME PSP_AUDIO_VOLUME_MAX
int pgaOutBlocking(unsigned long channel,unsigned long vol1,unsigned long vol2,void *buf)
{
if (!pga_ready) return -1;
if (channel>=PGA_CHANNELS) return -1;
if (vol1>MAXVOLUME) vol1=MAXVOLUME;
if (vol2>MAXVOLUME) vol2=MAXVOLUME;
return sceAudioOutputPannedBlocking(pga_handle[channel],vol1,vol2,buf);
}
|
I was using the non Blocking version
and: | Code: |
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;
}
} |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|