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) ...@@ -36,6 +36,12 @@ LocalRecorder::LocalRecorder(const bool& audioOnly)
recorder_->audioOnly(audioOnly); recorder_->audioOnly(audioOnly);
} }
LocalRecorder::~LocalRecorder()
{
if (isRecording())
stopRecording();
}
void void
LocalRecorder::setPath(const std::string& path) LocalRecorder::setPath(const std::string& path)
{ {
...@@ -94,15 +100,14 @@ LocalRecorder::startRecording() ...@@ -94,15 +100,14 @@ LocalRecorder::startRecording()
void void
LocalRecorder::stopRecording() LocalRecorder::stopRecording()
{ {
Recordable::stopRecording();
Manager::instance().getRingBufferPool().unBindHalfDuplexOut(path_, RingBufferPool::DEFAULT_ID);
if (auto ob = recorder_->getStream(audioInput_->getInfo().name)) if (auto ob = recorder_->getStream(audioInput_->getInfo().name))
audioInput_->detach(ob); audioInput_->detach(ob);
if (videoInput_) if (videoInput_)
if (auto ob = recorder_->getStream(videoInput_->getInfo().name)) if (auto ob = recorder_->getStream(videoInput_->getInfo().name))
videoInput_->detach(ob); videoInput_->detach(ob);
audioInput_.reset(); Manager::instance().getRingBufferPool().unBindHalfDuplexOut(path_, RingBufferPool::DEFAULT_ID);
videoInput_.reset(); // NOTE stopRecording should be last call to avoid data races
Recordable::stopRecording();
} }
} // namespace ring } // namespace ring
...@@ -40,13 +40,8 @@ namespace ring { ...@@ -40,13 +40,8 @@ namespace ring {
class LocalRecorder : public Recordable { class LocalRecorder : public Recordable {
public: 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(const bool& audioOnly);
~LocalRecorder();
/** /**
* Start local recording. Return true if recording was successfully * Start local recording. Return true if recording was successfully
...@@ -54,6 +49,9 @@ class LocalRecorder : public Recordable { ...@@ -54,6 +49,9 @@ class LocalRecorder : public Recordable {
*/ */
bool startRecording(); bool startRecording();
/**
* Stops recording.
*/
void stopRecording(); 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