Last sound is muted/destroyed when new sound is triggered, happens only on Android

I was able to use the very same FMod code in our game engine to work on Android, but after a while playing the sounds, the old playing sounds are muted, and the new sound mutes/destroys the previous one.
It happens only when the engine is build with build-ndk and the game runs on android, either emulator or phone. It does not happen when using same engine and code on Windows build.
Seems like there is no pool for new sounds, then old sounds are killed, but I still can’t find the problem.
During file loading, logcat reports strange errors I could not find in this forum or documentation. This happens before the killing of old playing sounds happens.

What version of FMOD are you using?
Would you be able to share the entire output log while using FMOD_DEBUG_LEVEL_LOG and the logging library.

Sorry for long delay, I struggled to generate log file from android. (fmod newbie here).
I’m using version 2.0.10 now.
In Windows, there are no issues with muting old sounds, it just happens on Android.
The messages on both logs looks quite similar. I guess it is trying five formats for each sample, before find that it is mp3.fmod_android.log (69.1 KB) fmod_windows.log (78.1 KB)

Thanks for that, what type of file are you trying to use?

We use mp3 files, but through our Filesystem abstraction, they are loaded into memory, then fmod loads it from memory.
I believe it is plausible to be the reason for the log messages, but the main concern is the muting that happens only on Android.

Update: I used
audioInfo.suggestedsoundtype = FMOD_SOUND_TYPE_MPEG;

Log shows better messages (attached), as expected. But the muting last sounds problem continues on android.
android fmod log.txt (50.8 KB)

It looks like you are setting the maximum channels, in System::init, to 32.

If the virtual voice limit is hit then Channels will be stolen and start returning FMOD_ERR_INVALID_HANDLE. Channels which have had their handle stolen in this way are permanently stopped and will never return.

https://fmod.com/resources/documentation-api?version=2.0&page=white-papers-virtual-voices.html#software-voices-vs-virtual-voices

32 channels should not be the problem, the effects are short and rarely there are more than 32 samples being played. In fact, at android, when the issue happens, only 1 sound is played.
I believe it is stolen, or going into virtual mistakenly.
Also, that issue never happens on Windows, same code, same channels.

I changed the code, for loading sounds direct from file (using file:///android_asset/), resulted no difference in behavior, then I changed the maximum channels to 128 while keeping software channels to 32:
result = m_system->init(128, FMOD_INIT_NORMAL, 0);
if (FMOD_ERRCHECK(result, m_logger))
return false;
result = m_system->setSoftwareChannels(32);
FMOD_ERRCHECK(result, m_logger);

The difference was that after some time (like when all 32 channels are used), all sounds were muted, and no new sound was played.
Like it is not freeing channels from already played samples.
I could not find information about that on log.
May be something with bad sorting or going virtual? some bug or odd default on android platform?

Short clip trying to illustrate the issue

If it runs out to the point sounds stop playing then that’s an update issue. Are the update loops for Windows and Android different?

1 Like

Thank you Cameron, main loop for Android was a different code and update was not being called.
I did not expect for fmod to work so far without it.

1 Like