From cb33592f3c2e964e339b7ad5644036d131c6bf03 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Tue, 24 Oct 2017 15:57:30 +0200 Subject: [PATCH] fix get play position --- libarmbox/playback_gst.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libarmbox/playback_gst.cpp b/libarmbox/playback_gst.cpp index c902232..3c852be 100644 --- a/libarmbox/playback_gst.cpp +++ b/libarmbox/playback_gst.cpp @@ -747,13 +747,18 @@ bool cPlayback::GetPosition(int &position, int &duration) { //position GstFormat fmt = GST_FORMAT_TIME; //Returns time in nanosecs - gint64 pts = 0; - unsigned long long int sec = 0; - - gst_element_query_position(m_gst_playbin, fmt, &pts); + if (audioSink || videoSink) + { + g_signal_emit_by_name(audioSink ? audioSink : videoSink, "get-decoder-time", &pts); + if (!GST_CLOCK_TIME_IS_VALID(pts)){ + lt_info( "%s - %d failed\n", __FUNCTION__, __LINE__); + } + }else{ + if(!gst_element_query_position(m_gst_playbin, fmt, &pts)) + lt_info( "%s - %d failed\n", __FUNCTION__, __LINE__); + } position = pts / 1000000.0; - // duration GstFormat fmt_d = GST_FORMAT_TIME; //Returns time in nanosecs double length = 0;