Skip to content

Commit 2f6e5d3

Browse files
committed
Optimize RecordNode::startRecording logic
1 parent e9c618e commit 2f6e5d3

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,6 @@ bool RecordNode::stopAcquisition()
791791
// called by GenericProcessor::setRecording() and CoreServices::setRecordingStatus()
792792
void RecordNode::startRecording()
793793
{
794-
795794
Array<int> chanProcessorMap;
796795
Array<int> chanOrderinProc;
797796
OwnedArray<RecordProcessorInfo> procInfo;
@@ -878,7 +877,7 @@ void RecordNode::startRecording()
878877
{
879878
DataQueue* queue = new DataQueue (bufferSize, DATA_BUFFER_NBLOCKS);
880879
queue->setChannelCount (recordedChannelsPerStream[i]);
881-
queue->setTimestampStreamCount (1); // Each queue has one timestamp stream
880+
queue->setTimestampStreamCount (1); // Each queue has one timestamp stream
882881
dataQueues.add (queue);
883882

884883
// Pre-compute source channel array for this stream
@@ -929,8 +928,7 @@ void RecordNode::startRecording()
929928
}
930929

931930
recordThread->setFileComponents (rootFolder, experimentNumber, recordingNumber);
932-
recordThread->startThread(Thread::Priority::highest);
933-
isRecording = true;
931+
recordThread->startThread (Thread::Priority::highest);
934932

935933
if (settingsNeeded)
936934
{
@@ -946,6 +944,14 @@ void RecordNode::startRecording()
946944
}
947945
}
948946

947+
void RecordNode::notifyRecordThreadFilesOpened()
948+
{
949+
MessageManager::callAsync ([this]()
950+
{
951+
if (recordThread->isThreadRunning())
952+
isRecording = true; });
953+
}
954+
949955
// called by GenericProcessor::setRecording() and CoreServices::setRecordingStatus()
950956
void RecordNode::stopRecording()
951957
{
@@ -1155,7 +1161,7 @@ void RecordNode::process (AudioBuffer<float>& buffer)
11551161
dataQueues[streamIndex]->writeSynchronizedTimestamps (
11561162
first,
11571163
second - first,
1158-
0, // timestamp stream index within this queue
1164+
0, // timestamp stream index within this queue
11591165
numSamples);
11601166
}
11611167

Source/Processors/RecordNode/RecordNode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class TESTABLE RecordNode : public GenericProcessor,
140140
/* Called at start of recording; launches the RecordThread*/
141141
void startRecording() override;
142142

143+
/** Called by RecordThread after opening files */
144+
void notifyRecordThreadFilesOpened();
145+
143146
/* Called at end of recording; stops the RecordThread*/
144147
void stopRecording() override;
145148

Source/Processors/RecordNode/RecordThread.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ void RecordThread::run()
114114

115115
m_engine->openFiles (m_rootFolder, m_experimentNumber, m_recordingNumber);
116116

117+
if (recordNode != nullptr)
118+
recordNode->notifyRecordThreadFilesOpened();
119+
117120
//2-Wait until the first block has arrived, so we can align the timestamps
118121
bool isWaiting = false;
119122
while (! m_receivedFirstBlock && ! threadShouldExit())

0 commit comments

Comments
 (0)