avmedia/source/gstreamer/gstplayer.cxx |   21 ++++-----------------
 avmedia/source/gstreamer/gstplayer.hxx |    1 -
 2 files changed, 4 insertions(+), 18 deletions(-)

New commits:
commit 82081487bdaf80c7fcb92b4a75e9ab6bcdd1c16d
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Feb 13 21:26:46 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Feb 15 10:30:39 2022 +0100

    Related: tdf#34759 ditch PlayPending hack and use GST_STATE_TARGET
    
    which seems to resolve the various problems here like that
    pressing stop makes it rewind to start but continue to play and
    that rewind/seek makes it start when it shouldn't
    
    Change-Id: I3df44f82205b7e81ecbc4ac86240e02d52a92e62
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129928
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/avmedia/source/gstreamer/gstplayer.cxx 
b/avmedia/source/gstreamer/gstplayer.cxx
index f25ec5c6bb0c..397fe8809d93 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -284,7 +284,6 @@ Player::Player() :
     mbUseGtkSink( false ),
     mbFakeVideo (false ),
     mnUnmutedVolume( 0 ),
-    mbPlayPending ( false ),
     mbMuted( false ),
     mbLooping( false ),
     mbInitialized( false ),
@@ -384,7 +383,6 @@ void Player::processMessage( GstMessage *message )
     switch( GST_MESSAGE_TYPE( message ) ) {
     case GST_MESSAGE_EOS:
         gst_element_set_state( mpPlaybin, GST_STATE_READY );
-        mbPlayPending = false;
         if (mbLooping)
             start();
         break;
@@ -400,9 +398,6 @@ void Player::processMessage( GstMessage *message )
             {
                 gst_video_overlay_expose(mpXOverlay);
             }
-
-            if (mbPlayPending)
-                mbPlayPending = ((newstate == GST_STATE_READY) || (newstate == 
GST_STATE_PAUSED));
         }
         break;
     default:
@@ -531,7 +526,6 @@ void Player::preparePlaybin( std::u16string_view rURL, 
GstElement *pSink )
     if (mpPlaybin != nullptr)
     {
         gst_element_set_state( mpPlaybin, GST_STATE_NULL );
-        mbPlayPending = false;
         g_object_unref( mpPlaybin );
     }
 
@@ -596,7 +590,6 @@ bool Player::create( const OUString& rURL )
         preparePlaybin( rURL, gst_element_factory_make( "fakesink", nullptr ) 
);
 
         gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
-        mbPlayPending = false;
 
         bRet = true;
     }
@@ -609,7 +602,6 @@ bool Player::create( const OUString& rURL )
     return bRet;
 }
 
-
 void SAL_CALL Player::start()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
@@ -618,11 +610,9 @@ void SAL_CALL Player::start()
     if( mbInitialized && mpPlaybin != nullptr )
     {
         gst_element_set_state( mpPlaybin, GST_STATE_PLAYING );
-        mbPlayPending = true;
     }
 }
 
-
 void SAL_CALL Player::stop()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
@@ -631,21 +621,19 @@ void SAL_CALL Player::stop()
     if( mpPlaybin )
         gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
 
-    mbPlayPending = false;
     SAL_INFO( "avmedia.gstreamer", AVVERSION "stop " << mpPlaybin );
 }
 
-
 sal_Bool SAL_CALL Player::isPlaying()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
 
-    bool            bRet = mbPlayPending;
+    bool bRet = false;
 
-    // return whether the pipeline is in PLAYING STATE or not
-    if( !mbPlayPending && mbInitialized && mpPlaybin )
+    // return whether the pipeline target is PLAYING STATE or not
+    if (mbInitialized && mpPlaybin)
     {
-        bRet = GST_STATE( mpPlaybin ) == GST_STATE_PLAYING;
+        bRet = GST_STATE_TARGET(mpPlaybin) == GST_STATE_PLAYING;
     }
 
     SAL_INFO( "avmedia.gstreamer", AVVERSION "isPlaying " << bRet );
@@ -653,7 +641,6 @@ sal_Bool SAL_CALL Player::isPlaying()
     return bRet;
 }
 
-
 double SAL_CALL Player::getDuration()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
diff --git a/avmedia/source/gstreamer/gstplayer.hxx 
b/avmedia/source/gstreamer/gstplayer.hxx
index a82dac3f2b39..2694ac00ce7e 100644
--- a/avmedia/source/gstreamer/gstplayer.hxx
+++ b/avmedia/source/gstreamer/gstplayer.hxx
@@ -86,7 +86,6 @@ private:
     bool                    mbFakeVideo;
 
     gdouble                 mnUnmutedVolume;
-    bool                    mbPlayPending;
     bool                    mbMuted;
     bool                    mbLooping;
     bool                    mbInitialized;

Reply via email to