Skip to content

Commit 9ce4840

Browse files
Sconyeocanha
authored andcommitted
[MSE][GStreamer] Skip waiting for preroll when audio sink is non-async
https://bugs.webkit.org/show_bug.cgi?id=262492 Reviewed by Alicia Boya Garcia. When the audio sink is non-async, the GST_STATE_CHANGE_ASYNC change will never happen. Under these circumstances, the asyncStateChangeDone() code will never run. This patch calls that method manually, fixing the issue. The method has been now given a better name (didPreroll()), which better expresses the semantics. Original author: Pawel Lampe <pawel.lampe@gmail.com> See: #1195 * Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp: (WebCore::MediaPlayerPrivateGStreamerMSE::doSeek): Manually call asyncStateChangeDone() when the audio sink is non-async. * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::handleMessage): asyncStateChangeDone() renamed to didPreroll(). * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: (WebCore::MediaPlayerPrivateGStreamer::didPreroll): Old asyncStateChangeDone(). (WebCore::MediaPlayerPrivateGStreamer::asyncStateChangeDone): Deleted. * Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp: (WebCore::MediaPlayerPrivateGStreamerMSE::doSeek): asyncStateChangeDone() renamed to didPreroll(). (WebCore::MediaPlayerPrivateGStreamerMSE::didPreroll): Old asyncStateChangeDone(). (WebCore::MediaPlayerPrivateGStreamerMSE::asyncStateChangeDone): Deleted. * Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h: Canonical link: https://commits.webkit.org/268845@main
1 parent 3b2979e commit 9ce4840

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,7 @@ void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
18351835

18361836
// The MediaPlayerPrivateGStreamer superclass now processes what it needs by calling updateStates() in handleMessage() for
18371837
// GST_MESSAGE_STATE_CHANGED. However, subclasses still need to override asyncStateChangeDone() to do their own stuff.
1838-
asyncStateChangeDone();
1838+
didPreroll();
18391839
break;
18401840
case GST_MESSAGE_STATE_CHANGED: {
18411841
GstState newState;

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface
501501

502502
virtual void updateStates();
503503
void finishSeek();
504-
virtual void asyncStateChangeDone() { }
504+
virtual void didPreroll() { }
505505

506506
void createGSTPlayBin(const URL&);
507507

Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,19 @@ bool MediaPlayerPrivateGStreamerMSE::doSeek(const MediaTime& position, float rat
259259
invalidateCachedPosition();
260260

261261
// Notify MediaSource and have new frames enqueued (when they're available).
262+
262263
m_mediaSource->seekToTime(m_seekTime);
264+
265+
if (m_player && !m_player->isVideoPlayer() && m_audioSink) {
266+
gboolean audioSinkPerformsAsyncStateChanges;
267+
g_object_get(m_audioSink.get(), "async", &audioSinkPerformsAsyncStateChanges, nullptr);
268+
if (!audioSinkPerformsAsyncStateChanges) {
269+
// If audio-only pipeline's sink is not performing async state changes
270+
// we must simulate preroll right away as otherwise nothing will trigger it.
271+
didPreroll();
272+
}
273+
}
274+
263275
return true;
264276
}
265277

@@ -310,7 +322,7 @@ void MediaPlayerPrivateGStreamerMSE::propagateReadyStateToPlayer()
310322
m_player->timeChanged();
311323
}
312324

313-
void MediaPlayerPrivateGStreamerMSE::asyncStateChangeDone()
325+
void MediaPlayerPrivateGStreamerMSE::didPreroll()
314326
{
315327
ASSERT(GST_STATE(m_pipeline.get()) >= GST_STATE_PAUSED);
316328
// There are three circumstances in which a preroll can occur:

Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class MediaPlayerPrivateGStreamerMSE : public MediaPlayerPrivateGStreamer {
7979

8080
void setInitialVideoSize(const FloatSize&);
8181

82-
void asyncStateChangeDone() override;
82+
void didPreroll() override;
8383

8484
void startSource(const Vector<RefPtr<MediaSourceTrackGStreamer>>& tracks);
8585
WebKitMediaSrc* webKitMediaSrc() { return reinterpret_cast<WebKitMediaSrc*>(m_source.get()); }

0 commit comments

Comments
 (0)