Сохрани накопленные исправления аудио, async и диагностики
This commit is contained in:
1 parent
b1e3193899
commit
bdcf8b5634
59 files changed
+4611
-1441
No files matched your search
@@ -183,25 +183,25 @@ void AudioDeviceSettingsPage::loadFromDb() {
|
||||
|
||||
/* Output devices */
|
||||
m_outputCombo->clear();
|
||||
m_outputCombo->addItem("Default (auto)", -1);
|
||||
m_outputCombo->addItem("Default (auto)", QString());
|
||||
for (int i = 0; i < playbackDevs.size(); i++) {
|
||||
QString label = playbackDevs[i].name;
|
||||
if (playbackDevs[i].isDefault) label += " (default)";
|
||||
m_outputCombo->addItem(label, i);
|
||||
m_outputCombo->addItem(label, playbackDevs[i].id);
|
||||
}
|
||||
|
||||
/* Input devices */
|
||||
m_inputCombo->clear();
|
||||
m_inputCombo->addItem("Default (auto)", -1);
|
||||
m_inputCombo->addItem("Default (auto)", QString());
|
||||
for (int i = 0; i < captureDevs.size(); i++) {
|
||||
QString label = captureDevs[i].name;
|
||||
if (captureDevs[i].isDefault) label += " (default)";
|
||||
m_inputCombo->addItem(label, i);
|
||||
m_inputCombo->addItem(label, captureDevs[i].id);
|
||||
}
|
||||
|
||||
if (m_db) {
|
||||
m_savedOutputIdx = m_db->getUiStateInt("audio_output_device", -1);
|
||||
m_savedInputIdx = m_db->getUiStateInt("audio_input_device", -1);
|
||||
m_savedOutputId = m_db->getUiState("audio_output_id");
|
||||
m_savedInputId = m_db->getUiState("audio_input_id");
|
||||
m_savedCodecPreset = m_db->getUiStateInt("opus_codec_preset", 1);
|
||||
m_savedRadioOpusMode = m_db->getUiStateInt("radio_opus_mode", 0);
|
||||
m_savedRadioOpusBitrate = m_db->getUiStateInt("radio_opus_bitrate", 32);
|
||||
@@ -215,11 +215,11 @@ void AudioDeviceSettingsPage::loadFromDb() {
|
||||
|
||||
/* Select saved indices */
|
||||
for (int i = 0; i < m_outputCombo->count(); i++) {
|
||||
if (m_outputCombo->itemData(i).toInt() == m_savedOutputIdx)
|
||||
if (m_outputCombo->itemData(i).toString() == m_savedOutputId)
|
||||
{ m_outputCombo->setCurrentIndex(i); break; }
|
||||
}
|
||||
for (int i = 0; i < m_inputCombo->count(); i++) {
|
||||
if (m_inputCombo->itemData(i).toInt() == m_savedInputIdx)
|
||||
if (m_inputCombo->itemData(i).toString() == m_savedInputId)
|
||||
{ m_inputCombo->setCurrentIndex(i); break; }
|
||||
}
|
||||
for (int i = 0; i < m_codecPresetCombo->count(); i++) {
|
||||
@@ -244,8 +244,8 @@ void AudioDeviceSettingsPage::loadFromDb() {
|
||||
}
|
||||
|
||||
void AudioDeviceSettingsPage::applyAndSave() {
|
||||
int outIdx = m_outputCombo->currentData().toInt();
|
||||
int inIdx = m_inputCombo->currentData().toInt();
|
||||
QString outputId = m_outputCombo->currentData().toString();
|
||||
QString inputId = m_inputCombo->currentData().toString();
|
||||
int codecPreset = m_codecPresetCombo->currentData().toInt();
|
||||
|
||||
auto saveKey = [](const char* key, int val) {
|
||||
@@ -260,8 +260,23 @@ void AudioDeviceSettingsPage::applyAndSave() {
|
||||
memcpy(arg->data + klen + 1, v.constData(), vlen + 1);
|
||||
gui_bridge_post_uasync_fn(chat_core_save_ui_state_trampoline, arg);
|
||||
};
|
||||
saveKey("audio_output_device", outIdx);
|
||||
saveKey("audio_input_device", inIdx);
|
||||
auto saveDevice = [](const char* key, const QString& id) {
|
||||
QByteArray value = id.toUtf8();
|
||||
size_t keyLen = strlen(key), valueLen = value.size();
|
||||
auto* arg = static_cast<save_ui_state_arg*>(u_calloc(1, sizeof(save_ui_state_arg)));
|
||||
if (!arg) return;
|
||||
if (keyLen + valueLen + 2 > sizeof(arg->data)) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CALL, "audio: device ID too long bytes=%zu", valueLen);
|
||||
u_free(arg); return;
|
||||
}
|
||||
arg->inst = gui_bridge_get_inst();
|
||||
memcpy(arg->data, key, keyLen + 1);
|
||||
memcpy(arg->data + keyLen + 1, value.constData(), valueLen + 1);
|
||||
gui_bridge_post_uasync_fn(chat_core_save_ui_state_trampoline, arg);
|
||||
};
|
||||
saveDevice("audio_output_id", outputId);
|
||||
saveDevice("audio_input_id", inputId);
|
||||
SoundManager::instance()->setDevices(outputId, inputId);
|
||||
saveKey("opus_codec_preset", codecPreset);
|
||||
|
||||
VoiceEncoder::setPreset(codecPreset);
|
||||
@@ -312,8 +327,8 @@ void AudioDeviceSettingsPage::applyAndSave() {
|
||||
postChat(m_configPath, "call_jitter_max_reserve_ms", jitterReserveMs);
|
||||
}
|
||||
|
||||
m_savedOutputIdx = outIdx;
|
||||
m_savedInputIdx = inIdx;
|
||||
m_savedOutputId = outputId;
|
||||
m_savedInputId = inputId;
|
||||
m_savedCodecPreset = codecPreset;
|
||||
m_savedRadioOpusMode = radioOpusMode;
|
||||
m_savedRadioOpusBitrate = radioOpusBitrate;
|
||||
@@ -322,13 +337,13 @@ void AudioDeviceSettingsPage::applyAndSave() {
|
||||
m_savedCompressorMaxGainDb = compMaxGain;
|
||||
m_savedCompressorRiseRate = compRiseRate;
|
||||
m_savedAecEnabled = aecEnabled;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "saved output=%d input=%d codec=%d radioOpus=%d/%dkbps stereo=%d compressor=%d gain=%ddB rise=%.1fx aec=%d",
|
||||
outIdx, inIdx, codecPreset, radioOpusMode, radioOpusBitrate, radioCaptureStereo,
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "saved output_default=%d input_default=%d codec=%d radioOpus=%d/%dkbps stereo=%d compressor=%d gain=%ddB rise=%.1fx aec=%d",
|
||||
outputId.isEmpty(), inputId.isEmpty(), codecPreset, radioOpusMode, radioOpusBitrate, radioCaptureStereo,
|
||||
compEnabled, compMaxGain, (float)compRiseRate, aecEnabled);
|
||||
|
||||
if (m_recorder) {
|
||||
m_recorder->setCompressorEnabled(compEnabled != 0);
|
||||
if (m_recorder->compressor() && compEnabled) {
|
||||
{
|
||||
audio_compressor_config_t compCfg = {0};
|
||||
compCfg.sample_rate = 48000;
|
||||
compCfg.channels = 1;
|
||||
@@ -337,7 +352,7 @@ void AudioDeviceSettingsPage::applyAndSave() {
|
||||
compCfg.lookahead_ms = 100;
|
||||
compCfg.rise_rate_per_sec = (float)compRiseRate;
|
||||
compCfg.target_level = 1.0f;
|
||||
audio_compressor_configure(m_recorder->compressor(), &compCfg);
|
||||
m_recorder->configureCompressor(compCfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -346,8 +361,8 @@ void AudioDeviceSettingsPage::onTestMicToggled() {
|
||||
if (m_testMicBtn->isChecked()) {
|
||||
m_testRecorder = new AudioRecorder(this);
|
||||
m_testRecorder->init();
|
||||
int inIdx = m_inputCombo->currentData().toInt();
|
||||
m_testRecorder->setCaptureDeviceIndex(inIdx);
|
||||
QString id = m_inputCombo->currentData().toString();
|
||||
m_testRecorder->setCaptureDevice(id);
|
||||
m_testRecorder->startRecording();
|
||||
m_micTestActive = true;
|
||||
m_levelTimer->start();
|
||||
|
||||
Reference in new issue
Block a user