Skip to content

[GSTMediaPlayer] Make fake preroll asynchronous (#1232) #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: wpe-2.46
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,30 @@ bool MediaPlayerPrivateGStreamerMSE::doSeek(const SeekTarget& target, float rate
m_mediaSourcePrivate->seekToTime(*result);

auto player = m_player.get();
if (player && !player->isVideoPlayer() && m_audioSink) {
if (player && !hasVideo() && m_audioSink) {
gboolean audioSinkPerformsAsyncStateChanges;
g_object_get(m_audioSink.get(), "async", &audioSinkPerformsAsyncStateChanges, nullptr);
if (!audioSinkPerformsAsyncStateChanges) {
// If audio-only pipeline's sink is not performing async state changes
// we must simulate preroll right away as otherwise nothing will trigger it.
bool mustPreventPositionReset = m_isWaitingForPreroll && m_isSeeking;
if (mustPreventPositionReset)
m_cachedPosition = currentTime();
didPreroll();
if (mustPreventPositionReset) {
propagateReadyStateToPlayer();
invalidateCachedPosition();
}

// Post this on HTML media element queue so it will be executed
// synchonously with media events (e.g. seeking). This will ensure
// that HTML element attributes (like HTMLmedia.seeking) are not reseted
// before app receives "seeking" event
player->queueTaskOnEventLoop([this, weakThis = ThreadSafeWeakPtr { *this }] {
RefPtr self = weakThis.get();
if (!self)
return;
bool mustPreventPositionReset = m_isWaitingForPreroll && m_isSeeking;
if (mustPreventPositionReset)
m_cachedPosition = currentTime();
didPreroll();
if (mustPreventPositionReset) {
propagateReadyStateToPlayer();
invalidateCachedPosition();
}
});
}
}
});
Expand Down