From 56eb65babcad94b3342f21a1b759306cfdb29829 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 3 Feb 2012 16:13:51 +0100 Subject: [PATCH] tests: fix some more tests --- tests/check/elements/apev2mux.c | 55 ++++++++++++++--------- tests/check/elements/audiofirfilter.c | 4 ++ tests/check/elements/audioiirfilter.c | 4 ++ tests/check/elements/cmmldec.c | 4 ++ tests/check/elements/id3v2mux.c | 64 ++++++++++++++++++--------- tests/check/elements/interleave.c | 4 ++ tests/check/elements/parser.c | 6 ++- tests/check/pipelines/wavenc.c | 4 ++ 8 files changed, 101 insertions(+), 44 deletions(-) diff --git a/tests/check/elements/apev2mux.c b/tests/check/elements/apev2mux.c index fbbfb0dd33..597b6c327e 100644 --- a/tests/check/elements/apev2mux.c +++ b/tests/check/elements/apev2mux.c @@ -48,7 +48,7 @@ test_taglib_apev2mux_create_tags (guint32 mask) { GstTagList *tags; - tags = gst_tag_list_new (); + tags = gst_tag_list_new_empty (); if (mask & (1 << 0)) { gst_tag_list_add (tags, GST_TAG_MERGE_KEEP, @@ -175,21 +175,27 @@ static void fill_mp3_buffer (GstElement * fakesrc, GstBuffer * buf, GstPad * pad, guint64 * p_offset) { - fail_unless (GST_BUFFER_SIZE (buf) == MP3_FRAME_SIZE); + gsize size; + + size = gst_buffer_get_size (buf); + + fail_unless (size == MP3_FRAME_SIZE); GST_LOG ("filling buffer with fake mp3 data, offset = %" G_GUINT64_FORMAT, *p_offset); - memcpy (GST_BUFFER_DATA (buf), mp3_dummyhdr, sizeof (mp3_dummyhdr)); + gst_buffer_fill (buf, 0, mp3_dummyhdr, sizeof (mp3_dummyhdr)); +#if 0 /* can't use gst_buffer_set_caps() here because the metadata isn't writable * because of the extra refcounts taken by the signal emission mechanism; * we know it's fine to use GST_BUFFER_CAPS() here though */ GST_BUFFER_CAPS (buf) = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL); +#endif GST_BUFFER_OFFSET (buf) = *p_offset; - *p_offset += GST_BUFFER_SIZE (buf); + *p_offset += size; } static void @@ -197,40 +203,47 @@ got_buffer (GstElement * fakesink, GstBuffer * buf, GstPad * pad, GstBuffer ** p_buf) { gint64 off; - guint size; + GstMapInfo map; off = GST_BUFFER_OFFSET (buf); - size = GST_BUFFER_SIZE (buf); - GST_LOG ("got buffer, size=%u, offset=%" G_GINT64_FORMAT, size, off); + gst_buffer_map (buf, &map, GST_MAP_READ); + + GST_LOG ("got buffer, size=%u, offset=%" G_GINT64_FORMAT, map.size, off); fail_unless (GST_BUFFER_OFFSET_IS_VALID (buf)); - if (*p_buf == NULL || (off + size) > GST_BUFFER_SIZE (*p_buf)) { + if (*p_buf == NULL || (off + map.size) > gst_buffer_get_size (*p_buf)) { GstBuffer *newbuf; /* not very elegant, but who cares */ - newbuf = gst_buffer_new_and_alloc (off + size); + newbuf = gst_buffer_new_and_alloc (off + map.size); if (*p_buf) { - memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (*p_buf), - GST_BUFFER_SIZE (*p_buf)); + GstMapInfo pmap; + + gst_buffer_map (*p_buf, &pmap, GST_MAP_READ); + gst_buffer_fill (newbuf, 0, pmap.data, pmap.size); + gst_buffer_unmap (*p_buf, &pmap); } - memcpy (GST_BUFFER_DATA (newbuf) + off, GST_BUFFER_DATA (buf), size); + gst_buffer_fill (newbuf, off, map.data, map.size); if (*p_buf) gst_buffer_unref (*p_buf); *p_buf = newbuf; } else { - memcpy (GST_BUFFER_DATA (*p_buf) + off, GST_BUFFER_DATA (buf), size); + gst_buffer_fill (*p_buf, off, map.data, map.size); } + gst_buffer_unmap (buf, &map); } static void demux_pad_added (GstElement * apedemux, GstPad * srcpad, GstBuffer ** p_outbuf) { GstElement *fakesink, *pipeline; + GstCaps *caps; - GST_LOG ("apedemux added source pad with caps %" GST_PTR_FORMAT, - GST_PAD_CAPS (srcpad)); + caps = gst_pad_get_current_caps (srcpad); + GST_LOG ("apedemux added source pad with caps %" GST_PTR_FORMAT, caps); + gst_caps_unref (caps); pipeline = apedemux; while (GST_OBJECT_PARENT (pipeline) != NULL) @@ -252,15 +265,17 @@ demux_pad_added (GstElement * apedemux, GstPad * srcpad, GstBuffer ** p_outbuf) static void test_taglib_apev2mux_check_output_buffer (GstBuffer * buf) { - guint8 *data = GST_BUFFER_DATA (buf); - guint size = GST_BUFFER_SIZE (buf); + GstMapInfo map; guint off; - g_assert (size % MP3_FRAME_SIZE == 0); + gst_buffer_map (buf, &map, GST_MAP_READ); + g_assert (map.size % MP3_FRAME_SIZE == 0); - for (off = 0; off < size; off += MP3_FRAME_SIZE) { - fail_unless (memcmp (data + off, mp3_dummyhdr, sizeof (mp3_dummyhdr)) == 0); + for (off = 0; off < map.size; off += MP3_FRAME_SIZE) { + fail_unless (memcmp (map.data + off, mp3_dummyhdr, + sizeof (mp3_dummyhdr)) == 0); } + gst_buffer_unmap (buf, &map); } static void diff --git a/tests/check/elements/audiofirfilter.c b/tests/check/elements/audiofirfilter.c index c4abaf9c2b..150dce44a8 100644 --- a/tests/check/elements/audiofirfilter.c +++ b/tests/check/elements/audiofirfilter.c @@ -18,6 +18,10 @@ * 02110-1301 USA */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include diff --git a/tests/check/elements/audioiirfilter.c b/tests/check/elements/audioiirfilter.c index 9625795205..5f8c505d6d 100644 --- a/tests/check/elements/audioiirfilter.c +++ b/tests/check/elements/audioiirfilter.c @@ -18,6 +18,10 @@ * 02110-1301 USA */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include diff --git a/tests/check/elements/cmmldec.c b/tests/check/elements/cmmldec.c index d3acb017a5..39cdfd6f52 100644 --- a/tests/check/elements/cmmldec.c +++ b/tests/check/elements/cmmldec.c @@ -21,6 +21,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include diff --git a/tests/check/elements/id3v2mux.c b/tests/check/elements/id3v2mux.c index b32827db92..694ef89466 100644 --- a/tests/check/elements/id3v2mux.c +++ b/tests/check/elements/id3v2mux.c @@ -64,7 +64,7 @@ test_taglib_id3mux_create_tags (guint32 mask) { GstTagList *tags; - tags = gst_tag_list_new (); + tags = gst_tag_list_new_empty (); if (mask & (1 << 0)) { gst_tag_list_add (tags, GST_TAG_MERGE_KEEP, @@ -130,13 +130,17 @@ static gboolean utf8_string_in_buf (GstBuffer * buf, const gchar * s) { gint i, len; + GstMapInfo map; len = strlen (s); - for (i = 0; i < (GST_BUFFER_SIZE (buf) - len); ++i) { - if (memcmp (GST_BUFFER_DATA (buf) + i, s, len) == 0) { + gst_buffer_map (buf, &map, GST_MAP_READ); + for (i = 0; i < (map.size - len); ++i) { + if (memcmp (map.data + i, s, len) == 0) { + gst_buffer_unmap (buf, &map); return TRUE; } } + gst_buffer_unmap (buf, &map); return FALSE; } @@ -256,21 +260,27 @@ static void fill_mp3_buffer (GstElement * fakesrc, GstBuffer * buf, GstPad * pad, guint64 * p_offset) { - fail_unless (GST_BUFFER_SIZE (buf) == MP3_FRAME_SIZE); + gsize size; + + size = gst_buffer_get_size (buf); + + fail_unless (size == MP3_FRAME_SIZE); GST_LOG ("filling buffer with fake mp3 data, offset = %" G_GUINT64_FORMAT, *p_offset); - memcpy (GST_BUFFER_DATA (buf), mp3_dummyhdr, sizeof (mp3_dummyhdr)); + gst_buffer_fill (buf, 0, mp3_dummyhdr, sizeof (mp3_dummyhdr)); +#if 0 /* can't use gst_buffer_set_caps() here because the metadata isn't writable * because of the extra refcounts taken by the signal emission mechanism; * we know it's fine to use GST_BUFFER_CAPS() here though */ GST_BUFFER_CAPS (buf) = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL); +#endif GST_BUFFER_OFFSET (buf) = *p_offset; - *p_offset += GST_BUFFER_SIZE (buf); + *p_offset += size; } static void @@ -278,40 +288,48 @@ got_buffer (GstElement * fakesink, GstBuffer * buf, GstPad * pad, GstBuffer ** p_buf) { gint64 off; - guint size; + GstMapInfo map; off = GST_BUFFER_OFFSET (buf); - size = GST_BUFFER_SIZE (buf); - GST_LOG ("got buffer, size=%u, offset=%" G_GINT64_FORMAT, size, off); + gst_buffer_map (buf, &map, GST_MAP_READ); + + GST_LOG ("got buffer, size=%u, offset=%" G_GINT64_FORMAT, map.size, off); fail_unless (GST_BUFFER_OFFSET_IS_VALID (buf)); - if (*p_buf == NULL || (off + size) > GST_BUFFER_SIZE (*p_buf)) { + if (*p_buf == NULL || (off + map.size) > gst_buffer_get_size (*p_buf)) { GstBuffer *newbuf; /* not very elegant, but who cares */ - newbuf = gst_buffer_new_and_alloc (off + size); + newbuf = gst_buffer_new_and_alloc (off + map.size); if (*p_buf) { - memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (*p_buf), - GST_BUFFER_SIZE (*p_buf)); + GstMapInfo pmap; + + gst_buffer_map (*p_buf, &pmap, GST_MAP_READ); + gst_buffer_fill (newbuf, 0, pmap.data, pmap.size); + gst_buffer_unmap (*p_buf, &pmap); } - memcpy (GST_BUFFER_DATA (newbuf) + off, GST_BUFFER_DATA (buf), size); + gst_buffer_fill (newbuf, off, map.data, map.size); + if (*p_buf) gst_buffer_unref (*p_buf); *p_buf = newbuf; } else { - memcpy (GST_BUFFER_DATA (*p_buf) + off, GST_BUFFER_DATA (buf), size); + gst_buffer_fill (*p_buf, off, map.data, map.size); } + gst_buffer_unmap (buf, &map); } static void demux_pad_added (GstElement * id3demux, GstPad * srcpad, GstBuffer ** p_outbuf) { GstElement *fakesink, *pipeline; + GstCaps *caps; - GST_LOG ("id3demux added source pad with caps %" GST_PTR_FORMAT, - GST_PAD_CAPS (srcpad)); + caps = gst_pad_get_current_caps (srcpad); + GST_LOG ("id3demux added source pad with caps %" GST_PTR_FORMAT, caps); + gst_caps_unref (caps); pipeline = id3demux; while (GST_OBJECT_PARENT (pipeline) != NULL) @@ -333,15 +351,17 @@ demux_pad_added (GstElement * id3demux, GstPad * srcpad, GstBuffer ** p_outbuf) static void test_taglib_id3mux_check_output_buffer (GstBuffer * buf) { - guint8 *data = GST_BUFFER_DATA (buf); - guint size = GST_BUFFER_SIZE (buf); + GstMapInfo map; guint off; - g_assert (size % MP3_FRAME_SIZE == 0); + gst_buffer_map (buf, &map, GST_MAP_READ); + g_assert (map.size % MP3_FRAME_SIZE == 0); - for (off = 0; off < size; off += MP3_FRAME_SIZE) { - fail_unless (memcmp (data + off, mp3_dummyhdr, sizeof (mp3_dummyhdr)) == 0); + for (off = 0; off < map.size; off += MP3_FRAME_SIZE) { + fail_unless (memcmp (map.data + off, mp3_dummyhdr, + sizeof (mp3_dummyhdr)) == 0); } + gst_buffer_unmap (buf, &map); } static void diff --git a/tests/check/elements/interleave.c b/tests/check/elements/interleave.c index d345fd2f3e..075afccf2b 100644 --- a/tests/check/elements/interleave.c +++ b/tests/check/elements/interleave.c @@ -18,6 +18,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H # include "config.h" #endif diff --git a/tests/check/elements/parser.c b/tests/check/elements/parser.c index c369278b9b..6622259785 100644 --- a/tests/check/elements/parser.c +++ b/tests/check/elements/parser.c @@ -153,8 +153,10 @@ setup_element (const gchar * factory, GstStaticPadTemplate * sink_template, sinkpad = gst_check_setup_sink_pad (element, sink_template); gst_pad_set_active (srcpad, TRUE); gst_pad_set_active (sinkpad, TRUE); - fail_unless (gst_pad_set_caps (srcpad, src_caps)); - fail_unless (gst_pad_set_caps (sinkpad, sink_caps)); + if (src_caps) + fail_unless (gst_pad_set_caps (srcpad, src_caps)); + if (sink_caps) + fail_unless (gst_pad_set_caps (sinkpad, sink_caps)); bus = gst_bus_new (); gst_element_set_bus (element, bus); diff --git a/tests/check/pipelines/wavenc.c b/tests/check/pipelines/wavenc.c index 15ee7f85f6..2fdfdc3e80 100644 --- a/tests/check/pipelines/wavenc.c +++ b/tests/check/pipelines/wavenc.c @@ -20,6 +20,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include #include