Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I have this function in my CSharp XNAgame: public static ISound PlaySound(ISoundSource soundSource, bool loop = false) I pass in a sound source any time I play a sound effect. Usually, everything is fine, but occasionally, the "return engine.Play2D(soundSource, loop, false, false);" throws an exception, and I cannot figure out what is going on. SEHException was unhandled {"External component has thrown an exception."} Error Code: -2147467259 |
||||
|
Difficult to say what the problem might be here, it could be anything. Are you doing something unusual with the engine, or is there any specific time where this happens? Maybe you are freeing some resources of the engine, which still need to be there, and it crashes because if that. However, any more details on how you are using irrklang would help. :) |
||||
|
I am still trying to see if there is something that I can do that will reliably cause it to happen, but have had no luck so far. I am not doing anything too fancy with irrKlang (v 1.4 - .Net 4). It is a small game that has a static class with an ISoundSource for each game sound. public static class Sounds When the game starts, all of the ISoundSources get initialized from .wav files. Sounds.Spawn = AudioManager.GetSoundSourceFromFile("spawn.wav"); public static ISoundSource GetSoundSourceFromFile(string path) I have a playerstate machine that calls certain sounds by passing in an ISoundSource. public void JumpStart() public static ISound PlaySound(ISoundSource soundSource, bool loop = false) When it crashes, it crashes playing a sound that will have played fine many times before the crash happens. I have reproducred on 2/2 computers that I have tried it on. |
||||
|
This looks all very normal and should work usually. Very strange. Are you maybe using an old irrklang version? |
||||
|
I am using 1.4.0b. I've done a lot of additional testing this weekend, but still haven't figured out what is causing it. It isn't one one particular sound either. It seems to happen with multiple sounds. On top of that, there are times where it doesn't throw an exception but instead hangs for up to 2 seconds on engine.Play2D. (like it is stuck in a loop for a while). |
||||
|
Difficult to say what this could be. Did you try using maybe the engine.Play2D call wich takes a file name instead of a sound source as first parameter? Getting the sound source manually first isn't really necessary. Who knows, maybe this is a workaround already. |
||||
|
Will using the file name load it from disk each time or not? That is what I was trying to avoid. |
||||
|
Hmmm, it is happening with the string version of Play2D as well. It never seems to happen right away. I'll just turn the game on and go to an area with a sound that fires every second, and come back later and it will have hit the SEHException. I have definitely used irrKlang on past projects and never had this error, but I think those used earlier versions of irrKlang (1.0.3861.18767). I am going to try to use that instead to see if it fixes the issue. |
||||
|
After going back to 1.0.3861.18767, I have not gotten it to crash or slow down yet. Edit: Nevermind, it was too good to be true. Just hit the exception again. |
||||
|
Alright, I just wrote a small program that repeats a sound over and over. I'll see if this causes the exception. using System; |
||||
|
Is it possible that the SEHException would have happened if there were ISounds that didn't have their Dispose() called on them? I added this to my Update(): (soundEffects is a List of all of my playing ISounds) for (int i = soundEffects.Count - 1; i >= 0; --i) And then here is StopSound public static void StopSound(ISound sound) I ran the game all night without a single crash. This seems to have done the trick. |
||||
|
Hm, not sure what you are doing now, are you now calling dispose or not so that it works? |
||||
|
Now, I am making sure every sound is getting disposed when it is done playing. It is working! |
|