Skip to content

Commit ca0d702

Browse files
committed
Fix recording initialization in TestFixtures
1 parent 5bb9768 commit ca0d702

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ void RecordNode::notifyRecordThreadFilesOpened()
946946
// called by GenericProcessor::setRecording() and CoreServices::setRecordingStatus()
947947
void RecordNode::stopRecording()
948948
{
949-
if (! isRecording)
949+
if (! isRecording && !recordThread->isThreadRunning())
950950
return;
951951

952952
isRecording = false;

Source/Processors/RecordNode/RecordThread.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ void RecordThread::run()
153153
wait (1);
154154
}
155155

156+
LOGD ("RecordThread received first block, starting main loop...");
157+
156158
// 3 - Get initial sample numbers from each stream's queue
157159
int globalChan = 0;
158160
for (int streamIdx = 0; streamIdx < numStreams; streamIdx++)

Tests/TestHelpers/include/TestFixtures.h

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

66
#include <Audio/AudioComponent.h>
77
#include <Processors/ProcessorGraph/ProcessorGraph.h>
8+
#include <Processors/RecordNode/RecordNode.h>
89
#include <Processors/SourceNode/SourceNode.h>
910
#include <UI/ControlPanel.h>
1011
#include <juce_audio_processors/juce_audio_processors.h>
@@ -162,6 +163,30 @@ class ProcessorTester
162163
{
163164
// Do it this way to ensure the GUI elements (which apparently control logic) are set properly
164165
controlPanel->setRecordingState (true, forceRecording);
166+
167+
// RecordNode::notifyRecordThreadFilesOpened() sets isRecording=true via
168+
// MessageManager::callAsync. Since tests run on the message thread, that callback
169+
// is only dispatched when we explicitly pump the message loop. Pump until all
170+
// record nodes report they are actively recording before returning.
171+
const int timeoutMs = 5000;
172+
for (int elapsed = 0; elapsed < timeoutMs; elapsed += 10)
173+
{
174+
juce::MessageManager::getInstance()->runDispatchLoopUntil (10);
175+
176+
bool allReady = true;
177+
for (auto* rn : processorGraph->getRecordNodes())
178+
{
179+
if (! rn->getRecordingStatus())
180+
{
181+
allReady = false;
182+
break;
183+
}
184+
}
185+
if (allReady)
186+
{
187+
break;
188+
}
189+
}
165190
}
166191
else
167192
{

0 commit comments

Comments
 (0)