Skip to content

Commit

Permalink
Fixup unreliable XML chan list read bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cboulay authored Sep 10, 2022
1 parent 1d4ac03 commit a3096a9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Runtime/Scripts/BaseInlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,23 @@ public virtual void AStreamIsFound(StreamInfo stream_info)
single_sample = new TData[nChannels];

XMLElement channels = inlet.info().desc().child("channels");
XMLElement chan;
if (!channels.empty())
chan = channels.first_child();
else
chan = channels;

ChannelNames.Clear();
for (int chan_ix = 0; chan_ix < nChannels; chan_ix++)
{

XMLElement chan = channels.first_child();
while (!chan.empty())
if (!chan.empty())
{
// Read chan
ChannelNames.Add(chan.child_value("label"));
chan = chan.next_sibling();
}
}
// Pad with empty strings to make ChannelNames length == nChannels.
for (int chan_ix = ChannelNames.Count; chan_ix < nChannels; chan_ix++)
{
ChannelNames.Add("Chan" + chan_ix);
else
// Pad with empty strings to make ChannelNames length == nChannels.
ChannelNames.Add("Chan" + chan_ix);
}

OnStreamAvailable();
Expand Down

0 comments on commit a3096a9

Please sign in to comment.