コード例 #1
0
        /// <summary>
        /// Provides functionality to enable processing on an input port.
        /// </summary>
        /// <param name="managedCallback"></param>
        internal virtual void EnablePort(Func <MMALBufferImpl, MMALPortBase, ProcessResult> managedCallback)
        {
            //We populate the input buffers with user provided data.
            this.BufferPool = new MMALPoolImpl(this);

            var length = this.BufferPool.Queue.QueueLength();

            for (int i = 0; i < length; i++)
            {
                MMALBufferImpl buffer = this.BufferPool.Queue.GetBuffer();

                ProcessResult result = managedCallback(buffer, this);

                buffer.ReadIntoBuffer(result.BufferFeed, result.EOF);

                this.SendBuffer(buffer);
            }
        }
コード例 #2
0
        internal void ReleaseInputBuffer(MMALBufferImpl bufferImpl)
        {
            bufferImpl.Release();

            if (this.Enabled && this.BufferPool != null)
            {
                var newBuffer = MMALQueueImpl.GetBuffer(this.BufferPool.Queue.Ptr);

                //Populate the new input buffer with user provided image data.
                var result = this.ManagedInputCallback(newBuffer, this);
                bufferImpl.ReadIntoBuffer(result.BufferFeed, result.EOF);

                try
                {
                    if (this.Trigger != null && this.Trigger.CurrentCount > 0 && result.EOF)
                    {
                        MMALLog.Logger.Debug("Received EOF. Releasing.");

                        this.Trigger.Signal();
                        newBuffer.Release();
                    }

                    if (newBuffer != null)
                    {
                        this.SendBuffer(newBuffer);
                    }
                    else
                    {
                        MMALLog.Logger.Warn("Buffer null. Continuing.");
                    }
                }
                catch (Exception ex)
                {
                    MMALLog.Logger.Warn($"Buffer handling failed. {ex.Message}");
                }
            }
        }