Formatted the entire codebase and added a CI check for formatting

This commit is contained in:
AlexandreRouma
2021-12-19 22:11:44 +01:00
parent 8644957881
commit ea587db0cb
161 changed files with 3302 additions and 3393 deletions

View File

@ -10,7 +10,7 @@
#define CONCAT(a, b) ((std::string(a) + b).c_str())
SDRPP_MOD_INFO {
SDRPP_MOD_INFO{
/* Name: */ "rtl_tcp_source",
/* Description: */ "RTL-TCP source module for SDR++",
/* Author: */ "Ryzerth",
@ -48,7 +48,7 @@ const char* sampleRatesTxt[] = {
"3.2MHz"
};
#define SAMPLE_RATE_COUNT (sizeof(sampleRates) / sizeof(double))
#define SAMPLE_RATE_COUNT (sizeof(sampleRates) / sizeof(double))
class RTLTCPSourceModule : public ModuleManager::Instance {
public:
@ -135,7 +135,7 @@ private:
RTLTCPSourceModule* _this = (RTLTCPSourceModule*)ctx;
spdlog::info("RTLTCPSourceModule '{0}': Menu Deselect!", _this->name);
}
static void start(void* ctx) {
RTLTCPSourceModule* _this = (RTLTCPSourceModule*)ctx;
if (_this->running) { return; }
@ -160,12 +160,12 @@ private:
// Setting it twice because for some reason it refuses to do it on the first time
_this->client.setGainIndex(_this->gain);
}
_this->running = true;
_this->workerThread = std::thread(worker, _this);
spdlog::info("RTLTCPSourceModule '{0}': Start!", _this->name);
}
static void stop(void* ctx) {
RTLTCPSourceModule* _this = (RTLTCPSourceModule*)ctx;
if (!_this->running) { return; }
@ -176,7 +176,7 @@ private:
_this->client.disconnect();
spdlog::info("RTLTCPSourceModule '{0}': Stop!", _this->name);
}
static void tune(double freq, void* ctx) {
RTLTCPSourceModule* _this = (RTLTCPSourceModule*)ctx;
if (_this->running) {
@ -185,7 +185,7 @@ private:
_this->freq = freq;
spdlog::info("RTLTCPSourceModule '{0}': Tune: {1}!", _this->name, freq);
}
static void menuHandler(void* ctx) {
RTLTCPSourceModule* _this = (RTLTCPSourceModule*)ctx;
float menuWidth = ImGui::GetContentRegionAvailWidth();
@ -338,20 +338,20 @@ private:
};
MOD_EXPORT void _INIT_() {
config.setPath(options::opts.root + "/rtl_tcp_config.json");
json defConf;
defConf["host"] = "localhost";
defConf["port"] = 1234;
defConf["sampleRate"] = 2400000.0;
defConf["directSamplingMode"] = 0;
defConf["ppm"] = 0;
defConf["rtlAGC"] = false;
defConf["tunerAGC"] = false;
defConf["gainIndex"] = 0;
defConf["biasTee"] = false;
defConf["offsetTuning"] = false;
config.load(defConf);
config.enableAutoSave();
config.setPath(options::opts.root + "/rtl_tcp_config.json");
json defConf;
defConf["host"] = "localhost";
defConf["port"] = 1234;
defConf["sampleRate"] = 2400000.0;
defConf["directSamplingMode"] = 0;
defConf["ppm"] = 0;
defConf["rtlAGC"] = false;
defConf["tunerAGC"] = false;
defConf["gainIndex"] = 0;
defConf["biasTee"] = false;
defConf["offsetTuning"] = false;
config.load(defConf);
config.enableAutoSave();
config.acquire();
if (!config.conf.contains("biasTee")) {

View File

@ -12,17 +12,17 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <netdb.h>
#endif
#ifdef _WIN32
#define __attribute__(x)
#pragma pack(push, 1)
#endif
struct command_t{
unsigned char cmd;
unsigned int param;
}__attribute__((packed));
struct command_t {
unsigned char cmd;
unsigned int param;
} __attribute__((packed));
#ifdef _WIN32
#pragma pack(pop)
#endif
@ -30,7 +30,6 @@ struct command_t{
class RTLTCPClient {
public:
RTLTCPClient() {
}
bool connectToRTL(char* host, uint16_t port) {
@ -39,14 +38,14 @@ public:
}
#ifdef _WIN32
struct addrinfo *result = NULL;
struct addrinfo *ptr = NULL;
struct addrinfo* result = NULL;
struct addrinfo* ptr = NULL;
struct addrinfo hints;
WSADATA wsaData;
WSAStartup(MAKEWORD(2,2), &wsaData);
WSAStartup(MAKEWORD(2, 2), &wsaData);
ZeroMemory( &hints, sizeof(hints) );
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
@ -88,13 +87,13 @@ public:
// TODO: Log error
return false;
}
struct hostent *server = gethostbyname(host);
struct hostent* server = gethostbyname(host);
struct sockaddr_in serv_addr;
bzero(&serv_addr, sizeof(struct sockaddr_in));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
bcopy((char*)server->h_addr, (char*)&serv_addr.sin_addr.s_addr, server->h_length);
serv_addr.sin_port = htons(port);
if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0) {
if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
// TODO: log error
return false;
}
@ -130,7 +129,7 @@ public:
cmd.cmd = command;
cmd.param = htonl(param);
#ifdef _WIN32
send(sock, (char*)&cmd, sizeof(command_t), 0);
send(sock, (char*)&cmd, sizeof(command_t), 0);
#else
(void)write(sockfd, &cmd, sizeof(command_t));
#endif
@ -196,7 +195,6 @@ private:
#else
int sockfd;
#endif
bool connected = false;
bool connected = false;
};