Apply shared audio changes without resetting saved preferences

This commit is contained in:
evgeny committed 2026-10-03 13:13:28 +03:00
1 parent afbce0efeb
commit 625846fa33
3 files changed
+11 -6

No files matched your search

+6 -4
View File
@@ -96,8 +96,8 @@ bool RadioAudioEngine::applySettings(const QMap<QString, int>& values) {
}
next[index] = it.value();
}
if (next == m_settings) return true;
if (!m_configPath.isEmpty()) {
if (next == m_settings && !m_active) return true;
if (next != m_settings && !m_configPath.isEmpty()) {
QFile input(m_configPath);
if (!input.open(QIODevice::ReadOnly)) {
m_settingsError = QStringLiteral("Не удалось прочитать конфигурацию: %1").arg(input.errorString());
@@ -154,7 +154,8 @@ void RadioAudioEngine::postSettings(const std::array<int, 6>& values, bool apply
}
auto* engine = request->engine;
auto snapshot = request->values;
QMetaObject::invokeMethod(engine, [engine, snapshot, success]() {
bool apply = request->apply;
QMetaObject::invokeMethod(engine, [engine, snapshot, success, apply]() {
bool changed = engine->m_settings != snapshot;
engine->m_settings = snapshot;
engine->m_settingsReady = true;
@@ -162,7 +163,7 @@ void RadioAudioEngine::postSettings(const std::array<int, 6>& values, bool apply
if (!success) engine->m_settingsError = QStringLiteral("Ядро отклонило настройки рации");
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "RadioAudio: settings applied=%d vad=%d threshold=%d hangover=%dms TX_AGC=%d "
"TX_gain=%ddB VAD_gain=%ddB", success, snapshot[0], snapshot[1], snapshot[2], snapshot[3], snapshot[4], snapshot[5]);
if (changed && engine->m_active) engine->reconfigureCapture();
if ((changed || apply) && engine->m_active) engine->reconfigureCapture();
emit engine->stateChanged();
}, Qt::QueuedConnection);
request->~SettingsRequest();
@@ -176,6 +177,7 @@ void RadioAudioEngine::reconfigureCapture() {
m_capture.close();
m_voice.stopCapture();
radio_audio_capture_stop();
m_wantStereo = chat_setting_get_int(gui_bridge_get_inst(), "radio_capture_stereo", 0) != 0;
updateState();
m_capture.retryNow();
recoverDevices();