Thank you @TomRumilus for your fix. I had the same problem using CocosSharp (based on MonoGame).
Since the OpenALSoundController is an internal class I couldn’t use your solution. But, bases on the MonoGame source I found out that OpenTK caused the problem. Adding CleanUpOpenAL function to OnStop() solved the problem.
protected override void OnStop()
{
base.OnStop();
CleanUpOpenAL();
}
private void CleanUpOpenAL()
{
try
{
var context = OpenTK.Audio.OpenAL.Alc.GetCurrentContext();
if (context != OpenTK.ContextHandle.Zero)
{
var device = OpenTK.Audio.OpenAL.Alc.GetContextsDevice(context);
OpenTK.Audio.OpenAL.Alc.DestroyContext(context);
context = OpenTK.ContextHandle.Zero;
if (device != IntPtr.Zero)
{
OpenTK.Audio.OpenAL.Alc.CloseDevice(device);
device = IntPtr.Zero;
}
}
}
catch (Exception e)
{
_logger.LogMessage(LogLevel.Error, "CleanUpOpenAL FAIL msg: " + e.Message);
}
}