Example #1
0
        /// <summary>
        /// For derived classes only.
        /// </summary>
        /// <param name="port">A reference to the midi port this buffer manager serves.</param>
        /// <param name="access">The type of access the stream provides to the underlying buffer.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="port"/> is null.</exception>
        protected MidiBufferManager(MidiPort port, FileAccess access)
        {
            Check.IfArgumentNull(port, nameof(port));

            MidiPort     = port;
            StreamAccess = access;
        }
Example #2
0
        /// <summary>
        /// For derived classes only.
        /// </summary>
        /// <param name="port">A reference to the midi port this buffer manager serves.</param>
        /// <param name="access">The type of access the stream provides to the underlying buffer.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="port"/> is null.</exception>
        internal MidiBufferManager(MidiPort port, FileAccess access)
        {
            Contract.Requires(port != null);
            Check.IfArgumentNull(port, "port");

            this.MidiPort     = port;
            this.StreamAccess = access;
        }
Example #3
0
        /// <summary>
        /// Returns the <paramref name="buffer"/> to the pool.
        /// </summary>
        /// <param name="buffer">Must not be null.</param>
        /// <remarks>Call this method when the <paramref name="buffer"/> is no longer needed.</remarks>
        public override void ReturnBuffer(MidiBufferStream buffer)
        {
            Check.IfArgumentNull(buffer, "buffer");

            // do not re-add buffers during a Reset (or Close) that is meant to return all
            // buffers from the MidiInPort to the buffer manager.
            if (!MidiPort.HasStatus(MidiPortStatus.Reset | MidiPortStatus.Closed))
            {
                // returned buffers are added to the midi in port again
                // to make them available for recording sysex.
                AddBufferToPort(buffer);
            }
            else
            {
                OnUnprepareBuffer(buffer);
                base.ReturnBuffer(buffer);
            }
        }