public void Close() { lock (mInstanceLock) { Reader?.Dispose(); Reader = null; Instance?.Dispose(); Instance = null; mActiveSource = null; } }
public void Close() { lock (mInstanceLock) { if (Reader != null) { Reader.Dispose(); Reader = null; } mActiveSource = null; } }
public DynamicSoundEffectInstance LoadSong() { lock (mInstanceLock) { try { if (!string.IsNullOrWhiteSpace(mRealPath)) { if (Reader == null) { // Do we have this cached? if (Globals.ContentManager.MusicPacks != null && Globals.ContentManager.MusicPacks.Contains(Path.GetFileName(mRealPath))) { // Read from cache, but close reader when we're done with it! Reader = new VorbisReader(Globals.ContentManager.MusicPacks.GetAsset(Path.GetFileName(mRealPath)), true); } else { Reader = new VorbisReader(mRealPath); } } if (Instance != null) { Instance.Dispose(); Instance = null; } Instance = new DynamicSoundEffectInstance( Reader.SampleRate, Reader.Channels == 1 ? AudioChannels.Mono : AudioChannels.Stereo ); mActiveSource = this; return(Instance); } } catch (Exception exception) { Log.Error($"Error loading '{mPath}'.", exception); ChatboxMsg.AddMessage( new ChatboxMsg( $"{Strings.Errors.LoadFile.ToString(Strings.Words.lcase_sound)} [{mPath}]", new Color(0xBF, 0x0, 0x0), Enums.ChatMessageType.Error ) ); } } mActiveSource = this; return(null); }
public DynamicSoundEffectInstance LoadSong() { lock (mInstanceLock) { if (!string.IsNullOrWhiteSpace(mPath)) { try { if (Reader == null) { Reader = new VorbisReader(mPath); } if (Instance != null) { Instance.Dispose(); Instance = null; } Instance = new DynamicSoundEffectInstance( Reader.SampleRate, Reader.Channels == 1 ? AudioChannels.Mono : AudioChannels.Stereo ); mActiveSource = this; return(Instance); } catch (Exception exception) { Log.Error($"Error loading '{mPath}'.", exception); ChatboxMsg.AddMessage( new ChatboxMsg( Strings.Errors.LoadFile.ToString(Strings.Words.lcase_sound), new Color(0xBF, 0x0, 0x0) ) ); } } } mActiveSource = this; return(null); }