From 6ce1fe1bb2c0ec03724009a67e2f93ae9cfa1d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 30 Sep 2011 14:50:51 +0100 Subject: [PATCH 1/4] tests: add minimal test for GstAtomicQueue Just new + free. --- tests/check/Makefile.am | 1 + tests/check/gst/.gitignore | 1 + tests/check/gst/gstatomicqueue.c | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/check/gst/gstatomicqueue.c diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index f0e597feef..8b6dfff87b 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -95,6 +95,7 @@ endif check_PROGRAMS = \ $(ABI_CHECKS) \ + gst/gstatomicqueue \ gst/gstbuffer \ gst/gstbufferlist \ gst/gstbus \ diff --git a/tests/check/gst/.gitignore b/tests/check/gst/.gitignore index d42a99ff4e..cfe258863a 100644 --- a/tests/check/gst/.gitignore +++ b/tests/check/gst/.gitignore @@ -1,6 +1,7 @@ .dirstamp gst gstabi +gstatomicqueue gstbin gstbuffer gstbufferlist diff --git a/tests/check/gst/gstatomicqueue.c b/tests/check/gst/gstatomicqueue.c new file mode 100644 index 0000000000..89801b8f4f --- /dev/null +++ b/tests/check/gst/gstatomicqueue.c @@ -0,0 +1,46 @@ +/* GStreamer + * Copyright (C) <2011> Tim-Philipp Müller + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include + +GST_START_TEST (test_create_free) +{ + GstAtomicQueue *aq; + + aq = gst_atomic_queue_new (20); + gst_atomic_queue_unref (aq); +} + +GST_END_TEST; + +static Suite * +gst_atomic_queue_suite (void) +{ + Suite *s = suite_create ("GstAtomicQueue"); + TCase *tc_chain = tcase_create ("GstAtomicQueue tests"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_create_free); + + return s; +} + +GST_CHECK_MAIN (gst_atomic_queue); From eeed4911700d9bbc58a1893a4886ef5545fe921c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 30 Sep 2011 14:52:01 +0100 Subject: [PATCH 2/4] gst.h: include header for atomic queue --- gst/gst.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gst/gst.h b/gst/gst.h index 6238dcf613..35ef29035d 100644 --- a/gst/gst.h +++ b/gst/gst.h @@ -31,6 +31,7 @@ #include #include +#include #include #include #include From f94701261aeba3a9eaa9abee5ff644bcc627fa15 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 26 Sep 2011 13:14:42 +0100 Subject: [PATCH 3/4] baseparse: answer position query in stream time and try upstream first Let the demuxer have first say as well. https://bugzilla.gnome.org/show_bug.cgi?id=659485 --- libs/gst/base/gstbaseparse.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 67e380a25b..f95c3aa910 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -3148,22 +3148,24 @@ gst_base_parse_query (GstPad * pad, GstQuery * query) GST_DEBUG_OBJECT (parse, "position query"); gst_query_parse_position (query, &format, NULL); - GST_OBJECT_LOCK (parse); - if (format == GST_FORMAT_BYTES) { - dest_value = parse->priv->offset; - res = TRUE; - } else if (format == parse->segment.format && - GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop)) { - dest_value = parse->segment.last_stop; - res = TRUE; - } - GST_OBJECT_UNLOCK (parse); - - if (res) - gst_query_set_position (query, format, dest_value); - else { - res = gst_pad_query_default (pad, query); - if (!res) { + /* try upstream first */ + res = gst_pad_query_default (pad, query); + if (!res) { + /* Fall back on interpreting segment */ + GST_OBJECT_LOCK (parse); + if (format == GST_FORMAT_BYTES) { + dest_value = parse->priv->offset; + res = TRUE; + } else if (format == parse->segment.format && + GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop)) { + dest_value = gst_segment_to_stream_time (&parse->segment, + parse->segment.format, parse->segment.last_stop); + res = TRUE; + } + GST_OBJECT_UNLOCK (parse); + if (res) + gst_query_set_position (query, format, dest_value); + else { /* no precise result, upstream no idea either, then best estimate */ /* priv->offset is updated in both PUSH/PULL modes */ res = gst_base_parse_convert (parse, From 0ac0b70c15e7b5377e29e22a1ac09338818b87f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 30 Sep 2011 15:25:20 +0100 Subject: [PATCH 4/4] baseparse: make estimating the position in query handler actually work No point estimating if we don't set the result afterwards. --- libs/gst/base/gstbaseparse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index f95c3aa910..699b1918e0 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -3163,14 +3163,14 @@ gst_base_parse_query (GstPad * pad, GstQuery * query) res = TRUE; } GST_OBJECT_UNLOCK (parse); - if (res) - gst_query_set_position (query, format, dest_value); - else { + if (!res) { /* no precise result, upstream no idea either, then best estimate */ /* priv->offset is updated in both PUSH/PULL modes */ res = gst_base_parse_convert (parse, GST_FORMAT_BYTES, parse->priv->offset, format, &dest_value); } + if (res) + gst_query_set_position (query, format, dest_value); } break; }