Skip to content

Conversation

@fly602
Copy link
Contributor

@fly602 fly602 commented Nov 3, 2025

  1. Replace os/exec.Command("pactl", ...) calls with native pulseaudio context methods
  2. Add UnloadModuleByName and UnloadModule methods to audio context
  3. Remove unused unsetMono() function from sink.go
  4. Add doActionByName helper for gesture actions
  5. Update gesture manager to show multi-task view on bottom swipe
  6. Upgrade go-dbus-factory and go-lib dependencies for new API support

Log: Improved audio module management reliability and added bottom swipe gesture for multi-task view

Influence:

  1. Test audio mono mode toggle functionality
  2. Verify echo-cancel module loading/unloading
  3. Test bottom edge swipe gesture triggers multi-task view
  4. Check audio module cleanup on service restart
  5. Verify gesture action name resolution works correctly
  6. Test pulseaudio context connection stability

refactor: 使用 pulseaudio API 替代 pactl 脚本调用

  1. 将 os/exec.Command("pactl", ...) 调用替换为原生 pulseaudio 上下文方法
  2. 为音频上下文添加 UnloadModuleByName 和 UnloadModule 方法
  3. 从 sink.go 中移除未使用的 unsetMono() 函数
  4. 为手势操作添加 doActionByName 辅助函数
  5. 更新手势管理器,底部滑动时显示多任务视图
  6. 升级 go-dbus-factory 和 go-lib 依赖以支持新 API

Log: 提升音频模块管理可靠性,新增底部滑动多任务视图手势

Influence:

  1. 测试音频单声道模式切换功能
  2. 验证回声消除模块的加载/卸载
  3. 测试底部边缘滑动手势触发多任务视图
  4. 检查服务重启时的音频模块清理
  5. 验证手势操作名称解析功能
  6. 测试 pulseaudio 上下文连接稳定性

PMS: BUG-288445

Summary by Sourcery

Refactor audio management to use native Pulseaudio API, streamline module loading/unloading, enhance gesture handling with a bottom-swipe multi-task view, and update dependencies.

New Features:

  • Add helper doActionByName for gesture actions
  • Show multi-task view on bottom-edge swipe gesture

Enhancements:

  • Replace pactl scripts with native Pulseaudio context methods
  • Add UnloadModuleByName and UnloadModule methods to audio context
  • Remove unused unsetMono function

Build:

  • Upgrade go-dbus-factory and go-lib dependencies for new Pulseaudio API support

Chores:

  • Remove legacy audio control scripts echoCancelEnable.sh and monoEnable.sh

1. Replace os/exec.Command("pactl", ...) calls with native pulseaudio
context methods
2. Add UnloadModuleByName and UnloadModule methods to audio context
3. Remove unused unsetMono() function from sink.go
4. Add doActionByName helper for gesture actions
5. Update gesture manager to show multi-task view on bottom swipe
6. Upgrade go-dbus-factory and go-lib dependencies for new API support

Log: Improved audio module management reliability and added bottom swipe
gesture for multi-task view

Influence:
1. Test audio mono mode toggle functionality
2. Verify echo-cancel module loading/unloading
3. Test bottom edge swipe gesture triggers multi-task view
4. Check audio module cleanup on service restart
5. Verify gesture action name resolution works correctly
6. Test pulseaudio context connection stability

refactor: 使用 pulseaudio API 替代 pactl 脚本调用

1. 将 os/exec.Command("pactl", ...) 调用替换为原生 pulseaudio 上下文方法
2. 为音频上下文添加 UnloadModuleByName 和 UnloadModule 方法
3. 从 sink.go 中移除未使用的 unsetMono() 函数
4. 为手势操作添加 doActionByName 辅助函数
5. 更新手势管理器,底部滑动时显示多任务视图
6. 升级 go-dbus-factory 和 go-lib 依赖以支持新 API

Log: 提升音频模块管理可靠性,新增底部滑动多任务视图手势

Influence:
1. 测试音频单声道模式切换功能
2. 验证回声消除模块的加载/卸载
3. 测试底部边缘滑动手势触发多任务视图
4. 检查服务重启时的音频模块清理
5. 验证手势操作名称解析功能
6. 测试 pulseaudio 上下文连接稳定性

PMS: BUG-288445
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 3, 2025

Reviewer's Guide

This PR refactors audio module management by replacing external pactl calls with native pulseaudio API methods, adds dedicated unload module functions, cleans up unused code, enhances gesture handling by introducing a doActionByName helper and enabling a bottom-swipe multi-task view, and upgrades go-dbus-factory and go-lib dependencies.

