Own pending radio settings in cancellable uasync tasks
This commit is contained in:
1 parent
312c2dd386
commit
a2bafb61c7
1 file changed
+10
-4
@@ -9,6 +9,8 @@
|
||||
extern "C" {
|
||||
#include "radio/radio_audio.h"
|
||||
#include "chat/chat_setting.h"
|
||||
#include "utun_instance.h"
|
||||
#include "../../lib/u_async.h"
|
||||
#include "../../lib/debug_config.h"
|
||||
#include "../../lib/mem.h"
|
||||
}
|
||||
@@ -24,6 +26,7 @@ constexpr const char* settingKeys[] = {"radio_vad_enabled", "radio_vad_threshold
|
||||
"radio_compressor_enabled", "radio_compressor_max_gain_db", "radio_vad_compressor_max_gain_db"};
|
||||
constexpr int settingMin[] = {0, 10, 50, 0, 1, 1}, settingMax[] = {1, 95, 2000, 1, 60, 60};
|
||||
struct SettingsRequest {
|
||||
posted_task task; // Первое поле: очередь освобождает весь запрос, включая отмену при shutdown.
|
||||
RadioAudioEngine* engine;
|
||||
UTUN_INSTANCE* inst;
|
||||
std::array<int, 6> values;
|
||||
@@ -134,11 +137,12 @@ void RadioAudioEngine::postSettings(const std::array<int, 6>& values, bool apply
|
||||
emit stateChanged();
|
||||
return;
|
||||
}
|
||||
auto* request = new (memory) SettingsRequest{this, inst, values, apply};
|
||||
auto* request = new (memory) SettingsRequest{{}, this, inst, values, apply};
|
||||
m_settingsBusy = true;
|
||||
m_settingsError.clear();
|
||||
emit stateChanged();
|
||||
gui_bridge_post_uasync_fn([](void* arg) {
|
||||
request->task.arg = request;
|
||||
request->task.callback = [](void* arg) {
|
||||
auto* request = static_cast<SettingsRequest*>(arg);
|
||||
bool success = true;
|
||||
for (size_t i = 0; i < request->values.size(); ++i) {
|
||||
@@ -167,8 +171,8 @@ void RadioAudioEngine::postSettings(const std::array<int, 6>& values, bool apply
|
||||
emit engine->stateChanged();
|
||||
}, Qt::QueuedConnection);
|
||||
request->~SettingsRequest();
|
||||
u_free(request);
|
||||
}, request);
|
||||
};
|
||||
uasync_post_reserved(inst->ua, &request->task);
|
||||
}
|
||||
|
||||
void RadioAudioEngine::reconfigureCapture() {
|
||||
@@ -198,6 +202,7 @@ int RadioAudioEngine::start(quint64 groupId) {
|
||||
m_capture.retryNow();
|
||||
recoverDevices();
|
||||
m_recoveryTimer.start();
|
||||
emit stateChanged();
|
||||
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "RadioAudio: listening group=%016llx", (unsigned long long)groupId);
|
||||
return 0;
|
||||
}
|
||||
@@ -278,6 +283,7 @@ void RadioAudioEngine::stop() {
|
||||
if (group) radio_audio_stop();
|
||||
updateState();
|
||||
if (talking) emit talkingChanged(false);
|
||||
if (group) emit stateChanged();
|
||||
if (group) DEBUG_INFO(DEBUG_CATEGORY_RADIO, "RadioAudio: stopped group=%016llx", (unsigned long long)group);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user