0
0

Hi,

I have a sample playback system which uses FSOUND_Sample_Alloc and
FSOUND_Sample_Lock / FSOUND_Sample_Unlock to modify the data. The uploading function looks something like this :

// I’M EXPECTING 16 bit SIGNED SHORTS.
// NOT FLOATS
void audioSample::loadSampleIntoFmod(char * rawData, int numBytes){

void *buf1 = NULL; 
void *buf2 = NULL; 
unsigned int len1=0, len2=0; 
if (!FSOUND_Sample_Lock (mySound, 0, numBytes, &buf1, &buf2, &len1, &len2)) 
{ 
   printf ("\nfailed to lock\n");
   lengthSample = 0; 
} 

lengthSample = numBytes/2;

signed short *buff = (signed short *)buf1;
for (int i = 0; i < MAXSAMPLELENGTH; i++){
    buff[i] = 0;
}

memcpy(buf1, rawData, numBytes); 

if (!FSOUND_Sample_Unlock (mySound, buf1, buf2, len1, len2)) 
{ 
    printf ("\nfailed to unlock\n"); 
} 

birthday = GetTickCount();
bReservedForPendingSample = false;
clearSimultaneousArray();

}

(this function is for an earliar constructed sample :
mySound = FSOUND_Sample_Alloc(FSOUND_FREE,MAXSAMPLELENGTH,LOCKMODE, 16000, 100, 128,255);
)

Is this proper usage? I have been using the system for a while, but last night I hit “failed to lock”. It’s a bug I can’t easily recreate, because I don’t understand the condition that caused it. The system itself is multithreaded and so on, so having a good sense of the causes of failure would help me pinpoint any errors in my logic. As it stands, I will have to do something to deal with any failures here (so I don’t crash), but in the meantime, would love to know what kind of things could cause a failure in FSOUND_Sample_Lock .

Thanks a ton,
zach

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.