From f2b14c68d504612e13d1f9bed1b4b92ecb8a4de0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 29 Jul 2013 12:17:57 +0200 Subject: [PATCH] midi: Fix handling of the SEGMENT query --- ext/timidity/gsttimidity.c | 22 ++++++++++++++++++---- ext/timidity/gstwildmidi.c | 22 ++++++++++++++++++---- gst/midi/midiparse.c | 22 ++++++++++++++++++---- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/ext/timidity/gsttimidity.c b/ext/timidity/gsttimidity.c index 0cea951..0867795 100644 --- a/ext/timidity/gsttimidity.c +++ b/ext/timidity/gsttimidity.c @@ -279,11 +279,25 @@ gst_timidity_src_query (GstPad * pad, GstQuery * query) gst_query_set_formats (query, 3, GST_FORMAT_TIME, GST_FORMAT_BYTES, GST_FORMAT_DEFAULT); break; - case GST_QUERY_SEGMENT: - gst_query_set_segment (query, timidity->o_segment->rate, - timidity->o_segment->format, timidity->o_segment->start, - timidity->o_segment->stop); + case GST_QUERY_SEGMENT:{ + GstFormat format; + gint64 start, stop; + + format = timidity->o_segment->format; + + start = + gst_segment_to_stream_time (timidity->o_segment, format, + timidity->o_segment->start); + if ((stop = timidity->o_segment->stop) == -1) + stop = timidity->o_segment->duration; + else + stop = gst_segment_to_stream_time (timidity->o_segment, format, stop); + + gst_query_set_segment (query, timidity->o_segment->rate, format, start, + stop); + res = TRUE; break; + } case GST_QUERY_SEEKING: gst_query_set_seeking (query, timidity->o_segment->format, TRUE, 0, timidity->o_len); diff --git a/ext/timidity/gstwildmidi.c b/ext/timidity/gstwildmidi.c index 2930671..24e6740 100644 --- a/ext/timidity/gstwildmidi.c +++ b/ext/timidity/gstwildmidi.c @@ -383,11 +383,25 @@ gst_wildmidi_src_query (GstPad * pad, GstObject * parent, GstQuery * query) gst_query_set_formats (query, 3, GST_FORMAT_TIME, GST_FORMAT_BYTES, GST_FORMAT_DEFAULT); break; - case GST_QUERY_SEGMENT: - gst_query_set_segment (query, wildmidi->o_segment->rate, - wildmidi->o_segment->format, wildmidi->o_segment->start, - wildmidi->o_segment->stop); + case GST_QUERY_SEGMENT:{ + GstFormat format; + gint64 start, stop; + + format = wildmidi->o_segment->format; + + start = + gst_segment_to_stream_time (wildmidi->o_segment, format, + wildmidi->o_segment->start); + if ((stop = wildmidi->o_segment->stop) == -1) + stop = wildmidi->o_segment->duration; + else + stop = gst_segment_to_stream_time (wildmidi->o_segment, format, stop); + + gst_query_set_segment (query, wildmidi->o_segment->rate, format, start, + stop); + res = TRUE; break; + } case GST_QUERY_SEEKING: gst_query_set_seeking (query, wildmidi->o_segment->format, TRUE, 0, wildmidi->o_len); diff --git a/gst/midi/midiparse.c b/gst/midi/midiparse.c index aa98ac4..c42c1b5 100644 --- a/gst/midi/midiparse.c +++ b/gst/midi/midiparse.c @@ -211,11 +211,25 @@ gst_midi_parse_src_query (GstPad * pad, GstObject * parent, GstQuery * query) case GST_QUERY_FORMATS: gst_query_set_formats (query, 1, GST_FORMAT_TIME); break; - case GST_QUERY_SEGMENT: - gst_query_set_segment (query, midiparse->segment.rate, - midiparse->segment.format, midiparse->segment.start, - midiparse->segment.stop); + case GST_QUERY_SEGMENT:{ + GstFormat format; + gint64 start, stop; + + format = midiparse->segment.format; + + start = + gst_segment_to_stream_time (&midiparse->segment, format, + midiparse->segment.start); + if ((stop = midiparse->segment.stop) == -1) + stop = midiparse->segment.duration; + else + stop = gst_segment_to_stream_time (&midiparse->segment, format, stop); + + gst_query_set_segment (query, midiparse->segment.rate, format, start, + stop); + res = TRUE; break; + } case GST_QUERY_SEEKING: gst_query_set_seeking (query, midiparse->segment.format, FALSE, 0, midiparse->segment.duration); -- 2.7.4