예제 #1
0
        // may be called on any thread
        public void Push(T[] frame)
        {
            lock (this)
            {
                if (this.started)
                {
                    if (frame.Length == 0)
                    {
                        return;
                    }

                    if (frame.Length != this.frameSize)
                    {
                        logger.LogError("{0} AudioSyncBuffer audio frames are not of  size: {1} != {2}", this.logPrefix, frame.Length, frameSize);
                        return;
                    }

                    //TODO: call framePool.AcquireOrCreate(frame.Length) and test
                    if (framePool.Info != frame.Length)
                    {
                        framePool.Init(frame.Length);
                    }
                    T[] b = framePool.AcquireOrCreate();
                    System.Buffer.BlockCopy(frame, 0, b, 0, System.Buffer.ByteLength(frame));

                    lock (this)
                    {
                        frameQueue.Enqueue(b);

                        syncFrameQueue();
                    }
                }
            }
        }
예제 #2
0
 public T[] New()
 {
     return(pool.AcquireOrCreate());
 }