Skip to content

Commit

Permalink
[GStreamer] Fix readyState calculations
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=248217

Reviewed by Philippe Normand.

On some platforms, the audio sink is acting as a fake sink while the decoder fetches data
from the pipeline and transfers it to the SoC drivers, even in READY and PAUSED states,
meaning we cannot rely on buffering messages anymore.

However, on that platform the audio sinks implements buffering queries, that are currently
issued to the entire pipeline, which on some platforms may yield misleading results
if some random element implements buffering queries and receives that query first.

Thus this patch first queries the audio sink, before trying the video sink and finally
the pipeline itself.

Original author: Pawel Lampe <pawel.lampe@gmail.com>
See: WebPlatformForEmbedded/WPEWebKit#975

* Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::updateStates): Send buffering query to audio/video sinks first

Canonical link: https://commits.webkit.org/257066@main
  • Loading branch information
vivienne-w authored and philn committed Nov 28, 2022
1 parent ab46c3e commit 7385258
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -2337,9 +2337,12 @@ void MediaPlayerPrivateGStreamer::updateStates()
GRefPtr<GstQuery> query = adoptGRef(gst_query_new_buffering(GST_FORMAT_PERCENT));

m_isBuffering = m_bufferingPercentage < 100;
if (gst_element_query(m_pipeline.get(), query.get())) {
if ((m_audioSink && gst_element_query(m_audioSink.get(), query.get()))
|| (m_videoSink && gst_element_query(m_videoSink.get(), query.get()))
|| gst_element_query(m_pipeline.get(), query.get())) {
gboolean isBuffering = m_isBuffering;
gst_query_parse_buffering_percent(query.get(), &isBuffering, nullptr);
GST_TRACE_OBJECT(pipeline(), "[Buffering] m_isBuffering forcefully updated from %d to %d", m_isBuffering, isBuffering);
m_isBuffering = isBuffering;
}

Expand Down

0 comments on commit 7385258

Please sign in to comment.