0
0

I am having problems when I try to pass a callback function to the CloseCallback component of the FSOUND_File_SetCallbacks. The function (wich does nothing more than just call fclose()) seems to prevent FSOUND from reading OGG, MP3, SGT and probably more others : only WAV streams&samples work properly. I have made a series of skinner functions (that just call fopen(), fseek() and such) FMOD works properly with them, but the skinner fclose() function will make FMOD unable to play sound. This is the function :

void FMOD_Close(unsigned int handle)
{fclose((FILE *)handle);}

can’t see anything wrong here. Could this be because FMOD expects a return a value of some sort (like the original fclose() does), but the CloseCallback has a void return value? I’m using FMOD 3.40.

  • You must to post comments
0
0

This is the CloseFile callback function we used in a game that we just published. Ignore the _DEBUG stuff and you will see that it basically just calls fclose() passing the given handle. Our filesystem could also read files directly from a ZIP archive, which was actually faster than reading the files from disk.
<pre>void FILE_Close(unsigned int handle)
{
#ifdef _DEBUG
if (handle == FILEID_ZIP)
ERR_LogInfo(“Closing file in zip”);
else
ERR_LogInfo(“Closing handle 0x%x”, handle);
#endif

if (handle == FILEID_ZIP)
unzCloseCurrentFile(zipFile);
else
fclose((FILE *)handle);
}</pre>

  • You must to post comments
0
0

Yup.. ignore the ZIP and _DEBUG stuff, and that’s the same function as what I posted.. However, it doesn’t work for me. Is it a bug in FMOD 3.40 maybe? (as I did have a file system working on 3.3x)

  • You must to post comments
0
0

Just did another series of tests.. I’m pretty positive that there has to be some bug in FMOD, cuz I can pass all my skinner functions and FMOD works perfectly, but when I pass the afforementioned

FMOD_Close(unsigned int handle){fclose((FILE *)handle)}

FMOD can’t load samples and will frequently crash if I try to play streams.

  • You must to post comments
0
0

Hrm.. did another series of tests : I figured out that FMOD crashed when BOTH the open and close procedures were set. Then I started comparing the simple.c code to mine, and found only one difference :

my code :
return fread(buffer, size, 1, (FILE *)handle);

your code :
return fread(buffer, 1, size, (FILE *)handle);

I swapped size with 1 and it worked. Hrm. st00pid mistake.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.