0
0

We are porting some C# code to Mac using the Mono Framework. For some reason, the audio played with FMOD Ex (we are using the standard C# wrappers) stutters on the Mac version. Investigating further, we noticed that the problem is related to Mono’s garbage collector: whenever it collects garbage, the audio stutters a bit.

We already tried to increase buffer sizes with System::setStreamBufferSize, but with little success – the stuttering continues regardless.

By the way, the garbage collector takes around 30ms to finish it’s job. While this is way too much anyway (and it’s another problem we are investigating currently), it bothers me, that shouldn’t FMOD’s threads be unaffected by it? After all, while debugging in Visual Studio on Windows, the audio streams started before pausing the program continue playing regardless whether the the program threads are running or not.

Any insights for resolving this stuttering problem would be much appreciated.

  • You must to post comments
0
0

We aren’t able to test on Mono but I looked at the documentation. The wording is a little unclear, but it may be that all the FMOD threads are suspended during garbage collection.
[quote:2p25gn0q]The Mono runtime will automatically register all threads that are created from the managed world with the garbage collector.[/quote:2p25gn0q]
From http://www.mono-project.com/Generational_GC

Even though FMOD is native code, it’s pInvoked from managed code, so I’m not uncertain if the above statement applies.
Your MSDN link won’t apply to the Mono runtime.

  • You must to post comments
0
0

All right, I have this one settled.

I wrote a minimal test tool (check the file attachment if you’re interested).

Due to certain circumstances, we had to use the older Garbage collector, "Boehm" with Mono. Run with the newer one, "SGen", I couldn’t make it stutter. Either the newer one doesn’t stop the native threads, or its generational collecting makes each collecting time so quick the buffers won’t starve. Anyways, using the newer one seems to solve our problem. Thanks for the help, Nick!

  • You must to post comments
0
0

Some further thinking: According to this [url:eu9f4sof]http://blogs.msdn.com/b/jmstall/archive/2005/10/04/managed-suspension.aspx[/url:eu9f4sof], native threads don’t get paused by garbage collection. FMOD Ex consists of native code (compiled from C?) and has bindings/wrappers for interfacing from C#. If I’ve understood right, the stop-the-world garbage collector SHOULDN’T stall the FMOD Ex threads. Either:

1) It somehow still manages to stall them.
2) FMOD runs, but for some reason, the stalled C# threads cause its buffers to starve.
3) Something that I haven’t thought of — what?

I’m also at a loss how to discriminate between these possibilities. What’s actually happening there?

  • You must to post comments
0
0

The function that controls the buffer sizes used between mixer thread and the device output is System::setDSPBufferSize, not setStreamBufferSize.

It is possible for the FMOD mixer to be blocked by the C# garbage collector if you are using any callbacks written in C# that are invoked on the mixer thread, e.g PCM read callback, DSP read callbacks.

  • You must to post comments
0
0

Hello and thanks for the reply!

Increasing DSPBufferSize helped to remove the stutter. Thanks! However, we are still investigating another resolutions, since it also introduces lag, and seems a bit ad hoc solution (We can’t be sure how long the collector will take on different platforms, so the audio might not work for someone else).

We tried to eliminate all callbacks functions passed to FMOD. If we haven’t missed anything, there should be none, but the stuttering continues. I attached fmod.log if it helps to pinpoint any problems.

[code:1yps38dl]
FMOD: OutputCoreAudio::enumerate : Enumerating...
FMOD: OutputCoreAudio::enumerate : Found input driver: "Built-in Microphone".
FMOD: OutputCoreAudio::enumerate : Found output driver: "Built-in Output".
FMOD: OutputCoreAudio::enumerate : Done.
FMOD: SystemI::init : FMOD Ex Version: 00044429
FMOD: SystemI::init : maxchannels = 64, flags = 00000080, extradriverdata = 0x0
FMOD: SystemI::close :
FMOD: SystemI::close : Stop all sounds
FMOD: SystemI::close : Shut down output.
FMOD: OutputCoreAudio::close : Closing...
FMOD: OutputCoreAudio::close : Done.
FMOD: SystemI::close : Remove miscllaneous DSP stuff.
FMOD: SystemI::close : done.

