예제 #1
0
        /// <summary>
        /// uses the <see cref="Search"/> class to find the next id3 / mp3 frame start at the buffer.
        /// </summary>
        /// <returns>Returns the search result.</returns>
        Search FindFrame()
        {
            // initialize the search and run it at the buffer
            var search = new Search();

            while (true)
            {
                // fill the buffer
                if (!m_Reader.EnsureBuffer(1024) && (m_Reader.Available < 4))
                {
                    if (m_Reader.Available == 0)
                    {
                        return(null);
                    }

                    // end of stream
                    var buffer = m_Reader.GetBuffer(m_Reader.Available);
                    InvalidData(buffer);
                    return(null);
                }

                // run the search
                {
                    if (m_Reader.Contains(search))
                    {
                        return(search);
                    }

                    // nothing found, enqueue invalid data...
                    var buffer = m_Reader.GetBuffer(m_Reader.Available - 2);
                    InvalidData(buffer);

                    // .. and start new search
                    search = new Search();
                }
            }
        }