fix: Optimize audio initialization timing and DBus interface timeout#757
Merged
deepin-bot[bot] merged 1 commit intoNov 17, 2025
Conversation
- Delay audio and camera watcher initialization to recording mode only, avoiding unnecessary resource usage in screenshot mode - Add initAudioAndCameraWatchers() method to handle audio/camera initialization separately - Set DBus interface timeout to 3 seconds instead of default 25 seconds using AudioDBusTimeout constant - Fix memory leaks in RecordProcess audio device name retrieval methods - Add null pointer checks for audio watchers in recording stop and mode switching scenarios - Stop audio/camera watchers when switching from recording to screenshot mode to save resources This optimization improves performance by reducing unnecessary audio service initialization in screenshot mode and provides faster DBus response times through reduced timeout values. 修复: 优化音频初始化时机和DBus接口超时配置 - 将音频和摄像头监视器初始化延迟到录屏模式,避免截图模式下的不必要资源占用 - 添加initAudioAndCameraWatchers()方法单独处理音频/摄像头初始化逻辑 - 使用AudioDBusTimeout常量将DBus接口超时时间设置为3秒,替代默认的25秒 - 修复RecordProcess中音频设备名称获取方法的内存泄漏问题 - 为录屏停止和模式切换场景添加音频监视器空指针检查 - 从录屏模式切换到截图模式时停止音频/摄像头监视器以节省资源 此优化通过减少截图模式下不必要的音频服务初始化提升了性能,并通过缩短超时时间提供了更快的DBus响应速度。
deepin pr auto review我来对这个diff进行代码审查:
void MainWindow::initAudioAndCameraWatchers()
{
// 添加更详细的注释
if (!m_toolBarInit) { // 添加工具栏初始化检查
qCWarning(dsrApp) << "工具栏未初始化,跳过音频和摄像头监视器初始化";
return;
}
qCDebug(dsrApp) << "初始化音频和摄像头监视器...";
// 初始化音频监视器
if (!m_pVoiceVolumeWatcher) {
m_pVoiceVolumeWatcher = new voiceVolumeWatcher(this);
m_pVoiceVolumeWatcher->setWatch(true);
connect(m_pVoiceVolumeWatcher, &voiceVolumeWatcher::sigRecodeState,
this, &MainWindow::microPhoneEnable); // 使用新式连接语法
emit microPhoneEnable(false);
qCDebug(dsrApp) << "音频监视器初始化完成";
}
// 初始化摄像头监视器
if (!m_pCameraWatcher) {
m_pCameraWatcher = new CameraWatcher(this);
m_pCameraWatcher->setWatch(true);
qCDebug(dsrApp) << "摄像头监视器初始化完成";
}
}
总的来说,这个改动主要是代码重构,提高了代码的可维护性和健壮性,但还可以进一步优化错误处理和资源管理。 |
lzwind
approved these changes
Nov 17, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind 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 |
Member
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
79043bb
into
linuxdeepin:develop/snipe
8 of 9 checks passed
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.
This optimization improves performance by reducing unnecessary audio service initialization in screenshot mode and provides faster DBus response times through reduced timeout values.
修复: 优化音频初始化时机和DBus接口超时配置
此优化通过减少截图模式下不必要的音频服务初始化提升了性能,并通过缩短超时时间提供了更快的DBus响应速度。