FMOD: OutputCoreAudio::enumerate : Enumerating...
FMOD: OutputCoreAudio::enumerate : Found input driver: "Built-in Microphone".
FMOD: OutputCoreAudio::enumerate : Found output driver: "Built-in Output".
FMOD: OutputCoreAudio::enumerate : Done.
FMOD: OutputCoreAudio::init : Initialising...
FMOD: OutputCoreAudio::init : Forcing output format to match device native format: PCM Float.
FMOD: OutputCoreAudio::init : Forcing sample rate to match device rate: 44100.
FMOD: OutputCoreAudio::init : Done.
FMOD: SystemI::init : Set up software engine
FMOD: SystemI::init : Set up emulated output
FMOD: SystemI::init : create the channel pool
FMOD: SystemI::init : Set up streamer
FMOD: Thread::initThread : Initializing FMOD stream thread. priority 2
FMOD: Thread::initThread : – Stacksize 65536. Stack pointer 0x0 : usesemaphore = 0 : sleeptime = 10
FMOD: Thread::callback : * FMOD stream thread started
FMOD: Thread::initThread : done.
FMOD: SystemI::init : done

FMOD: OutputCoreAudio::enumerate : Enumerating...
FMOD: OutputCoreAudio::enumerate : Found input driver: "Built-in Microphone".
FMOD: OutputCoreAudio::enumerate : Found output driver: "Built-in Output".
FMOD: OutputCoreAudio::enumerate : Done.
FMOD: SystemI::init : FMOD Ex Version: 00044429
FMOD: SystemI::init : maxchannels = 64, flags = 00000080, extradriverdata = 0x0
FMOD: SystemI::close :
FMOD: SystemI::close : Stop all sounds
FMOD: SystemI::close : Shut down output.
FMOD: OutputCoreAudio::close : Closing...
FMOD: OutputCoreAudio::close : Done.
FMOD: SystemI::close : Remove miscllaneous DSP stuff.
FMOD: SystemI::close : done.

FMOD: OutputCoreAudio::enumerate : Enumerating...
FMOD: OutputCoreAudio::enumerate : Found input driver: "Built-in Microphone".
FMOD: OutputCoreAudio::enumerate : Found output driver: "Built-in Output".
FMOD: OutputCoreAudio::enumerate : Done.
FMOD: OutputCoreAudio::init : Initialising...
FMOD: OutputCoreAudio::init : Forcing output format to match device native format: PCM Float.
FMOD: OutputCoreAudio::init : Forcing sample rate to match device rate: 44100.
FMOD: OutputCoreAudio::init : Done.
FMOD: SystemI::init : Set up software engine
FMOD: SystemI::init : Set up emulated output
FMOD: SystemI::init : create the channel pool
FMOD: SystemI::init : Set up streamer
FMOD: Thread::initThread : Initializing FMOD stream thread. priority 2
FMOD: Thread::initThread : – Stacksize 65536. Stack pointer 0x0 : usesemaphore = 0 : sleeptime = 10
FMOD: Thread::callback : * FMOD stream thread started
FMOD: Thread::initThread : done.
FMOD: SystemI::init : done

FMOD: SystemI::createSoundInternal : filename = REMOVED/menu_theme0.ogg : mode 000000ca
FMOD: SystemI::createSoundInternal : 19 codecs found. Scan all until one succeeds
FMOD: CodecTag::openInternal : attempting to open ID3 or ASF tags..
FMOD: Codec::release :
FMOD: Plugin::release : (0x10948ab98)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecCDDA::openInternal : attempting to open as CDDA..
FMOD: Codec::release :
FMOD: Plugin::release : (0x10948ab98)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecFSB5::openInternal : attempting to open as FSB5..
FMOD: CodecFSB5::headerReadCheck : Header check failed. Not an FSB5
FMOD: Codec::release :
FMOD: CodecFSB5::closeInternal :
FMOD: CodecFSB5::closeInternal : done
FMOD: Plugin::release : (0x1094934c8)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecFSB::openInternal : attempting to open as FSB..
FMOD: CodecFSB::openInternal : Header check failed. Not an FSB
FMOD: Codec::release :
FMOD: CodecFSB::closeInternal :
FMOD: CodecFSB::closeInternal : done
FMOD: Plugin::release : (0x129090b38)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecWav::openInternal : attempting to open as WAV..
FMOD: Codec::release :
FMOD: Plugin::release : (0x128a4db28)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecOggVorbis::openInternal : attempting to open as OGG..
FMOD: SystemI::createSoundInternal : Format has 0 subsounds.
FMOD: SystemI::createSoundInternal : Create as FMOD_CREATESTREAM
FMOD: System::createSoundInternal : decode buffersize = 17408 : blocksize = 256 : format = 2
FMOD: SystemI::createSample : mode 000000ca length 17408 samples, lengthbytes 2910725
FMOD: SystemI::createSample : subsamples = 1, channels = 2
FMOD: SystemI::createSample : subsample 0. output = 0x10bf52358
FMOD: SystemI::createSample : mSoftware = 0x10bf52358
FMOD: OutputSoftware::createSample : lengthpcm 17408, lengthbytes 2910725, channels 2, format 2, freq 44100, mode 000000ca
FMOD: OutputSoftware::createSample : done
FMOD: SystemI::createSample : done
FMOD: System::createSoundInternal : Seek stream to start
FMOD: System::createSoundInternal : flush stream buffer
FMOD: System::createSoundInternal : flush successful.
FMOD: System::createSoundInternal : switch file handle from small blocking single buffered to large nonblocking doublebuffered.
FMOD: Thread::initThread : Initializing FMOD file thread. priority 1
FMOD: Thread::initThread : – Stacksize 8192. Stack pointer 0x0 : usesemaphore = 0 : sleeptime = 10
FMOD: Thread::callback : * FMOD file thread started
FMOD: Thread::initThread : done.
FMOD: SystemI::createSoundInternal : No name found in file, use filename.
FMOD: SystemI::createSoundInternal : done. OpenState now = FMOD_OPENSTATE_READY.

