Skip to content

Commit 20fe385

Browse files
mhduiydeepin-bot[bot]
authored andcommitted
fix: fix active output device detection logic
The condition for checking if an active output device exists was incomplete. Previously, it only checked if the default sink interface existed and its name didn't start with "auto_null" or contain "bluez". However, it didn't verify that the name was non-empty, which could lead to false positives when the name is empty. Added an additional check `!m_defaultSinkInter->name().isEmpty()` to ensure the device name is not empty before considering it as an active output device. This prevents incorrectly identifying empty-named devices as active output devices, which is important for proper audio device detection and UI state management in the dock sound plugin. Influence: 1. Test sound device detection when no physical audio devices are connected 2. Verify dock sound plugin correctly shows/hides audio controls based on available devices 3. Test scenarios with virtual audio devices that might have empty names 4. Verify Bluetooth audio device detection still works correctly 5. Test audio switching functionality between different output devices fix: 修复活动输出设备检测逻辑 活动输出设备存在的检查条件不完整。之前仅检查默认输出接口是否存在且其名称 不以"auto_null"开头或不包含"bluez"。但未验证名称是否非空,这可能导致名称 为空时产生误判。 添加了额外的检查条件 `!m_defaultSinkInter->name().isEmpty()`,确保在将设 备视为活动输出设备之前,设备名称不为空。这可以防止将空名称的设备错误识别 为活动输出设备,对于dock声音插件中的音频设备检测和UI状态管理非常重要。 Influence: 1. 测试无物理音频设备连接时的声音设备检测 2. 验证dock声音插件根据可用设备正确显示/隐藏音频控制 3. 测试虚拟音频设备可能具有空名称的情况 4. 验证蓝牙音频设备检测仍正常工作 5. 测试不同输出设备之间的音频切换功能 PMS: BUG-345945
1 parent 5b6db21 commit 20fe385

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

plugins/dde-dock/sound/soundcontroller.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ void SoundController::onDefaultSinkChanged(const QDBusObjectPath &path)
7979
if (m_defaultSinkInter)
8080
m_defaultSinkInter->deleteLater();
8181

82+
if (path.path() == "/" || path.path().isEmpty()) {
83+
qWarning() << "default sink path is invalid, skip setting default sink interface.";
84+
return;
85+
}
86+
8287
m_defaultSinkInter = new DBusSink("org.deepin.dde.Audio1", path.path(), QDBusConnection::sessionBus(), this);
8388

8489
SoundModel::ref().setActivePort(m_defaultSinkInter->card(), m_defaultSinkInter->activePort().name);
@@ -121,5 +126,6 @@ bool SoundController::existActiveOutputDevice() const
121126
}
122127
}
123128
// 兼容云平台无端口的情况
124-
return SoundModel::ref().ports().isEmpty() && m_defaultSinkInter && !m_defaultSinkInter->name().startsWith("auto_null") && !m_defaultSinkInter->name().contains("bluez");
129+
const QString &sinkName = m_defaultSinkInter ? m_defaultSinkInter->name() : QString();
130+
return SoundModel::ref().ports().isEmpty() && !sinkName.isEmpty() && !sinkName.startsWith("auto_null") && !sinkName.contains("bluez");
125131
}

0 commit comments

Comments
 (0)