Under some conditions, GetMaxPosition() returns zero, which should cause
position queries to fail rather than crash.
gst_query_parse_position (query, &format, NULL);
if (format == GST_FORMAT_TIME) {
gint64 pos;
-
- pos = (modplug->song_length * modplug->mSoundFile->GetCurrentPos ());
- pos /= modplug->mSoundFile->GetMaxPosition ();
- gst_query_set_position (query, format, pos);
- res = TRUE;
+ guint32 max;
+
+ max = modplug->mSoundFile->GetMaxPosition();
+ if (max > 0) {
+ pos = (modplug->song_length * modplug->mSoundFile->GetCurrentPos ()) /
+ max;
+ gst_query_set_position (query, format, pos);
+ res = TRUE;
+ }
}
}
break;