From 667de7f8240d80a7c83b76a4265619733ee40d20 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Wed, 4 Sep 2024 02:25:07 -0700 Subject: [PATCH] [GStreamer][MediaStream] Reduce usage of the player's m_isPaused variable https://bugs.webkit.org/show_bug.cgi?id=278983 Reviewed by Xabier Rodriguez-Calvar. Use the paused() method to know if the newly added audio track should start or not. The m_isPaused variable is confusing, see also bug #260385. Covered by fast/mediastream/play-newly-added-audio-track.html * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::paused const): (WebCore::MediaPlayerPrivateGStreamer::configureMediaStreamAudioTracks): (WebCore::MediaPlayerPrivateGStreamer::updateStates): Canonical link: https://commits.webkit.org/283144@main --- .../graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index 739bd8a81673e..62d2cebc2586f 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -517,7 +517,7 @@ bool MediaPlayerPrivateGStreamer::paused() const // For debug mode (either GStreamer of WebKit) we make some extra check to ensure there is no desynchronization // between pipeline and player. In the case of media stream, we just return the result of the pipeline as there are // nuances regarding the prerolling creating some regressions in the tests. -#if !defined(GST_DISABLE_GST_DEBUG) || !defined(NDEBUG) || (defined(ENABLE_MEDIA_STREAM) && ENABLE_MEDIA_STREAM) +#if !defined(GST_DISABLE_GST_DEBUG) || !defined(NDEBUG) || ENABLE(MEDIA_STREAM) GstState state, pending; auto stateChange = gst_element_get_state(m_pipeline.get(), &state, &pending, 0); bool isPipelinePaused = state <= GST_STATE_PAUSED; @@ -1767,7 +1767,7 @@ void MediaPlayerPrivateGStreamer::configureMediaStreamAudioTracks() { #if ENABLE(MEDIA_STREAM) if (WEBKIT_IS_MEDIA_STREAM_SRC(m_source.get())) - webkitMediaStreamSrcConfigureAudioTracks(WEBKIT_MEDIA_STREAM_SRC(m_source.get()), volume(), isMuted(), !m_isPaused); + webkitMediaStreamSrcConfigureAudioTracks(WEBKIT_MEDIA_STREAM_SRC(m_source.get()), volume(), isMuted(), !paused()); #endif } @@ -2524,7 +2524,6 @@ void MediaPlayerPrivateGStreamer::updateStates() MediaPlayer::NetworkState oldNetworkState = m_networkState; MediaPlayer::ReadyState oldReadyState = m_readyState; - bool oldIsPaused = m_isPaused; GstState pending, state; bool stateReallyChanged = false; RefPtr player = m_player.get(); @@ -2713,9 +2712,6 @@ void MediaPlayerPrivateGStreamer::updateStates() } else if (m_isSeeking && !(state == GST_STATE_PLAYING && pending == GST_STATE_PAUSED)) finishSeek(); } - - if (oldIsPaused != m_isPaused) - configureMediaStreamAudioTracks(); } void MediaPlayerPrivateGStreamer::mediaLocationChanged(GstMessage* message)