Commit d0390c98 authored by Philippe Gorley's avatar Philippe Gorley

recorder: fix sequence of operations

Change-Id: I1dc2f0c12cc7be2efea92add495fa42a982ad8a1
parent ee2dd41a
......@@ -99,8 +99,18 @@ MediaRecorder::startRecording()
encoder_.reset(new MediaEncoder);
RING_DBG() << "Start recording '" << getPath() << "'";
if (initRecord() >= 0)
if (initRecord() >= 0) {
isRecording_ = true;
// start thread after isRecording_ is set to true
ThreadPool::instance().run([rec = shared_from_this()] {
while (rec->isRecording()) {
rec->filterAndEncode(rec->videoFilter_.get(), rec->videoIdx_);
rec->filterAndEncode(rec->audioFilter_.get(), rec->audioIdx_);
}
rec->flush();
rec->reset(); // allows recorder to be reused in same call
});
}
return 0;
}
......@@ -247,14 +257,6 @@ MediaRecorder::initRecord()
}
RING_DBG() << "Recording initialized";
ThreadPool::instance().run([rec = shared_from_this()] {
while (rec->isRecording()) {
rec->filterAndEncode(rec->videoFilter_.get(), rec->videoIdx_);
rec->filterAndEncode(rec->audioFilter_.get(), rec->audioIdx_);
}
rec->flush();
rec->reset(); // allows recorder to be reused in same call
});
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment