Skip to content

Commit 68757c2

Browse files
committed
fix: fix card profile change detection logic
Fixed incorrect profile change detection in card comparison logic The comparison was incorrectly using current card's ActiveProfile.Name against the old card's ActiveProfile.Name instead of comparing pulseaudio's current profile with the old card's profile This ensures proper detection of profile changes when handling audio events Influence: 1. Test audio profile switching functionality 2. Verify Bluetooth audio mode changes are properly detected 3. Check that audio device changes trigger correct refresh operations 4. Validate profile change logging shows correct before/after values fix: 修复声卡配置文件变化检测逻辑 修复了声卡比较逻辑中配置文件变化检测的错误 原先错误地将当前声卡的 ActiveProfile.Name 与旧声卡的 ActiveProfile.Name 进行比较,而不是将 pulseaudio 的当前配置文件与旧声卡的配置文件进行比较 这确保了在处理音频事件时能够正确检测配置文件变化 Influence: 1. 测试音频配置文件切换功能 2. 验证蓝牙音频模式变化是否正确检测 3. 检查音频设备变化是否触发正确的刷新操作 4. 验证配置文件变化日志显示正确的变更前后值 PMS: BUG-354931 Change-Id: Ie2e09b57ba05bb020821c455e85ea1110e833740
1 parent fef0661 commit 68757c2

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

audio1/audio_events.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,13 @@ func (a *Audio) handleSinkChanged(idx uint32) {
466466
if isPhysicalDevice(sink.Name) && a.checkCardIsReady(sink.Card) {
467467
a.autoSwitchPort()
468468
}
469+
470+
if a.defaultSink != nil && a.defaultSink.index == idx && isBluezAudio(sink.Name) {
471+
card, err := a.cards.get(sink.Card)
472+
if err == nil && card.ActiveProfile != nil && a.BluetoothAudioMode != card.ActiveProfile.Name {
473+
a.refreshBluetoothOpts()
474+
}
475+
}
469476
}
470477

471478
func (a *Audio) handleSourceEvent(eventType int, idx uint32) {

audio1/card.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,9 @@ func (card *Card) doDiff(oldCard *Card, autoPause bool) ChangeType {
350350
pc := card.core
351351
// 检查配置文件变化
352352
if card.ActiveProfile != nil {
353-
if pc.ActiveProfile.Name != card.ActiveProfile.Name {
353+
if pc.ActiveProfile.Name != oldCard.ActiveProfile.Name {
354354
logger.Infof("card %s profile changed from %v to %v",
355-
card.Name, pc.ActiveProfile.Name, card.ActiveProfile.Name)
355+
card.Name, oldCard.ActiveProfile.Name, pc.ActiveProfile.Name)
356356
changed |= ProfileChanged
357357
}
358358
}

0 commit comments

Comments
 (0)