mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
Meta: Consolidate checking for the system audio backend
The goal here is to ensure we check for audio backends in a way that makes sense. On macOS, let's just always use Audio Unit (and thus avoid any checks for Pulse, to reduce needless/confusing build log noise). We will also only use the Qt audio backend if no other backend was found, rather than only checking for Pulse.
This commit is contained in:
parent
33a1e38646
commit
79a2b96d1c
Notes:
github-actions[bot]
2024-12-25 11:01:34 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/79a2b96d1c4 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3027
5 changed files with 35 additions and 19 deletions
|
@ -1,6 +1,7 @@
|
||||||
|
include(audio)
|
||||||
|
|
||||||
if (NOT ANDROID AND NOT WIN32)
|
if (NOT ANDROID AND NOT WIN32)
|
||||||
include(ffmpeg)
|
include(ffmpeg)
|
||||||
include(pulseaudio)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
@ -30,23 +31,20 @@ else()
|
||||||
target_sources(LibMedia PRIVATE FFmpeg/FFmpegVideoDecoderStub.cpp)
|
target_sources(LibMedia PRIVATE FFmpeg/FFmpegVideoDecoderStub.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Audio backend -- how we output audio to the speakers
|
if (LADYBIRD_AUDIO_BACKEND STREQUAL "PULSE")
|
||||||
if (HAVE_PULSEAUDIO)
|
|
||||||
target_sources(LibMedia PRIVATE
|
target_sources(LibMedia PRIVATE
|
||||||
Audio/PlaybackStreamPulseAudio.cpp
|
Audio/PlaybackStreamPulseAudio.cpp
|
||||||
Audio/PulseAudioWrappers.cpp
|
Audio/PulseAudioWrappers.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(LibMedia PRIVATE PkgConfig::PULSEAUDIO)
|
target_link_libraries(LibMedia PRIVATE PkgConfig::PULSEAUDIO)
|
||||||
target_compile_definitions(LibMedia PUBLIC HAVE_PULSEAUDIO=1)
|
elseif (LADYBIRD_AUDIO_BACKEND STREQUAL "AUDIO_UNIT")
|
||||||
elseif (APPLE AND NOT IOS)
|
|
||||||
target_sources(LibMedia PRIVATE Audio/PlaybackStreamAudioUnit.cpp)
|
target_sources(LibMedia PRIVATE Audio/PlaybackStreamAudioUnit.cpp)
|
||||||
|
|
||||||
find_library(AUDIO_UNIT AudioUnit REQUIRED)
|
find_library(AUDIO_UNIT AudioUnit REQUIRED)
|
||||||
target_link_libraries(LibMedia PRIVATE ${AUDIO_UNIT})
|
target_link_libraries(LibMedia PRIVATE ${AUDIO_UNIT})
|
||||||
elseif (ANDROID)
|
elseif (LADYBIRD_AUDIO_BACKEND STREQUAL "OBOE")
|
||||||
target_sources(LibMedia PRIVATE Audio/PlaybackStreamOboe.cpp)
|
target_sources(LibMedia PRIVATE Audio/PlaybackStreamOboe.cpp)
|
||||||
find_package(oboe REQUIRED CONFIG)
|
find_package(oboe REQUIRED CONFIG)
|
||||||
target_link_libraries(LibMedia PRIVATE log oboe::oboe)
|
target_link_libraries(LibMedia PRIVATE log oboe::oboe)
|
||||||
else()
|
elseif (DEFINED LADYBIRD_AUDIO_BACKEND)
|
||||||
message(WARNING "No audio backend available")
|
message(FATAL_ERROR "Please update ${CMAKE_CURRENT_LIST_FILE} for audio backend ${LADYBIRD_AUDIO_BACKEND}")
|
||||||
endif()
|
endif()
|
||||||
|
|
20
Meta/CMake/audio.cmake
Normal file
20
Meta/CMake/audio.cmake
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
include_guard()
|
||||||
|
|
||||||
|
# Audio backend -- how we output audio to the speakers.
|
||||||
|
if (APPLE AND NOT IOS)
|
||||||
|
set(LADYBIRD_AUDIO_BACKEND "AUDIO_UNIT")
|
||||||
|
return()
|
||||||
|
elseif (ANDROID)
|
||||||
|
set(LADYBIRD_AUDIO_BACKEND "OBOE")
|
||||||
|
return()
|
||||||
|
elseif (NOT WIN32)
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(PULSEAUDIO IMPORTED_TARGET libpulse)
|
||||||
|
|
||||||
|
if (PULSEAUDIO_FOUND)
|
||||||
|
set(LADYBIRD_AUDIO_BACKEND "PULSE")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(WARNING "No audio backend available")
|
|
@ -1,8 +0,0 @@
|
||||||
include_guard()
|
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
|
||||||
pkg_check_modules(PULSEAUDIO IMPORTED_TARGET libpulse)
|
|
||||||
|
|
||||||
if (PULSEAUDIO_FOUND)
|
|
||||||
set(HAVE_PULSEAUDIO ON CACHE BOOL "" FORCE)
|
|
||||||
endif()
|
|
|
@ -1,4 +1,4 @@
|
||||||
include(pulseaudio)
|
include(audio)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
ConnectionFromClient.cpp
|
ConnectionFromClient.cpp
|
||||||
|
@ -35,7 +35,7 @@ if (ENABLE_QT)
|
||||||
target_link_libraries(WebContent PRIVATE Qt::Core)
|
target_link_libraries(WebContent PRIVATE Qt::Core)
|
||||||
target_compile_definitions(WebContent PRIVATE HAVE_QT=1)
|
target_compile_definitions(WebContent PRIVATE HAVE_QT=1)
|
||||||
|
|
||||||
if (NOT HAVE_PULSEAUDIO)
|
if (NOT DEFINED LADYBIRD_AUDIO_BACKEND)
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Multimedia)
|
find_package(Qt6 REQUIRED COMPONENTS Multimedia)
|
||||||
|
|
||||||
target_sources(WebContent PRIVATE
|
target_sources(WebContent PRIVATE
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
include(audio)
|
||||||
|
|
||||||
set(TEST_SOURCES
|
set(TEST_SOURCES
|
||||||
TestH264Decode.cpp
|
TestH264Decode.cpp
|
||||||
TestParseMatroska.cpp
|
TestParseMatroska.cpp
|
||||||
|
@ -10,3 +12,7 @@ set(TEST_SOURCES
|
||||||
foreach(source IN LISTS TEST_SOURCES)
|
foreach(source IN LISTS TEST_SOURCES)
|
||||||
lagom_test("${source}" LibMedia LIBS LibMedia LibFileSystem WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
lagom_test("${source}" LibMedia LIBS LibMedia LibFileSystem WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
if (LADYBIRD_AUDIO_BACKEND STREQUAL "PULSE")
|
||||||
|
target_compile_definitions(TestPlaybackStream PRIVATE HAVE_PULSEAUDIO=1)
|
||||||
|
endif()
|
||||||
|
|
Loading…
Reference in a new issue