diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp index 954dbd6d..d4d76acb 100644 --- a/core/src/gui/main_window.cpp +++ b/core/src/gui/main_window.cpp @@ -362,21 +362,14 @@ void MainWindow::draw() { if (playing) { ImGui::PushID(ImGui::GetID("sdrpp_stop_btn")); if (ImGui::ImageButton(icons::STOP, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(GLFW_KEY_END, false)) { - playing = false; - onPlayStateChange.emit(false); - sigpath::sourceManager.stop(); - sigpath::signalPath.inputBuffer.flush(); + setPlayState(false); } ImGui::PopID(); } else { // TODO: Might need to check if there even is a device ImGui::PushID(ImGui::GetID("sdrpp_play_btn")); if (ImGui::ImageButton(icons::PLAY, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(GLFW_KEY_END, false)) { - sigpath::signalPath.inputBuffer.flush(); - sigpath::sourceManager.start(); - sigpath::sourceManager.tune(gui::waterfall.getCenterFrequency()); - playing = true; - onPlayStateChange.emit(true); + setPlayState(true); } ImGui::PopID(); } @@ -659,6 +652,23 @@ void MainWindow::draw() { } } +void MainWindow::setPlayState(bool _playing) { + if (_playing == playing) { return; } + if (_playing) { + sigpath::signalPath.inputBuffer.flush(); + sigpath::sourceManager.start(); + sigpath::sourceManager.tune(gui::waterfall.getCenterFrequency()); + playing = true; + onPlayStateChange.emit(true); + } + else { + playing = false; + onPlayStateChange.emit(false); + sigpath::sourceManager.stop(); + sigpath::signalPath.inputBuffer.flush(); + } +} + void MainWindow::setViewBandwidthSlider(float bandwidth) { bw = bandwidth; } diff --git a/core/src/gui/main_window.h b/core/src/gui/main_window.h index b2413cb1..265ee549 100644 --- a/core/src/gui/main_window.h +++ b/core/src/gui/main_window.h @@ -23,6 +23,7 @@ public: // TODO: Replace with it's own class void setVFO(double freq); + void setPlayState(bool _playing); bool isPlaying(); bool lockWaterfallControls = false; diff --git a/misc_modules/rigctl_server/src/main.cpp b/misc_modules/rigctl_server/src/main.cpp index 45911ecb..07535f8b 100644 --- a/misc_modules/rigctl_server/src/main.cpp +++ b/misc_modules/rigctl_server/src/main.cpp @@ -613,6 +613,12 @@ private: else if (parts[0] == "q" || parts[0] == "\\quit") { // Will close automatically } + else if (parts[0] == "\\start") { + gui::mainWindow.setPlayState(true); + } + else if (parts[0] == "\\stop") { + gui::mainWindow.setPlayState(false); + } else if (parts[0] == "\\dump_state") { std::lock_guard lck(vfoMtx); resp =