[NotNull] private static DecoderPipeline GetOrCreateDecoderPipeline(FrameFormat format, [NotNull] IVolumeProvider volume)
        {
            if (volume == null)
            {
                throw new ArgumentNullException("volume");
            }

            ConcurrentPool <DecoderPipeline> pool;

            if (!FreePipelines.TryGetValue(format, out pool))
            {
                pool = new ConcurrentPool <DecoderPipeline>(3, () => {
                    var decoder = DecoderFactory.Create(format);

                    return(new DecoderPipeline(decoder, format.FrameSize, p =>
                    {
                        p.Reset();
                        Recycle(format, p);
                    }));
                });
                FreePipelines[format] = pool;
            }

            var pipeline = pool.Get();

            pipeline.Reset();

            pipeline.VolumeProvider = volume;

            return(pipeline);
        }
示例#2
0
        [NotNull] private static ConcurrentPool <DecoderPipeline> GetPool(FrameFormat format)
        {
            ConcurrentPool <DecoderPipeline> pool;

            if (!Pools.TryGetValue(format, out pool))
            {
                pool = new ConcurrentPool <DecoderPipeline>(3, () => {
                    var decoder = DecoderFactory.Create(format);

                    var uuid = _nextPipelineId.ToString();
                    return(new DecoderPipeline(decoder, format.FrameSize, p => {
                        p.Reset();
                        Recycle(format, p);
                    }, uuid));
                });
                Pools[format] = pool;

                _nextPipelineId++;
            }

            return(pool);
        }