fix(sound): improve bluetooth audio mode switching debounce mechanism#3315
fix(sound): improve bluetooth audio mode switching debounce mechanism#3315Ivy233 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ivy233 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
TAG Bot New tag: 6.1.96 |
14b9904 to
3805a07
Compare
3805a07 to
d9a14e4
Compare
d9a14e4 to
8b1014b
Compare
… to prevent UI flicker Monitor DefaultSink changes via D-Bus to accurately detect device switching completion. Use sink name to identify target device and end debounce early when matched. Add content change detection in setOutPutPortCombo to filter redundant UI updates. Block output device list, balance, and bluetooth mode options updates during debounce. Use 1.5s timeout with early termination when target device detected (~100-600ms typical). Log: add debounce mechanism for bluetooth audio mode switching to prevent UI flicker fix(sound): 添加蓝牙音频模式切换防抖机制以防止UI闪烁 通过 D-Bus 监听 DefaultSink 变化,精确检测设备切换完成。 使用 sink name 识别目标设备,匹配成功时提前结束防抖。 在 setOutPutPortCombo 中添加内容变化检测,过滤冗余UI更新。 防抖期间阻止输出设备列表、平衡和蓝牙模式选项更新。 使用 1.5 秒超时,检测到目标设备时提前结束(典型耗时约 100-600ms)。 Log: 添加蓝牙音频模式切换防抖机制以防止UI闪烁 PMS: BUG-362189
8b1014b to
0a7d94b
Compare
deepin pr auto review★ 总体评分:79分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // soundworker.cpp
#include <QRegularExpression>
// 提取蓝牙设备MAC地址的辅助函数,用于准确判断设备切换
static QString extractBluetoothMac(const QString &sinkName) {
// 匹配 bluez_output.XX_XX_XX_XX_XX_XX.xxx 或类似格式
QRegularExpression re("bluez_output\\.([0-9A-Fa-f_]+)\\.");
QRegularExpressionMatch match = re.match(sinkName);
if (match.hasMatch()) {
return match.captured(1);
}
return QString();
}
void SoundWorker::setBluetoothMode(const QString &mode)
{
// 记录期望的蓝牙设备MAC地址,而非会随Mode改变的Sink名称
m_expectedSinkName = extractBluetoothMac(m_soundDBusInter->nameSink());
// 停止可能正在运行的其他定时器,避免干扰防抖
m_waitOutputReceiptTimer->stop();
// 启动防抖:阻止Output Device列表更新,禁用相关控件
m_model->setDebounceOutputDeviceList(true);
m_model->setOutPutPortComboEnable(false);
m_debounceChangeModeTimer->start(1500); // 蓝牙Mode切换需要更长时间
m_soundDBusInter->SetBluetoothAudioMode(mode);
}
void SoundWorker::onDefaultSinkChangedForDebounce(const QDBusObjectPath &)
{
if (!m_model->debounceOutputDeviceList() || !m_debounceChangeModeTimer->isActive()) {
return;
}
QString currentMac = extractBluetoothMac(m_soundDBusInter->nameSink());
// 基于MAC地址匹配,解决Mode切换时Sink名称改变导致无法提前结束防抖的问题
if (!currentMac.isEmpty() && currentMac == m_expectedSinkName) {
m_debounceChangeModeTimer->stop();
onBluetoothModeDebounceTimeout();
} else {
// 设备仍在切换中,重启定时器
m_debounceChangeModeTimer->start(1500);
}
} |
|
TAG Bot New tag: 6.1.97 |
|
TAG Bot New tag: 6.1.98 |
|
TAG Bot New tag: 6.1.99 |
|
TAG Bot New tag: 6.1.100 |
… to prevent UI flicker
修复蓝牙音频模式切换时输出设备列表闪烁问题
PMS: BUG-362189