modplug: small seeking code reshuffle

Put the code that checks stop values together. Don't clamp a cur value of -1 to 0 (should not happen right now).
This commit is contained in:
Stefan Sauer 2013-12-20 18:12:53 +01:00
parent a18ad22b47
commit 0e3917b9c0

View file

@ -345,8 +345,8 @@ gst_modplug_do_seek (GstModPlug * modplug, GstEvent * event)
modplug->frequency); modplug->frequency);
#endif #endif
gst_event_parse_seek (event, &rate, &format, &flags, gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur,
&cur_type, &cur, &stop_type, &stop); &stop_type, &stop);
if (format != GST_FORMAT_TIME) if (format != GST_FORMAT_TIME)
goto no_time; goto no_time;
@ -357,8 +357,10 @@ gst_modplug_do_seek (GstModPlug * modplug, GstEvent * event)
if (stop_type == GST_SEEK_TYPE_NONE) if (stop_type == GST_SEEK_TYPE_NONE)
stop = GST_CLOCK_TIME_NONE; stop = GST_CLOCK_TIME_NONE;
if (!GST_CLOCK_TIME_IS_VALID (stop) && modplug->song_length > 0)
stop = modplug->song_length;
cur = CLAMP (cur, 0, modplug->song_length); cur = CLAMP (cur, -1, modplug->song_length);
GST_DEBUG_OBJECT (modplug, "seek to %" GST_TIME_FORMAT, GST_DEBUG_OBJECT (modplug, "seek to %" GST_TIME_FORMAT,
GST_TIME_ARGS ((guint64) cur)); GST_TIME_ARGS ((guint64) cur));
@ -379,8 +381,6 @@ gst_modplug_do_seek (GstModPlug * modplug, GstEvent * event)
gst_element_post_message (GST_ELEMENT (modplug), gst_element_post_message (GST_ELEMENT (modplug),
gst_message_new_segment_start (GST_OBJECT (modplug), format, cur)); gst_message_new_segment_start (GST_OBJECT (modplug), format, cur));
} }
if (stop == -1 && modplug->song_length > 0)
stop = modplug->song_length;
if (flush) { if (flush) {
gst_pad_push_event (modplug->srcpad, gst_event_new_flush_stop (TRUE)); gst_pad_push_event (modplug->srcpad, gst_event_new_flush_stop (TRUE));