I’ve been trying to figure out why my Java application does not terminate after playing a sound generated via the FMOD_SOUND_PCMREADCALLBACK. I’ve been in contact with Jerome Jouvie and he believes that the Java wrapper should be OK with respect to this problem.
In the Java debugger (Eclipse) I see that there is a thread that starts on play but does not terminate when stopping play. When I exit the application the process keeps running (as seen in Windows XP task manager). This happens when there is a non-daemon thread that is running.
I’ve found that (in my application) if the sound length is greater than 2 times the decode buffer size (even by 1 sample) then the application does not terminate but otherwise it is fine. The maddening thing is the sample application does not have this problem.
Any clues would be very much appreciated since I must get past this problem to be able to let other people run my application. I’m using the latest version 4.02.10 ( the previous versions also had this behavior) on Windows XP.
Thanks in advance.
Here is the setup code:
public void createStream(Sound sound)
FMOD_CREATESOUNDEXINFO createSoundExInfo = FMOD_CREATESOUNDEXINFO.create();
int samplesPerSecond = 44100; int bytesPerSample = 2; createSoundExInfo.setDecodeBufferSize(samplesPerSecond); int numSeconds = 2; // 2 or below is OK; above 2 prevents app from terminating int len = samplesPerSecond * bytesPerSample * numSeconds; // even 1 sample above 2 seconds prevents app from terminating createSoundExInfo.setLength( len ); createSoundExInfo.setNumChannels( 1 ); createSoundExInfo.setDefaultFrequency( 44100 ); createSoundExInfo.setFormat(FMOD_SOUND_FORMAT.FMOD_SOUND_FORMAT_PCM16 ); createSoundExInfo.setPcmReadCallback(pcmreadcallback); /* User callback for reading.*/ createSoundExInfo.setPcmSetPosCallback(pcmsetposcallback); /* User callback for seeking. */ int mode = FMOD_MODE.FMOD_2D | FMOD_MODE.FMOD_OPENUSER | FMOD_MODE.FMOD_CREATESTREAM| FMOD_MODE.FMOD_SOFTWARE; FMOD_RESULT result = _audioSystem.createStream( (String)null, mode, createSoundExInfo, sound); AudioUtils.ERRCHECK( result ); }
- groovin asked 12 years ago
- You must login to post comments