diff --git a/daemon/src/audio/alsa/alsalayer.cpp b/daemon/src/audio/alsa/alsalayer.cpp index 9af4251248e1b5890878c2b75f6deb98831c871c..19ef6ba14c60d3f0beba54cde2fdf6eb4b197db1 100644 --- a/daemon/src/audio/alsa/alsalayer.cpp +++ b/daemon/src/audio/alsa/alsalayer.cpp @@ -707,7 +707,7 @@ void AlsaLayer::capture() // TODO: handle ALSA multichannel capture const int toGetBytes = in.samples() * sizeof(SFLAudioSample); - SFLAudioSample * const in_ptr = &(*in.getChannel()->begin()); + SFLAudioSample * const in_ptr = &(*in.getChannel(0)->begin()); if (read(in_ptr, toGetBytes) != toGetBytes) { ERROR("ALSA MIC : Couldn't read!"); @@ -748,7 +748,7 @@ void AlsaLayer::playback(int maxSamples) else if (file_tone && !ringtoneHandle_) file_tone->getNext(out, playbackGain_); - write(out.getChannel()->data(), bytesToPut, playbackHandle_); + write(out.getChannel(0)->data(), bytesToPut, playbackHandle_); } else { // play the regular sound samples @@ -781,9 +781,9 @@ void AlsaLayer::playback(int maxSamples) //SFLAudioSample * const rsmpl_out_ptr = &(*rsmpl_out.begin()); //converter_.resample(out_ptr, rsmpl_out_ptr, rsmpl_out.size(), mainBufferSampleRate, sampleRate_, samplesToGet); converter_.resample(out, rsmpl_out); - write(rsmpl_out.getChannel()->data(), outBytes, playbackHandle_); + write(rsmpl_out.getChannel(0)->data(), outBytes, playbackHandle_); } else { - write(out.getChannel()->data(), bytesToGet, playbackHandle_); + write(out.getChannel(0)->data(), bytesToGet, playbackHandle_); } } } @@ -811,7 +811,7 @@ void AlsaLayer::audioCallback() urgentRingBuffer_.get(out, MainBuffer::DEFAULT_ID); out.applyGain(playbackGain_); - write(out.getChannel()->data(), samplesToGet*sizeof(SFLAudioSample), playbackHandle_); + write(out.getChannel(0)->data(), samplesToGet * sizeof(SFLAudioSample), playbackHandle_); // Consume the regular one as well (same amount of bytes) Manager::instance().getMainBuffer().discard(samplesToGet, MainBuffer::DEFAULT_ID); } else { @@ -834,7 +834,7 @@ void AlsaLayer::audioCallback() file_tone->getNext(out, playbackGain_); } - write(out.getChannel()->data(), ringtoneAvailBytes, ringtoneHandle_); + write(out.getChannel(0)->data(), ringtoneAvailBytes, ringtoneHandle_); } // Additionally handle the mic's audio stream diff --git a/daemon/src/audio/audiobuffer.h b/daemon/src/audio/audiobuffer.h index 009c38f5bfabbd11d5fd9967c2d06c15f1902005..a1981f5d051f6d20b83da82f5b40d758a6182d18 100644 --- a/daemon/src/audio/audiobuffer.h +++ b/daemon/src/audio/audiobuffer.h @@ -122,7 +122,7 @@ class AudioBuffer { * Return the data (audio samples) for a given channel number. * Channel data can be modified but size of individual channel vectors should not be changed manually. */ - std::vector<SFLAudioSample> *getChannel(unsigned chan = 0); + std::vector<SFLAudioSample> *getChannel(unsigned chan); /** * Return a pointer to the raw data in this buffer. diff --git a/daemon/src/audio/audiorecord.cpp b/daemon/src/audio/audiorecord.cpp index 2ed60da34a5e9816b5bd9ae48cc0be42ffa53b15..47873fcee8baef531d96a9ccb392760716388210 100644 --- a/daemon/src/audio/audiorecord.cpp +++ b/daemon/src/audio/audiorecord.cpp @@ -420,22 +420,22 @@ void AudioRecord::closeWavFile() WARN("Can't close file"); } -//void AudioRecord::recData(SFLAudioSample* buffer, size_t nSamples) void AudioRecord::recData(AudioBuffer& buffer) { - if (recordingEnabled_) { - if (fileHandle_ == 0) { - DEBUG("Can't record data, a file has not yet been opened!"); - return; - } + if (not recordingEnabled_) + return; + + if (fileHandle_ == 0) { + DEBUG("Can't record data, a file has not yet been opened!"); + return; + } - size_t nSamples = buffer.samples(); + const size_t nSamples = buffer.samples(); - if (fwrite(buffer.getChannel(), sizeof(SFLAudioSample), nSamples, fileHandle_) != nSamples) - WARN("Could not record data! "); - else { - fflush(fileHandle_); - byteCounter_ += nSamples * sizeof(SFLAudioSample); - } + if (fwrite(buffer.getChannel(0), sizeof(SFLAudioSample), nSamples, fileHandle_) != nSamples) { + WARN("Could not record data! "); + } else { + fflush(fileHandle_); + byteCounter_ += nSamples * sizeof(SFLAudioSample); } } diff --git a/daemon/src/audio/gaincontrol.cpp b/daemon/src/audio/gaincontrol.cpp index be7a98344185b3c7369cc8cab52064a5c5cf7d89..8e8bc07b2954049b3b269a766d762e8821282abe 100644 --- a/daemon/src/audio/gaincontrol.cpp +++ b/daemon/src/audio/gaincontrol.cpp @@ -58,7 +58,7 @@ GainControl::GainControl(double sr, double target) : averager_(sr, SFL_GAIN_ATTA void GainControl::process(AudioBuffer& buf) { - process(buf.getChannel()->data(), buf.samples()); + process(buf.getChannel(0)->data(), buf.samples()); } void GainControl::process(SFLAudioSample *buf, int samples) diff --git a/daemon/src/audio/noisesuppress.cpp b/daemon/src/audio/noisesuppress.cpp index f0d5ca4307d7605803b2ed8c39e135a7e08c63e7..961cb88215d841775f51cb44be8d02bb24471afd 100644 --- a/daemon/src/audio/noisesuppress.cpp +++ b/daemon/src/audio/noisesuppress.cpp @@ -64,7 +64,7 @@ NoiseSuppress::~NoiseSuppress() void NoiseSuppress::process(AudioBuffer& buff, int samples) { - SFLAudioSample* data = buff.getChannel()->data(); + SFLAudioSample* data = buff.getChannel(0)->data(); if (noiseState_) { assert(smplPerFrame_ == samples); speex_preprocess_run(noiseState_, data); diff --git a/daemon/src/audio/pulseaudio/pulselayer.cpp b/daemon/src/audio/pulseaudio/pulselayer.cpp index 8792faee6d766106b94e0430b7920364edf6337b..1fcfdc8449d9e940314a66a873fe44f44a607166 100644 --- a/daemon/src/audio/pulseaudio/pulselayer.cpp +++ b/daemon/src/audio/pulseaudio/pulselayer.cpp @@ -538,7 +538,7 @@ void PulseLayer::readFromMic() Manager::instance().getMainBuffer().putData(*out, MainBuffer::DEFAULT_ID); #ifdef RECTODISK - outfileResampled.write((const char *)out->getChannel(), out->samples()*sizeof(SFLAudioSample)); + outfileResampled.write((const char *)out->getChannel(0), out->samples() * sizeof(SFLAudioSample)); #endif if (pa_stream_drop(record_->pulseStream()) < 0) diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 4dde1df152644de7c0fa1b214dc620fa17a68088..a19019f28bb02e0d1164f1b7e76d48e8fe211e5a 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -1443,7 +1443,7 @@ void ManagerImpl::playDtmf(char code) dtmfKey_->startTone(code); // copy the sound - if (dtmfKey_->generateDTMF(*buf.getChannel())) { + if (dtmfKey_->generateDTMF(*buf.getChannel(0))) { // Put buffer to urgentRingBuffer // put the size in bytes... // so size * 1 channel (mono) * sizeof (bytes for the data)