Conversation
SetMute中判断了音量是否为0,但是Volume是根据事件刷新的,此时还不是设置后的音量,因此会影响判断 Log: PMS: BUG-351645 Influence: audio mute settings
|
[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 GuideAdjusts Sink.SetVolume’s unmute path to call the internal mute setter, handle errors, and synchronize the global mute output config when unmuting, fixing incorrect mute state when using volume hotkeys. Sequence diagram for updated Sink.SetVolume unmute behaviorsequenceDiagram
participant App as App
participant Sink as Sink
participant Mute as setMute
participant Config as ConfigKeeper
participant Log as logger
App->>Sink: SetVolume(value > 0, isPlay)
alt value <= 0.001
Sink->>Sink: value = 0.001
Sink->>Mute: setMute(true)
else value > 0.001
Sink->>Mute: setMute(false)
alt setMute succeeds
Sink->>Config: GetConfigKeeper()
Config-->>Sink: keeper
Sink->>Config: read keeper.Mute.MuteOutput
alt keeper.Mute.MuteOutput is true
Sink->>Config: SetMuteOutput(false)
end
else setMute returns error
Sink->>Log: Warning(err)
end
end
Sink->>Sink: update s.cVolume and properties
Sink-->>App: *dbus.Error (nil on success)
Class diagram for Sink and ConfigKeeper changesclassDiagram
class Sink {
-PropsMu
-cVolume
SetVolume(value float64, isPlay bool) *dbus.Error
-setMute(mute bool) error
}
class ConfigKeeper {
-MuteConfig MuteConfig
+Mute MuteConfig
+SetMuteOutput(muted bool) error
}
class MuteConfig {
+MuteOutput bool
}
Sink ..> ConfigKeeper : uses
ConfigKeeper o-- MuteConfig : has
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review这段代码修改主要是为了解决在设置音量时,静音状态更新与音量属性更新不同步的问题。以下是对这段代码的详细审查和改进建议: 1. 代码逻辑审查优点:
问题点:
2. 代码质量改进建议func (s *Sink) SetVolume(value float64, isPlay bool) *dbus.Error {
if value < 0.001 {
value = 0.001
if err := s.setMute(true); err != nil {
logger.Warningf("Failed to set mute to true: %v", err)
// 根据业务需求决定是否返回错误
// return dbus.NewError("org.example.Error", []string{err.Error()})
}
} else {
// 明确说明取消静音的操作
if err := s.setMute(false); err != nil {
logger.Warningf("Failed to set mute to false: %v", err)
// 考虑是否需要继续执行
} else {
// 只有成功取消静音时才更新配置
if GetConfigKeeper().Mute.MuteOutput {
if err := GetConfigKeeper().SetMuteOutput(false); err != nil {
logger.Warningf("Failed to update MuteOutput config: %v", err)
}
}
}
}
s.PropsMu.Lock()
cv := s.cVolume.SetAvg(value)
// ... 其余代码
}3. 代码性能建议
4. 代码安全建议
5. 其他建议
这些改进可以使代码更加健壮、可维护和可调试。 |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In the new
elsebranch,logger.Warning(err)referenceserroutside the shortif err := s.setMute(false);scope, which will not compile; declareerrseparately before theifor log it inside theifblock. - You call
GetConfigKeeper()twice in the same success path; consider storing the result in a local variable to avoid repeated lookups and make the intent clearer when updatingMuteOutput.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the new `else` branch, `logger.Warning(err)` references `err` outside the short `if err := s.setMute(false);` scope, which will not compile; declare `err` separately before the `if` or log it inside the `if` block.
- You call `GetConfigKeeper()` twice in the same success path; consider storing the result in a local variable to avoid repeated lookups and make the intent clearer when updating `MuteOutput`.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
TAG Bot New tag: 6.1.77 |
SetMute中判断了音量是否为0,但是Volume是根据事件刷新的,此时还不是设置后的音量,因此会影响判断
Log:
PMS: BUG-351645
Influence: audio mute settings
Summary by Sourcery
Fix incorrect mute state handling when adjusting volume via shortcuts by aligning mute logic with updated volume and configuration state.
Bug Fixes:
Enhancements: