feat: add module unloading functionality#115
Merged
fly602 merged 1 commit intolinuxdeepin:masterfrom Nov 3, 2025
Merged
Conversation
1. Implement UnloadModule function to unload modules by index 2. Add UnloadModuleByName helper to unload modules by name 3. Use safeDo wrapper for thread-safe PulseAudio operations 4. Follow existing pattern of operation cleanup with pa_operation_unref 5. Provide both direct index-based and name-based unloading options Influence: 1. Test unloading modules with valid and invalid indices 2. Verify UnloadModuleByName finds and unloads correct modules 3. Test behavior when module name doesn't exist 4. Verify thread safety during concurrent unload operations 5. Test module state after unloading 6. Verify no memory leaks from operation cleanup feat: 添加模块卸载功能 1. 实现 UnloadModule 函数通过索引卸载模块 2. 添加 UnloadModuleByName 辅助函数通过名称卸载模块 3. 使用 safeDo 包装器确保 PulseAudio 操作线程安全 4. 遵循现有的 pa_operation_unref 操作清理模式 5. 提供基于索引和基于名称的卸载选项 Influence: 1. 测试使用有效和无效索引卸载模块 2. 验证 UnloadModuleByName 能正确找到并卸载模块 3. 测试模块名称不存在时的行为 4. 验证并发卸载操作期间的线程安全性 5. 测试卸载后模块状态 6. 验证操作清理无内存泄漏
deepin pr auto review我来对这个diff进行代码审查:
改进后的代码建议: // UnloadModule unloads a module by its index
func (c *Context) UnloadModule(index uint32) error {
if index < 0 {
return fmt.Errorf("invalid module index: %d", index)
}
var err error
c.safeDo(func() {
op := C.pa_context_unload_module(c.ctx, C.uint32_t(index), C.get_success_cb(), nil)
if op == nil {
err = fmt.Errorf("failed to unload module: %d", index)
}
C.pa_operation_unref(op)
})
return err
}
// UnloadModuleByName unloads the first module matching the given name
func (c *Context) UnloadModuleByName(name string) error {
if len(name) == 0 || len(name) > 256 {
return fmt.Errorf("invalid module name: %s", name)
}
modules := c.GetModuleList()
for _, module := range modules {
if module.Name == name {
return c.UnloadModule(module.Index)
}
}
return fmt.Errorf("module not found: %s", name)
}这些改进增加了错误处理和参数验证,使代码更加健壮和安全。 |
mhduiy
approved these changes
Nov 3, 2025
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Influence:
feat: 添加模块卸载功能
Influence: