Low-level ring buffer starvation

We tested FMOD Studio on several devices,but some of them crashed,log is here,the device are
Samsung Note 3 N9005,Huawei G621-TL00M and G7,the test on Nexus 6P is all passed.

04-21 11:02:16.987    5912-5984/? I/Fmod﹕ Systemi::Init                            : Fmod Studio Version: 00010800 (73609)
04-21 11:02:16.987    5912-5984/? I/Fmod﹕ Systemi::Init                            : Maxchannels = 32, Flags = 00000000, Extradriverdata = 0X0
04-21 11:02:16.987    5912-5984/? I/Fmod﹕ Systemi::Close                           :
04-21 11:02:16.987    5912-5984/? I/Fmod﹕ Systemi::Close                           : Stop All Sounds
04-21 11:02:16.987    5912-5984/? I/Fmod﹕ Systemi::Close                           : Done.
04-21 11:02:16.987    5912-5984/? I/Fmod﹕ Fmod_Os_Init                             : Detected Neon Instruction Support, Will Use Neon Optimized Mixing And Resampling.

04-21 11:02:16.987    5912-5984/? I/fmod﹕ OutputOpenSL::init                       : Sample rate: HW = 48000, SW = 24000  Block size: HW = 960, SW = 512.
04-21 11:02:16.987    5912-5984/? W/fmod﹕ OutputOpenSL::init                       : Only mono and stereo supported, defaulting to stereo.

04-21 11:02:17.007    5912-5984/? W/fmod﹕ SystemI::init                            : Output requires a sample rate of 48000Hz, resampling will occur.
04-21 11:02:17.007    5912-5984/? I/fmod﹕ Thread::initThread                       : Initializing FMOD mixer thread.  priority 3
04-21 11:02:17.007    5912-5984/? I/fmod﹕ Thread::initThread                       : - Stacksize 49152.  Stack pointer 0x0 : usesemaphore = 1 : sleeptime = 0

04-21 11:02:17.007    5912-5987/? I/fmod﹕ Thread::callback                         : * FMOD mixer thread started

04-21 11:02:17.007    5912-5984/? I/fmod﹕ SystemI::init                            : Set up emulated output

04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::init                            : create the channel pool
04-21 11:02:17.017    5912-5984/? I/fmod﹕ Thread::initThread                       : Initializing FMOD stream thread.  priority 2
04-21 11:02:17.017    5912-5984/? I/fmod﹕ Thread::initThread                       : - Stacksize 65536.  Stack pointer 0x0 : usesemaphore = 0 : sleeptime = 10
04-21 11:02:17.017    5912-5988/? I/fmod﹕ Thread::callback                         : * FMOD stream thread started
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : filename = file:///android_asset/drumloop.wav : mode 00000009
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : Format has 0 subsounds.
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : Create as FMOD_CREATESAMPLE
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : creating subsound 0/0
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSample                    : mode 00000009 length 42158 samples, lengthbytes 84316
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSample                    : channels = 1
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSample                    : output = 0x75f7b7f0
04-21 11:02:17.017    5912-5984/? I/fmod﹕ OutputSoftware::createSample             : lengthpcm 42158, lengthbytes 84316, channels 1, format 2, freq 44100, mode 00000009
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : No name found in file, use filename.
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : done.  OpenState now = FMOD_OPENSTATE_READY.
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : filename = file:///android_asset/stereo.ogg : mode 00000009
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : Format has 0 subsounds.
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : Create as FMOD_CREATESAMPLE
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : creating subsound 0/0
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSample                    : mode 00000009 length 88200 samples, lengthbytes 15263
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSample                    : channels = 2
04-21 11:02:17.017    5912-5984/? I/fmod﹕ SystemI::createSample                    : output = 0x75f7b7f0
04-21 11:02:17.017    5912-5984/? I/fmod﹕ OutputSoftware::createSample             : lengthpcm 88200, lengthbytes 15263, channels 2, format 2, freq 44100, mode 00000009

04-21 11:02:17.087    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : No name found in file, use filename.
04-21 11:02:17.087    5912-5984/? I/fmod﹕ SystemI::createSoundInternal             : done.  OpenState now = FMOD_OPENSTATE_READY.
04-21 11:02:17.107    5912-5986/? W/fmod﹕ Output::RingBuffer::read                 : Buffer starvation detected, requested 3840 bytes, only 2816 bytes available.
04-21 11:02:17.127    5912-5986/? W/fmod﹕ Output::RingBuffer::read                 : Buffer starvation detected, requested 3840 bytes, only 2048 bytes available.

Since here there are tons of “Buffer starvation detected”.

For the devices with buffer starvation can you try two things (separately).

  1. System::setDSPBufferSize(1024, 4) call this before System::init
  2. System::setOutput(FMOD_OUTPUTTYPE_AUDIOTRACK) call this before System::init
    Please let me know if either of these options helped, don’t use them both at the same time.

For the devices that crashed, can you please provide the log output leading up to the crash.

Also, for the devices that crash, are you able to get them to crash in our examples?

Hi Mathew,thanks for your help,we try the both ways separately,and both of them are useful to solve the problem,I have to say sorry because it isn’t the “crash”,instead it’s the sample stretching and compressing phenomenon happened when tests on those devices,all the test was based on the examples in the low-level api folder.
We have tracked the problem to the audio driver which those devices used,all of them are OPENSL rather than AUDIOTRACK,and I wander whether FMOD may automatically detects the Android OS version and then call the suitable driver or not??
And these devices are all above Android 4.4,our programmer said only the device’s system is below Android 2.2 then the audio driver would be AUDIOTRACK,it’s a little bit strange here.
Also maybe there is a bug,
[2016-04-22 13:55:39.400] [FMOD Warning] FMOD output type: 16
[2016-04-22 13:55:39.401] [FMOD Warning] FMOD DSP buffer size: 512, buffer num: 4
the log as you can see showed that the DSP buffer size is 512,we never changed the default value,and the API document says the default is 1024,can you tell us what happend here??Thanks a lot.

We have some heuristics that determine which output driver to select based on what the OS tells us. I have a tweak planned for our next 1.08.xx release that should cause the automatic selection to work better for the devices you have listed.

1.08.03 will have better hardware block size detection which should improve things for the devices you have listed.