private void Quit(object sender, QuitEventArgs e) { SdlMixer.Mix_CloseAudio(); timer.Stop(); Events.QuitApplication(); }
/// <summary> /// Stops the music processing. /// </summary> public void Stop() { // Kill all music SdlMixer.Mix_HaltMusic(); SdlMixer.Mix_HaltChannel(-1); SdlMixer.Mix_CloseAudio(); }
private bool SdlInstalled() { try { Sdl.SDL_QuitSubSystem(Sdl.SDL_INIT_AUDIO); SdlMixer.Mix_CloseAudio(); return(true); } catch (DllNotFoundException e) { AgateLib.Core.ErrorReporting.Report(AgateLib.ErrorLevel.Warning, "A DllNotFoundException was thrown when attempting to load SDL binaries." + Environment.NewLine + "This indicates that SDL.dll or SDL_mixer.dll was not found.", e); return(false); } catch (BadImageFormatException e) { AgateLib.Core.ErrorReporting.Report(AgateLib.ErrorLevel.Warning, "A BadImageFormatException was thrown when attempting to load SDL binaries." + Environment.NewLine + "This is likely due to running a 64-bit executable with 32-bit SDL binaries.", e); return(false); } }
/// <summary> /// Closes and destroys this object /// </summary> public static void CloseMixer() { try { SdlMixer.Mix_CloseAudio(); if (Sdl.SDL_WasInit(Sdl.SDL_INIT_AUDIO) != 0) { Sdl.SDL_QuitSubSystem(Sdl.SDL_INIT_AUDIO); } } catch (AccessViolationException) { } }
private bool SdlInstalled() { try { Sdl.SDL_QuitSubSystem(Sdl.SDL_INIT_AUDIO); SdlMixer.Mix_CloseAudio(); return(true); } catch (DllNotFoundException) { return(false); } }
private void Dispose(bool disposing) { SdlMixer.Mix_CloseAudio(); Sdl.SDL_QuitSubSystem(Sdl.SDL_INIT_AUDIO); foreach (string file in tempfiles) { try { File.Delete(file); } catch (Exception) { System.Diagnostics.Trace.WriteLine(string.Format( "Failed to delete the temp file {0}.", file)); } } tempfiles.Clear(); }
/// <summary> /// /// </summary> public void Run() { Sdl.SDL_Event evt; bool quitFlag = false; int flags = (Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT); int bpp = 16; int width = 352; int height = 240; Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); Sdl.SDL_WM_SetCaption("Tao.Sdl Example - SmpegPlayer", ""); surfacePtr = Sdl.SDL_SetVideoMode( width, height, bpp, flags); SdlMixer.Mix_OpenAudio(SdlMixer.MIX_DEFAULT_FREQUENCY, unchecked (Sdl.AUDIO_S16LSB), 2, 1024); Smpeg.SMPEG_Info info = new Smpeg.SMPEG_Info(); string filepath = @"../../"; if (File.Exists("Data/SdlExamples.SmpegPlayer.mpg")) { filepath = ""; } //SdlMixer.MixFunctionDelegate audioMixer = new SdlMixer.MixFunctionDelegate(this.player); //int freq; //short format; //int channels; SdlMixer.Mix_CloseAudio(); IntPtr intPtr = Smpeg.SMPEG_new(filepath + "Data/SdlExamples.SmpegPlayer.mpg", out info, 1); //Smpeg.SMPEG_enableaudio(intPtr, 0); //SdlMixer.Mix_QuerySpec(out freq, out unchecked(format), out channels); //Sdl.SDL_AudioSpec audiofmt = new Tao.Sdl.Sdl.SDL_AudioSpec(); //audiofmt.freq = freq; //audiofmt.format = unchecked(format); //audiofmt.channels = (byte) channels; //Console.WriteLine("Freq: " + audiofmt.freq); //Console.WriteLine("Format: " + audiofmt.format); //Console.WriteLine("Channels: " + audiofmt.channels); Smpeg.SMPEG_getinfo(intPtr, out info); Console.WriteLine("Time: " + info.total_time.ToString()); Console.WriteLine("Width: " + info.width.ToString()); Console.WriteLine("Height: " + info.height.ToString()); Console.WriteLine("Size: " + info.total_size.ToString()); Console.WriteLine("Smpeg_error: " + Smpeg.SMPEG_error(intPtr)); //Smpeg.SMPEG_actualSpec(intPtr, ref audiofmt); //SdlMixer.Mix_HookMusic(audioMixer, intPtr); Smpeg.SMPEG_setdisplay(intPtr, surfacePtr, IntPtr.Zero, null); Smpeg.SMPEG_play(intPtr); //Smpeg.SMPEG_loop(intPtr, 1); //Smpeg.SMPEG_enableaudio(intPtr, 1); while ((Smpeg.SMPEG_status(intPtr) == Smpeg.SMPEG_PLAYING) && (quitFlag == false)) { Sdl.SDL_PollEvent(out evt); if (evt.type == Sdl.SDL_QUIT) { quitFlag = true; } else if (evt.type == Sdl.SDL_KEYDOWN) { if ((evt.key.keysym.sym == (int)Sdl.SDLK_ESCAPE) || (evt.key.keysym.sym == (int)Sdl.SDLK_q)) { quitFlag = true; } } } Smpeg.SMPEG_stop(intPtr); Smpeg.SMPEG_delete(intPtr); }
/// <summary> /// /// </summary> private void QuitAudio() { SdlMixer.Mix_CloseAudio(); Sdl.SDL_Quit(); }
public void CloseAudio() { InitAudio(); SdlMixer.Mix_CloseAudio(); Sdl.SDL_Quit(); }
/// <summary> /// Destroy the audio manager and free used resoueces. /// </summary> public void Destroy() { SdlMixer.Mix_CloseAudio(); Sdl.SDL_Quit(); }