Commit bb88a719 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

switch to c++11 mutex and lock for MainBuffer

parent 86bdd9bc
...@@ -122,6 +122,9 @@ void AudioBuffer::applyGain(double gain) ...@@ -122,6 +122,9 @@ void AudioBuffer::applyGain(double gain)
for (auto &channel : samples_) for (auto &channel : samples_)
for (auto &sample : channel) for (auto &sample : channel)
sample *= g; sample *= g;
/* for (unsigned i=0, f=frames(), c=channels(); i < c; ++i)
for (unsigned j = 0; j < f; ++j)
samples_[i][j] *= g;*/
} }
size_t AudioBuffer::interleave(SFLAudioSample* out) const size_t AudioBuffer::interleave(SFLAudioSample* out) const
...@@ -135,8 +138,8 @@ size_t AudioBuffer::interleave(SFLAudioSample* out) const ...@@ -135,8 +138,8 @@ size_t AudioBuffer::interleave(SFLAudioSample* out) const
size_t AudioBuffer::interleaveFloat(float* out) const size_t AudioBuffer::interleaveFloat(float* out) const
{ {
for (unsigned i = 0; i < frames(); i++) for (unsigned i=0, f=frames(), c=channels(); i < f; i++)
for (unsigned j = 0; j < samples_.size(); j++) for (unsigned j = 0; j < c; j++)
*out++ = (float) samples_[j][i] * .000030517578125f; *out++ = (float) samples_[j][i] * .000030517578125f;
return frames() * samples_.size(); return frames() * samples_.size();
......
...@@ -31,17 +31,17 @@ ...@@ -31,17 +31,17 @@
#include "mainbuffer.h" #include "mainbuffer.h"
#include "ringbuffer.h" #include "ringbuffer.h"
#include "sfl_types.h" // for SIZEBUF #include "sfl_types.h" // for SIZEBUF
#include <climits> #include <limits>
#include <cstring> #include <cstring>
#include <utility> // for std::pair #include <utility> // for std::pair
#include "scoped_lock.h" //#include "scoped_lock.h"
#include "logger.h" #include "logger.h"
const char * const MainBuffer::DEFAULT_ID = "audiolayer_id"; const char * const MainBuffer::DEFAULT_ID = "audiolayer_id";
MainBuffer::MainBuffer() : ringBufferMap_(), callIDMap_(), mutex_(), internalSamplingRate_(8000) MainBuffer::MainBuffer() : ringBufferMap_(), callIDMap_(), mutex_(), internalSamplingRate_(8000)
{ {
pthread_mutex_init(&mutex_, NULL); //pthread_mutex_init(&mutex_, NULL);
} }
MainBuffer::~MainBuffer() MainBuffer::~MainBuffer()
...@@ -50,7 +50,7 @@ MainBuffer::~MainBuffer() ...@@ -50,7 +50,7 @@ MainBuffer::~MainBuffer()
for (auto &item : ringBufferMap_) for (auto &item : ringBufferMap_)
delete item.second; delete item.second;
pthread_mutex_destroy(&mutex_); //pthread_mutex_destroy(&mutex_);
} }
void MainBuffer::setInternalSamplingRate(int sr) void MainBuffer::setInternalSamplingRate(int sr)
...@@ -139,7 +139,7 @@ void MainBuffer::removeRingBuffer(const std::string &call_id) ...@@ -139,7 +139,7 @@ void MainBuffer::removeRingBuffer(const std::string &call_id)
void MainBuffer::bindCallID(const std::string & call_id1, const std::string & call_id2) void MainBuffer::bindCallID(const std::string & call_id1, const std::string & call_id2)
{ {
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
createRingBuffer(call_id1); createRingBuffer(call_id1);
createCallIDSet(call_id1); createCallIDSet(call_id1);
...@@ -154,7 +154,7 @@ void MainBuffer::bindCallID(const std::string & call_id1, const std::string & ca ...@@ -154,7 +154,7 @@ void MainBuffer::bindCallID(const std::string & call_id1, const std::string & ca
void MainBuffer::bindHalfDuplexOut(const std::string & process_id, const std::string & call_id) void MainBuffer::bindHalfDuplexOut(const std::string & process_id, const std::string & call_id)
{ {
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
// This method is used only for active calls, if this call does not exist, do nothing // This method is used only for active calls, if this call does not exist, do nothing
if (!getRingBuffer(call_id)) if (!getRingBuffer(call_id))
...@@ -167,7 +167,7 @@ void MainBuffer::bindHalfDuplexOut(const std::string & process_id, const std::st ...@@ -167,7 +167,7 @@ void MainBuffer::bindHalfDuplexOut(const std::string & process_id, const std::st
void MainBuffer::unBindCallID(const std::string & call_id1, const std::string & call_id2) void MainBuffer::unBindCallID(const std::string & call_id1, const std::string & call_id2)
{ {
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
removeCallIDfromSet(call_id1, call_id2); removeCallIDfromSet(call_id1, call_id2);
removeCallIDfromSet(call_id2, call_id1); removeCallIDfromSet(call_id2, call_id1);
...@@ -197,7 +197,7 @@ void MainBuffer::unBindCallID(const std::string & call_id1, const std::string & ...@@ -197,7 +197,7 @@ void MainBuffer::unBindCallID(const std::string & call_id1, const std::string &
void MainBuffer::unBindHalfDuplexOut(const std::string & process_id, const std::string & call_id) void MainBuffer::unBindHalfDuplexOut(const std::string & process_id, const std::string & call_id)
{ {
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
removeCallIDfromSet(process_id, call_id); removeCallIDfromSet(process_id, call_id);
...@@ -237,7 +237,7 @@ void MainBuffer::unBindAll(const std::string & call_id) ...@@ -237,7 +237,7 @@ void MainBuffer::unBindAll(const std::string & call_id)
//void MainBuffer::putData(void *buffer, size_t toCopy, const std::string &call_id) //void MainBuffer::putData(void *buffer, size_t toCopy, const std::string &call_id)
void MainBuffer::putData(AudioBuffer& buffer, const std::string &call_id) void MainBuffer::putData(AudioBuffer& buffer, const std::string &call_id)
{ {
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
RingBuffer* ring_buffer = getRingBuffer(call_id); RingBuffer* ring_buffer = getRingBuffer(call_id);
...@@ -248,7 +248,7 @@ void MainBuffer::putData(AudioBuffer& buffer, const std::string &call_id) ...@@ -248,7 +248,7 @@ void MainBuffer::putData(AudioBuffer& buffer, const std::string &call_id)
//size_t MainBuffer::getData(void *buffer, size_t toCopy, const std::string &call_id) //size_t MainBuffer::getData(void *buffer, size_t toCopy, const std::string &call_id)
size_t MainBuffer::getData(AudioBuffer& buffer, const std::string &call_id) size_t MainBuffer::getData(AudioBuffer& buffer, const std::string &call_id)
{ {
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
CallIDSet* callid_set = getCallIDSet(call_id); CallIDSet* callid_set = getCallIDSet(call_id);
...@@ -296,7 +296,7 @@ size_t MainBuffer::getDataByID(AudioBuffer& buffer, const std::string & call_id, ...@@ -296,7 +296,7 @@ size_t MainBuffer::getDataByID(AudioBuffer& buffer, const std::string & call_id,
size_t MainBuffer::availableForGet(const std::string &call_id) size_t MainBuffer::availableForGet(const std::string &call_id)
{ {
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
CallIDSet* callid_set = getCallIDSet(call_id); CallIDSet* callid_set = getCallIDSet(call_id);
...@@ -313,7 +313,7 @@ size_t MainBuffer::availableForGet(const std::string &call_id) ...@@ -313,7 +313,7 @@ size_t MainBuffer::availableForGet(const std::string &call_id)
} else { } else {
size_t availableSamples = INT_MAX; size_t availableSamples = std::numeric_limits<int>::max();
for (auto &i : *callid_set) { for (auto &i : *callid_set) {
const size_t nbSamples = availableForGetByID(i, call_id); const size_t nbSamples = availableForGetByID(i, call_id);
...@@ -344,7 +344,7 @@ size_t MainBuffer::availableForGetByID(const std::string &call_id, ...@@ -344,7 +344,7 @@ size_t MainBuffer::availableForGetByID(const std::string &call_id,
size_t MainBuffer::discard(size_t toDiscard, const std::string &call_id) size_t MainBuffer::discard(size_t toDiscard, const std::string &call_id)
{ {
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
CallIDSet* callid_set = getCallIDSet(call_id); CallIDSet* callid_set = getCallIDSet(call_id);
...@@ -367,7 +367,7 @@ void MainBuffer::discardByID(size_t toDiscard, const std::string & call_id, cons ...@@ -367,7 +367,7 @@ void MainBuffer::discardByID(size_t toDiscard, const std::string & call_id, cons
void MainBuffer::flush(const std::string & call_id) void MainBuffer::flush(const std::string & call_id)
{ {
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
CallIDSet* callid_set = getCallIDSet(call_id); CallIDSet* callid_set = getCallIDSet(call_id);
...@@ -396,7 +396,7 @@ void MainBuffer::flushAllBuffers() ...@@ -396,7 +396,7 @@ void MainBuffer::flushAllBuffers()
void MainBuffer::dumpInfo() void MainBuffer::dumpInfo()
{ {
#if 0 #if 0
sfl::ScopedLock guard(mutex_); std::lock_guard<std::mutex> guard(mutex_);
// print each call and bound call ids // print each call and bound call ids
for (const auto &item_call : callIDMap_) { for (const auto &item_call : callIDMap_) {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <map> #include <map>
#include <set> #include <set>
#include <string> #include <string>
#include <pthread.h> #include <mutex>
#include "audiobuffer.h" #include "audiobuffer.h"
#include "mainbuffer.h" #include "mainbuffer.h"
...@@ -84,10 +84,8 @@ class MainBuffer { ...@@ -84,10 +84,8 @@ class MainBuffer {
void unBindAll(const std::string &call_id); void unBindAll(const std::string &call_id);
//void putData(void *buffer, size_t toCopy, const std::string &call_id);
void putData(AudioBuffer& buffer, const std::string &call_id); void putData(AudioBuffer& buffer, const std::string &call_id);
//size_t getData(void *buffer, size_t toCopy, const std::string &call_id);
size_t getData(AudioBuffer& buffer, const std::string &call_id); size_t getData(AudioBuffer& buffer, const std::string &call_id);
size_t availableForGet(const std::string &call_id); size_t availableForGet(const std::string &call_id);
...@@ -126,7 +124,6 @@ class MainBuffer { ...@@ -126,7 +124,6 @@ class MainBuffer {
RingBuffer* getRingBuffer(const std::string &call_id); RingBuffer* getRingBuffer(const std::string &call_id);
const RingBuffer* getRingBuffer(const std::string & call_id) const; const RingBuffer* getRingBuffer(const std::string & call_id) const;
//size_t getDataByID(void *buffer, size_t toCopy, const std::string &call_id, const std::string &reader_id);
size_t getDataByID(AudioBuffer& buffer, const std::string &call_id, const std::string &reader_id); size_t getDataByID(AudioBuffer& buffer, const std::string &call_id, const std::string &reader_id);
size_t availableForGetByID(const std::string &call_id, const std::string &reader_id) const; size_t availableForGetByID(const std::string &call_id, const std::string &reader_id) const;
...@@ -141,7 +138,7 @@ class MainBuffer { ...@@ -141,7 +138,7 @@ class MainBuffer {
typedef std::map<std::string, CallIDSet*> CallIDMap; typedef std::map<std::string, CallIDSet*> CallIDMap;
CallIDMap callIDMap_; CallIDMap callIDMap_;
pthread_mutex_t mutex_; std::mutex mutex_;
int internalSamplingRate_; int internalSamplingRate_;
......
...@@ -747,7 +747,7 @@ bool OpenSLLayer::audioPlaybackFillWithToneOrRingtone(AudioBuffer &buffer) ...@@ -747,7 +747,7 @@ bool OpenSLLayer::audioPlaybackFillWithToneOrRingtone(AudioBuffer &buffer)
bool OpenSLLayer::audioPlaybackFillWithUrgent(AudioBuffer &buffer, size_t samplesToGet) bool OpenSLLayer::audioPlaybackFillWithUrgent(AudioBuffer &buffer, size_t samplesToGet)
{ {
// Urgent data (dtmf, incoming call signal) come first. // Urgent data (dtmf, incoming call signal) come first.
samplesToGet = std::min(samplesToGet, buffer.frames()); samplesToGet = std::min(samplesToGet, BUFFER_SIZE);
buffer.resize(samplesToGet); buffer.resize(samplesToGet);
urgentRingBuffer_.get(buffer, MainBuffer::DEFAULT_ID); urgentRingBuffer_.get(buffer, MainBuffer::DEFAULT_ID);
buffer.applyGain(playbackGain_); buffer.applyGain(playbackGain_);
...@@ -776,7 +776,7 @@ bool OpenSLLayer::audioPlaybackFillWithVoice(AudioBuffer &buffer, size_t samples ...@@ -776,7 +776,7 @@ bool OpenSLLayer::audioPlaybackFillWithVoice(AudioBuffer &buffer, size_t samples
AudioBuffer out(buffer, false); AudioBuffer out(buffer, false);
out.setSampleRate(sampleRate_); out.setSampleRate(sampleRate_);
converter_.resample(buffer, out); converter_.resample(buffer, out);
buffer = std::move(out); buffer = out;
} }
return true; return true;
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <SLES/OpenSLES.h> #include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h> #include <SLES/OpenSLES_Android.h>
#include <vector> #include <vector>
#include <atomic>
#include "../audiolayer.h" #include "../audiolayer.h"
#include "logger.h" #include "logger.h"
...@@ -53,8 +52,8 @@ class AudioPreference; ...@@ -53,8 +52,8 @@ class AudioPreference;
class OpenSLThread; class OpenSLThread;
#define ANDROID_BUFFER_QUEUE_LENGTH 2 #define ANDROID_BUFFER_QUEUE_LENGTH 2U
#define BUFFER_SIZE 80 #define BUFFER_SIZE 80U
/** /**
......
...@@ -109,7 +109,7 @@ PulseLayer::PulseLayer(AudioPreference &pref) ...@@ -109,7 +109,7 @@ PulseLayer::PulseLayer(AudioPreference &pref)
pa_context_set_state_callback(context_, context_state_callback, this); pa_context_set_state_callback(context_, context_state_callback, this);
if (pa_context_connect(context_, NULL , PA_CONTEXT_NOAUTOSPAWN , NULL) < 0) if (pa_context_connect(context_, nullptr , PA_CONTEXT_NOAUTOSPAWN , nullptr) < 0)
throw std::runtime_error("Could not connect pulseaudio context to the server"); throw std::runtime_error("Could not connect pulseaudio context to the server");
pa_threaded_mainloop_lock(mainloop_); pa_threaded_mainloop_lock(mainloop_);
...@@ -165,7 +165,7 @@ void PulseLayer::context_state_callback(pa_context* c, void *user_data) ...@@ -165,7 +165,7 @@ void PulseLayer::context_state_callback(pa_context* c, void *user_data)
case PA_CONTEXT_READY: case PA_CONTEXT_READY:
DEBUG("Connection to PulseAudio server established"); DEBUG("Connection to PulseAudio server established");
pa_threaded_mainloop_signal(pulse->mainloop_, 0); pa_threaded_mainloop_signal(pulse->mainloop_, 0);
pa_context_subscribe(c, mask, NULL, pulse); pa_context_subscribe(c, mask, nullptr, pulse);
pa_context_set_subscribe_callback(c, context_changed_callback, pulse); pa_context_set_subscribe_callback(c, context_changed_callback, pulse);
pulse->updateSinkList(); pulse->updateSinkList();
pulse->updateSourceList(); pulse->updateSourceList();
...@@ -190,7 +190,7 @@ void PulseLayer::updateSinkList() ...@@ -190,7 +190,7 @@ void PulseLayer::updateSinkList()
enumeratingSinks_ = true; enumeratingSinks_ = true;
pa_operation *op = pa_context_get_sink_info_list(context_, sink_input_info_callback, this); pa_operation *op = pa_context_get_sink_info_list(context_, sink_input_info_callback, this);
if (op != NULL) if (op != nullptr)
pa_operation_unref(op); pa_operation_unref(op);
} }
...@@ -200,7 +200,7 @@ void PulseLayer::updateSourceList() ...@@ -200,7 +200,7 @@ void PulseLayer::updateSourceList()
enumeratingSources_ = true; enumeratingSources_ = true;
pa_operation *op = pa_context_get_source_info_list(context_, source_input_info_callback, this); pa_operation *op = pa_context_get_source_info_list(context_, source_input_info_callback, this);
if (op != NULL) if (op != nullptr)
pa_operation_unref(op); pa_operation_unref(op);
} }
...@@ -257,7 +257,7 @@ const PaDeviceInfos* PulseLayer::getDeviceInfos(const std::vector<PaDeviceInfos> ...@@ -257,7 +257,7 @@ const PaDeviceInfos* PulseLayer::getDeviceInfos(const std::vector<PaDeviceInfos>
{ {
std::vector<PaDeviceInfos>::const_iterator dev_info = std::find_if(list.begin(), list.end(), PaDeviceInfos::nameComparator(name)); std::vector<PaDeviceInfos>::const_iterator dev_info = std::find_if(list.begin(), list.end(), PaDeviceInfos::nameComparator(name));
if (dev_info == list.end()) return NULL; if (dev_info == list.end()) return nullptr;
return &(*dev_info); return &(*dev_info);
} }
...@@ -304,7 +304,7 @@ void PulseLayer::createStreams(pa_context* c) ...@@ -304,7 +304,7 @@ void PulseLayer::createStreams(pa_context* c)
// Create playback stream // Create playback stream
const PaDeviceInfos* dev_infos = getDeviceInfos(sinkList_, playbackDevice); const PaDeviceInfos* dev_infos = getDeviceInfos(sinkList_, playbackDevice);
if (dev_infos == NULL) { if (dev_infos == nullptr) {
dev_infos = &sinkList_[0]; dev_infos = &sinkList_[0];
DEBUG("Prefered playback device not found in device list, selecting %s instead.", dev_infos->name.c_str()); DEBUG("Prefered playback device not found in device list, selecting %s instead.", dev_infos->name.c_str());
} }
...@@ -317,7 +317,7 @@ void PulseLayer::createStreams(pa_context* c) ...@@ -317,7 +317,7 @@ void PulseLayer::createStreams(pa_context* c)
// Create capture stream // Create capture stream
dev_infos = getDeviceInfos(sourceList_, captureDevice); dev_infos = getDeviceInfos(sourceList_, captureDevice);
if (dev_infos == NULL) { if (dev_infos == nullptr) {
dev_infos = &sourceList_[0]; dev_infos = &sourceList_[0];
DEBUG("Prefered capture device not found in device list, selecting %s instead.", dev_infos->name.c_str()); DEBUG("Prefered capture device not found in device list, selecting %s instead.", dev_infos->name.c_str());
} }
...@@ -330,7 +330,7 @@ void PulseLayer::createStreams(pa_context* c) ...@@ -330,7 +330,7 @@ void PulseLayer::createStreams(pa_context* c)
// Create ringtone stream // Create ringtone stream
dev_infos = getDeviceInfos(sinkList_, ringtoneDevice); dev_infos = getDeviceInfos(sinkList_, ringtoneDevice);
if (dev_infos == NULL) { if (dev_infos == nullptr) {
dev_infos = &sinkList_[0]; dev_infos = &sinkList_[0];
DEBUG("Prefered ringtone device not found in device list, selecting %s instead.", dev_infos->name.c_str()); DEBUG("Prefered ringtone device not found in device list, selecting %s instead.", dev_infos->name.c_str());
} }
...@@ -383,10 +383,10 @@ PulseLayer::stopStream() ...@@ -383,10 +383,10 @@ PulseLayer::stopStream()
pa_threaded_mainloop_lock(mainloop_); pa_threaded_mainloop_lock(mainloop_);
if (playback_) if (playback_)
pa_stream_flush(playback_->pulseStream(), NULL, NULL); pa_stream_flush(playback_->pulseStream(), nullptr, nullptr);
if (record_) if (record_)
pa_stream_flush(record_->pulseStream(), NULL, NULL); pa_stream_flush(record_->pulseStream(), nullptr, nullptr);
pa_threaded_mainloop_unlock(mainloop_); pa_threaded_mainloop_unlock(mainloop_);
...@@ -433,7 +433,7 @@ void PulseLayer::writeToSpeaker() ...@@ -433,7 +433,7 @@ void PulseLayer::writeToSpeaker()
urgentRingBuffer_.get(linearbuff, MainBuffer::DEFAULT_ID); // retrive only the first sample_spec->channels channels urgentRingBuffer_.get(linearbuff, MainBuffer::DEFAULT_ID); // retrive only the first sample_spec->channels channels
linearbuff.applyGain(playbackGain_); linearbuff.applyGain(playbackGain_);
linearbuff.interleave(data); linearbuff.interleave(data);
pa_stream_write(s, data, urgentBytes, NULL, 0, PA_SEEK_RELATIVE); pa_stream_write(s, data, urgentBytes, nullptr, 0, PA_SEEK_RELATIVE);
// Consume the regular one as well (same amount of samples) // Consume the regular one as well (same amount of samples)
Manager::instance().getMainBuffer().discard(urgentSamples, MainBuffer::DEFAULT_ID); Manager::instance().getMainBuffer().discard(urgentSamples, MainBuffer::DEFAULT_ID);
return; return;
...@@ -449,7 +449,7 @@ void PulseLayer::writeToSpeaker() ...@@ -449,7 +449,7 @@ void PulseLayer::writeToSpeaker()
AudioBuffer linearbuff(writableSamples, n_channels); AudioBuffer linearbuff(writableSamples, n_channels);
toneToPlay->getNext(linearbuff, playbackGain_); // retrive only n_channels toneToPlay->getNext(linearbuff, playbackGain_); // retrive only n_channels
linearbuff.interleave(data); linearbuff.interleave(data);
pa_stream_write(s, data, writableBytes, NULL, 0, PA_SEEK_RELATIVE); pa_stream_write(s, data, writableBytes, nullptr, 0, PA_SEEK_RELATIVE);
} }
return; return;
...@@ -462,7 +462,7 @@ void PulseLayer::writeToSpeaker() ...@@ -462,7 +462,7 @@ void PulseLayer::writeToSpeaker()
if (availSamples == 0) { if (availSamples == 0) {
pa_stream_begin_write(s, (void**)&data, &writableBytes); pa_stream_begin_write(s, (void**)&data, &writableBytes);
memset(data, 0, writableBytes); memset(data, 0, writableBytes);
pa_stream_write(s, data, writableBytes, NULL, 0, PA_SEEK_RELATIVE); pa_stream_write(s, data, writableBytes, nullptr, 0, PA_SEEK_RELATIVE);
return; return;
} }
...@@ -493,11 +493,11 @@ void PulseLayer::writeToSpeaker() ...@@ -493,11 +493,11 @@ void PulseLayer::writeToSpeaker()
converter_.resample(linearbuff, rsmpl_out); converter_.resample(linearbuff, rsmpl_out);
rsmpl_out.applyGain(playbackGain_); rsmpl_out.applyGain(playbackGain_);
rsmpl_out.interleave(data); rsmpl_out.interleave(data);
pa_stream_write(s, data, resampledBytes, NULL, 0, PA_SEEK_RELATIVE); pa_stream_write(s, data, resampledBytes, nullptr, 0, PA_SEEK_RELATIVE);
} else { } else {
linearbuff.applyGain(playbackGain_); linearbuff.applyGain(playbackGain_);
linearbuff.interleave(data); linearbuff.interleave(data);
pa_stream_write(s, data, resampledBytes, NULL, 0, PA_SEEK_RELATIVE); pa_stream_write(s, data, resampledBytes, nullptr, 0, PA_SEEK_RELATIVE);
} }
} }
...@@ -506,7 +506,7 @@ void PulseLayer::readFromMic() ...@@ -506,7 +506,7 @@ void PulseLayer::readFromMic()
if (!record_ or !record_->isReady()) if (!record_ or !record_->isReady())
return; return;
const char *data = NULL; const char *data = nullptr;
size_t bytes; size_t bytes;
const size_t sample_size = record_->sampleSize(); const size_t sample_size = record_->sampleSize();
...@@ -583,7 +583,7 @@ void PulseLayer::ringtoneToSpeaker() ...@@ -583,7 +583,7 @@ void PulseLayer::ringtoneToSpeaker()
memset(data, 0, bytes); memset(data, 0, bytes);
} }
pa_stream_write(s, data, bytes, NULL, 0, PA_SEEK_RELATIVE); pa_stream_write(s, data, bytes, nullptr, 0, PA_SEEK_RELATIVE);
} }
void void
...@@ -604,7 +604,7 @@ PulseLayer::context_changed_callback(pa_context* c, ...@@ -604,7 +604,7 @@ PulseLayer::context_changed_callback(pa_context* c,
context->sinkList_.clear(); context->sinkList_.clear();
op = pa_context_get_sink_info_list(c, sink_input_info_callback, userdata); op = pa_context_get_sink_info_list(c, sink_input_info_callback, userdata);
if (op != NULL) if (op != nullptr)
pa_operation_unref(op); pa_operation_unref(op);
default: default:
...@@ -621,7 +621,7 @@ PulseLayer::context_changed_callback(pa_context* c, ...@@ -621,7 +621,7 @@ PulseLayer::context_changed_callback(pa_context* c,
context->sourceList_.clear(); context->sourceList_.clear();
op = pa_context_get_source_info_list(c, source_input_info_callback, userdata); op = pa_context_get_source_info_list(c, source_input_info_callback, userdata);
if (op != NULL) if (op != nullptr)
pa_operation_unref(op); pa_operation_unref(op);
default: default:
......
...@@ -48,7 +48,7 @@ class AudioStream; ...@@ -48,7 +48,7 @@ class AudioStream;
/** /**
* Convenience structure to hold PulseAudio device propreties such as supported channel number etc. * Convenience structure to hold PulseAudio device propreties such as supported channel number etc.
*/ */
typedef struct PaDeviceInfos { typedef struct {
uint32_t index; uint32_t index;
std::string name; std::string name;
pa_sample_spec sample_spec; pa_sample_spec sample_spec;
...@@ -150,17 +150,17 @@ class PulseLayer : public AudioLayer { ...@@ -150,17 +150,17 @@ class PulseLayer : public AudioLayer {
AudioStream* ringtone_; AudioStream* ringtone_;
/** /**
* Contain the list of playback devices * Contains the list of playback devices
*/ */
std::vector<PaDeviceInfos> sinkList_; std::vector<PaDeviceInfos> sinkList_;
/** /**
* Contain the list of capture devices * Contains the list of capture devices