From bbdd624d50313b7b5a3b4d570a9a8e38b0f23c13 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 2 Nov 2023 13:53:38 -0400 Subject: [PATCH] Ladybird: Do not require Qt6 Multimedia if PulseAudio is available If PulseAudio is available, the Qt6 audio plugin will never be used. So let's remove it from the build. Note that on macOS, the Qt6 audio plugin will be used if the Qt chrome is enabled. Otherwise, Audio Unit will be used for the AppKit chrome. --- Documentation/BuildInstructionsLadybird.md | 2 ++ Ladybird/CMakeLists.txt | 2 +- Ladybird/WebContent/CMakeLists.txt | 16 +++++++++++++--- Ladybird/WebContent/main.cpp | 11 +++++++---- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Documentation/BuildInstructionsLadybird.md b/Documentation/BuildInstructionsLadybird.md index 1b922f667c7..69e2b30f8b0 100644 --- a/Documentation/BuildInstructionsLadybird.md +++ b/Documentation/BuildInstructionsLadybird.md @@ -4,6 +4,8 @@ Qt6 development packages and a C++20 capable compiler are required. g++-12 or clang-15 are required at a minimum for c++20 support. +NOTE: In all of the below lists of packages, the Qt6 multimedia package is not needed if your Linux system supports PulseAudio. + On Debian/Ubuntu required packages include, but are not limited to: ``` diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index 98456d8f885..eb56a4ff83c 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -95,7 +95,7 @@ if (ENABLE_QT) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) - find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network Multimedia) + find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network) elseif (APPLE) find_library(COCOA_LIBRARY Cocoa) endif() diff --git a/Ladybird/WebContent/CMakeLists.txt b/Ladybird/WebContent/CMakeLists.txt index 89efdb394c4..72aad5417d2 100644 --- a/Ladybird/WebContent/CMakeLists.txt +++ b/Ladybird/WebContent/CMakeLists.txt @@ -16,8 +16,6 @@ set(WEBCONTENT_SOURCES if (ENABLE_QT) qt_add_executable(WebContent ${WEBCONTENT_SOURCES}) target_sources(WebContent PRIVATE - ../Qt/AudioCodecPluginQt.cpp - ../Qt/AudioThread.cpp ../Qt/EventLoopImplementationQt.cpp ../Qt/EventLoopImplementationQtEventTarget.cpp ../Qt/RequestManagerQt.cpp @@ -27,8 +25,20 @@ if (ENABLE_QT) ../Qt/WebSocketImplQt.cpp main.cpp ) - target_link_libraries(WebContent PRIVATE Qt::Core Qt::Network Qt::Multimedia) + target_link_libraries(WebContent PRIVATE Qt::Core Qt::Network) target_compile_definitions(WebContent PRIVATE HAVE_QT=1) + + if (NOT HAVE_PULSEAUDIO) + find_package(Qt6 REQUIRED COMPONENTS Multimedia) + + target_sources(WebContent PRIVATE + ../Qt/AudioCodecPluginQt.cpp + ../Qt/AudioThread.cpp + ) + + target_link_libraries(WebContent PRIVATE Qt::Multimedia) + target_compile_definitions(WebContent PRIVATE HAVE_QT_MULTIMEDIA=1) + endif() else() set(LIB_TYPE STATIC) if (ANDROID) diff --git a/Ladybird/WebContent/main.cpp b/Ladybird/WebContent/main.cpp index ddbef5b05c7..8d4d1bbac33 100644 --- a/Ladybird/WebContent/main.cpp +++ b/Ladybird/WebContent/main.cpp @@ -34,11 +34,14 @@ #include #if defined(HAVE_QT) -# include # include # include # include # include + +# if defined(HAVE_QT_MULTIMEDIA) +# include +# endif #endif static ErrorOr load_content_filters(); @@ -60,10 +63,10 @@ ErrorOr serenity_main(Main::Arguments arguments) Web::Platform::ImageCodecPlugin::install(*new Ladybird::ImageCodecPlugin); Web::Platform::AudioCodecPlugin::install_creation_hook([](auto loader) { -#if defined(AK_OS_MACOS) || defined(HAVE_PULSEAUDIO) - return Web::Platform::AudioCodecPluginAgnostic::create(move(loader)); -#elif defined(HAVE_QT) +#if defined(HAVE_QT_MULTIMEDIA) return Ladybird::AudioCodecPluginQt::create(move(loader)); +#elif defined(AK_OS_MACOS) || defined(HAVE_PULSEAUDIO) + return Web::Platform::AudioCodecPluginAgnostic::create(move(loader)); #else (void)loader; return Error::from_string_literal("Don't know how to initialize audio in this configuration!");