Commit b2654881 authored by Philippe Gorley's avatar Philippe Gorley

localrecorder: correctly create read offsets

Also avoids race conditions when stopping the recorder

Change-Id: I498b2f9802e647a05410bd5bcb5cf4248a02bcf4
parent 8ada1f2d
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Copyright (C) 2018 Savoir-faire Linux Inc. * Copyright (C) 2018 Savoir-faire Linux Inc.
* *
* Author: Hugo Lefeuvre <hugo.lefeuvre@savoirfairelinux.com> * Author: Hugo Lefeuvre <hugo.lefeuvre@savoirfairelinux.com>
* Author: Philippe Gorley <philippe.gorley@savoirfairelinux.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -69,12 +70,11 @@ LocalRecorder::startRecording() ...@@ -69,12 +70,11 @@ LocalRecorder::startRecording()
} }
// audio recording // audio recording
auto rb = ring::Manager::instance().getRingBufferPool().getRingBuffer(RingBufferPool::DEFAULT_ID); // create read offset in RingBuffer
rb->createReadOffset(RingBufferPool::DEFAULT_ID); Manager::instance().getRingBufferPool().bindHalfDuplexOut(path_, RingBufferPool::DEFAULT_ID);
ring::Manager::instance().startAudioDriverStream(); Manager::instance().startAudioDriverStream();
// TODO wait for AudioLayer::hardwareFormatAvailable callback, otherwise a race condition happens here
audioInput_.reset(new ring::AudioInput(RingBufferPool::DEFAULT_ID)); audioInput_.reset(new AudioInput(path_));
audioInput_->initRecorder(recorder_); audioInput_->initRecorder(recorder_);
#ifdef RING_VIDEO #ifdef RING_VIDEO
...@@ -96,16 +96,13 @@ LocalRecorder::startRecording() ...@@ -96,16 +96,13 @@ LocalRecorder::startRecording()
void void
LocalRecorder::stopRecording() LocalRecorder::stopRecording()
{ {
Recordable::stopRecording();
if (audioInput_) { if (audioInput_) {
auto rb = ring::Manager::instance().getRingBufferPool().getRingBuffer(RingBufferPool::DEFAULT_ID); Manager::instance().getRingBufferPool().unBindHalfDuplexOut(path_, RingBufferPool::DEFAULT_ID);
rb->removeReadOffset(RingBufferPool::DEFAULT_ID);
audioInput_.reset();
audioInput_ = nullptr;
} else { } else {
RING_ERR("could not stop audio layer (audio input is null)"); RING_ERR("could not stop audio layer (audio input is null)");
} }
Recordable::stopRecording();
} }
} // namespace ring } // namespace ring
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