mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 12:07:49 +02:00
Push before potential f*ck up
This commit is contained in:
@ -26,6 +26,7 @@
|
||||
#include <gui/menus/source.h>
|
||||
#include <gui/menus/display.h>
|
||||
#include <gui/menus/bandplan.h>
|
||||
#include <gui/menus/sink.h>
|
||||
#include <gui/menus/audio.h>
|
||||
#include <gui/menus/scripting.h>
|
||||
#include <gui/dialogs/credits.h>
|
||||
@ -95,6 +96,7 @@ void windowInit() {
|
||||
core::configManager.release();
|
||||
|
||||
gui::menu.registerEntry("Source", sourecmenu::draw, NULL);
|
||||
gui::menu.registerEntry("Sinks", sinkmenu::draw, NULL);
|
||||
gui::menu.registerEntry("Audio", audiomenu::draw, NULL);
|
||||
gui::menu.registerEntry("Scripting", scriptingmenu::draw, NULL);
|
||||
gui::menu.registerEntry("Band Plan", bandplanmenu::draw, NULL);
|
||||
@ -117,6 +119,7 @@ void windowInit() {
|
||||
mod::loadFromList(ROOT_DIR "/module_list.json");
|
||||
|
||||
sourecmenu::init();
|
||||
sinkmenu::init();
|
||||
audiomenu::init();
|
||||
scriptingmenu::init();
|
||||
bandplanmenu::init();
|
||||
|
@ -3,8 +3,12 @@
|
||||
#include <imgui/imgui.h>
|
||||
#include <core.h>
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SinkManager::SinkManager() {
|
||||
|
||||
SinkManager::SinkProvider prov;
|
||||
prov.create = SinkManager::NullSink::create;
|
||||
registerSinkProvider("None", prov);
|
||||
}
|
||||
|
||||
SinkManager::Stream::Stream(dsp::stream<dsp::stereo_t>* in, const Event<float>::EventHandler& srChangeHandler, float sampleRate) {
|
||||
@ -15,11 +19,19 @@ SinkManager::Stream::Stream(dsp::stream<dsp::stereo_t>* in, const Event<float>::
|
||||
}
|
||||
|
||||
void SinkManager::Stream::start() {
|
||||
if (running) {
|
||||
return;
|
||||
}
|
||||
sink->start();
|
||||
running = true;
|
||||
}
|
||||
|
||||
void SinkManager::Stream::stop() {
|
||||
if (!running) {
|
||||
return;
|
||||
}
|
||||
sink->stop();
|
||||
running = false;
|
||||
}
|
||||
|
||||
void SinkManager::Stream::setInput(dsp::stream<dsp::stereo_t>* in) {
|
||||
@ -72,7 +84,7 @@ void SinkManager::registerStream(std::string name, SinkManager::Stream* stream)
|
||||
provider = providers[providerName];
|
||||
}
|
||||
|
||||
stream->sink = provider.create(stream, provider.ctx);
|
||||
stream->sink = provider.create(stream, name, provider.ctx);
|
||||
}
|
||||
|
||||
void SinkManager::unregisterStream(std::string name) {
|
||||
@ -136,8 +148,16 @@ void SinkManager::showMenu() {
|
||||
ImGui::SetCursorPosX((menuWidth / 2.0f) - (ImGui::CalcTextSize(name.c_str()).x / 2.0f));
|
||||
ImGui::Text("%s", name.c_str());
|
||||
|
||||
if (ImGui::Combo("", &stream->providerId, provStr.c_str())) {
|
||||
|
||||
if (ImGui::Combo(CONCAT("##_sdrpp_sink_select_", name), &stream->providerId, provStr.c_str())) {
|
||||
if (stream->running) {
|
||||
stream->sink->stop();
|
||||
}
|
||||
delete stream->sink;
|
||||
SinkManager::SinkProvider prov = providers[providerNames[stream->providerId]];
|
||||
stream->sink = prov.create(stream, name, prov.ctx);
|
||||
if (stream->running) {
|
||||
stream->sink->start();
|
||||
}
|
||||
}
|
||||
|
||||
stream->sink->menuHandler();
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <dsp/stream.h>
|
||||
#include <dsp/types.h>
|
||||
#include <dsp/routing.h>
|
||||
#include <dsp/sink.h>
|
||||
#include <mutex>
|
||||
#include <event.h>
|
||||
#include <vector>
|
||||
@ -34,25 +35,36 @@ public:
|
||||
friend SinkManager;
|
||||
friend SinkManager::Sink;
|
||||
|
||||
Event<float> srChange;
|
||||
SinkManager::Sink* sink;
|
||||
int providerId = 0;
|
||||
Event<float> srChange;
|
||||
|
||||
private:
|
||||
void setSampleRate(float sampleRate);
|
||||
|
||||
dsp::stream<dsp::stereo_t>* _in;
|
||||
dsp::Splitter<dsp::stereo_t> splitter;
|
||||
SinkManager::Sink* sink;
|
||||
std::mutex ctrlMtx;
|
||||
float _sampleRate;
|
||||
|
||||
int providerId = 0;
|
||||
bool running = false;
|
||||
};
|
||||
|
||||
struct SinkProvider {
|
||||
SinkManager::Sink* (*create)(SinkManager::Stream* stream, void* ctx);
|
||||
SinkManager::Sink* (*create)(SinkManager::Stream* stream, std::string streamName, void* ctx);
|
||||
void* ctx;
|
||||
};
|
||||
|
||||
class NullSink : SinkManager::Sink {
|
||||
public:
|
||||
void start() {}
|
||||
void stop() {}
|
||||
void menuHandler() {}
|
||||
|
||||
static SinkManager::Sink* create(SinkManager::Stream* stream, std::string streamName, void* ctx) {
|
||||
return new SinkManager::NullSink;
|
||||
}
|
||||
};
|
||||
|
||||
void registerSinkProvider(std::string name, SinkProvider provider);
|
||||
|
||||
void registerStream(std::string name, Stream* stream);
|
||||
|
Reference in New Issue
Block a user