public void FlushBuffers() { if (this._buffer.Length > 0L) this.ProcessMetadata((Stream) this._buffer); this._audioParser.FlushBuffers(); this._state = ShoutcastMetadataFilter.State.Data; this._buffer.SetLength(0L); this._remainingData = this._interval; }
public void ProcessData(byte[] buffer, int offset, int length) { while (length > 0) { switch (this._state) { case ShoutcastMetadataFilter.State.Data: if (this._remainingData > length) { this._audioParser.ProcessData(buffer, offset, length); this._remainingData -= length; return; } if (this._remainingData > 0) { this._audioParser.ProcessData(buffer, offset, this._remainingData); length -= this._remainingData; offset += this._remainingData; this._remainingData = this._interval; } this._state = ShoutcastMetadataFilter.State.MetadataLength; break; case ShoutcastMetadataFilter.State.MetadataLength: this._metadataLength = (int)buffer[offset] * 16; --length; ++offset; this._state = this._metadataLength > 0 ? ShoutcastMetadataFilter.State.Metadata : ShoutcastMetadataFilter.State.Data; break; case ShoutcastMetadataFilter.State.Metadata: if (this._metadataLength > length) { this._buffer.Write(buffer, offset, length); this._metadataLength -= length; return; } if (this._metadataLength > 0) { this._buffer.Write(buffer, offset, this._metadataLength); length -= this._metadataLength; offset += this._metadataLength; this._metadataLength = 0; } if (this._buffer.Length > 0L) { this.ProcessMetadata((Stream)this._buffer); } this._state = ShoutcastMetadataFilter.State.Data; break; } } }