Esempio n. 1
0
        /// <summary>
        /// Stops capturing process. If WaitOnStop property is false then
        /// exits immediately - the output stream can be then closed only after Stopped event
        /// is fired.
        /// </summary>
        /// <remarks>
        /// Stopping process may last some time especially when NormalizeVolume is true.
        /// The sound is normalized after the call to Stop() method, then - if you use MP3 output
        /// type - all data must be yet compressed. All that can take time.
        /// </remarks>
        public void Stop()
        {
            if (capturing != null)
            {
                lock (CaptureLock)
                {
                    CapturingProcess capturingObject = capturing;
                    capturing = null;

                    FireEvent(Stopping);

                    if (WaitOnStop)
                    {
                        PerformStop(capturingObject);
                    }
                    else
                    {
                        StopMethod stopping = () =>
                        {
                            PerformStop(capturingObject);
                        };
                        stopping.BeginInvoke(null, null);
                    }
                }
            }
        }
Esempio n. 2
0
 private void Initialize()
 {
     this.syncContext               = System.Threading.SynchronizationContext.Current;
     this.CaptureDevice             = SoundCaptureDevice.Default;
     this.Mp3BitRate                = Mp3BitRate.BitRate64;
     this.NormalizeVolume           = false;
     this.UseVOX                    = false;
     this.OutputType                = Outputs.Mp3;
     this.UseSynchronizationContext = true;
     this.WaveFormat                = PcmSoundFormat.Pcm22kHz16bitMono;
     this.WaitOnStop                = true;
     this.IsDirectory               = false;
     this.AsyncStopping             = new StopMethod(PerformStop);
 }