Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
        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();
        }