From dd2072b28e25fed2b0d0e88f1c5c23875f129083 Mon Sep 17 00:00:00 2001 From: BearOso Date: Fri, 7 Jul 2023 14:13:17 -0500 Subject: [PATCH] Fix silence adder. --- apu/resampler.h | 19 +++++++++---------- qt/src/FoldersPanel.cpp | 8 +++++++- vulkan/std_chrono_throttle.cpp | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apu/resampler.h b/apu/resampler.h index b4c83949..89859945 100644 --- a/apu/resampler.h +++ b/apu/resampler.h @@ -99,19 +99,18 @@ class Resampler inline void add_silence(unsigned int num_samples) { - if ((unsigned int)space_empty() <= num_samples) - { - int new_end = (end + num_samples) % buffer_size; + if ((unsigned int)space_empty() < num_samples) + return; - if (new_end < end) - { - memset(buffer + end, 0, 2 * (buffer_size - end)); - memset(buffer, 0, 2 * (num_samples - (buffer_size - end))); - } + int new_end = (end + num_samples) % buffer_size; - memset(buffer + end, 0, 2 * num_samples); - end = new_end; + if (new_end < end) { + memset(buffer + end, 0, 2 * (buffer_size - end)); + memset(buffer, 0, 2 * (num_samples - (buffer_size - end))); } + + memset(buffer + end, 0, 2 * num_samples); + end = new_end; } inline bool pull(int16_t *dst, int num_samples) diff --git a/qt/src/FoldersPanel.cpp b/qt/src/FoldersPanel.cpp index 6f7ccd32..0ef79023 100644 --- a/qt/src/FoldersPanel.cpp +++ b/qt/src/FoldersPanel.cpp @@ -53,7 +53,13 @@ void FoldersPanel::refreshEntry(QComboBox *combo, QLineEdit *lineEdit, QPushButt { bool custom = (*location == EmuConfig::eCustomDirectory); combo->setCurrentIndex(*location); - lineEdit->setText(custom ? QString::fromUtf8(*folder) : ""); + if (custom) + lineEdit->setText(QString::fromUtf8(*folder)); + else if (*location == EmuConfig::eConfigDirectory) + lineEdit->setText(tr("Config folder is %1").arg(app->config->findConfigDir().c_str())); + else + lineEdit->clear(); + lineEdit->setEnabled(custom); browse->setEnabled(custom); diff --git a/vulkan/std_chrono_throttle.cpp b/vulkan/std_chrono_throttle.cpp index ddce52cf..c83af954 100644 --- a/vulkan/std_chrono_throttle.cpp +++ b/vulkan/std_chrono_throttle.cpp @@ -29,7 +29,7 @@ void Throttle::wait_for_frame() auto time_to_wait = remaining(); - if (time_to_wait < -frame_duration_us / 10) + if (time_to_wait < -frame_duration_us) { reset(); return; @@ -57,7 +57,7 @@ void Throttle::wait_for_frame() { auto time_to_wait = remaining(); - if (time_to_wait < -frame_duration_us / 10) + if (time_to_wait < -frame_duration_us) { reset(); return;