From 6a0ccd3477b0ddb0a550b56bdc41e8ae1cf740a6 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Wed, 16 Sep 2009 16:55:29 +1000 Subject: Fixes: Fixed incorrect tracks number calculation with phonon/gst RevBy: Andrew den Exter Details: gst_element_query_duration(element,format,duration) doesn't always return duration in format being asked for (tracks in this case), it can also return duration in format it can (Time) and modify format parameter, so check the format is still the same as requested is necessary. This bug prevented Phonon to emit finished() signal with some files, since it expected next tracks to exist. --- src/3rdparty/phonon/gstreamer/mediaobject.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp index 74fc1b4..13f9734 100644 --- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp +++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp @@ -965,11 +965,15 @@ void MediaObject::getStreamInfo() gint64 titleCount; GstFormat format = gst_format_get_by_nick("track"); if (gst_element_query_duration (m_pipeline, &format, &titleCount)) { - int oldAvailableTitles = m_availableTitles; - m_availableTitles = (int)titleCount; - if (m_availableTitles != oldAvailableTitles) { - emit availableTitlesChanged(m_availableTitles); - m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this); + //check if returned format is still "track", + //gstreamer sometimes returns the total time, if tracks information is not available. + if (qstrcmp(gst_format_get_name(format), "track") == 0) { + int oldAvailableTitles = m_availableTitles; + m_availableTitles = (int)titleCount; + if (m_availableTitles != oldAvailableTitles) { + emit availableTitlesChanged(m_availableTitles); + m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this); + } } } -- cgit v0.12