Exemple #1
0
		void DisposeSound() {
			DisposeOutputs(ref monoOutputs);
			DisposeOutputs(ref stereoOutputs);
			if (firstSoundOut != null) {
				firstSoundOut.Dispose();
				firstSoundOut = null;
			}
		}
        void DisposeOf( ref IAudioOutput output, ref Thread thread )
        {
            if( output == null ) return;
            output.Stop();
            thread.Join();

            output.Dispose();
            output = null;
            thread = null;
        }
Exemple #3
0
        void DisposeOf(ref IAudioOutput output, ref Thread thread)
        {
            if (output == null)
            {
                return;
            }
            output.Stop();
            thread.Join();

            output.Dispose();
            output = null;
            thread = null;
        }
Exemple #4
0
        void DoMusicThread()
        {
            if (musicFiles.Length == 0)
            {
                return;
            }
            Random rnd = new Random();

            while (!disposingMusic)
            {
                string file = musicFiles[rnd.Next(0, musicFiles.Length)];
                Utils.LogDebug("playing music file: " + file);

                string path = Path.Combine("audio", file);
                using (Stream fs = Platform.FileOpen(path)) {
                    try {
                        musicOut.SetVolume(game.MusicVolume / 100.0f);
                        musicOut.PlayStreaming(fs);
                    } catch (InvalidOperationException ex) {
                        HandleMusicError(ex);
                        try { musicOut.Dispose(); } catch { }
                        return;
                    } catch (Exception ex) {
                        ErrorHandler.LogError("AudioPlayer.DoMusicThread()", ex);
                        game.Chat.Add("&cError while trying to play music file " + file);
                        try { musicOut.Dispose(); } catch { }
                        return;
                    }
                }
                if (disposingMusic)
                {
                    break;
                }

                int delay = 1000 * 120 + rnd.Next(0, 1000 * 300);
                musicHandle.WaitOne(delay, false);
            }
        }
Exemple #5
0
 public override void UnloadContent()
 {
     gfx.Dispose();
     audioDriver.Dispose();
 }