Skip to content

fix: adapt dynamic library loading for Windows (MSYS2/MinGW) - #730

Open
kt286 wants to merge 1 commit into
linuxdeepin:masterfrom
kt286:split/fix-dynlib-loading
Open

fix: adapt dynamic library loading for Windows (MSYS2/MinGW)#730
kt286 wants to merge 1 commit into
linuxdeepin:masterfrom
kt286:split/fix-dynlib-loading

Conversation

@kt286

@kt286 kt286 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor
  • Add Windows DLL names (libvlc.dll, avcodec-62, avformat-62, avutil-60)
  • Add avutil library loading support
  • Fix VLC library path correction on Windows (avoid loading vlccore)
  • Improve library search to support multiple paths and .dll suffix
  • Add application directory as first search path on Windows
  • Update libExist() for Windows compatibility

fix: 适配动态库加载以支持 Windows(MSYS2/MinGW)

  • 添加 Windows DLL 名称(libvlc.dll、avcodec-62、avformat-62、avutil-60)
  • 添加 avutil 库加载支持
  • 修正 Windows 上 VLC 库路径(避免加载 vlccore)
  • 改进库搜索以支持多路径和 .dll 后缀
  • 在 Windows 上将应用程序目录作为首选搜索路径
  • 更新 libExist() 以兼容 Windows

Summary by Sourcery

Adapt dynamic library loading to correctly support VLC/FFmpeg on Windows (MSYS2/MinGW) while keeping Linux behavior intact.

New Features:

  • Add dynamic loading support for avutil and swresample libraries alongside existing VLC/FFmpeg libraries.
  • Enable VLC playback engine initialization on Windows using native DLL names and paths.

Bug Fixes:

  • Correct VLC library path resolution on Windows to avoid accidentally loading libvlccore instead of libvlc.
  • Fix library existence checks and name handling so they work properly with Windows DLLs as well as Linux shared objects.

Enhancements:

  • Improve cross-platform library search to handle multiple lookup paths, including the application directory on Windows, and platform-specific file suffixes.
  • Extend FFmpeg symbol resolution to try avcodec, avformat, avutil, and swresample in order, with clearer logging of resolution failures and successes.

- Add Windows DLL names (libvlc.dll, avcodec-62, avformat-62, avutil-60)
- Add avutil library loading support
- Fix VLC library path correction on Windows (avoid loading vlccore)
- Improve library search to support multiple paths and .dll suffix
- Add application directory as first search path on Windows
- Update libExist() for Windows compatibility

fix: 适配动态库加载以支持 Windows(MSYS2/MinGW)

- 添加 Windows DLL 名称(libvlc.dll、avcodec-62、avformat-62、avutil-60)
- 添加 avutil 库加载支持
- 修正 Windows 上 VLC 库路径(避免加载 vlccore)
- 改进库搜索以支持多路径和 .dll 后缀
- 在 Windows 上将应用程序目录作为首选搜索路径
- 更新 libExist() 以兼容 Windows

@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 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

This pull request adapts dynamic library loading to work correctly on Windows (MSYS2/MinGW) by making library names/platform guards Windows-aware, expanding the VLC/FFmpeg libraries that are loaded, and updating the search and detection logic for libraries and playback engine initialization.

Sequence diagram for updated ffmpeg symbol resolution in DynamicLibraries::resolve

sequenceDiagram
    participant DynamicLibraries
    participant avcodecLib
    participant avformateLib
    participant avutilLib
    participant swresampleLib

    DynamicLibraries->>avcodecLib: resolve(symbol)
    alt resolved in avcodecLib
        avcodecLib-->>DynamicLibraries: QFunctionPointer
    else not resolved
        DynamicLibraries->>avformateLib: resolve(symbol)
        alt resolved in avformateLib
            avformateLib-->>DynamicLibraries: QFunctionPointer
        else not resolved
            DynamicLibraries->>avutilLib: resolve(symbol)
            alt resolved in avutilLib
                avutilLib-->>DynamicLibraries: QFunctionPointer
            else not resolved
                DynamicLibraries->>swresampleLib: resolve(symbol)
                alt resolved in swresampleLib
                    swresampleLib-->>DynamicLibraries: QFunctionPointer
                else not resolved
                    DynamicLibraries-->>DynamicLibraries: [log "[ffmpeg] Failed to resolve function"]
                end
            end
        end
    end
    DynamicLibraries-->>DynamicLibraries: m_funMap[symbol] = fgp
Loading

File-Level Changes

Change Details Files
Make dynamic library names and loaded set platform-aware, adding avutil/swresample and avoiding libvlccore on Windows.
  • Introduce Q_OS_WIN branches for VLC and FFmpeg-related library base names (no .so suffix on Windows; add avutil and swresample).
  • Ensure DynamicLibraries destructor unloads the newly managed avutil and swresample libraries.
  • Extend ffmpeg symbol resolution to search avcodec, then avformat, then avutil, then swresample, with improved debug logging and a single failure warning.
  • Correct libvlc loading on Windows by detecting paths that resolve to vlccore and re-pointing to libvlc.dll explicitly.
  • Add avutil library loading as required (failure is fatal) and swresample loading as optional with warnings when unavailable.
src/libdmusic/core/dynamiclibraries.cpp
src/libdmusic/core/dynamiclibraries.h
Improve library search path resolution and existence checks to support Windows-specific behavior and multiple search paths.
  • Change DmGlobal::libPath to iterate through a list of search paths (application directory first on Windows, then Qt LibrariesPath), scanning for exact and compatible library names.
  • Add Windows-specific handling in libPath to match .dll suffixes instead of .so when choosing a compatible library.
  • Adjust libExist to treat Windows library names literally and preserve .dll-style names, while retaining the .so-stripping behavior on non-Windows.
  • Update initPlaybackEngineType to use Windows-appropriate library names for VLC/FFmpeg detection and to log Windows-specific messages.
src/libdmusic/global.cpp
Refresh SPDX-FileCopyrightText ranges to cover 2023–2026 in modified files.
  • Update SPDX-FileCopyrightText year ranges at the top of dynamiclibraries.cpp, global.cpp, and dynamiclibraries.h to 2023–2026.
src/libdmusic/core/dynamiclibraries.cpp
src/libdmusic/global.cpp
src/libdmusic/core/dynamiclibraries.h

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

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