public bool PlaySound(IStreamingSound sound, bool loop = false) { lock (_thread) { Stop(); lock (_soundUsers) { if (_sound != null) { _soundUsers.Remove(_sound); } if (sound != null) { if (_soundUsers.ContainsKey(sound)) { throw new InvalidOperationException("Sound is already in use by another channel!"); } _soundUsers.Add(sound, this); } } _sound = sound; _isLooping = loop; return(Play()); } }
public StreamingSoundChannel() { _readBuffer = new short[5760 * 2]; _sound = null; _source = AL.GenSource(); _buffers = AL.GenBuffers(4); _thread = new Thread(ThreadProc); _thread.IsBackground = true; _thread.Start(); }