[Libreoffice-commits] core.git: slideshow/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Feb 28 23:24:30 UTC 2019


 slideshow/source/engine/animationnodes/animationaudionode.cxx |   21 ++++++++--
 slideshow/source/engine/animationnodes/animationaudionode.hxx |    1 
 slideshow/source/engine/soundplayer.cxx                       |    5 ++
 slideshow/source/inc/soundplayer.hxx                          |    1 
 4 files changed, 25 insertions(+), 3 deletions(-)

New commits:
commit 71755f36394c1ffbf01af0180a05a258916dd5c9
Author:     Mark Hung <marklh9 at gmail.com>
AuthorDate: Wed Feb 27 23:20:31 2019 +0800
Commit:     Mark Hung <marklh9 at gmail.com>
CommitDate: Fri Mar 1 00:24:05 2019 +0100

    tdf#123743 deactive after the player is stopped.
    
    The queried media duration for gstreamer isn't ready at the beginning.
    Instead of deactivate the audio node immediately after querying the
    duration, schedule to update the media duration and use the updated
    duration to schedule deactivation.
    
    Change-Id: I8bfa69377fbc18b21baf48bc293d2d0853e8805a
    Reviewed-on: https://gerrit.libreoffice.org/68451
    Tested-by: Jenkins
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/slideshow/source/engine/animationnodes/animationaudionode.cxx b/slideshow/source/engine/animationnodes/animationaudionode.cxx
index b024de24de53..9e3f6bc25271 100644
--- a/slideshow/source/engine/animationnodes/animationaudionode.cxx
+++ b/slideshow/source/engine/animationnodes/animationaudionode.cxx
@@ -76,12 +76,14 @@ void AnimationAudioNode::activate_st()
         }
         else
         {
-            // no node duration. Take inherent media time, then
+            // no node duration. Take inherent media time. We have to recheck
+            // if the player is playing in case the duration isn't accurate
+            // or the progress fall behind.
             auto self(getSelf());
             scheduleDeactivationEvent(
-                makeDelay( [self] () { self->deactivate(); },
+                makeDelay( [this] () { this->checkPlayingStatus(); },
                            mpPlayer->getDuration(),
-                           "AnimationAudioNode::deactivate with delay") );
+                           "AnimationAudioNode::check if sitll playing with delay") );
         }
     }
     else
@@ -182,6 +184,19 @@ bool AnimationAudioNode::handleAnimationEvent(
     return true;
 }
 
+void AnimationAudioNode::checkPlayingStatus()
+{
+    auto self(getSelf());
+    double nDuration = mpPlayer->getDuration();
+    if (!mpPlayer->isPlaying() || nDuration < 0.0)
+        nDuration = 0.0;
+
+    scheduleDeactivationEvent(
+        makeDelay( [self] () { self->deactivate(); },
+            nDuration,
+            "AnimationAudioNode::deactivate with delay") );
+}
+
 } // namespace internal
 } // namespace presentation
 
diff --git a/slideshow/source/engine/animationnodes/animationaudionode.hxx b/slideshow/source/engine/animationnodes/animationaudionode.hxx
index 6efd40fdbd20..30de41cfb44e 100644
--- a/slideshow/source/engine/animationnodes/animationaudionode.hxx
+++ b/slideshow/source/engine/animationnodes/animationaudionode.hxx
@@ -59,6 +59,7 @@ private:
 
     void createPlayer() const;
     void resetPlayer() const;
+    void checkPlayingStatus();
 };
 
 } // namespace internal
diff --git a/slideshow/source/engine/soundplayer.cxx b/slideshow/source/engine/soundplayer.cxx
index 65b578304d62..18a1948089f9 100644
--- a/slideshow/source/engine/soundplayer.cxx
+++ b/slideshow/source/engine/soundplayer.cxx
@@ -170,6 +170,11 @@ namespace slideshow
             if( mxPlayer.is() )
                 mxPlayer->setPlaybackLoop( bLoop );
         }
+
+        bool SoundPlayer::isPlaying() const
+        {
+            return mxPlayer->isPlaying();
+        }
     }
 }
 
diff --git a/slideshow/source/inc/soundplayer.hxx b/slideshow/source/inc/soundplayer.hxx
index ea496d88b8cc..92ac94b851fb 100644
--- a/slideshow/source/inc/soundplayer.hxx
+++ b/slideshow/source/inc/soundplayer.hxx
@@ -83,6 +83,7 @@ namespace slideshow
 
             bool startPlayback();
             bool stopPlayback();
+            bool isPlaying() const;
 
             void setPlaybackLoop( bool bLoop );
 


More information about the Libreoffice-commits mailing list