Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions xdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,22 @@ int Xdf::load_xdf(std::string filename)
else
ts = streams[index].last_timestamp + streams[index].sampling_interval;

//read the event
auto length = Xdf::readLength(file);

char* buffer = new char[length + 1];
file.read(buffer, length);
buffer[length] = '\0';
eventMap.emplace_back(std::make_pair(buffer, ts), index);
delete[] buffer;
//read one length-prefixed string per channel: a string
//sample contains channel_count values, just like the
//numeric branches above. Reading only a single string
//here leaves the remaining channels' bytes unconsumed,
//which desyncs the file cursor and breaks the next chunk.
for (int v = 0; v < streams[index].info.channel_count; ++v)
{
//read the event
auto length = Xdf::readLength(file);

char* buffer = new char[length + 1];
file.read(buffer, length);
buffer[length] = '\0';
eventMap.emplace_back(std::make_pair(buffer, ts), index);
delete[] buffer;
}
streams[index].last_timestamp = ts;
}
}
Expand Down
Loading