-
Notifications
You must be signed in to change notification settings - Fork 693
recordEngine - improve writeTimestampSyncText signature #670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2ac2a0a
to
d9dd820
Compare
Hi @d1manson, Thanks for the detailed PR and explanation! Let me provide some context about the First of all, the The reason why the method is named I'm not very sure about the motive behind making these changes. Are you writing a record engine that needs to write the first sample number AND timestamp at the start of each recording? If so, why can't you use the timestamps and sample numbers that are being written via the data-specific write methods ( Regarding the PLUGIN API version bump: we only increase the API version as part of a planned major GUI release (e.g., v2.0.0) that delivers a cohesive set of breaking changes and/or substantial new features. This change doesn’t meet that bar, and bumping early would create extra maintenance for downstream plugins (rebuilding and redeploying) and cause existing plugins to fail to load after updating the GUI. If you could provide some more clarity on your use case and what specific functionality you're trying to achieve, that would be great. Understanding the motivation will help us better evaluate whether these API changes are necessary or if there's an alternative approach that would work for your needs. Thanks! |
Thanks @anjaldoshi for the quick reply here. In terms of why I need this (at least why i think i need it)... At least prior to v1 (and I think this remains the case), if you want the zero time to correspond to the start of recording rather than the start of acquisition, you needed to listen for the In terms of why I only suggested this now, the main reason is that whereas before there was only one data stream from the aquisition board, now there are two (the memory_usage is the second), which complicates a few things downstream where preivously I was able to ignore the possibility of additional datastreams. For now I have built the main GUI app on my fork (see here), so that it is available for users of this plugin, but in the longer run it would be nice if this PR did make it into the main repo, assuming it does make sense to do so. *see here for the version that doesn't rely on this change to the plugin api, or here for the version that works with this change to the api. |
In terms of the wider context for why i have this plugin (actually a pair of plugins), they are trying to recreate the kind of data files and workflow that are familiar to several people at UCL (and others in Europe who have been using the same hardware/software for a few decades). For now it's only being used by Guifen Chen's lab at QMUL (she was at UCL previously), but might be of interest to others who have come up with alternative shims to migrate to OE without having to make big changes to their workflow and matlab code etc. (I know of at least one person/lab in that category). |
Not exactly related to this, but I believe i've encountered a bug where Not sure what is causing it to return |
The old version had a few quirks:
streamId
, but there is no way to lookup a stream bystreamId
within the record engine, only by index.0
for thesourceSampleRate
(this is hardcoded at the one call site), so this param is useless.sampleNumber
rather than a timestamp. This is also especially painful as the other virtual functions on the record engine recieve timestamps not sample numbers, and I don't think you have access to the synchroniser to do the conversion in either direction.So to address that, I suggest:
DataStream*
rather than astreamId
, this means you can also get any properties you want from the stream, such as the sample rate. Anullptr
can be provided for this arg if needed, and indeed it seems it is (I don't quite understand how/why that is happening, but thewriteTimestampSyncText
function has historically been called with a non-stream first).This is of course a breaking change to the plugin api. But it should be pretty trivial to migrate given you can always call
stream == nullptr ? 0 : stream->getStreamId()
to recover thestreamId
, and aside from that we haven't lost anything (given thesourceSampleRate
was never providing any actual data, and the newtimestamp
arg is an addition.In terms of thread-saftey considerations, as far as I understand I'm not doing anything especially novel in the
RecordThread
, but worth someone who understands things better checking this.In terms of the
timestamp
calculation, it would be good for someone to confirm this is right. I adapted the logic from the call todataQueue->writeSynchronizedTimestamps(..)
withinRecordNode::process
.--
In addition to the main change here, I've also added a
getDataStreams()
function on theRecordEngine
, wrapping the function on the underlyingrecordNode
.Without that there was no way to iterate over the streams safely, as far as I can tell. You might think you can iterate from
0
togetNumRecordedDataStreams()
, and callgetDataStream(index)
in each case, but that doesn't work becausegetNumRecordedDataStreams
can return a number less than the total number of streams, and there's no reason that the recorded stream(s) are guaranteeed to come first in the list (i.e. if you stop iterating too soon you might miss actual recorded streams).TODO:
PLUGIN_API_VER
, presumably.I have posted about this in discord here.