Skip to content

fix: improve VLC engine detection and null safety - #749

Open
kt286 wants to merge 1 commit into
linuxdeepin:masterfrom
kt286:split/fix-vlc-engine
Open

fix: improve VLC engine detection and null safety#749
kt286 wants to merge 1 commit into
linuxdeepin:masterfrom
kt286:split/fix-vlc-engine

Conversation

@kt286

@kt286 kt286 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor
  • Add null pointer safety guards for m_qvplayer in all VLC player methods
  • Replace inline VLC library detection with DynamicLibraries singleton
  • Set playback engine type to VLC when dynamic libraries load successfully

fix: 优化VLC引擎检测和空值安全

  • 在所有VLC播放器方法中为m_qvplayer添加空指针安全保护
  • 使用DynamicLibraries单例替换内联VLC库检测
  • 当动态库加载成功时设置播放引擎类型为VLC

Summary by Sourcery

Improve VLC playback initialization and resilience when the VLC player or libraries are unavailable.

Bug Fixes:

  • Prevent VLC player operations from dereferencing an unavailable player instance by adding null-safe fallback behavior.

Enhancements:

  • Centralize VLC availability detection through the DynamicLibraries singleton and set the playback engine to VLC after successful library initialization.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @kt286, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kt286

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

@deepin-ci-robot

Copy link
Copy Markdown

Hi @kt286. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai

sourcery-ai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR centralizes VLC engine detection through the DynamicLibraries singleton and makes the VLC player more robust by adding null-pointer guards around m_qvplayer usage, while ensuring the playback engine type is correctly set to VLC on successful dynamic library initialization.

Sequence diagram for playback engine initialization via DynamicLibraries

sequenceDiagram
    participant DmGlobal
    participant DynamicLibraries

    DmGlobal->>DmGlobal: initPlaybackEngineType()
    DmGlobal->>DynamicLibraries: instance()
    activate DynamicLibraries
    DynamicLibraries->>DynamicLibraries: DynamicLibraries()
    alt [dynamic libraries load failed]
        DynamicLibraries->>DmGlobal: setPlaybackEngineType(0)
    else [dynamic libraries load succeed]
        DynamicLibraries->>DmGlobal: setPlaybackEngineType(1)
    end
    deactivate DynamicLibraries
    DmGlobal->>DmGlobal: engineType used in logging
Loading

File-Level Changes

Change Details Files
Use DynamicLibraries singleton to drive playback engine detection instead of inline library checks.
  • Include core/dynamiclibraries.h in the global module.
  • Replace OS-specific libExist-based VLC/FFmpeg detection logic in initPlaybackEngineType() with a call to DynamicLibraries::instance(), relying on that singleton to set engineType.
  • Adjust logging in initPlaybackEngineType() to report the final engineType value rather than branch-specific messages.
src/libdmusic/global.cpp
Harden VlcPlayer against null m_qvplayer and improve initialization flow for CDA and playback operations.
  • After init() calls in VlcPlayer methods, add early-return guards when m_qvplayer is null to avoid dereferencing it.
  • Ensure play(), time(), length(), and equalizer-related methods safely handle cases where the underlying VLC player is unavailable, returning default values where needed.
  • In startCdaThread(), verify m_qvplayer after init() before wiring the CDA thread to the media player core.
src/libdmusic/player/vlcplayer.cpp
Set playback engine type to VLC when dynamic libraries initialize successfully.
  • In DynamicLibraries constructor, set DmGlobal::engineType to 1 (VLC) when dynamic libraries load without errors, instead of only logging success.
src/libdmusic/core/dynamiclibraries.cpp

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

@kt286
kt286 force-pushed the split/fix-vlc-engine branch 4 times, most recently from a552419 to 6bf406a Compare August 11, 2026 01:00
@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.63
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #762

@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.64
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #765

@kt286
kt286 force-pushed the split/fix-vlc-engine branch from 6bf406a to 202471e Compare August 18, 2026 05:30
@deepin-bot

deepin-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.65
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #768

@deepin-bot

deepin-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.66
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #779

- Add null pointer safety guards for m_qvplayer in all VLC player methods
- Replace inline VLC library detection with DynamicLibraries singleton
- Set playback engine type to VLC when dynamic libraries load successfully

fix: 优化VLC引擎检测和空值安全

- 在所有VLC播放器方法中为m_qvplayer添加空指针安全保护
- 使用DynamicLibraries单例替换内联VLC库检测
- 当动态库加载成功时设置播放引擎类型为VLC
@kt286
kt286 force-pushed the split/fix-vlc-engine branch from 202471e to 8b40338 Compare August 20, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants