Skip to content

Fix build failures on Linux and Windows #42

Open
navidicted wants to merge 4 commits intosjoenk:mainfrom
navidicted:fix-platform-builds
Open

Fix build failures on Linux and Windows #42
navidicted wants to merge 4 commits intosjoenk:mainfrom
navidicted:fix-platform-builds

Conversation

@navidicted
Copy link
Copy Markdown

Description

This PR resolves build issues on both Linux and Windows when compiling the plugin with newer compilers.

Changes Included

1. Linux Build Fix

  • Issue:
    • With GCC 15.2.1 compiler, the G_DEFINE_TYPE macro fails when the required class and instance types are not declared beforehand. This results in undefined type errors and prevents the plugin from building correctly, potentially leading to a MissingPluginException at runtime.
  • Fix:
    • Added explicit forward typedef declarations for _AudioDecoderPlugin and _AudioDecoderPluginClass before the struct definitions so the macro can resolve the types correctly.

2. Windows Build Fix

  • Issues:
    • MSVC defines legacy min and max macros via <windows.h>, which conflict with std::min and std::max, causing C2589 and C2059 compilation errors.
    • C4245 warning caused by an implicit conversion when passing MF_SOURCE_READER_MEDIASOURCE to a DWORD.
    • In newer Flutter Windows SDK version, flutter::EncodableMap and flutter::EncodableList types no longer transitively included via standart_method_codec.h and without fix it gives compilation error.
    • std::tolower returns int, assignment to char caused possible data loss warning.
  • Fixes:
    • Wrapped std::min and std::max calls in parentheses (e.g. (std::min)(...)) to avoid macro expansion conflicts.
    • Added an explicit static_cast<DWORD> for MF_SOURCE_READER_MEDIASOURCE to match the expected type.
    • Added necessary library import into audio_decoder_plugin.h
    • Explicitly cast result to char, use unsigned char input to avoidd undefined behaviour for negative char values.

Environment Tested

  • Linux: GCC 15.2.1
  • Windows: MSVC toolchain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant