Commit aeca0be5 authored by Tristan Matthews's avatar Tristan Matthews

* #27693: audio: hold a reference to main buffer instead of a pointer

parent 542b83a1
......@@ -38,11 +38,9 @@
int AudioRecorder::count_ = 0;
AudioRecorder::AudioRecorder(AudioRecord *arec, MainBuffer *mb) :
AudioRecorder::AudioRecorder(AudioRecord *arec, MainBuffer &mb) :
recorderId_(), mbuffer_(mb), arecord_(arec), running_(false), thread_(0)
{
assert(mb);
++count_;
std::string id("processid_");
......@@ -87,9 +85,9 @@ void AudioRecorder::run()
AudioBuffer buffer(BUFFER_LENGTH);
while (running_) {
const size_t availableSamples = mbuffer_->availableForGet(recorderId_);
const size_t availableSamples = mbuffer_.availableForGet(recorderId_);
buffer.resize(std::min(availableSamples, BUFFER_LENGTH));
mbuffer_->getData(buffer, recorderId_);
mbuffer_.getData(buffer, recorderId_);
if (availableSamples > 0)
arecord_->recData(buffer);
......
......@@ -41,7 +41,7 @@ class MainBuffer;
class AudioRecorder {
public:
AudioRecorder(AudioRecord *arec, MainBuffer *mb);
AudioRecorder(AudioRecord *arec, MainBuffer &mb);
~AudioRecorder();
std::string getRecorderID() const {
return recorderId_;
......@@ -56,7 +56,7 @@ class AudioRecorder {
static int count_;
std::string recorderId_;
MainBuffer *mbuffer_;
MainBuffer &mbuffer_;
AudioRecord *arecord_;
bool running_;
pthread_t thread_;
......
......@@ -31,7 +31,7 @@
#include "manager.h"
#include "logger.h"
Recordable::Recordable() : recAudio_(), recorder_(&recAudio_, &Manager::instance().getMainBuffer())
Recordable::Recordable() : recAudio_(), recorder_(&recAudio_, Manager::instance().getMainBuffer())
{
DEBUG("Set recording options: %s", Manager::instance().audioPreference.getRecordPath().c_str());
recAudio_.setRecordingOption(AudioRecord::FILE_WAV, 8000, Manager::instance().audioPreference.getRecordPath());
......
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