Pooling objects to avoid allocation may help in reducing GC pause, though that’s difficult to do in everywhere. Many small objects are also allocated in library side.
If mute issue occurs with older versions, then the problem might be in OGG/WAV loader.
Does that issue occur with any sound file you tested?
Would you mind posting sound file in question (and ideally minimal code that reproduces the issue), if possible?
Here’s my SFX.hx file that I use to play small sound effects. It has changed since I last posted. I call the init function when the game starts, and I call play function to play a particular sound effect. On android, atm, each sound effect plays on once - on flash it works fine. If I swap the #cpp and #else code, then the sound effects play at some occasions only - on android.
(I will post the music code as well soon)
class SFX
{
public function new()
{
}
public static var EXTENSION:String;
public static var soundNames:Array<String>;
#if cpp
public static var sounds:Array<AudioSource>;
#else
public static var sounds:Array<Sound>;
#end
public static var DIAL:String = "audio/dial";
public static var DIAL_SELECT:String = "audio/dial_select";
public static function init() {
EXTENSION = ".wav";
soundNames = [DIAL, DIAL_SELECT];
sounds = new Array();
for (i in 0...soundNames.length) {
#if cpp
sounds.push(new AudioSource(lime.Assets.getAudioBuffer(soundNames[i] + EXTENSION)));
#else
sounds.push(openfl.Assets.getSound(soundNames[i] + EXTENSION));
#end
}
}
public static function play(name:String) {
sounds[soundNames.indexOf(name)].play();
}
Are you able to build from source? If so, try commenting out the delete buffer and delete source calls for the OpenAL garbage collection (then running openfl rebuild android again)
lime_al_delete_source does not disable hxCFFI finalizer with val_gc(source, 0), so this could be the cause of premature deletion issues. lime will end up calling alGenSources() twice with the same source id.
As a result, lime may stop unrelated sources since OpenAL implementations could reuse the same source id when new source is requested with alGenSources().
This problem might be more noticeable on Android because it tends to have much lower amount of memory. If you write an app that allocates memory very often, that will also cause frequent garbage collection (though this is hard to avoid).
I’m experiencing the same problem at least on Windows target. (OpenFL 4.5.1, Lime 3.5.1)
My music simply stops playing (mute?), if any other sound is playing.
Let’s say I have music playing and I click some button that play “click” sound - music just stops playing.
When I click button again, I hear a bit of music and “click” sound at the same time and then no music again.
UPDATE: I’ve done some more test and it’s sound problem, but some bugs because of my code still written for legacy mode. So, fixed now.