Пример #1
0
        private void UnixPlayThread(object state)
        {
            if (_unixPlayStopEvent.WaitOne(0))
            {
                return;
            }
            Stream      stream = null;
            AudioDevice dev    = null;

            try
            {
                lock (s_playSync)
                {
                    dev          = AudioDevice.CreateAlsaDevice(_latency);
                    stream       = ReadFile((string)state);
                    _unixWavData = new WavData(_logger, stream, _unixPlayStopEvent);
                }
                _unixWavData.Setup(dev);
                _unixWavData.Play(dev);
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                _logger.LogError(Message.SoundPlayError, ex, (string)state);
            }
            finally
            {
                if (dev != null)
                {
                    dev.Dispose();
                }
                if (stream != null)
                {
                    stream.Close();
                }
                if (_unixWavData == null || !_unixWavData.IsStopped)
                {
                    PlayingStopped.RaiseEvent(this);
                }
            }
        }