0
0

Is there a way to, for example, mmap the fsb files and then tell FMOD to "use this region of ram for this FSB file"?

Using setFilesystem won’t work since it requires the data to be copied into a buffer, which would defeat the point of using mmap().

  • You must to post comments
0
0

Look at eventSystem->preloadFSB, is that what you mean?

  • You must to post comments
0
0

Oh! That’s exactly what I mean. I forgot about that – thanks :) I’ll report back for the record when I have a chance to try it out and see what the effect is. The goal is to reduce iPhone crashing due to low memory conditions by mmapping as much data as possible. If it’s hitchy or starts thrashing, then letting the OS fault the data is obviously not going to work out well for a game. We already try to be smart about loading/unloading only the necessary sounds, so it should be an interesting stress test.

  • You must to post comments
0
0

You’d probably want to use FMOD_OPENMEMORY_POINT when creating the sound for preloadFSB, but I’m not sure how well that will work in conjunction with mmap. It would be interesting to hear how it goes.

  • You must to post comments
0
0

We’re still testing, but it seems to work fine provided you jump through a couple of hoops:

1) You can’t "Decompress on load" any of your sounds. And since decompressing during playback eats a lot of CPU on the iPhone, this means you have to store your FSBs as PCM. But if it means lower risk of running out of RAM, it’s worth it IMO.

2) You have to use "PROT_READ | PROT_WRITE" and "MAP_PRIVATE" with mmap. There are a few place where FMOD will actually write to the OPENMEMORY_POINT data (loop points or something?). If you don’t use PROT_WRITE, you get invalid memory access. If you don’t MAP_PRIVATE, then writing to the memory mapped region will result in trying to write to the backing file. I’m not sure what would happen in that case.

3) You have to call "madvise( mappedFile, fileSize, POSIX_MADV_SEQUENTIAL )". Doing this tells the kernel to read ahead on fault by default. If you don’t do this, you get stuttering and lagging during faults. If you make this call, it’s completely transparent. Amazing.

And that’s about it.

  • You must to post comments
0
0

That’s good to know – thanks for the info! Is there any particular reason you’re doing it that way rather than using streams? Is it just so you can play more than one instance of the sound for the same cost?

  • You must to post comments
0
0

Streaming requires nearly constant file reading and scales unpredictably on the iPhone. Using mmap means that file reads only happen when absolutely necessary. Most sounds that are used in a particular area of the game are used constantly. I also have a hunch that streaming would end up using much more RAM inside FMOD.

Also, we are also using streaming for sounds that are very large or are rarely used (e.g. cinematics, music, ambience). Memory mapping is used for fsbs that mainly contain a relatively large number of small waves (e.g. monsters, weapons, effects).

  • You must to post comments
0
0

I see, that makes sense. Thanks for the info!

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.