/// <summary>
        /// Immediately stop the entire transmission system
        /// </summary>
        private void StopTransmissionPipeline()
        {
            //Stop microphone
            if (_microphone != null && _microphone.IsRecording)
            {
                _microphone.StopCapture();
            }

            //Dispose preprocessor and encoder
            if (_preprocessor != null)
            {
                if (_microphone != null)
                {
                    _microphone.Unsubscribe(_preprocessor);
                }
                if (_encoder != null)
                {
                    _preprocessor.Unsubscribe(_encoder);
                }

                _preprocessor.Dispose();
                _preprocessor = null;
            }

            if (_encoder != null)
            {
                _encoder.Dispose();
                _encoder = null;
            }

            _encoderSubscribed = false;
        }
예제 #2
0
        private void StopCapture()
        {
            if (!_subscribed)
            {
                throw Log.CreatePossibleBugException("Cannot unsubscribe encoder from mic: not subscribed", "8E0EAC83-BF44-4BE3-B132-BFE02AD1FADB");
            }
            Log.Debug("Unsubscribing encoder from microphone");

            _mic.Unsubscribe(this);
            _subscribed    = false;
            _resetRequired = true;

            //Disposing the output writers is racy, because the audio thread is trying to write to them at the same time.
            //That's fine, because the writer have an internal SpinLock ensuring that doing this is safe
            if (_microphoneDiagnosticOutput != null)
            {
                _microphoneDiagnosticOutput.Dispose();
                _microphoneDiagnosticOutput = null;
            }

            if (_preEncodeDiagnosticOutput != null)
            {
                _preEncodeDiagnosticOutput.Dispose();
                _preEncodeDiagnosticOutput = null;
            }
        }
        /// <summary>
        /// Immediately stop the entire transmission system
        /// </summary>
        private void StopTransmissionPipeline()
        {
#if !NCRUNCH
            Profiler.BeginSample("CapturePipelineManager: StopTransmissionPipeline");
#endif

            //Stop microphone
            if (_microphone != null && _microphone.IsRecording)
            {
                _microphone.StopCapture();
            }

            //Dispose preprocessor and encoder
            if (_preprocessor != null)
            {
                if (_microphone != null)
                {
                    _microphone.Unsubscribe(_preprocessor);
                }
                if (_encoder != null)
                {
                    _preprocessor.Unsubscribe(_encoder);
                }

                _preprocessor.Dispose();
                _preprocessor = null;
            }

            if (_encoder != null)
            {
                _encoder.Dispose();
                _encoder = null;
            }

            _encoderSubscribed = false;

#if !NCRUNCH
            Profiler.EndSample();
#endif
        }