Upgraded to 3.5.1 today (develop branch) to fix this old crash problem…
Microsoft.Xna.Framework.Audio.NoAudioHardwareException: No audio hardware available
… but upgrading to 3.5.1 has ended up causing more issues.
Sound Effect instances only seem to play occasionally and if I repeatedly spam a button (so the SFX plays a few times) it will eventually crash here in SoundEffectInstance.OpenAL.cs:
AL.Source (SourceId, ALSource3f.Position, _pan, 0, 0.1f);
ALHelper.CheckError("Failed to set source pan.");
With the reason that it has ‘Invalid Value’.
Any ideas what might cause this? The sound effect always plays the first time its supposed to play but most subsequent times its just silence until the eventual crash.
Here is the method in my AudioManager where the sound effect is handled:
Definitely some issues with sound effects on Android in the current develop branch… just getting the sound to play consistently is causing problems.
Heres the stack trace from the crash mentioned in my last post:
System.Diagnostics.Debugger.Mono_UnhandledException_internal() in
System.Diagnostics.Debugger.Mono_UnhandledException(System.InvalidOperationException ex) in /Users/builder/data/lanes/3415/7db2aac3/source/mono/mcs/class/corlib/System.Diagnostics/Debugger.cs:122
object.c94ec1c3-d180-47f9-8867-b5a6cb9d6249( arg0, arg1) in
Microsoft.Xna.Framework.Audio.SoundEffectInstance.PlatformPlay() in /Users/Hammy/Projects/MonoGame-develop/MonoGame.Framework/Audio/SoundEffectInstance.OpenAL.cs:129
Microsoft.Xna.Framework.Audio.SoundEffectInstance.Play() in /Users/Hammy/Projects/MonoGame-develop/MonoGame.Framework/Audio/SoundEffectInstance.cs:160
Drawtopia.AudioManagerClass.AddSound(Microsoft.Xna.Framework.Audio.SoundEffect sound) in /Users/Hammy/Projects/Drawtopia/Drawtopia Android/Drawtopia/AudioManagerClass.cs:175
Drawtopia.AudioManagerClass.MenuBeep() in /Users/Hammy/Projects/Drawtopia/Drawtopia Android/Drawtopia/AudioManagerClass.cs:192
Drawtopia.GameplayScreen.HandleInput(Microsoft.Xna.Framework.GameTime gameTime, Drawtopia.InputState input) in /Users/Hammy/Projects/Drawtopia/Drawtopia Android/Drawtopia/Screens/GameplayScreen.cs:2266
Drawtopia.ScreenManager.Update(Microsoft.Xna.Framework.GameTime gameTime) in /Users/Hammy/Projects/Drawtopia/Drawtopia Android/Drawtopia/ScreenManager/ScreenManager.cs:295
Microsoft.Xna.Framework.Game.AnonymousMethod__D(Drawtopia.ScreenManager updateable, Microsoft.Xna.Framework.GameTime gameTime) in /Users/Hammy/Projects/MonoGame-develop/MonoGame.Framework/Game.cs:557
Microsoft.Xna.Framework.Game.SortingFilteringCollection<Microsoft.Xna.Framework.IUpdateable>.ForEachFilteredItem<Microsoft.Xna.Framework.GameTime>(System.Action<Microsoft.Xna.Framework.IUpdateable,Microsoft.Xna.Framework.GameTime> action, Microsoft.Xna.Framework.GameTime userData) in /Users/Hammy/Projects/MonoGame-develop/MonoGame.Framework/Game.cs:840
Microsoft.Xna.Framework.Game.Update(Microsoft.Xna.Framework.GameTime gameTime) in /Users/Hammy/Projects/MonoGame-develop/MonoGame.Framework/Game.cs:561
Microsoft.Xna.Framework.Game.DoUpdate(Microsoft.Xna.Framework.GameTime gameTime) in /Users/Hammy/Projects/MonoGame-develop/MonoGame.Framework/Game.cs:655
Microsoft.Xna.Framework.Game.Tick() in /Users/Hammy/Projects/MonoGame-develop/MonoGame.Framework/Game.cs:461
Microsoft.Xna.Framework.AndroidGameWindow.OnUpdateFrame(Microsoft.Xna.Framework.MonoGameAndroidGameView sender, OpenTK.FrameEventArgs frameEventArgs) in /Users/Hammy/Projects/MonoGame-develop/MonoGame.Framework/Android/AndroidGameWindow.cs:86
OpenTK.GameViewBase.OnUpdateFrame(OpenTK.FrameEventArgs e) in /Users/builder/data/lanes/3415/7db2aac3/source/opentk/Source/OpenTK/Platform/Android/GameViewBase.cs:313
OpenTK.Platform.Android.AndroidGameView.UpdateFrameInternal(OpenTK.FrameEventArgs e) in /Users/builder/data/lanes/3415/7db2aac3/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:349
OpenTK.Platform.Android.AndroidGameView.RunIteration(System.Threading.CancellationToken token) in /Users/builder/data/lanes/3415/7db2aac3/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:569
OpenTK.Platform.Android.AndroidGameView.StartThread.AnonymousMethod__0(object _) in /Users/builder/data/lanes/3415/7db2aac3/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:459
Android.App.SyncContext.Send.AnonymousMethod__0() in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:32
Java.Lang.Thread.RunnableImplementor.Run() in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
Java.Lang.IRunnableInvoker.n_Run(System.IntPtr jnienv, System.IntPtr native__this) in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Java.Lang.IRunnable.cs:81
object.c94ec1c3-d180-47f9-8867-b5a6cb9d6249( arg0, arg1) in
Rolling back to MonoGame 3.4 I dont get any of the issues mentioned, just the occasional crash report from Google Play about:
Microsoft.Xna.Framework.Audio.NoAudioHardwareException: No audio hardware available
I cant actually reproduce the no audio hardware error on any device I’ve tried so I’m just gonna gonna have to try/catch the exception and see if I can make it silently fail for now.
Hi! I’m too getting major sound issues on Android with MG 3.5.1. I’m playing sounds with almost the same code like you.
The problem with all this is that it is so random that I can’t get any idea what’s causing the problem except that is is MG fault. I occasionaly get: (i’m only using 16bit .wav 22050hz stereo)
sounds stop playing in the middle (mutes)
sound1.play() playing sound2 which was paused or disposed (momory issues?)
Can you relate to that before I create an issue here?
Is rolling back to 3.4 the only solution for me too? Is it even guaranted that it will work?
Yup, I had sounds cutting out half way or just point blank refusing to play. When they did play the quality was absolutely awful too, along with all sorts of other randomness.
Rolling back to 3.4 fixed all issues for me so I would definitely do that for now if you’re having the same problem.
As for the ‘No Audio Hardware’ issue which affects only a select few devices (like Galaxy Tab 10.1), I just check for the exception and then disable Audio if its thrown, that way the game is still playable at least.
OK, Seems that replacing MonoGame.Framework.dll to ver 3.4 on nuget did just that. Now every sound is running great…
MG team pls do something about it Contact me if you need any specific info about my andro device or the way I play .wav. Or anything that will help you solve the problem. Damn shame I need to use different mg versions on desktop and andro.