mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 13:48:38 -05:00
Cleanup: audio file, audio threads
This commit is contained in:
parent
19b1ecd7c2
commit
0b97bd360a
@ -5,13 +5,9 @@
|
|||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
AudioFile::AudioFile() {
|
AudioFile::AudioFile() = default;
|
||||||
|
|
||||||
}
|
AudioFile::~AudioFile() = default;
|
||||||
|
|
||||||
AudioFile::~AudioFile() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioFile::setOutputFileName(std::string filename) {
|
void AudioFile::setOutputFileName(std::string filename) {
|
||||||
filenameBase = filename;
|
filenameBase = filename;
|
||||||
|
@ -22,7 +22,8 @@ namespace little_endian_io
|
|||||||
|
|
||||||
template <typename Word>
|
template <typename Word>
|
||||||
std::istream& read_word(std::istream& ins, Word& value, unsigned size = sizeof(Word)) {
|
std::istream& read_word(std::istream& ins, Word& value, unsigned size = sizeof(Word)) {
|
||||||
for (unsigned n = 0, value = 0; n < size; ++n) {
|
value = 0;
|
||||||
|
for (unsigned n = 0; n < size; ++n) {
|
||||||
value |= ins.get() << (8 * n);
|
value |= ins.get() << (8 * n);
|
||||||
}
|
}
|
||||||
return ins;
|
return ins;
|
||||||
@ -50,11 +51,10 @@ namespace big_endian_io
|
|||||||
|
|
||||||
using namespace little_endian_io;
|
using namespace little_endian_io;
|
||||||
|
|
||||||
AudioFileWAV::AudioFileWAV() : AudioFile() {
|
AudioFileWAV::AudioFileWAV() : AudioFile(), dataChunkPos(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioFileWAV::~AudioFileWAV() {
|
AudioFileWAV::~AudioFileWAV() = default;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string AudioFileWAV::getExtension()
|
std::string AudioFileWAV::getExtension()
|
||||||
@ -119,7 +119,7 @@ bool AudioFileWAV::closeFile()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioFileWAV::writeHeaderToFileStream(AudioThreadInputPtr input) {
|
void AudioFileWAV::writeHeaderToFileStream(const AudioThreadInputPtr& input) {
|
||||||
|
|
||||||
// Based on simple wav file output code from
|
// Based on simple wav file output code from
|
||||||
// http://www.cplusplus.com/forum/beginner/166954/
|
// http://www.cplusplus.com/forum/beginner/166954/
|
||||||
@ -140,7 +140,7 @@ void AudioFileWAV::writeHeaderToFileStream(AudioThreadInputPtr input) {
|
|||||||
outputFileStream << "data----"; // (chunk size to be filled in later)
|
outputFileStream << "data----"; // (chunk size to be filled in later)
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioFileWAV::writePayloadToFileStream(AudioThreadInputPtr input, size_t startInputPosition, size_t endInputPosition) {
|
void AudioFileWAV::writePayloadToFileStream(const AudioThreadInputPtr& input, size_t startInputPosition, size_t endInputPosition) {
|
||||||
|
|
||||||
// Prevent clipping
|
// Prevent clipping
|
||||||
float intScale = (input->peak < 1.0) ? 32767.0f : (32767.0f / input->peak);
|
float intScale = (input->peak < 1.0) ? 32767.0f : (32767.0f / input->peak);
|
||||||
@ -164,7 +164,7 @@ void AudioFileWAV::writePayloadToFileStream(AudioThreadInputPtr input, size_t st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t AudioFileWAV::getMaxWritableNumberOfSamples(AudioThreadInputPtr input) {
|
size_t AudioFileWAV::getMaxWritableNumberOfSamples(const AudioThreadInputPtr& input) const {
|
||||||
|
|
||||||
long long remainingBytesInFile = (long long)(MAX_WAV_FILE_SIZE) - currentFileSize;
|
long long remainingBytesInFile = (long long)(MAX_WAV_FILE_SIZE) - currentFileSize;
|
||||||
|
|
||||||
|
@ -11,19 +11,19 @@ class AudioFileWAV : public AudioFile {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
AudioFileWAV();
|
AudioFileWAV();
|
||||||
~AudioFileWAV();
|
~AudioFileWAV() override;
|
||||||
|
|
||||||
//override to manage name change with multi-part WAV.
|
//override to manage name change with multi-part WAV.
|
||||||
virtual void setOutputFileName(std::string filename);
|
void setOutputFileName(std::string filename) override;
|
||||||
|
|
||||||
//override of the base method to generate multi-part
|
//override of the base method to generate multi-part
|
||||||
//WAV to overcome the WAV format size limit.
|
//WAV to overcome the WAV format size limit.
|
||||||
virtual std::string getOutputFileName();
|
std::string getOutputFileName() override;
|
||||||
|
|
||||||
virtual std::string getExtension();
|
std::string getExtension() override;
|
||||||
|
|
||||||
virtual bool writeToFile(AudioThreadInputPtr input);
|
bool writeToFile(AudioThreadInputPtr input) override;
|
||||||
virtual bool closeFile();
|
bool closeFile() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::ofstream outputFileStream;
|
std::ofstream outputFileStream;
|
||||||
@ -33,10 +33,10 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
size_t getMaxWritableNumberOfSamples(AudioThreadInputPtr input);
|
size_t getMaxWritableNumberOfSamples(const AudioThreadInputPtr& input) const;
|
||||||
|
|
||||||
void writeHeaderToFileStream(AudioThreadInputPtr input);
|
void writeHeaderToFileStream(const AudioThreadInputPtr& input);
|
||||||
|
|
||||||
//write [startInputPosition; endInputPosition[ samples from input into the file.
|
//write [startInputPosition; endInputPosition[ samples from input into the file.
|
||||||
void writePayloadToFileStream(AudioThreadInputPtr input, size_t startInputPosition, size_t endInputPosition);
|
void writePayloadToFileStream(const AudioThreadInputPtr& input, size_t startInputPosition, size_t endInputPosition);
|
||||||
};
|
};
|
@ -11,7 +11,7 @@ class AudioSinkFileThread : public AudioSinkThread {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
AudioSinkFileThread();
|
AudioSinkFileThread();
|
||||||
~AudioSinkFileThread();
|
~AudioSinkFileThread() override;
|
||||||
|
|
||||||
enum SquelchOption {
|
enum SquelchOption {
|
||||||
SQUELCH_RECORD_SILENCE = 0, // default value, record as a user would hear it.
|
SQUELCH_RECORD_SILENCE = 0, // default value, record as a user would hear it.
|
||||||
@ -20,8 +20,8 @@ public:
|
|||||||
SQUELCH_RECORD_MAX
|
SQUELCH_RECORD_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void sink(AudioThreadInputPtr input);
|
void sink(AudioThreadInputPtr input) override;
|
||||||
virtual void inputChanged(AudioThreadInput oldProps, AudioThreadInputPtr newProps);
|
void inputChanged(AudioThreadInput oldProps, AudioThreadInputPtr newProps) override;
|
||||||
|
|
||||||
void setAudioFileHandler(AudioFile *output);
|
void setAudioFileHandler(AudioFile *output);
|
||||||
|
|
||||||
|
@ -11,9 +11,7 @@ AudioSinkThread::AudioSinkThread() {
|
|||||||
setInputQueue("input", inputQueuePtr);
|
setInputQueue("input", inputQueuePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioSinkThread::~AudioSinkThread() {
|
AudioSinkThread::~AudioSinkThread() = default;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioSinkThread::run() {
|
void AudioSinkThread::run() {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -10,10 +10,10 @@ class AudioSinkThread : public IOThread {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
AudioSinkThread();
|
AudioSinkThread();
|
||||||
virtual ~AudioSinkThread();
|
~AudioSinkThread() override;
|
||||||
|
|
||||||
virtual void run();
|
void run() override;
|
||||||
virtual void terminate();
|
void terminate() override;
|
||||||
|
|
||||||
virtual void sink(AudioThreadInputPtr input) = 0;
|
virtual void sink(AudioThreadInputPtr input) = 0;
|
||||||
virtual void inputChanged(AudioThreadInput oldProps, AudioThreadInputPtr newProps) = 0;
|
virtual void inputChanged(AudioThreadInput oldProps, AudioThreadInputPtr newProps) = 0;
|
||||||
|
@ -2,13 +2,10 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0+
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
#include "AudioThread.h"
|
#include "AudioThread.h"
|
||||||
#include "CubicSDRDefs.h"
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
#include "DemodulatorThread.h"
|
|
||||||
#include "DemodulatorInstance.h"
|
#include "DemodulatorInstance.h"
|
||||||
#include <memory.h>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
//50 ms
|
//50 ms
|
||||||
@ -80,9 +77,9 @@ void AudioThread::deviceCleanup() {
|
|||||||
//NOT PROTECTED by m_device_mutex on purpose, to prevent deadlocks with i->second->controllerThread
|
//NOT PROTECTED by m_device_mutex on purpose, to prevent deadlocks with i->second->controllerThread
|
||||||
// it doesn't matter, it is only called when all "normal" audio threads are detached from the controller.
|
// it doesn't matter, it is only called when all "normal" audio threads are detached from the controller.
|
||||||
//
|
//
|
||||||
for (auto i = deviceController.begin(); i != deviceController.end(); i++) {
|
for (auto & i : deviceController) {
|
||||||
|
|
||||||
delete i->second;
|
delete i.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceController.clear();
|
deviceController.clear();
|
||||||
@ -98,7 +95,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
|
|||||||
::memset(out, 0, nBufferFrames * 2 * sizeof(float));
|
::memset(out, 0, nBufferFrames * 2 * sizeof(float));
|
||||||
|
|
||||||
//src in the controller thread:
|
//src in the controller thread:
|
||||||
AudioThread *src = (AudioThread *)userData;
|
auto *src = (AudioThread *)userData;
|
||||||
|
|
||||||
//by construction, src is a controller thread, from deviceController:
|
//by construction, src is a controller thread, from deviceController:
|
||||||
std::lock_guard<std::recursive_mutex> lock(src->getMutex());
|
std::lock_guard<std::recursive_mutex> lock(src->getMutex());
|
||||||
@ -157,7 +154,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (srcmix->currentInput->channels == 0 || !srcmix->currentInput->data.size()) {
|
if (srcmix->currentInput->channels == 0 || srcmix->currentInput->data.empty()) {
|
||||||
if (!srcmix->inputQueue->empty()) {
|
if (!srcmix->inputQueue->empty()) {
|
||||||
srcmix->audioQueuePtr = 0;
|
srcmix->audioQueuePtr = 0;
|
||||||
if (srcmix->currentInput) {
|
if (srcmix->currentInput) {
|
||||||
@ -195,7 +192,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
|
|||||||
mixPeak = srcPeak;
|
mixPeak = srcPeak;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (srcmix->currentInput && srcmix->currentInput->data.size()) {
|
if (srcmix->currentInput && !srcmix->currentInput->data.empty()) {
|
||||||
float v = srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
|
float v = srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
|
||||||
out[i * 2] += v;
|
out[i * 2] += v;
|
||||||
out[i * 2 + 1] += v;
|
out[i * 2 + 1] += v;
|
||||||
@ -204,7 +201,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 0, iMax = srcmix->currentInput->channels * nBufferFrames; i < iMax; i++) {
|
for (unsigned int i = 0, iMax = srcmix->currentInput->channels * nBufferFrames; i < iMax; i++) {
|
||||||
|
|
||||||
if (srcmix->audioQueuePtr >= srcmix->currentInput->data.size()) {
|
if (srcmix->audioQueuePtr >= srcmix->currentInput->data.size()) {
|
||||||
srcmix->audioQueuePtr = 0;
|
srcmix->audioQueuePtr = 0;
|
||||||
@ -222,7 +219,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
|
|||||||
mixPeak = srcPeak;
|
mixPeak = srcPeak;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (srcmix->currentInput && srcmix->currentInput->data.size()) {
|
if (srcmix->currentInput && !srcmix->currentInput->data.empty()) {
|
||||||
|
|
||||||
out[i] = out[i] + srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
|
out[i] = out[i] + srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
|
||||||
}
|
}
|
||||||
@ -248,9 +245,9 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
|
|||||||
void AudioThread::enumerateDevices(std::vector<RtAudio::DeviceInfo> &devs) {
|
void AudioThread::enumerateDevices(std::vector<RtAudio::DeviceInfo> &devs) {
|
||||||
RtAudio endac;
|
RtAudio endac;
|
||||||
|
|
||||||
int numDevices = endac.getDeviceCount();
|
unsigned int numDevices = endac.getDeviceCount();
|
||||||
|
|
||||||
for (int i = 0; i < numDevices; i++) {
|
for (unsigned int i = 0; i < numDevices; i++) {
|
||||||
RtAudio::DeviceInfo info = endac.getDeviceInfo(i);
|
RtAudio::DeviceInfo info = endac.getDeviceInfo(i);
|
||||||
|
|
||||||
devs.push_back(info);
|
devs.push_back(info);
|
||||||
@ -322,7 +319,7 @@ void AudioThread::setDeviceSampleRate(int deviceId, int sampleRate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioThread::setSampleRate(int sampleRate) {
|
void AudioThread::setSampleRate(int sampleRate_in) {
|
||||||
|
|
||||||
bool thisIsAController = false;
|
bool thisIsAController = false;
|
||||||
|
|
||||||
@ -332,7 +329,7 @@ void AudioThread::setSampleRate(int sampleRate) {
|
|||||||
|
|
||||||
if (deviceController[outputDevice.load()] == this) {
|
if (deviceController[outputDevice.load()] == this) {
|
||||||
thisIsAController = true;
|
thisIsAController = true;
|
||||||
deviceSampleRate[outputDevice.load()] = sampleRate;
|
deviceSampleRate[outputDevice.load()] = sampleRate_in;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,31 +341,30 @@ void AudioThread::setSampleRate(int sampleRate) {
|
|||||||
dac.closeStream();
|
dac.closeStream();
|
||||||
|
|
||||||
//Set bounded sample rate:
|
//Set bounded sample rate:
|
||||||
for (size_t j = 0; j < boundThreads.size(); j++) {
|
for (auto srcmix : boundThreads) {
|
||||||
AudioThread *srcmix = boundThreads[j];
|
srcmix->setSampleRate(sampleRate_in);
|
||||||
srcmix->setSampleRate(sampleRate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//make a local copy, snapshot of the list of demodulators
|
//make a local copy, snapshot of the list of demodulators
|
||||||
std::vector<DemodulatorInstancePtr> demodulators = wxGetApp().getDemodMgr().getDemodulators();
|
std::vector<DemodulatorInstancePtr> demodulators = wxGetApp().getDemodMgr().getDemodulators();
|
||||||
|
|
||||||
for (auto demod : demodulators) {
|
for (const auto& demod : demodulators) {
|
||||||
if (demod->getOutputDevice() == outputDevice.load()) {
|
if (demod->getOutputDevice() == outputDevice.load()) {
|
||||||
demod->setAudioSampleRate(sampleRate);
|
demod->setAudioSampleRate(sampleRate_in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dac.openStream(¶meters, NULL, RTAUDIO_FLOAT32, sampleRate, &nBufferFrames, &audioCallback, (void *)this, &opts);
|
dac.openStream(¶meters, nullptr, RTAUDIO_FLOAT32, sampleRate_in, &nBufferFrames, &audioCallback, (void *)this, &opts);
|
||||||
dac.startStream();
|
dac.startStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->sampleRate = sampleRate;
|
sampleRate = sampleRate_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AudioThread::getSampleRate() {
|
int AudioThread::getSampleRate() {
|
||||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||||
|
|
||||||
return this->sampleRate;
|
return sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioThread::setupDevice(int deviceId) {
|
void AudioThread::setupDevice(int deviceId) {
|
||||||
@ -411,7 +407,7 @@ void AudioThread::setupDevice(int deviceId) {
|
|||||||
if (deviceController.find(parameters.deviceId) == deviceController.end()) {
|
if (deviceController.find(parameters.deviceId) == deviceController.end()) {
|
||||||
|
|
||||||
//Create a new controller thread for parameters.deviceId:
|
//Create a new controller thread for parameters.deviceId:
|
||||||
AudioThread* newController = new AudioThread();
|
auto* newController = new AudioThread();
|
||||||
|
|
||||||
newController->setInitOutputDevice(parameters.deviceId, sampleRate);
|
newController->setInitOutputDevice(parameters.deviceId, sampleRate);
|
||||||
newController->bindThread(this);
|
newController->bindThread(this);
|
||||||
@ -422,7 +418,7 @@ void AudioThread::setupDevice(int deviceId) {
|
|||||||
else if (deviceController[parameters.deviceId] == this) {
|
else if (deviceController[parameters.deviceId] == this) {
|
||||||
|
|
||||||
//Attach callback
|
//Attach callback
|
||||||
dac.openStream(¶meters, NULL, RTAUDIO_FLOAT32, sampleRate, &nBufferFrames, &audioCallback, (void *)this, &opts);
|
dac.openStream(¶meters, nullptr, RTAUDIO_FLOAT32, sampleRate, &nBufferFrames, &audioCallback, (void *)this, &opts);
|
||||||
dac.startStream();
|
dac.startStream();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -455,21 +451,21 @@ int AudioThread::getOutputDevice() {
|
|||||||
return outputDevice;
|
return outputDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioThread::setInitOutputDevice(int deviceId, int sampleRate) {
|
void AudioThread::setInitOutputDevice(int deviceId, int sampleRate_in) {
|
||||||
|
|
||||||
//global lock
|
//global lock
|
||||||
std::lock_guard<std::recursive_mutex> lock(m_device_mutex);
|
std::lock_guard<std::recursive_mutex> lock(m_device_mutex);
|
||||||
|
|
||||||
outputDevice = deviceId;
|
outputDevice = deviceId;
|
||||||
if (sampleRate == -1) {
|
if (sampleRate_in == -1) {
|
||||||
if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) {
|
if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) {
|
||||||
sampleRate = deviceSampleRate[deviceId];
|
sampleRate_in = deviceSampleRate[deviceId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deviceSampleRate[deviceId] = sampleRate;
|
deviceSampleRate[deviceId] = sampleRate_in;
|
||||||
}
|
}
|
||||||
this->sampleRate = sampleRate;
|
sampleRate = sampleRate_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioThread::run() {
|
void AudioThread::run() {
|
||||||
@ -517,20 +513,20 @@ void AudioThread::run() {
|
|||||||
//Nullify currentInput...
|
//Nullify currentInput...
|
||||||
currentInput = nullptr;
|
currentInput = nullptr;
|
||||||
|
|
||||||
//Stop : Retreive the matching controling thread in a scope lock:
|
//Stop : Retrieve the matching controlling thread in a scope lock:
|
||||||
AudioThread* controllerThread = nullptr;
|
AudioThread* controllerMatchingThread;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> global_lock(m_device_mutex);
|
std::lock_guard<std::recursive_mutex> global_lock(m_device_mutex);
|
||||||
controllerThread = deviceController[parameters.deviceId];
|
controllerMatchingThread = deviceController[parameters.deviceId];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controllerThread != this) {
|
if (controllerMatchingThread != this) {
|
||||||
//'this' is not the controller, so remove it from the bounded list:
|
//'this' is not the controller, so remove it from the bounded list:
|
||||||
//beware, we must take the controller mutex, because the audio callback may use the list of bounded
|
//beware, we must take the controller mutex, because the audio callback may use the list of bounded
|
||||||
//threads at that moment:
|
//threads at that moment:
|
||||||
std::lock_guard<std::recursive_mutex> lock(controllerThread->getMutex());
|
std::lock_guard<std::recursive_mutex> lock(controllerMatchingThread->getMutex());
|
||||||
|
|
||||||
controllerThread->removeThread(this);
|
controllerMatchingThread->removeThread(this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 'this' is a controller thread:
|
// 'this' is a controller thread:
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
|
|
||||||
class AudioThreadInput {
|
class AudioThreadInput {
|
||||||
public:
|
public:
|
||||||
long long frequency;
|
long long frequency{};
|
||||||
int inputRate;
|
int inputRate{};
|
||||||
int sampleRate;
|
int sampleRate{};
|
||||||
int channels;
|
int channels{};
|
||||||
float peak;
|
float peak{};
|
||||||
int type;
|
int type{};
|
||||||
bool is_squelch_active;
|
bool is_squelch_active{};
|
||||||
|
|
||||||
std::vector<float> data;
|
std::vector<float> data;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AudioThreadInput(AudioThreadInput *copyFrom) {
|
explicit AudioThreadInput(AudioThreadInput *copyFrom) {
|
||||||
copy(copyFrom);
|
copy(copyFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,9 +47,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual ~AudioThreadInput() {
|
virtual ~AudioThreadInput() = default;
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<AudioThreadInput> AudioThreadInputPtr;
|
typedef std::shared_ptr<AudioThreadInput> AudioThreadInputPtr;
|
||||||
@ -83,17 +81,17 @@ class AudioThread : public IOThread {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
AudioThread();
|
AudioThread();
|
||||||
virtual ~AudioThread();
|
~AudioThread() override;
|
||||||
|
|
||||||
static void enumerateDevices(std::vector<RtAudio::DeviceInfo> &devs);
|
static void enumerateDevices(std::vector<RtAudio::DeviceInfo> &devs);
|
||||||
|
|
||||||
void setInitOutputDevice(int deviceId, int sampleRate = -1);
|
void setInitOutputDevice(int deviceId, int sampleRate_in = -1);
|
||||||
int getOutputDevice();
|
int getOutputDevice();
|
||||||
|
|
||||||
int getSampleRate();
|
int getSampleRate();
|
||||||
|
|
||||||
virtual void run();
|
void run() override;
|
||||||
virtual void terminate();
|
void terminate() override;
|
||||||
|
|
||||||
bool isActive();
|
bool isActive();
|
||||||
void setActive(bool state);
|
void setActive(bool state);
|
||||||
@ -141,7 +139,7 @@ private:
|
|||||||
std::recursive_mutex m_mutex;
|
std::recursive_mutex m_mutex;
|
||||||
|
|
||||||
void setupDevice(int deviceId);
|
void setupDevice(int deviceId);
|
||||||
void setSampleRate(int sampleRate);
|
void setSampleRate(int sampleRate_in);
|
||||||
|
|
||||||
void bindThread(AudioThread *other);
|
void bindThread(AudioThread *other);
|
||||||
void removeThread(AudioThread *other);
|
void removeThread(AudioThread *other);
|
||||||
|
Loading…
Reference in New Issue
Block a user