mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 12:07:49 +02:00
Formatted the entire codebase and added a CI check for formatting
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "audio_sink",
|
||||
/* Description: */ "Audio sink module for SDR++",
|
||||
/* Author: */ "Ryzerth",
|
||||
@ -59,7 +59,6 @@ public:
|
||||
}
|
||||
|
||||
~AudioSink() {
|
||||
|
||||
}
|
||||
|
||||
void start() {
|
||||
@ -131,12 +130,12 @@ public:
|
||||
if (running) { doStop(); }
|
||||
if (running) { doStart(); }
|
||||
}
|
||||
|
||||
|
||||
void menuHandler() {
|
||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||
|
||||
ImGui::SetNextItemWidth(menuWidth);
|
||||
if (ImGui::Combo(("##_audio_sink_dev_"+_streamName).c_str(), &devId, txtDevList.c_str())) {
|
||||
if (ImGui::Combo(("##_audio_sink_dev_" + _streamName).c_str(), &devId, txtDevList.c_str())) {
|
||||
selectById(devId);
|
||||
config.acquire();
|
||||
config.conf[_streamName]["device"] = devList[devId].name;
|
||||
@ -144,7 +143,7 @@ public:
|
||||
}
|
||||
|
||||
ImGui::SetNextItemWidth(menuWidth);
|
||||
if (ImGui::Combo(("##_audio_sink_sr_"+_streamName).c_str(), &srId, sampleRatesTxt.c_str())) {
|
||||
if (ImGui::Combo(("##_audio_sink_sr_" + _streamName).c_str(), &srId, sampleRatesTxt.c_str())) {
|
||||
sampleRate = sampleRates[srId];
|
||||
_stream->setSampleRate(sampleRate);
|
||||
if (running) {
|
||||
@ -173,7 +172,7 @@ private:
|
||||
audio.startStream();
|
||||
stereoPacker.start();
|
||||
}
|
||||
catch ( RtAudioError& e ) {
|
||||
catch (RtAudioError& e) {
|
||||
spdlog::error("Could not open audio device");
|
||||
return;
|
||||
}
|
||||
@ -193,7 +192,7 @@ private:
|
||||
stereoPacker.out.clearReadStop();
|
||||
}
|
||||
|
||||
static int callback( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData) {
|
||||
static int callback(void* outputBuffer, void* inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void* userData) {
|
||||
AudioSink* _this = (AudioSink*)userData;
|
||||
int count = _this->stereoPacker.out.read();
|
||||
if (count < 0) { return 0; }
|
||||
@ -210,7 +209,7 @@ private:
|
||||
_this->stereoPacker.out.flush();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
SinkManager::Stream* _stream;
|
||||
dsp::StereoToMono s2m;
|
||||
dsp::Packer<float> monoPacker;
|
||||
@ -234,7 +233,6 @@ private:
|
||||
unsigned int sampleRate = 48000;
|
||||
|
||||
RtAudio audio;
|
||||
|
||||
};
|
||||
|
||||
class AudioSinkModule : public ModuleManager::Instance {
|
||||
@ -274,7 +272,6 @@ private:
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
SinkManager::SinkProvider provider;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "network_sink",
|
||||
/* Description: */ "Network sink module for SDR++",
|
||||
/* Author: */ "Ryzerth",
|
||||
@ -61,7 +61,7 @@ public:
|
||||
s2m.init(&packer.out);
|
||||
monoSink.init(&s2m.out, monoHandler, this);
|
||||
stereoSink.init(&packer.out, stereoHandler, this);
|
||||
|
||||
|
||||
|
||||
// Create a list of sample rates
|
||||
for (int sr = 12000; sr < 200000; sr += 12000) {
|
||||
@ -83,11 +83,17 @@ public:
|
||||
sprintf(buffer, "%d", (int)sr);
|
||||
sampleRatesTxt += buffer;
|
||||
sampleRatesTxt += '\0';
|
||||
if (sr == sampleRate) { srId = id; found = true; }
|
||||
if (sr == sampleRate) {
|
||||
srId = id;
|
||||
found = true;
|
||||
}
|
||||
if (sr == 48000.0) { _48kId = id; }
|
||||
id++;
|
||||
}
|
||||
if (!found) { srId = _48kId; sampleRate = 48000.0; }
|
||||
if (!found) {
|
||||
srId = _48kId;
|
||||
sampleRate = 48000.0;
|
||||
}
|
||||
_stream->setSampleRate(sampleRate);
|
||||
|
||||
// Start if needed
|
||||
@ -220,7 +226,7 @@ private:
|
||||
conn = net::openUDP("0.0.0.0", port, hostname, port, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void stopServer() {
|
||||
if (conn) { conn->close(); }
|
||||
if (listener) { listener->close(); }
|
||||
@ -230,10 +236,10 @@ private:
|
||||
NetworkSink* _this = (NetworkSink*)ctx;
|
||||
std::lock_guard lck(_this->connMtx);
|
||||
if (!_this->conn || !_this->conn->isOpen()) { return; }
|
||||
|
||||
|
||||
volk_32f_s32f_convert_16i(_this->netBuf, (float*)samples, 32768.0f, count);
|
||||
|
||||
_this->conn->write(count*sizeof(int16_t), (uint8_t*)_this->netBuf);
|
||||
_this->conn->write(count * sizeof(int16_t), (uint8_t*)_this->netBuf);
|
||||
}
|
||||
|
||||
static void stereoHandler(dsp::stereo_t* samples, int count, void* ctx) {
|
||||
@ -241,9 +247,9 @@ private:
|
||||
std::lock_guard lck(_this->connMtx);
|
||||
if (!_this->conn || !_this->conn->isOpen()) { return; }
|
||||
|
||||
volk_32f_s32f_convert_16i(_this->netBuf, (float*)samples, 32768.0f, count*2);
|
||||
volk_32f_s32f_convert_16i(_this->netBuf, (float*)samples, 32768.0f, count * 2);
|
||||
|
||||
_this->conn->write(count*2*sizeof(int16_t), (uint8_t*)_this->netBuf);
|
||||
_this->conn->write(count * 2 * sizeof(int16_t), (uint8_t*)_this->netBuf);
|
||||
}
|
||||
|
||||
static void clientHandler(net::Conn client, void* ctx) {
|
||||
@ -259,12 +265,11 @@ private:
|
||||
_this->conn->close();
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
_this->listener->acceptAsync(clientHandler, _this);
|
||||
}
|
||||
|
||||
|
||||
SinkManager::Stream* _stream;
|
||||
dsp::Packer<dsp::stereo_t> packer;
|
||||
dsp::StereoToMono s2m;
|
||||
@ -291,7 +296,6 @@ private:
|
||||
net::Listener listener;
|
||||
net::Conn conn;
|
||||
std::mutex connMtx;
|
||||
|
||||
};
|
||||
|
||||
class NetworkSinkModule : public ModuleManager::Instance {
|
||||
@ -331,7 +335,6 @@ private:
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
SinkManager::SinkProvider provider;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
#define BLOCK_SIZE_DIVIDER 60
|
||||
#define AUDIO_LATENCY 1.0 / 60.0
|
||||
#define BLOCK_SIZE_DIVIDER 60
|
||||
#define AUDIO_LATENCY 1.0 / 60.0
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "new_portaudio_sink",
|
||||
/* Description: */ "Audio sink module for SDR++",
|
||||
/* Author: */ "Ryzerth;Maxime Biette",
|
||||
@ -37,7 +37,7 @@ public:
|
||||
std::vector<double> sampleRates;
|
||||
std::string sampleRatesTxt;
|
||||
};
|
||||
|
||||
|
||||
AudioSink(SinkManager::Stream* stream, std::string streamName) {
|
||||
_stream = stream;
|
||||
_streamName = streamName;
|
||||
@ -72,7 +72,7 @@ public:
|
||||
|
||||
void start() {
|
||||
if (running || selectedDevName.empty()) { return; }
|
||||
|
||||
|
||||
// Get device and samplerate
|
||||
AudioDevice_t& dev = devices[deviceNames[devId]];
|
||||
double sampleRate = dev.sampleRates[srId];
|
||||
@ -80,7 +80,7 @@ public:
|
||||
|
||||
// Set the SDR++ stream sample rate
|
||||
_stream->setSampleRate(sampleRate);
|
||||
|
||||
|
||||
// Update the block size on the packer
|
||||
packer.setSampleCount(blockSize);
|
||||
|
||||
@ -126,7 +126,7 @@ public:
|
||||
// Stop DSP
|
||||
packer.stop();
|
||||
s2m.stop();
|
||||
|
||||
|
||||
// Stop stream
|
||||
Pa_AbortStream(devStream);
|
||||
|
||||
@ -135,7 +135,7 @@ public:
|
||||
|
||||
running = false;
|
||||
}
|
||||
|
||||
|
||||
void menuHandler() {
|
||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||
|
||||
@ -327,13 +327,13 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static int _mono_cb(const void *input, void *output, unsigned long frameCount,
|
||||
const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) {
|
||||
static int _mono_cb(const void* input, void* output, unsigned long frameCount,
|
||||
const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* userData) {
|
||||
AudioSink* _this = (AudioSink*)userData;
|
||||
|
||||
|
||||
// For OSX, mute audio when not playing
|
||||
if (!gui::mainWindow.isPlaying()) {
|
||||
memset(output, 0, frameCount*sizeof(float));
|
||||
if (!gui::mainWindow.isPlaying()) {
|
||||
memset(output, 0, frameCount * sizeof(float));
|
||||
_this->s2m.out.flush();
|
||||
return 0;
|
||||
}
|
||||
@ -345,13 +345,13 @@ private:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _stereo_cb(const void *input, void *output, unsigned long frameCount,
|
||||
const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) {
|
||||
static int _stereo_cb(const void* input, void* output, unsigned long frameCount,
|
||||
const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* userData) {
|
||||
AudioSink* _this = (AudioSink*)userData;
|
||||
|
||||
|
||||
// For OSX, mute audio when not playing
|
||||
if (!gui::mainWindow.isPlaying()) {
|
||||
memset(output, 0, frameCount*sizeof(dsp::stereo_t));
|
||||
if (!gui::mainWindow.isPlaying()) {
|
||||
memset(output, 0, frameCount * sizeof(dsp::stereo_t));
|
||||
_this->packer.out.flush();
|
||||
return 0;
|
||||
}
|
||||
@ -377,7 +377,7 @@ private:
|
||||
dsp::Packer<dsp::stereo_t> packer;
|
||||
dsp::StereoToMono s2m;
|
||||
|
||||
PaStream *devStream;
|
||||
PaStream* devStream;
|
||||
|
||||
EventHandler<bool> playStateHandler;
|
||||
};
|
||||
@ -421,7 +421,6 @@ private:
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
SinkManager::SinkProvider provider;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "audio_sink",
|
||||
/* Description: */ "Audio sink module for SDR++",
|
||||
/* Author: */ "Ryzerth",
|
||||
@ -28,7 +28,7 @@ public:
|
||||
std::vector<double> sampleRates;
|
||||
std::string txtSampleRates;
|
||||
};
|
||||
|
||||
|
||||
AudioSink(SinkManager::Stream* stream, std::string streamName) {
|
||||
_stream = stream;
|
||||
_streamName = streamName;
|
||||
@ -42,13 +42,13 @@ public:
|
||||
// Initialize PortAudio
|
||||
devCount = Pa_GetDeviceCount();
|
||||
devId = Pa_GetDefaultOutputDevice();
|
||||
const PaDeviceInfo *deviceInfo;
|
||||
const PaDeviceInfo* deviceInfo;
|
||||
PaStreamParameters outputParams;
|
||||
outputParams.sampleFormat = paFloat32;
|
||||
outputParams.hostApiSpecificStreamInfo = NULL;
|
||||
|
||||
// Gather hardware info
|
||||
for(int i = 0; i < devCount; i++) {
|
||||
for (int i = 0; i < devCount; i++) {
|
||||
deviceInfo = Pa_GetDeviceInfo(i);
|
||||
if (deviceInfo->maxOutputChannels < 1) {
|
||||
continue;
|
||||
@ -114,12 +114,12 @@ public:
|
||||
doStop();
|
||||
running = false;
|
||||
}
|
||||
|
||||
|
||||
void menuHandler() {
|
||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||
|
||||
ImGui::SetNextItemWidth(menuWidth);
|
||||
if (ImGui::Combo(("##_audio_sink_dev_"+_streamName).c_str(), &devListId, txtDevList.c_str())) {
|
||||
if (ImGui::Combo(("##_audio_sink_dev_" + _streamName).c_str(), &devListId, txtDevList.c_str())) {
|
||||
// TODO: Load SR from config
|
||||
if (running) {
|
||||
doStop();
|
||||
@ -131,7 +131,7 @@ public:
|
||||
AudioDevice_t* dev = devices[devListId];
|
||||
|
||||
ImGui::SetNextItemWidth(menuWidth);
|
||||
if (ImGui::Combo(("##_audio_sink_sr_"+_streamName).c_str(), &dev->srId, dev->txtSampleRates.c_str())) {
|
||||
if (ImGui::Combo(("##_audio_sink_sr_" + _streamName).c_str(), &dev->srId, dev->txtSampleRates.c_str())) {
|
||||
_stream->setSampleRate(dev->sampleRates[dev->srId]);
|
||||
if (running) {
|
||||
doStop();
|
||||
@ -143,7 +143,7 @@ public:
|
||||
|
||||
private:
|
||||
void doStart() {
|
||||
const PaDeviceInfo *deviceInfo;
|
||||
const PaDeviceInfo* deviceInfo;
|
||||
AudioDevice_t* dev = devices[devListId];
|
||||
PaStreamParameters outputParams;
|
||||
deviceInfo = Pa_GetDeviceInfo(dev->index);
|
||||
@ -206,22 +206,22 @@ private:
|
||||
// stereoPacker.out.clearWriteStop();
|
||||
}
|
||||
|
||||
static int _mono_cb(const void *input, void *output, unsigned long frameCount,
|
||||
const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) {
|
||||
static int _mono_cb(const void* input, void* output, unsigned long frameCount,
|
||||
const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* userData) {
|
||||
AudioSink* _this = (AudioSink*)userData;
|
||||
if (!gui::mainWindow.isPlaying()) {
|
||||
memset(output, 0, frameCount*sizeof(float));
|
||||
if (!gui::mainWindow.isPlaying()) {
|
||||
memset(output, 0, frameCount * sizeof(float));
|
||||
return 0;
|
||||
}
|
||||
_this->monoRB.data.read((float*)output, frameCount);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _stereo_cb(const void *input, void *output, unsigned long frameCount,
|
||||
const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) {
|
||||
static int _stereo_cb(const void* input, void* output, unsigned long frameCount,
|
||||
const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* userData) {
|
||||
AudioSink* _this = (AudioSink*)userData;
|
||||
if (!gui::mainWindow.isPlaying()) {
|
||||
memset(output, 0, frameCount*sizeof(dsp::stereo_t));
|
||||
if (!gui::mainWindow.isPlaying()) {
|
||||
memset(output, 0, frameCount * sizeof(dsp::stereo_t));
|
||||
return 0;
|
||||
}
|
||||
_this->stereoRB.data.read((dsp::stereo_t*)output, frameCount);
|
||||
@ -245,8 +245,8 @@ private:
|
||||
// _this->stereoPacker.out.flush();
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
SinkManager::Stream* _stream;
|
||||
dsp::StereoToMono s2m;
|
||||
dsp::RingBufferSink<float> monoRB;
|
||||
@ -256,7 +256,7 @@ private:
|
||||
// dsp::Packer<dsp::stereo_t> stereoPacker;
|
||||
|
||||
std::string _streamName;
|
||||
PaStream *stream;
|
||||
PaStream* stream;
|
||||
|
||||
int srId = 0;
|
||||
int devCount;
|
||||
@ -277,7 +277,6 @@ private:
|
||||
std::vector<AudioDevice_t*> devices;
|
||||
std::vector<std::string> deviceNames;
|
||||
std::string txtDevList;
|
||||
|
||||
};
|
||||
|
||||
class AudioSinkModule : public ModuleManager::Instance {
|
||||
@ -319,7 +318,6 @@ private:
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
SinkManager::SinkProvider provider;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
@ -333,9 +331,7 @@ MOD_EXPORT void* _CREATE_INSTANCE_(std::string name) {
|
||||
}
|
||||
|
||||
MOD_EXPORT void _DELETE_INSTANCE_() {
|
||||
|
||||
}
|
||||
|
||||
MOD_EXPORT void _END_() {
|
||||
|
||||
}
|
Reference in New Issue
Block a user