-
Notifications
You must be signed in to change notification settings - Fork 28
fix: fix active output device detection logic #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the logic for detecting an active output device in the dock sound controller by adding a guard that ignores default sink interfaces with empty names, preventing false positives when no real audio device is present. Class diagram for updated SoundController existActiveOutputDevice logicclassDiagram
class SoundController {
+bool existActiveOutputDevice() const
-SinkInterface m_defaultSinkInter
}
class SoundModel {
+static SoundModel ref()
+QList~Port~ ports()
}
class SinkInterface {
+QString name()
}
SoundController --> SoundModel : uses
SoundController --> SinkInterface : holds
Flow diagram for updated existActiveOutputDevice decision logicflowchart TD
A[existActiveOutputDevice] --> B{SoundModel_ref_ports_isEmpty}
B -- no --> N[return false]
B -- yes --> C{m_defaultSinkInter_not_null}
C -- no --> N
C -- yes --> D{name_startsWith_auto_null}
D -- yes --> N
D -- no --> E{name_contains_bluez}
E -- yes --> N
E -- no --> F{name_isEmpty}
F -- yes --> N
F -- no --> P[return true]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- Consider caching
m_defaultSinkInter->name()in a localconst auto &namevariable to avoid repeated method calls and make the condition more readable. - You might want to check
!m_defaultSinkInter->name().isEmpty()earlier in the condition (beforestartsWith/contains) to short-circuit quickly when the name is empty.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider caching `m_defaultSinkInter->name()` in a local `const auto &name` variable to avoid repeated method calls and make the condition more readable.
- You might want to check `!m_defaultSinkInter->name().isEmpty()` earlier in the condition (before `startsWith`/`contains`) to short-circuit quickly when the name is empty.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
b13041a to
c638d4b
Compare
deepin pr auto review我来对这个diff进行详细的代码审查:
建议进一步改进的地方:
总体来说,这些改动提高了代码的健壮性和可维护性,是一个很好的改进。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, 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 |
The condition for checking if an active output device exists was incomplete. Previously, it only checked if the default sink interface existed and its name didn't start with "auto_null" or contain "bluez". However, it didn't verify that the name was non-empty, which could lead to false positives when the name is empty. Added an additional check `!m_defaultSinkInter->name().isEmpty()` to ensure the device name is not empty before considering it as an active output device. This prevents incorrectly identifying empty-named devices as active output devices, which is important for proper audio device detection and UI state management in the dock sound plugin. Influence: 1. Test sound device detection when no physical audio devices are connected 2. Verify dock sound plugin correctly shows/hides audio controls based on available devices 3. Test scenarios with virtual audio devices that might have empty names 4. Verify Bluetooth audio device detection still works correctly 5. Test audio switching functionality between different output devices fix: 修复活动输出设备检测逻辑 活动输出设备存在的检查条件不完整。之前仅检查默认输出接口是否存在且其名称 不以"auto_null"开头或不包含"bluez"。但未验证名称是否非空,这可能导致名称 为空时产生误判。 添加了额外的检查条件 `!m_defaultSinkInter->name().isEmpty()`,确保在将设 备视为活动输出设备之前,设备名称不为空。这可以防止将空名称的设备错误识别 为活动输出设备,对于dock声音插件中的音频设备检测和UI状态管理非常重要。 Influence: 1. 测试无物理音频设备连接时的声音设备检测 2. 验证dock声音插件根据可用设备正确显示/隐藏音频控制 3. 测试虚拟音频设备可能具有空名称的情况 4. 验证蓝牙音频设备检测仍正常工作 5. 测试不同输出设备之间的音频切换功能 PMS: BUG-345945
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Fixed the existActiveOutputDevice() method to include an additional check for empty device name. The previous logic could incorrectly identify an active output device when the default sink interface exists but has an empty name. This ensures that devices with empty names are not considered active output devices, improving the accuracy of device detection in sound controller.
Influence:
fix: 修复活动输出设备检测逻辑
修复了existActiveOutputDevice()方法,增加了对空设备名称的检查。之前的逻
辑在默认音频输出接口存在但名称为空时可能会错误地识别为活动输出设备。此修
复确保名称为空的设备不会被识别为活动输出设备,提高了声音控制器中设备检测
的准确性。
Influence:
Summary by Sourcery
Bug Fixes: