SDR++ server beta :)

This commit is contained in:
AlexandreRouma
2022-01-21 20:22:13 +01:00
parent 1185e4e114
commit 74b9d13360
37 changed files with 2731 additions and 498 deletions

View File

@ -9,6 +9,7 @@
#include <config.h>
#include <options.h>
#include <gui/widgets/stepped_slider.h>
#include <gui/smgui.h>
#define CONCAT(a, b) ((std::string(a) + b).c_str())
@ -155,28 +156,29 @@ private:
static void menuHandler(void* ctx) {
SpyServerSourceModule* _this = (SpyServerSourceModule*)ctx;
float menuWidth = ImGui::GetContentRegionAvailWidth();
bool connected = (_this->client && _this->client->isOpen());
gui::mainWindow.playButtonLocked = !connected;
if (connected) { style::beginDisabled(); }
if (ImGui::InputText(CONCAT("##_spyserver_srv_host_", _this->name), _this->hostname, 1023)) {
if (connected) { SmGui::BeginDisabled(); }
if (SmGui::InputText(CONCAT("##_spyserver_srv_host_", _this->name), _this->hostname, 1023)) {
config.acquire();
config.conf["hostname"] = _this->hostname;
config.release(true);
}
ImGui::SameLine();
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::InputInt(CONCAT("##_spyserver_srv_port_", _this->name), &_this->port, 0, 0)) {
SmGui::SameLine();
SmGui::FillWidth();
if (SmGui::InputInt(CONCAT("##_spyserver_srv_port_", _this->name), &_this->port, 0, 0)) {
config.acquire();
config.conf["port"] = _this->port;
config.release(true);
}
if (connected) { style::endDisabled(); }
if (connected) { SmGui::EndDisabled(); }
if (_this->running) { style::beginDisabled(); }
if (!connected && ImGui::Button("Connect##spyserver_source", ImVec2(menuWidth, 0))) {
if (_this->running) { SmGui::BeginDisabled(); }
SmGui::FillWidth();
SmGui::ForceSync();
if (!connected && SmGui::Button("Connect##spyserver_source")) {
try {
if (_this->client) { _this->client.reset(); }
_this->client = spyserver::connect(_this->hostname, _this->port, &_this->stream);
@ -223,17 +225,17 @@ private:
spdlog::error("Could not connect to spyserver {0}", e.what());
}
}
else if (connected && ImGui::Button("Disconnect##spyserver_source", ImVec2(menuWidth, 0))) {
else if (connected && SmGui::Button("Disconnect##spyserver_source")) {
_this->client->close();
}
if (_this->running) { style::endDisabled(); }
if (_this->running) { SmGui::EndDisabled(); }
if (connected) {
if (_this->running) { style::beginDisabled(); }
ImGui::LeftLabel("Samplerate");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::Combo("##spyserver_source_sr", &_this->srId, _this->sampleRatesTxt.c_str())) {
SmGui::LeftLabel("Samplerate");
SmGui::FillWidth();
if (SmGui::Combo("##spyserver_source_sr", &_this->srId, _this->sampleRatesTxt.c_str())) {
_this->sampleRate = _this->sampleRates[_this->srId];
core::setInputSampleRate(_this->sampleRate);
config.acquire();
@ -242,9 +244,9 @@ private:
}
if (_this->running) { style::endDisabled(); }
ImGui::LeftLabel("Sample bit depth");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::Combo("##spyserver_source_type", &_this->iqType, streamFormatStr)) {
SmGui::LeftLabel("Sample bit depth");
SmGui::FillWidth();
if (SmGui::Combo("##spyserver_source_type", &_this->iqType, streamFormatStr)) {
int srvBits = streamFormatsBitCount[_this->iqType];
_this->client->setSetting(SPYSERVER_SETTING_IQ_FORMAT, streamFormats[_this->iqType]);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->client->computeDigitalGain(srvBits, _this->gain, _this->srId + _this->client->devInfo.MinimumIQDecimation));
@ -255,8 +257,8 @@ private:
}
if (_this->client->devInfo.MaximumGainIndex) {
ImGui::SetNextItemWidth(menuWidth);
if (ImGui::SliderInt("##spyserver_source_gain", (int*)&_this->gain, 0, _this->client->devInfo.MaximumGainIndex)) {
SmGui::FillWidth();
if (SmGui::SliderInt("##spyserver_source_gain", (int*)&_this->gain, 0, _this->client->devInfo.MaximumGainIndex)) {
int srvBits = streamFormatsBitCount[_this->iqType];
_this->client->setSetting(SPYSERVER_SETTING_GAIN, _this->gain);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->client->computeDigitalGain(srvBits, _this->gain, _this->srId + _this->client->devInfo.MinimumIQDecimation));
@ -266,14 +268,14 @@ private:
}
}
ImGui::Text("Status:");
ImGui::SameLine();
SmGui::Text("Status:");
SmGui::SameLine();
ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "Connected (%s)", deviceTypesStr[_this->client->devInfo.DeviceType]);
}
else {
ImGui::Text("Status:");
ImGui::SameLine();
ImGui::Text("Not connected");
SmGui::Text("Status:");
SmGui::SameLine();
SmGui::Text("Not connected");
}
}