Sequence diagram for audio module unloading using pulseaudio API

sequenceDiagram
    participant Audio
    participant Context
    Audio->>Context: UnloadModuleByName("module-echo-cancel")
    Context-->>Audio: Module unloaded
Loading

Sequence diagram for gesture action resolution using doActionByName

sequenceDiagram
    participant Manager
    participant doActionByName
    participant actionInfo
    Manager->>doActionByName: doActionByName("ShowMultiTask")
    doActionByName->>actionInfo: Find action with Name="ShowMultiTask"
    actionInfo-->>doActionByName: Execute fn()
    doActionByName-->>Manager: Return result
Loading

Class diagram for updated Audio context and module management

classDiagram
    class Audio {
        +SetMono(enable bool) *dbus.Error
        +unsetMono()
        +setMono(enable bool) error
        +unsetReduceNoise()
        +hasReduceNoise(source string) bool
    }
    class Context {
        +UnloadModuleByName(name string)
        +UnloadModule(index int)
    }
    Audio --> Context : uses
    class Sink {
        +SetVolume(value float64, isPlay bool) *dbus.Error
        +SetMono(enable bool) error
    }
    Sink --> Audio : uses
Loading

Class diagram for updated Gesture Manager and action handling

classDiagram
    class Manager {
        +Exec(evInfo EventInfo) error
        +GetInterfaceName() string
        +handleTouchEdgeMoveStopLeave(context *touchEventContext, edge string, position string, p Point) error
    }
    class actionInfo {
        +Name string
        +fn func() error
    }
    class doActionByName {
        +doActionByName(name string) error
    }
    Manager --> doActionByName : uses
    doActionByName --> actionInfo : iterates actions
Loading

File-Level Changes

Change Details Files
Native pulseaudio API integration
  • Added UnloadModuleByName and UnloadModule methods to Audio context
  • Replaced exec.Command("pactl") calls with context.UnloadModule*/ByName calls
  • Removed os/exec import and deleted legacy pactl shell scripts
audio1/audio.go
audio1/sink.go
misc/dde-daemon/audio/echoCancelEnable.sh
misc/dde-daemon/audio/monoEnable.sh
Gesture action handling enhancement
  • Added doActionByName helper for resolving gesture actions by name
  • Updated Manager to use doActionByName for bottom-swipe multi-task view
  • Removed builtinSets map and handleBuiltinAction method
gesture1/manager.go
gesture1/gesture_action.go
Dependency upgrades
  • Bumped github.com/linuxdeepin/go-dbus-factory to latest commit
  • Updated github.com/linuxdeepin/go-lib to new version
go.mod
Cleanup of unused code
  • Removed obsolete unsetMono() function in sink.go
  • Deleted unused unsetMono helper and removal logic
audio1/sink.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

deepin pr auto review

我来分析这个代码变更:

  1. 代码质量改进:
  • 移除了不必要的 shell 脚本依赖,用 Go 代码直接实现功能,提高了代码的可维护性
  • 删除了未使用的 import "os/exec"
  • 将重复的命令执行逻辑封装成函数,提高了代码复用性
  1. 性能优化:
  • 避免了通过 exec.Command 调用外部命令,直接使用 context API,减少了进程创建的开销
  • 使用 UnloadModuleByName 和 UnloadModule 替代了命令行调用,提高了执行效率
  1. 代码安全性改进:
  • 移除了 shell 脚本执行,避免了命令注入的风险
  • 使用 API 调用替代命令行执行,减少了潜在的安全隐患
  1. 具体改进建议:
  • 在 unsetMono() 函数中,建议添加错误处理和日志记录
  • doActionByName() 函数建议添加参数校验,确保 name 参数不为空
  • 在处理 dock 位置判断时,使用 switch 语句比 if-else 更清晰,这是一个好的改进
  1. 其他建议:
  • 建议为新增的函数添加详细的注释说明
  • UnloadModuleByName 和 UnloadModule 的调用建议添加错误处理
  • 建议将一些魔法字符串(如 "remap-sink-mono")定义为常量
  1. 依赖更新:
  • go.mod 和 go.sum 的更新表明项目依赖得到了更新,这是一个好的实践

总体来说,这次代码变更提高了代码质量和安全性,减少了外部依赖,是一个很好的改进。建议继续完善错误处理和日志记录。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602, mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fly602 fly602 merged commit 15cf528 into linuxdeepin:master Nov 6, 2025
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants