For personal usage, I just hacked a bit in the code and made it soft-fail on those cases, where it just won't use the uncreated threads/channels, but the code gets pretty sluggish.
Also, after taking a look at the sound code, it doesn't seem like it could be a problem of that and as jimparis said, pspaudiolib hasn't changed really in quite some time and the prototype change cannot be the cause (if it were, it just wouldn't compile).
For an easy solution, you should create a local copy of pspaudiolib in the src/psp folder, include the files directly and change the init function as follows:
Code: Select all
int pspAudioInit()
{
printf("pspAudioInit().\n");
printf("NUM_AUDIO_CHANNELS: %i\n", PSP_NUM_AUDIO_CHANNELS);
int i,ret;
int failed=0;
char str[32];
audio_terminate=0;
audio_ready=0;
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
printf("Initializing Channel %i.\n",i);
AudioStatus[i].handle = -1;
AudioStatus[i].threadhandle = -1;
AudioStatus[i].volumeright = PSP_VOLUME_MAX;
AudioStatus[i].volumeleft = PSP_VOLUME_MAX;
AudioStatus[i].callback = 0;
AudioStatus[i].pdata = 0;
}
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
printf("Reserving audio channel %i.\n",i);
if ((AudioStatus[i].handle = sceAudioChReserve(-1,PSP_NUM_AUDIO_SAMPLES,0))<0) {
printf("Error reserving audio channel %i.\n",i);
failed=1;
} else
printf("Got channel No %i.\n", AudioStatus[i].handle);
}
if (failed) {
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
printf("Releasing audio channel %i.\n",i);
if (AudioStatus[i].handle != -1)
sceAudioChRelease(AudioStatus[i].handle);
AudioStatus[i].handle = -1;
}
return -1;
}
audio_ready = 1;
strcpy(str,"audiot0");
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
printf("Creating thread for channel %i.\n",i);
str[6]='0'+i;
AudioStatus[i].threadhandle = sceKernelCreateThread(str,(void*)&AudioChannelThread,0x12,0x10000,PSP_THREAD_ATTR_USER,NULL);
if (AudioStatus[i].threadhandle < 0) {
AudioStatus[i].threadhandle = -1;
printf("Error creating thread for channel %i.\n",i );
//failed=1;
break;
}
printf("Starting thread for channel %i.\n",i);
ret=sceKernelStartThread(AudioStatus[i].threadhandle,sizeof(i),&i);
if (ret!=0) {
printf("Error starting thread for channel %i.\n",i );
//failed=1;
break;
}
}
if (failed) {
audio_terminate=1;
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
printf("Deleting thread for channel %i.\n",i);
if (AudioStatus[i].threadhandle != -1) {
//sceKernelWaitThreadEnd(AudioStatus[i].threadhandle,NULL);
sceKernelDeleteThread(AudioStatus[i].threadhandle);
}
AudioStatus[i].threadhandle = -1;
}
audio_ready=0;
return -1;
}
return 0;
}
Not entirely sure if that fixes the problems, but it's my best guess.
PS: Maybe I can even be assed to create a cleaner version of pspaudiolib and provide a patch for the SDK.