Crash when switching buffer size / suspending (and fix too!)


#1

Hey All, I have been running into a somewhat common bug when switching buffer sizes in my app on android. It appeared to be an issue with the OpenSLSessionT object stopping when it was in the middle of doing work on the audio thread. It appears there is already a guard in the class but it is not being used on stop. To fix this bug I made the stop function:

void stop() override
{
     OpenSLSession::stop();
    while( guard.get() == 1 )
        sleep(10);
    guard.set(1);
    if (inputChannels > 0)
        recorder->setState (false);

    if (outputChannels > 0)
        player->setState (false);
   guard.set(0);
}

This allows the audio thread to finish up, and also stops the audio thread from being called while the states are being set. If there are any issues/ any alternative fixes let me know!


#2

Thanks for the report. A fix for this will soon appear on develop.