diff --git a/src/main.cpp b/src/main.cpp index 48425379..a6962cb1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -195,8 +195,8 @@ wxString utTxFile; wxString utRxFile; wxString utTxFeatureFile; wxString utRxFeatureFile; -int utTxTimeSeconds; -int utTxAttempts; +long utTxTimeSeconds; +long utTxAttempts; // WxWidgets - initialize the application @@ -476,7 +476,7 @@ bool MainApp::OnCmdLineParsed(wxCmdLineParser& parser) log_info("Piping %s through TX pipeline", (const char*)utTxFile.ToUTF8()); } - if (parser.Found("txtime", (long*)&utTxTimeSeconds)) + if (parser.Found("txtime", &utTxTimeSeconds)) { log_info("Will transmit for %d seconds", utTxTimeSeconds); } @@ -485,7 +485,7 @@ bool MainApp::OnCmdLineParsed(wxCmdLineParser& parser) utTxTimeSeconds = 60; } - if (parser.Found("txattempts", (long*)&utTxAttempts)) + if (parser.Found("txattempts", &utTxAttempts)) { log_info("Will transmit %d time(s)", utTxAttempts); } diff --git a/src/pipeline/PlaybackStep.cpp b/src/pipeline/PlaybackStep.cpp index 09ec69d5..d239686f 100644 --- a/src/pipeline/PlaybackStep.cpp +++ b/src/pipeline/PlaybackStep.cpp @@ -45,8 +45,8 @@ PlaybackStep::PlaybackStep( // Pre-allocate buffers so we don't have to do so during real-time operation. auto maxSamples = std::max(getInputSampleRate(), getOutputSampleRate()); outputSamples_ = std::shared_ptr( - new short[maxSamples], - std::default_delete()); + AllocRealtime_(maxSamples), + RealtimeDeleter()); assert(outputSamples_ != nullptr); // Create output FIFO @@ -64,13 +64,9 @@ PlaybackStep::~PlaybackStep() { nonRtThread_.join(); } - - if (playbackResampler_ != nullptr) - { - delete playbackResampler_; - } codec2_fifo_destroy(outputFifo_); + outputSamples_ = nullptr; } int PlaybackStep::getInputSampleRate() const @@ -160,6 +156,12 @@ void PlaybackStep::nonRtThreadEntry_() std::this_thread::sleep_for(100ms); } + + if (playbackResampler_ != nullptr) + { + delete playbackResampler_; + playbackResampler_ = nullptr; + } } void PlaybackStep::reset() diff --git a/test/hamlibserver.py b/test/hamlibserver.py index 94b8d3b0..a7b86e85 100755 --- a/test/hamlibserver.py +++ b/test/hamlibserver.py @@ -322,11 +322,11 @@ class HamlibHandler: self.ErrParam() else: if (not x) and self.app.ptt: - # Sleep for 20ms to match typical SDR behavior + 30ms to account for varying system load/virtual audio latency. + # Sleep for 20ms to match typical SDR behavior + 60ms to account for varying system load/virtual audio latency. # References: - # Virtual audio latency: https://vb-audio.com/Cable/VBCABLE_ReferenceManual.pdf (assuming 10ms/512 sample buffer size @ 48 kHz) + # Virtual audio latency: https://vb-audio.com/Cable/VBCABLE_ReferenceManual.pdf (assuming 20ms/1024 sample buffer size @ 48 kHz) # Example TX->RX switching time: Flex 6000/8000 (https://community.flexradio.com/discussion/8028104/question-regarding-tx-delay) - time.sleep(50 / 1000) + time.sleep(80 / 1000) os.kill(self.pid, signal.SIGTERM) if x: self.app.ptt = 1