From e5333665217d1e5e4675945f1d383ce1e8ae0785 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 22 Feb 2008 06:06:06 +0000 Subject: [PATCH] ext/wavpack/gstwavpackparse.*: Always report the duration if we know it in push mode and don't return 0 just to make ... Original commit message from CVS: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_src_query), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackparse.h: Always report the duration if we know it in push mode and don't return 0 just to make totem believe we can't seek in push mode. Newer totem version use the SEEKING query which properly reports if we can seek or not. --- ChangeLog | 10 ++++++++++ ext/wavpack/gstwavpackparse.c | 19 ++++++++----------- ext/wavpack/gstwavpackparse.h | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2682f7d..81aa8a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2008-02-22 Sebastian Dröge + * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_src_query), + (gst_wavpack_parse_create_src_pad): + * ext/wavpack/gstwavpackparse.h: + Always report the duration if we know it in push mode and don't + return 0 just to make totem believe we can't seek in push mode. + Newer totem version use the SEEKING query which properly reports + if we can seek or not. + +2008-02-22 Sebastian Dröge + Patch by: Jens Granseuer * tests/examples/equalizer/demo.c: (main): diff --git a/ext/wavpack/gstwavpackparse.c b/ext/wavpack/gstwavpackparse.c index 0c34401..2cdf007 100644 --- a/ext/wavpack/gstwavpackparse.c +++ b/ext/wavpack/gstwavpackparse.c @@ -275,16 +275,15 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query) switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION:{ - gint64 cur, len; + gint64 cur; guint rate; GST_OBJECT_LOCK (parse); cur = parse->segment.last_stop; - len = parse->total_samples; rate = parse->samplerate; GST_OBJECT_UNLOCK (parse); - if (len < 0 || rate == 0) { + if (rate == 0) { GST_DEBUG_OBJECT (parse, "haven't read header yet"); break; } @@ -315,12 +314,10 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query) GST_OBJECT_LOCK (parse); rate = parse->samplerate; - /* FIXME: return 0 if we work in push based mode to let totem - * recognize that we can't seek */ - len = (parse->adapter) ? 0 : parse->total_samples; + len = parse->total_samples; GST_OBJECT_UNLOCK (parse); - if (len < 0 || rate == 0) { + if (rate == 0) { GST_DEBUG_OBJECT (parse, "haven't read header yet"); break; } @@ -329,7 +326,8 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query) switch (format) { case GST_FORMAT_TIME: - len = gst_util_uint64_scale_int (len, GST_SECOND, rate); + if (len != -1) + len = gst_util_uint64_scale_int (len, GST_SECOND, rate); gst_query_set_duration (query, GST_FORMAT_TIME, len); ret = TRUE; break; @@ -827,9 +825,8 @@ gst_wavpack_parse_create_src_pad (GstWavpackParse * wvparse, GstBuffer * buf, wvparse->samplerate = WavpackGetSampleRate (wpc); wvparse->channels = WavpackGetNumChannels (wpc); - wvparse->total_samples = header->total_samples; - if (wvparse->total_samples == (int32_t) - 1) - wvparse->total_samples = 0; + wvparse->total_samples = (header->total_samples == (int32_t) - 1) ? + -1 : header->total_samples; caps = gst_caps_new_simple ("audio/x-wavpack", "width", G_TYPE_INT, WavpackGetBitsPerSample (wpc), diff --git a/ext/wavpack/gstwavpackparse.h b/ext/wavpack/gstwavpackparse.h index 67d093f..60504a7 100644 --- a/ext/wavpack/gstwavpackparse.h +++ b/ext/wavpack/gstwavpackparse.h @@ -57,7 +57,7 @@ struct _GstWavpackParse guint samplerate; guint channels; - guint total_samples; + gint64 total_samples; gboolean need_newsegment; gboolean discont; -- 2.7.4