/// <summary> /// Reads a frame from the MP3 stream. Returns whether the operation was successful. If it wasn't, /// the source stream is probably at its end. /// </summary> private bool ReadFrame(bool first = false) { // Read a frame from the bitstream. Header header = m_BitStream.readFrame(); if (header == null) { return(false); } try { // Set the channel count and frequency values for the stream. if (header.mode() == Header.SINGLE_CHANNEL) { m_ChannelCountRep = 1; } else { m_ChannelCountRep = 2; } m_FrequencyRep = header.frequency(); // if (first) // m_TotalMs = header.total_ms((int) m_SourceStream.Length); // Decode the frame. ABuffer decoderOutput = m_Decoder.DecodeFrame(header, m_BitStream); // Apparently, the way JavaZoom sets the output buffer // on the decoder is a bit dodgy. Even though // this exception should never happen, we test to be sure. if (decoderOutput != m_Buffer) { throw new ApplicationException("Output buffers are different."); } // And we're done. } finally { // No resource leaks please! m_BitStream.CloseFrame(); } return(true); }