mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
modplug: avoid division by zero
Under some conditions, GetMaxPosition() returns zero, which should cause position queries to fail rather than crash.
This commit is contained in:
parent
04fd705906
commit
2b024ec1b4
1 changed files with 8 additions and 4 deletions
|
@ -298,11 +298,15 @@ gst_modplug_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
gst_query_parse_position (query, &format, NULL);
|
||||
if (format == GST_FORMAT_TIME) {
|
||||
gint64 pos;
|
||||
guint32 max;
|
||||
|
||||
pos = (modplug->song_length * modplug->mSoundFile->GetCurrentPos ());
|
||||
pos /= modplug->mSoundFile->GetMaxPosition ();
|
||||
gst_query_set_position (query, format, pos);
|
||||
res = TRUE;
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue