Ejemplo n.º 1
0
        protected void SetAudioReader(AudioFileReaderEx autioReader)
        {
            lock (_lockingObject)
            {
                if (!autioReader.Equals(_audioFileReader))
                {
                    CleanAfterLastPlayback();
                }

                _audioFileReader = autioReader;
                if (_audioFileReader.Reused)
                {
                    return;
                }
                _waveOutDevice = new WaveOut();
                _waveOutDevice.PlaybackStopped += WaveOutDevice_PlaybackStopped;
            }
        }
Ejemplo n.º 2
0
 private void CleanAfterLastPlayback()
 {
     lock (_lockingObject)
     {
         if (_waveOutDevice != null)
         {
             StopPlayback();
         }
         if (_audioFileReader != null)
         {
             _audioFileReader.Dispose();
             _audioFileReader = null;
         }
         if (_waveOutDevice != null)
         {
             _waveOutDevice.PlaybackStopped -= WaveOutDevice_PlaybackStopped;
             _waveOutDevice.Dispose();
             _waveOutDevice = null;
         }
     }
     GC.Collect();
 }