diff --git a/InterfacePlayerRDK.cpp b/InterfacePlayerRDK.cpp index fb3c3bf..c7c5888 100644 --- a/InterfacePlayerRDK.cpp +++ b/InterfacePlayerRDK.cpp @@ -1581,7 +1581,7 @@ bool InterfacePlayerRDK::IsUsingRialtoSink() /** * @brief Flush cached GstBuffers and set seek position & rate */ -bool InterfacePlayerRDK::Flush(double position, int rate, bool shouldTearDown, bool isAppSeek) +bool InterfacePlayerRDK::Flush(double position, int rate, bool shouldTearDown, bool isAppSeek, bool keepPausedSeek) { GstState aud_current; GstState aud_pending; @@ -1634,6 +1634,12 @@ bool InterfacePlayerRDK::Flush(double position, int rate, bool shouldTearDown, b } GstStateChangeReturn ret; ret = gst_element_get_state(interfacePlayerPriv->gstPrivateContext->pipeline, ¤t, &pending, 100 * GST_MSECOND); + if (GST_STATE_CHANGE_ASYNC == ret && keepPausedSeek) + { + MW_LOG_WARN("InterfacePlayerRDK: Flush requested during in-flight state change (current=%s pending=%s) - waiting to settle", + gst_element_state_get_name(current), gst_element_state_get_name(pending)); + ret = gst_element_get_state(interfacePlayerPriv->gstPrivateContext->pipeline, ¤t, &pending, 300 * GST_MSECOND); + } if ((current != GST_STATE_PLAYING && current != GST_STATE_PAUSED) || ret == GST_STATE_CHANGE_FAILURE) { MW_LOG_WARN("InterfacePlayerRDK: Pipeline state %s, ret %u", gst_element_state_get_name(current), ret); @@ -3441,12 +3447,14 @@ bool InterfacePlayerRDK::Pause(bool pause , bool forceStopGstreamerPreBuffering) /* wait a bit longer for the state change to conclude */ if (nextState != validateStateWithMsTimeout(this,nextState, 100)) { - MW_LOG_ERR("InterfacePlayerRDK_Pause - validateStateWithMsTimeout - FAILED GstState %d", nextState); + MW_LOG_ERR("InterfacePlayerRDK_Pause - validateStateWithMsTimeout - FAILED GstState %d ret-false", nextState); + retValue = false; } } else if (GST_STATE_CHANGE_SUCCESS != rc) { - MW_LOG_ERR("InterfacePlayerRDK_Pause - gst_element_set_state - FAILED rc %d", rc); + MW_LOG_ERR("InterfacePlayerRDK_Pause - gst_element_set_state - FAILED rc %d ret-false", rc); + retValue = false; } interfacePlayerPriv->gstPrivateContext->buffering_target_state = nextState; diff --git a/InterfacePlayerRDK.h b/InterfacePlayerRDK.h index ba5a090..343e5f0 100644 --- a/InterfacePlayerRDK.h +++ b/InterfacePlayerRDK.h @@ -716,8 +716,9 @@ class InterfacePlayerRDK * @param[in] shouldTearDown Whether to tear down the pipeline. * @param[in] GstState The desired GStreamer pipeline state. * @param[in] gstMediaFormat The media format for the pipeline. + * @param[in] keepPausedSeek true only for an explicit seek-with-keepPaused request */ - bool Flush(double position, int rate, bool shouldTearDown, bool isAppSeek); + bool Flush(double position, int rate, bool shouldTearDown, bool isAppSeek, bool keepPausedSeek); /** * @fn TimerAdd * @param[in] funcPtr function to execute on timer expiry