mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02:00
In order to free up memory when a video is paused for an extended period, we add a new Suspended state to PlaybackManager which tells the data providers to suspend. The data providers will handle this signal by disposing of their entire decoded data queue and flushing their decoder. When initially creating a PlaybackManager, and when resuming to a paused state, the delay before suspension will be much lower than when pausing from any other state. This is intended to prevent media elements from consuming memory for long when decoding the first frame for display, as well as to allow the data providers to suspend much more quickly after a seek while paused. Currently, resuming playback doesn't display much of a delay on my MacBook, though that may change once we completely tear down the decoder in the suspended state. It may also be exacerbated by using hardware decoders due more complex decoder initialization.
60 lines
2.1 KiB
CMake
60 lines
2.1 KiB
CMake
include(audio)
|
|
|
|
include(ffmpeg)
|
|
|
|
set(SOURCES
|
|
Containers/Matroska/MatroskaDemuxer.cpp
|
|
Containers/Matroska/Reader.cpp
|
|
IncrementallyPopulatedStream.cpp
|
|
PlaybackManager.cpp
|
|
PlaybackStates/PausedStateHandler.cpp
|
|
PlaybackStates/PlaybackStateHandler.cpp
|
|
PlaybackStates/ResumingStateHandler.cpp
|
|
Providers/AudioDataProvider.cpp
|
|
Providers/GenericTimeProvider.cpp
|
|
Providers/VideoDataProvider.cpp
|
|
Sinks/AudioMixingSink.cpp
|
|
Sinks/DisplayingVideoSink.cpp
|
|
TimedImage.cpp
|
|
VideoFrame.cpp
|
|
)
|
|
|
|
ladybird_lib(LibMedia media EXPLICIT_SYMBOL_EXPORT)
|
|
target_link_libraries(LibMedia PRIVATE LibCore LibCrypto LibIPC LibGfx LibThreading LibUnicode)
|
|
|
|
target_sources(LibMedia PRIVATE
|
|
FFmpeg/FFmpegAudioConverter.cpp
|
|
FFmpeg/FFmpegAudioDecoder.cpp
|
|
FFmpeg/FFmpegDemuxer.cpp
|
|
FFmpeg/FFmpegHelpers.cpp
|
|
FFmpeg/FFmpegIOContext.cpp
|
|
FFmpeg/FFmpegVideoDecoder.cpp
|
|
)
|
|
|
|
if (NOT ANDROID)
|
|
target_link_libraries(LibMedia PRIVATE PkgConfig::AVCODEC PkgConfig::AVFORMAT PkgConfig::AVUTIL PkgConfig::LIBSWRESAMPLE)
|
|
else()
|
|
target_include_directories(LibMedia PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
|
target_link_directories(LibMedia PRIVATE ${FFMPEG_LIBRARY_DIRS})
|
|
target_link_libraries(LibMedia PRIVATE ${FFMPEG_LIBRARIES})
|
|
endif()
|
|
|
|
if (LADYBIRD_AUDIO_BACKEND STREQUAL "PULSE")
|
|
target_sources(LibMedia PRIVATE
|
|
Audio/PlaybackStreamPulseAudio.cpp
|
|
Audio/PulseAudioWrappers.cpp
|
|
)
|
|
target_link_libraries(LibMedia PRIVATE PkgConfig::PULSEAUDIO)
|
|
elseif (LADYBIRD_AUDIO_BACKEND STREQUAL "AUDIO_UNIT")
|
|
target_sources(LibMedia PRIVATE Audio/PlaybackStreamAudioUnit.cpp)
|
|
find_library(AUDIO_TOOLBOX AudioToolbox REQUIRED)
|
|
target_link_libraries(LibMedia PRIVATE ${AUDIO_TOOLBOX})
|
|
elseif(LADYBIRD_AUDIO_BACKEND STREQUAL "WASAPI")
|
|
target_sources(LibMedia PRIVATE Audio/PlaybackStreamWasapi.cpp)
|
|
target_link_libraries(LibMedia PRIVATE ole32 avrt winmm)
|
|
elseif (DEFINED LADYBIRD_AUDIO_BACKEND)
|
|
message(FATAL_ERROR "Please update ${CMAKE_CURRENT_LIST_FILE} for audio backend ${LADYBIRD_AUDIO_BACKEND}")
|
|
else ()
|
|
target_sources(LibMedia PRIVATE Audio/PlaybackStream.cpp)
|
|
endif()
|