mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 17:29:01 +00:00
LibVideo: Allow PlaybackManager owners to terminate the decoder thread
This will be needed by LibWeb to explicitly stop the decoder thread just before the media element is garbage collected.
This commit is contained in:
parent
8588008d42
commit
84fd37704e
Notes:
sideshowbarker
2024-07-17 06:28:38 +09:00
Author: https://github.com/trflynn89
Commit: 84fd37704e
Pull-request: https://github.com/SerenityOS/serenity/pull/24110
Issue: https://github.com/SerenityOS/serenity/issues/24044
2 changed files with 14 additions and 5 deletions
|
@ -96,11 +96,7 @@ PlaybackManager::PlaybackManager(NonnullOwnPtr<Demuxer>& demuxer, Track video_tr
|
|||
|
||||
PlaybackManager::~PlaybackManager()
|
||||
{
|
||||
m_stop_decoding.exchange(true);
|
||||
m_decode_wait_condition.broadcast();
|
||||
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Waiting for decode thread to end...");
|
||||
(void)m_decode_thread->join();
|
||||
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Successfully destroyed PlaybackManager.");
|
||||
terminate_playback();
|
||||
}
|
||||
|
||||
void PlaybackManager::resume_playback()
|
||||
|
@ -117,6 +113,18 @@ void PlaybackManager::pause_playback()
|
|||
TRY_OR_FATAL_ERROR(m_playback_handler->pause());
|
||||
}
|
||||
|
||||
void PlaybackManager::terminate_playback()
|
||||
{
|
||||
m_stop_decoding.exchange(true);
|
||||
m_decode_wait_condition.broadcast();
|
||||
|
||||
if (m_decode_thread->needs_to_be_joined()) {
|
||||
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Waiting for decode thread to end...");
|
||||
(void)m_decode_thread->join();
|
||||
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Successfully destroyed PlaybackManager.");
|
||||
}
|
||||
}
|
||||
|
||||
Duration PlaybackManager::current_playback_time()
|
||||
{
|
||||
return m_playback_handler->current_time();
|
||||
|
|
|
@ -122,6 +122,7 @@ public:
|
|||
void resume_playback();
|
||||
void pause_playback();
|
||||
void restart_playback();
|
||||
void terminate_playback();
|
||||
void seek_to_timestamp(Duration, SeekMode = DEFAULT_SEEK_MODE);
|
||||
bool is_playing() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue