We are porting an existing iOS game to Android, and FMOD is working great. But for compatibility reason we use some custom fopen/fread function to access the assest manager (assets are not on the SD card). We use system::setFileSystem to call those function from FMOD and it works. (the real "fopen" will call "fmod_open" and this one will call our JNIfopen to read the asset manager)
But, if we call them from another thread (for example when playing a non blocking mp3 stream), we have to do an JNIEnv::AttachCurrentThread, and a DetachCurrentThread. Attaching is not a problem, but detaching can cause a crash depending on the context (imagine 2 nested function eachs calling attach/detach). The solution is to attach the thread only when it’s created and detach it when it’s done. But how can we do that with FMOD threads? I did not see any callback for that purpose. I guess we are not the only ones to have this issue and I wonder how do you guys do?
A workaround would be to call the attach/detach in our fmod_fopen/fmod_fclose callback functions made for FMOD, but it does not seem very clean (many attach/detach for nothing).
- dav asked 4 years ago
- You must login to post comments