private XEFEvent ReadDataEvent() { if (!EndOfStream) { try { short streamIndex, streamFlags; GetEventKey(out streamIndex, out streamFlags); // Get event stream XEFStream eventStream = null; if (_streams.ContainsKey(streamIndex)) { eventStream = _streams[streamIndex]; } // Read event metadata int dataSize = _reader.ReadInt32(); TimeSpan relativeTime = TimeSpan.FromTicks(_reader.ReadInt64()); uint unknown = _reader.ReadUInt32(); int fullDataSize = _reader.ReadInt32(); // Uncompressed data size // Read tag if needed byte[] tagData = null; int frameIndex = 0; if (eventStream != null) { if (eventStream.TagSize > 0) { tagData = _reader.ReadBytes(eventStream.TagSize); // Treat tag as frame number if (eventStream.TagSize == 4) { frameIndex = BitConverter.ToInt32(tagData, 0); } } Debug.Assert(!eventStream.IsCompressed || fullDataSize != dataSize); // Verify event is valid } else { tagData = _reader.ReadBytes(DataConstants.EVENT_DEFAULT_TAG_SIZE); } // Read event data byte[] eventData = _reader.ReadBytes(dataSize); return(new XEFEvent(eventStream, frameIndex, relativeTime, fullDataSize, tagData, eventData, unknown)); } catch (IOException) { EndOfStream = true; StreamError = true; } } return(null); }
public XEFEvent(XEFStream eventStream, int frameIndex, TimeSpan relativeTime, int eventDataSize, byte[] tagData, byte[] eventData, uint unknown) { EventStream = eventStream; FrameIndex = frameIndex; RelativeTime = relativeTime; TagData = tagData; EventDataSize = eventDataSize; RawEventData = eventData; Unknown = unknown; if (EventStream != null) { EventIndex = EventStream.EventCount; EventStream.AddEvent(this); // Need to tell stream that an event has been added } }