FMOD: SoundI::release : menu_theme0.ogg (0x10948ab98)
FMOD: SoundI::release : remove stream samples. (0x10948ab98)
FMOD: SoundI::release : (0x12894d058)
FMOD: SoundI::release : free this. (0x12894d058)
FMOD: SoundI::release : done (0x12894d058)
FMOD: SoundI::release : release codec. (0x10948ab98)
FMOD: Codec::release :
FMOD: Codec::release : Close file (mFile = 0x109492968)
FMOD: Plugin::release : (0x1045d2e08)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: SoundI::release : free this. (0x10948ab98)
FMOD: SoundI::release : done (0x10948ab98)
FMOD: SystemI::createSoundInternal : filename = REMOVED/menu_theme0.ogg : mode 000000ca
FMOD: SystemI::createSoundInternal : 19 codecs found. Scan all until one succeeds
FMOD: CodecTag::openInternal : attempting to open ID3 or ASF tags..
FMOD: Codec::release :
FMOD: Plugin::release : (0x10c168148)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecCDDA::openInternal : attempting to open as CDDA..
FMOD: Codec::release :
FMOD: Plugin::release : (0x1289754f8)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecFSB5::openInternal : attempting to open as FSB5..
FMOD: CodecFSB5::headerReadCheck : Header check failed. Not an FSB5
FMOD: Codec::release :
FMOD: CodecFSB5::closeInternal :
FMOD: CodecFSB5::closeInternal : done
FMOD: Plugin::release : (0x12896af28)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecFSB::openInternal : attempting to open as FSB..
FMOD: CodecFSB::openInternal : Header check failed. Not an FSB
FMOD: Codec::release :
FMOD: CodecFSB::closeInternal :
FMOD: CodecFSB::closeInternal : done
FMOD: Plugin::release : (0x10b6db788)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecWav::openInternal : attempting to open as WAV..
FMOD: Codec::release :
FMOD: Plugin::release : (0x128a4db28)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecOggVorbis::openInternal : attempting to open as OGG..
FMOD: SystemI::createSoundInternal : Format has 0 subsounds.
FMOD: SystemI::createSoundInternal : Create as FMOD_CREATESTREAM
FMOD: System::createSoundInternal : decode buffersize = 17408 : blocksize = 256 : format = 2
FMOD: SystemI::createSample : mode 000000ca length 17408 samples, lengthbytes 2910725
FMOD: SystemI::createSample : subsamples = 1, channels = 2
FMOD: SystemI::createSample : subsample 0. output = 0x10bf52358
FMOD: SystemI::createSample : mSoftware = 0x10bf52358
FMOD: OutputSoftware::createSample : lengthpcm 17408, lengthbytes 2910725, channels 2, format 2, freq 44100, mode 000000ca
FMOD: OutputSoftware::createSample : done
FMOD: SystemI::createSample : done
FMOD: System::createSoundInternal : Seek stream to start
FMOD: System::createSoundInternal : flush stream buffer
FMOD: System::createSoundInternal : flush successful.
FMOD: System::createSoundInternal : switch file handle from small blocking single buffered to large nonblocking doublebuffered.
FMOD: SystemI::createSoundInternal : No name found in file, use filename.
FMOD: SystemI::createSoundInternal : done. OpenState now = FMOD_OPENSTATE_READY.

