Commit 4fba37f6 authored by Philippe Gorley's avatar Philippe Gorley

localrecorder: fix crash on stop

Change-Id: I11ac40fa68bf6bd94d5aaae9246e5bd1e1a556b6
parent 4d480644
......@@ -36,6 +36,12 @@ LocalRecorder::LocalRecorder(const bool& audioOnly)
recorder_->audioOnly(audioOnly);
}
LocalRecorder::~LocalRecorder()
{
if (isRecording())
stopRecording();
}
void
LocalRecorder::setPath(const std::string& path)
{
......@@ -94,15 +100,14 @@ LocalRecorder::startRecording()
void
LocalRecorder::stopRecording()
{
Recordable::stopRecording();
Manager::instance().getRingBufferPool().unBindHalfDuplexOut(path_, RingBufferPool::DEFAULT_ID);
if (auto ob = recorder_->getStream(audioInput_->getInfo().name))
audioInput_->detach(ob);
if (videoInput_)
if (auto ob = recorder_->getStream(videoInput_->getInfo().name))
videoInput_->detach(ob);
audioInput_.reset();
videoInput_.reset();
Manager::instance().getRingBufferPool().unBindHalfDuplexOut(path_, RingBufferPool::DEFAULT_ID);
// NOTE stopRecording should be last call to avoid data races
Recordable::stopRecording();
}
} // namespace ring
......@@ -40,13 +40,8 @@ namespace ring {
class LocalRecorder : public Recordable {
public:
/**
* Constructor of a LocalRecorder.
* Passed VideoInput pointer will be used for recording.
* If input pointer in null, video recording will be disabled on this
* recorder.
*/
LocalRecorder(const bool& audioOnly);
~LocalRecorder();
/**
* Start local recording. Return true if recording was successfully
......@@ -54,6 +49,9 @@ class LocalRecorder : public Recordable {
*/
bool startRecording();
/**
* Stops recording.
*/
void stopRecording();
/**
......
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