soloud icon indicating copy to clipboard operation
soloud copied to clipboard

Android thread startup is slow, leaving noise at the beginning of the audio

Open eduardodoria opened this issue 4 years ago • 1 comments

Expected behavior:

Get a clean audio after init() and play()

Actual behavior:

Getting noise after audio start

Steps to reproduce the problem:

soloud.init();
soloud.play(wav);

// Wait for mixing thread.
SoLoud::Thread::sleep(1000);

// Wait until sounds have finished
while (soloud.getActiveVoiceCount() > 0)
{
    // Still going, sleep for a bit
    SoLoud::Thread::sleep(100);
}

soloud.deinit();

Steps to workaround the problem:

Just sleep after init() (pthread_create) :

soloud.init();
SoLoud::Thread::sleep(100);
soloud.play(wav);

// Wait for mixing thread.
SoLoud::Thread::sleep(1000);

// Wait until sounds have finished
while (soloud.getActiveVoiceCount() > 0)
{
    // Still going, sleep for a bit
    SoLoud::Thread::sleep(100);
}

soloud.deinit();

SoLoud version, operating system, backend used, any other potentially useful information:

Release: 20200207 OS: Android Backend: OpenSL ES

eduardodoria avatar May 07 '20 13:05 eduardodoria

This not happen when using with Miniaudio backend (tested with OpenSL ES and AAudio) This can be closed. I'm considering to use Miniaudio in all platforms.

Last question: In a game when is loading many audio sources during running, should I call init() only once on app start and never call deInit(), or call init() many times before play() with deInit() after? Which one is the best architecture?

eduardodoria avatar May 09 '20 23:05 eduardodoria