Skip to content

Commit 2307932

Browse files
committed
fix: fix audio device switching and mute synchronization issues
1. Added proper disconnection of previous DBus sink interface before creating new one to prevent signal conflicts 2. Fixed device activation timing issue by manually refreshing device list before setting active port 3. Changed mute handling logic to automatically set mute when volume reaches 0 4. Removed automatic unmute on volume change to prevent inconsistent state Log: Fixed audio device switching issues and improved mute/volume synchronization Influence: 1. Test audio device switching between different output devices 2. Verify mute state synchronization when volume is set to 0 3. Test volume adjustment while muted/unmuted 4. Check for any signal conflicts during device switching 5. Verify device list refresh works correctly on specific hardware models fix: 修复音频设备切换和静音同步问题 1. 在创建新的DBus接收器接口前正确断开之前的连接,防止信号冲突 2. 通过手动刷新设备列表再设置活动端口,修复设备激活时序问题 3. 修改静音处理逻辑,当音量达到0时自动设置静音 4. 移除音量变化时的自动取消静音,防止状态不一致 Log: 修复音频设备切换问题并改进静音/音量同步 Influence: 1. 测试不同输出设备之间的音频设备切换 2. 验证音量设为0时的静音状态同步 3. 测试静音/取消静音状态下的音量调整 4. 检查设备切换过程中是否有信号冲突 5. 验证特定硬件型号上的设备列表刷新功能 PMS: BUG-350057
1 parent 9b025ed commit 2307932

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

plugins/dde-dock/sound/soundcontroller.cpp

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

7474
void SoundController::onDefaultSinkChanged(const QDBusObjectPath &path)
7575
{
76+
if (m_defaultSinkInter)
77+
m_defaultSinkInter->disconnect(this);
7678
// 防止手动切换设备,与后端交互时,获取到多个信号,设备切换多次,造成混乱
7779

7880
if (m_defaultSinkInter)
@@ -84,23 +86,20 @@ void SoundController::onDefaultSinkChanged(const QDBusObjectPath &path)
8486
}
8587

8688
m_defaultSinkInter = new DBusSink("org.deepin.dde.Audio1", path.path(), QDBusConnection::sessionBus(), this);
87-
89+
// 某些机型,如flmx,add和active先后时序有问题,active触发时,设备add还没执行,导致找不到需要active的设备项
90+
// 这里手动刷新一下设备列表,再执行active操作
91+
SoundModel::ref().setCardsInfo(m_audioInter->cardsWithoutUnavailable());
8892
SoundModel::ref().setActivePort(m_defaultSinkInter->card(), m_defaultSinkInter->activePort().name);
8993
SoundModel::ref().setMute(m_defaultSinkInter->mute());
9094
SoundModel::ref().setVolume(existActiveOutputDevice() ? m_defaultSinkInter->volume() : 0);
91-
9295
// 音量和静音状态变化时手动获取下另外一个的状态,有时候收不到 changed 信号
9396
connect(m_defaultSinkInter, &DBusSink::MuteChanged, &SoundModel::ref(), [this] (bool value) {
9497
Q_UNUSED(value)
9598
SoundModel::ref().setMute(m_defaultSinkInter->mute());
9699
SoundModel::ref().setVolume(m_defaultSinkInter->volume());
97100
});
98-
connect(m_defaultSinkInter, &DBusSink::VolumeChanged, &SoundModel::ref(), [this] (double value) {
101+
connect(m_defaultSinkInter, &DBusSink::VolumeChanged, &SoundModel::ref(), [] (double value) {
99102
SoundModel::ref().setVolume(value);
100-
// 收到音量变化 dbus 后再取消静音,避免时序问题
101-
if (m_defaultSinkInter->mute()) {
102-
m_defaultSinkInter->SetMuteQueued(false);
103-
}
104103
});
105104
connect(m_defaultSinkInter, &DBusSink::ActivePortChanged, this, [this](AudioPort port) {
106105
SoundModel::ref().setActivePort(m_defaultSinkInter->card(), port.name);

0 commit comments

Comments
 (0)