FMOD: SystemI::createSoundInternal : filename = REMOVED/gui_hover.ogg : mode 00000048
FMOD: SystemI::createSoundInternal : 19 codecs found. Scan all until one succeeds
FMOD: CodecTag::openInternal : attempting to open ID3 or ASF tags..
FMOD: Codec::release :
FMOD: Plugin::release : (0x12894f208)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecCDDA::openInternal : attempting to open as CDDA..
FMOD: Codec::release :
FMOD: Plugin::release : (0x12894f208)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecFSB5::openInternal : attempting to open as FSB5..
FMOD: CodecFSB5::headerReadCheck : Header check failed. Not an FSB5
FMOD: Codec::release :
FMOD: CodecFSB5::closeInternal :
FMOD: CodecFSB5::closeInternal : done
FMOD: Plugin::release : (0x128c49c18)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecFSB::openInternal : attempting to open as FSB..
FMOD: CodecFSB::openInternal : Header check failed. Not an FSB
FMOD: Codec::release :
FMOD: CodecFSB::closeInternal :
FMOD: CodecFSB::closeInternal : done
FMOD: Plugin::release : (0x129091008)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecWav::openInternal : attempting to open as WAV..
FMOD: Codec::release :
FMOD: Plugin::release : (0x1289eed38)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecOggVorbis::openInternal : attempting to open as OGG..
FMOD: SystemI::createSoundInternal : Format has 0 subsounds.
FMOD: SystemI::createSoundInternal : Create as FMOD_CREATESAMPLE
FMOD: SystemI::createSoundInternal : creating subsound 0/0
FMOD: SystemI::createSample : mode 00000048 length 139797 samples, lengthbytes 64998
FMOD: SystemI::createSample : subsamples = 1, channels = 2
FMOD: SystemI::createSample : subsample 0. output = 0x10bf52358
FMOD: SystemI::createSample : mSoftware = 0x10bf52358
FMOD: OutputSoftware::createSample : lengthpcm 139797, lengthbytes 64998, channels 2, format 2, freq 44100, mode 00000049
FMOD: OutputSoftware::createSample : done
FMOD: SystemI::createSample : done
FMOD: SystemI::createSoundInternal : No name found in file, use filename.
FMOD: SystemI::createSoundInternal : done. OpenState now = FMOD_OPENSTATE_READY.

FMOD: SystemI::createSoundInternal : filename = REMOVED/gui_select.ogg : mode 00000048
FMOD: SystemI::createSoundInternal : 19 codecs found. Scan all until one succeeds
FMOD: CodecTag::openInternal : attempting to open ID3 or ASF tags..
FMOD: Codec::release :
FMOD: Plugin::release : (0x12894f208)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecCDDA::openInternal : attempting to open as CDDA..
FMOD: Codec::release :
FMOD: Plugin::release : (0x12894f208)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecFSB5::openInternal : attempting to open as FSB5..
FMOD: CodecFSB5::headerReadCheck : Header check failed. Not an FSB5
FMOD: Codec::release :
FMOD: CodecFSB5::closeInternal :
FMOD: CodecFSB5::closeInternal : done
FMOD: Plugin::release : (0x10b6df438)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecFSB::openInternal : attempting to open as FSB..
FMOD: CodecFSB::openInternal : Header check failed. Not an FSB
FMOD: Codec::release :
FMOD: CodecFSB::closeInternal :
FMOD: CodecFSB::closeInternal : done
FMOD: Plugin::release : (0x10b6df438)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecWav::openInternal : attempting to open as WAV..
FMOD: Codec::release :
FMOD: Plugin::release : (0x1289eed38)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: CodecOggVorbis::openInternal : attempting to open as OGG..
FMOD: SystemI::createSoundInternal : Format has 0 subsounds.
FMOD: SystemI::createSoundInternal : Create as FMOD_CREATESAMPLE
FMOD: SystemI::createSoundInternal : creating subsound 0/0
FMOD: SystemI::createSample : mode 00000048 length 139797 samples, lengthbytes 63923
FMOD: SystemI::createSample : subsamples = 1, channels = 2
FMOD: SystemI::createSample : subsample 0. output = 0x10bf52358
FMOD: SystemI::createSample : mSoftware = 0x10bf52358
FMOD: OutputSoftware::createSample : lengthpcm 139797, lengthbytes 63923, channels 2, format 2, freq 44100, mode 00000049
FMOD: OutputSoftware::createSample : done
FMOD: SystemI::createSample : done
FMOD: SystemI::createSoundInternal : No name found in file, use filename.
FMOD: SystemI::createSoundInternal : done. OpenState now = FMOD_OPENSTATE_READY.

FMOD: SoundI::release : menu_theme0.ogg (0x1289738d8)
FMOD: SoundI::release : remove stream samples. (0x1289738d8)
FMOD: SoundI::release : (0x12894d528)
FMOD: SoundI::release : free this. (0x12894d528)
FMOD: SoundI::release : done (0x12894d528)
FMOD: SoundI::release : release codec. (0x1289738d8)
FMOD: Codec::release :
FMOD: Codec::release : Close file (mFile = 0x10c16a728)
FMOD: Plugin::release : (0x1045d2e08)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: SoundI::release : free this. (0x1289738d8)
FMOD: SoundI::release : done (0x1289738d8)
[/code:1yps38dl]

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.