Skip to content

Commit 8aa57f1

Browse files
committed
Update logic for when to use synchronizer dependent methods
1 parent cfe8450 commit 8aa57f1

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

Source/Processors/RecordNode/DataQueue.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ float DataQueue::writeSynchronizedTimestampChannel(double start, double step, in
174174
}
175175

176176

177-
void DataQueue::writeChannel(const AudioSampleBuffer& buffer, int srcChannel, int destChannel, int nSamples, int64 timestamp)
177+
float DataQueue::writeChannel(const AudioSampleBuffer& buffer, int srcChannel, int destChannel, int nSamples, int64 timestamp)
178178
{
179179
int index1, size1, index2, size2;
180180
m_fifos[destChannel]->prepareToWrite(nSamples, index1, size1, index2, size2);
@@ -205,6 +205,8 @@ void DataQueue::writeChannel(const AudioSampleBuffer& buffer, int srcChannel, in
205205
fillTimestamps(destChannel, index2, size2, timestamp + size1);
206206
}
207207
m_fifos[destChannel]->finishedWrite(size1 + size2);
208+
209+
return 1.0f - (float)m_fifos[destChannel]->getFreeSpace() / (float)m_fifos[destChannel]->getTotalSize();
208210
}
209211

210212
/*

Source/Processors/RecordNode/DataQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class DataQueue
4949

5050
//Only the methods after this comment are considered thread-safe.
5151
//Caution must be had to avoid calling more than one of the methods above simulatenously
52-
void writeChannel(const AudioSampleBuffer& buffer, int srcChannel, int destChannel, int nSamples, int64 timestamp);
52+
float writeChannel(const AudioSampleBuffer& buffer, int srcChannel, int destChannel, int nSamples, int64 timestamp);
5353
float writeSynchronizedTimestampChannel(double start, double step, int destChannel, int64 nSamples);
5454
bool startRead(Array<CircularBufferIndexes>& indexes, Array<int64>& timestamps, int nMax);
5555
bool startSynchronizedRead(Array<CircularBufferIndexes>& dataIndexes, Array<CircularBufferIndexes>& ftsIndexes, Array<int64>& timestamps, int nMax);

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ void RecordNode::startRecording()
520520
}
521521
*/
522522

523+
useSynchronizer = static_cast<RecordNodeEditor*> (getEditor())->getSelectedEngineIdx() == 0;
524+
523525
recordThread->setFileComponents(rootFolder, experimentNumber, recordingNumber);
524526
recordThread->startThread();
525527
isRecording = true;
@@ -657,9 +659,21 @@ void RecordNode::process(AudioSampleBuffer& buffer)
657659

658660
if (isFirstChannelInRecordedSubprocessor(channelMap[ch]))
659661
{
660-
double first = synchronizer->convertTimestamp(sourceID, subProcIdx, timestamp);
661-
double second = synchronizer->convertTimestamp(sourceID, subProcIdx, timestamp + 1);
662-
fifoUsage[sourceID][subProcIdx] = dataQueue->writeSynchronizedTimestampChannel(first, second - first, ftsChannelMap[ch], numSamples);
662+
663+
if (useSynchronizer)
664+
{
665+
double first = synchronizer->convertTimestamp(sourceID, subProcIdx, timestamp);
666+
double second = synchronizer->convertTimestamp(sourceID, subProcIdx, timestamp + 1);
667+
fifoUsage[sourceID][subProcIdx] = dataQueue->writeSynchronizedTimestampChannel(first, second - first, ftsChannelMap[ch], numSamples);
668+
}
669+
else
670+
{
671+
fifoUsage[sourceID][subProcIdx] = dataQueue->writeChannel(buffer, channelMap[ch], ch, numSamples, timestamp);
672+
samplesWritten+=numSamples;
673+
continue;
674+
}
675+
676+
663677
}
664678

665679
dataQueue->writeChannel(buffer, channelMap[ch], ch, numSamples, timestamp);

Source/Processors/RecordNode/RecordNode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class RecordNode : public GenericProcessor, public FilenameComponentListener
167167

168168
private:
169169

170+
bool useSynchronizer;
171+
170172
bool receivedSoftwareTime;
171173

172174
int lastDataChannelArraySize;

Source/Processors/RecordNode/RecordNodeEditor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ void RecordNodeEditor::loadCustomParameters(XmlElement* xml)
214214

215215
}
216216

217+
int RecordNodeEditor::getSelectedEngineIdx()
218+
{
219+
return engineSelectCombo->getSelectedId()-1;
220+
}
221+
217222
void RecordNodeEditor::timerCallback()
218223
{
219224

Source/Processors/RecordNode/RecordNodeEditor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class RecordNodeEditor : public GenericEditor, ComboBoxListener
112112

113113
void updateSubprocessorFifos();
114114
void showSubprocessorFifos(bool);
115+
116+
int getSelectedEngineIdx();
115117

116118
bool subprocessorsVisible;
117119

0 commit comments

Comments
 (0)