Skip to content

Commit db8a7c9

Browse files
committed
Add warning for hardware timestamp override when assigning sync lines
1 parent 4e2fa41 commit db8a7c9

3 files changed

Lines changed: 42 additions & 3 deletions

File tree

Source/Processors/Parameter/ParameterEditor.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "../Editors/GenericEditor.h"
2727
#include "../GenericProcessor/GenericProcessor.h"
28+
#include "../RecordNode/RecordNode.h"
2829

2930
void ParameterEditor::setLayout (Layout newLayout)
3031
{
@@ -980,6 +981,27 @@ TtlLineParameterEditor::TtlLineParameterEditor (Parameter* param,
980981

981982
void TtlLineParameterEditor::selectedLineChanged (int newLine)
982983
{
984+
int prevLine = getSelectedLine();
985+
// If a sync line is assigned, show a warning if the stream generates hardware timestamps
986+
if (syncParam != nullptr)
987+
{
988+
DataStream* paramStream = ((DataStream*) param->getOwner());
989+
if (! RecordNode::overrideTimestampWarningShown
990+
&& paramStream->generatesTimestamps()
991+
&& newLine >= 0
992+
&& prevLine == -1)
993+
{
994+
AlertWindow::showMessageBox (AlertWindow::WarningIcon,
995+
"Hardware Timestamps Will Be Overridden",
996+
"The \"" + paramStream->getKey() + "\" stream is synchronized using hardware-generated timestamps, but a sync line has been assigned. "
997+
"As a result, the hardware timestamps will be replaced with software-generated ones from the Synchronizer, using the main stream's clock and sync events.\n\n"
998+
"To continue using hardware-generated timestamps, please remove the sync line by clicking it again",
999+
"OK");
1000+
1001+
RecordNode::overrideTimestampWarningShown = true;
1002+
}
1003+
}
1004+
9831005
param->setNextValue (newLine);
9841006
updateView();
9851007
}

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ using namespace std::chrono;
3939
#define CONTINUOUS_CHANNELS_ON_BY_DEFAULT true
4040
#define RECEIVED_SOFTWARE_TIME (event.getVelocity() == 136)
4141

42+
bool RecordNode::overrideTimestampWarningShown = false;
43+
4244
EventMonitor::EventMonitor()
4345
: receivedEvents (0),
4446
receivedSpikes (0),
@@ -162,9 +164,20 @@ void RecordNode::parameterValueChanged (Parameter* p)
162164
{
163165
LOGD ("Parameter changed: sync_line");
164166
int selectedLine = ((TtlLineParameter*) p)->getSelectedLine();
165-
synchronizer.setSyncLine (getDataStream (p->getStreamId())->getKey(), selectedLine);
167+
const String streamKey = getDataStream (p->getStreamId())->getKey();
168+
169+
synchronizer.setSyncLine (streamKey, selectedLine);
170+
171+
// Assume overrideTimestampWarningShown is already true if a sync line is set for any hardware-synced stream
172+
if (getDataStream (streamKey)->generatesTimestamps()
173+
&& selectedLine >= 0
174+
&& !overrideTimestampWarningShown)
175+
{
176+
overrideTimestampWarningShown = true;
177+
}
166178

167-
if (selectedLine == -1 && synchronizer.mainStreamKey == getDataStream (p->getStreamId())->getKey())
179+
// If sync line is set to none and this is the main stream, we need to find another main stream
180+
if (selectedLine == -1 && synchronizer.mainStreamKey == streamKey)
168181
{
169182
int streamIndex = 0;
170183
for (auto stream : dataStreams)
@@ -186,7 +199,7 @@ void RecordNode::parameterValueChanged (Parameter* p)
186199
int streamIndex = 0;
187200
for (auto stream : dataStreams)
188201
{
189-
if (stream->getKey() == getDataStream (p->getStreamId())->getKey())
202+
if (stream->getKey() == streamKey)
190203
{
191204
getParameter ("main_sync")->setNextValue (streamIndex, false);
192205
return;

Source/Processors/RecordNode/RecordNode.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ class TESTABLE RecordNode : public GenericProcessor,
257257
/** Actual sync monitor update -- can be called independently of timer*/
258258
void updateSyncMonitors();
259259

260+
/** Static flag to ensure override timestamps warning
261+
* for hardware-synced streams is shown only once per run */
262+
static bool overrideTimestampWarningShown;
263+
260264
private:
261265
/** Handles other types of events (text, sync texts, etc.) */
262266
void handleEvent (const EventChannel* channel, const EventPacket& eventPacket);

0 commit comments

Comments
 (0)