Skip to content

Commit 39e8cba

Browse files
mhduiyIvy233
authored andcommitted
perf(sound): optimize audio device switching performance
Filter invalid sink paths immediately before processing to avoid unnecessary delays. Remove the 200ms blocking sleep that was originally used for debouncing, as invalid signals are now filtered early and valid signals arrive with sufficient intervals (typically >250ms). This change improves UI responsiveness by eliminating the blocking delay while maintaining stable device switching behavior. 优化音频设备切换性能 在处理前立即过滤无效的 sink 路径以避免不必要的延迟。移除原本用于 防抖的 200ms 阻塞延迟,因为无效信号现在会被提前过滤,而有效信号 到达的间隔已足够大(通常 >250ms)。 此改动通过消除阻塞延迟来提升 UI 响应速度,同时保持稳定的设备切换 行为。 Log: optimize audio device switching performance PMS: BUG-295929
1 parent a858879 commit 39e8cba

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

plugins/dde-dock/sound/soundcontroller.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,15 @@ void SoundController::SetMute(bool in0)
7373

7474
void SoundController::onDefaultSinkChanged(const QDBusObjectPath &path)
7575
{
76-
// 防止手动切换设备,与后端交互时,获取到多个信号,设备切换多次,造成混乱
77-
QThread::msleep(200);
78-
79-
if (m_defaultSinkInter)
80-
m_defaultSinkInter->deleteLater();
81-
76+
// Filter invalid sink paths immediately to avoid unnecessary processing
8277
if (path.path() == "/" || path.path().isEmpty()) {
8378
qWarning() << "default sink path is invalid, skip setting default sink interface.";
8479
return;
8580
}
8681

82+
if (m_defaultSinkInter)
83+
m_defaultSinkInter->deleteLater();
84+
8785
m_defaultSinkInter = new DBusSink("org.deepin.dde.Audio1", path.path(), QDBusConnection::sessionBus(), this);
8886

8987
SoundModel::ref().setActivePort(m_defaultSinkInter->card(), m_defaultSinkInter->activePort().name);

0 commit comments

Comments
 (0)