First of all, it should be noted that my program does not rely on efficiency of playback so I exclusively use streams instead of samples, even for short files.
Now, the program that I am attempting to use this in does not have one generic area where sounds are loaded in so that I can play them at anytime and then free them all at the end. Rather, it needs to be a little more robust in that I can give it a path to a .wav or .mp3 and have it open the stream then play right there (using FSOUND_Stream_OpenFile and FSOUND_Stream_Play). This works fine and dandy except that now there is nothing to close the stream. I would prefer that it close itself (and free memory) when the stream has finished playing all on its own rather than me constantly having to monitor for when it has finished.
Naively, I attempted to use the EndCallback to call FSOUND_Stream_Close when the file was done being played. This seemed to work until I tried playing many streams at once (say, 16). After the first stream closed itself off and the next one attempted to, the program would crash. I investigated a little further and found that all FSOUND functions called inside the callback that used the FSOUND_STREAM * ptr would generate the error FMOD_ERR_INVALID_PARAM. This includes such simple things as FSOUND_Stream_SetTime and FSOUND_Stream_Play (which I tested by having SetTime reset the sound to the beginning and then play it over and they both functioned fine other than generating that error).
I noticed in another post that a user had problems calling FSOUND_Stream_Close inside a callback until the latest version of FMOD, but I have version 3.6 and and am running on a Win2k machine with all the latest drivers/service packs, etc. I’m not sure this is a problem with FMOD but I’m afraid my only solution might be to have the callback post a user-defined message to the main window and have the Close function called there in the winproc (this has worked so far in testing). Any other recommendations to solve this whole problem would be very appreciated.
- Horminga asked 14 years ago
- You must login to post comments