fix: solve audio silent issue after upgrade#1132
Conversation
Added a method to check profile existence in ProfileList and modified audio setup to handle missing profiles by selecting an existing one when the stored profile is not found. This addresses compatibility issues after pipewire upgrades where configuration files change or audio ports are not reported simultaneously during initialization, preventing audio from being silent. Log: Fixed audio issue where sound was lost after system upgrade, ensuring proper profile selection. Influence: 1. Test audio playback after a system upgrade to ensure no sound loss. 2. Verify that audio profiles are correctly selected when stored profiles are missing. 3. Check audio initialization scenarios where ports might not be reported simultaneously. 4. Test compatibility with different pipewire versions or upgrade paths. fix: 解决升级后音频无声的问题 添加了一个方法来检查 ProfileList 中是否存在配置文件,并在音频设置中, 当存储的配置文件未找到时,选择一个已存在的配置文件而非失败。这解决了 pipewire 升级后配置文件变化或音频端口在初始化时未同时上报导致的兼容性问 题,从而防止音频无声。 Log: 修复了系统升级后音频丢失的问题,确保正确的配置文件选择。 Influence: 1. 测试系统升级后的音频播放,确保无声音丢失。 2. 验证当存储的配置文件缺失时,音频配置文件是否被正确选择。 3. 检查音频初始化场景,其中端口可能未同时上报。 4. 测试与不同 pipewire 版本或升级路径的兼容性。 PMS: BUG-358827 Change-Id: Iee93871193e5ca05edbde091d362c71a0c12a801
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602 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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a profile-existence helper on ProfileList and updates audio port/profile selection logic so that when a previously stored profile is missing (e.g., after pipewire upgrades or staggered port reporting), the code falls back to a valid existing profile instead of failing, preventing silent audio after upgrades. Sequence diagram for updated audio profile selection in setPortsequenceDiagram
participant Audio
participant ConfigKeeper
participant Card
participant Port
participant ProfileList
Audio->>ConfigKeeper: GetConfigKeeper
Audio->>ConfigKeeper: Mode(card, portName)
ConfigKeeper-->>Audio: profile
alt [profile is empty]
Audio->>Port: Profiles.SelectProfile
Port-->>Audio: profile
Audio->>ConfigKeeper: SetMode(card, portName, profile)
else [profile is not empty]
Audio->>ProfileList: card.Profiles.Exists(profile)
alt [profile exists]
Audio->>Card: use existing profile
else [profile missing]
Audio->>Port: Profiles.SelectProfile
Port-->>Audio: profile
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review你好!我是CodeGeeX,你的智能编程助手。我已经仔细审查了你提供的Git Diff代码。这段代码主要处理了音频配置文件在特定场景下找不到的兼容性问题,并新增了一个辅助判断方法。 以下是我从语法逻辑、代码质量、代码性能和代码安全四个维度提出的详细审查意见和改进建议: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进后的代码建议针对上述审查意见,主要是为了增强代码的健壮性(防止空指针 Panic),建议对 func (l ProfileList) Exists(name string) bool {
for _, p := range l {
// 防御性编程:防止 ProfileList 中存在未初始化的 nil 指针导致 panic
if p != nil && p.Name == name {
return true
}
}
return false
}对于 } else {
// 情况一:兼容pipewire升级导致的声卡的配置文件的发生变化,导致配置找不到
// 情况二:另一种情况是pipewire初始化时,音频端口不是同时上报上来的,导致配置文件找不到,暂时先切换到已存在的profile
// 由于情况二的场景存在,不能在这里调用 SetMode 修改配置文件
if card.Profiles != nil && !card.Profiles.Exists(profile) {
profile = port.Profiles.SelectProfile()
}
}总体而言,这段代码的修改目标明确,容错设计合理,只需稍微注意一下空指针的边界情况即可。希望这些意见对你有所帮助!如果有其他代码需要审查,随时告诉我。 |
Added a method to check profile existence in ProfileList and modified audio setup to handle missing profiles by selecting an existing one when the stored profile is not found. This addresses compatibility issues after pipewire upgrades where configuration files change or audio ports are not reported simultaneously during initialization, preventing audio from being silent.
Log: Fixed audio issue where sound was lost after system upgrade, ensuring proper profile selection.
Influence:
fix: 解决升级后音频无声的问题
添加了一个方法来检查 ProfileList 中是否存在配置文件,并在音频设置中,
当存储的配置文件未找到时,选择一个已存在的配置文件而非失败。这解决了
pipewire 升级后配置文件变化或音频端口在初始化时未同时上报导致的兼容性问
题,从而防止音频无声。
Log: 修复了系统升级后音频丢失的问题,确保正确的配置文件选择。
Influence:
PMS: BUG-358827
Change-Id: Iee93871193e5ca05edbde091d362c71a0c12a801
Summary by Sourcery
Ensure audio continues working after configuration changes by validating stored audio profiles and falling back to an available profile when necessary.
Bug Fixes:
Enhancements: