Example #1
0
        private static void Recycle(FrameFormat format, [CanBeNull] DecoderPipeline pipeline)
        {
            if (pipeline == null)
            {
                return;
            }

            GetPool(format).Put(pipeline);
        }
Example #2
0
 /// <summary>
 ///     Stops the current session.
 /// </summary>
 /// <param name="logNoSessionError">If true and no session is currently active this method will log a warning</param>
 public void StopSession(bool logNoSessionError = true)
 {
     if (_active != null)
     {
         _active.Stop();
         _active = null;
     }
     else if (logNoSessionError)
     {
         Log.Warn(Log.PossibleBugMessage("Attempted to stop a session, but there is no active session", "6DB702AA-D683-47AA-9544-BE4857EF8160"));
     }
 }
        private static void Recycle(FrameFormat format, DecoderPipeline pipeline)
        {
            ConcurrentPool <DecoderPipeline> pool;

            if (!FreePipelines.TryGetValue(format, out pool))
            {
                Log.Warn(Log.PossibleBugMessage("Tried to recycle a pipeline but the pool for this pipeline format does not exist", "A6212BCF-9318-4224-B69F-BA4B5A651785"));
            }
            else
            {
                pool.Put(pipeline);
            }
        }
        /// <summary>
        ///     Starts a new speech session and adds it to the queue for playback
        /// </summary>
        /// <param name="format">The frame format.</param>
        /// <param name="now">Current time, or null for DateTime.UtcNow</param>
        /// <param name="jitter">Jitter estimator, or null for this stream to estimate it's own jitter</param>
        public void StartSession(FrameFormat format, DateTime?now = null, [CanBeNull] IJitterEstimator jitter = null)
        {
            if (PlayerName == null)
            {
                throw Log.CreatePossibleBugException("Attempted to `StartSession` but `PlayerName` is null", "0C0F3731-8D6B-43F6-87C1-33CEC7A26804");
            }

            _active = GetOrCreateDecoderPipeline(format, _volumeProvider);

            var session = SpeechSession.Create(new SessionContext(PlayerName, unchecked (_currentId++)), jitter ?? this, _active, _active, now ?? DateTime.UtcNow);

            _awaitingActivation.Enqueue(session);

            Log.Debug("Created new speech session with buffer time of {0}ms", session.Delay.TotalMilliseconds);
        }