From ad095ae31661db873add93ceb5e064768e6ec51e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Stadler?= Date: Fri, 28 Oct 2011 14:05:48 +0200 Subject: [PATCH] tests: audiochebband: port to 0.11 --- tests/check/elements/audiochebband.c | 265 +++++++++++++++++---------- 1 file changed, 169 insertions(+), 96 deletions(-) diff --git a/tests/check/elements/audiochebband.c b/tests/check/elements/audiochebband.c index 73a8b15d70..ecb278b026 100644 --- a/tests/check/elements/audiochebband.c +++ b/tests/check/elements/audiochebband.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -32,35 +33,35 @@ GstPad *mysrcpad, *mysinkpad; #define BUFFER_CAPS_STRING_32 \ - "audio/x-raw-float, " \ + "audio/x-raw, " \ "channels = (int) 1, " \ "rate = (int) 44100, " \ - "endianness = (int) BYTE_ORDER, " \ - "width = (int) 32" \ + "format = (string) " GST_AUDIO_NE(F32) #define BUFFER_CAPS_STRING_64 \ - "audio/x-raw-float, " \ + "audio/x-raw, " \ "channels = (int) 1, " \ "rate = (int) 44100, " \ - "endianness = (int) BYTE_ORDER, " \ - "width = (int) 64" \ + "format = (string) " GST_AUDIO_NE(F64) static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " + GST_STATIC_CAPS ("audio/x-raw, " "channels = (int) 1, " "rate = (int) 44100, " - "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }") - ); + "format = (string) { " + GST_AUDIO_NE(F32) ", " + GST_AUDIO_NE(F64) " }")); static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " + GST_STATIC_CAPS ("audio/x-raw, " "channels = (int) 1, " "rate = (int) 44100, " - "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }") - ); + "format = (string) { " + GST_AUDIO_NE(F32) ", " + GST_AUDIO_NE(F64) " }")); static GstElement * setup_audiochebband (void) @@ -119,13 +120,14 @@ GST_START_TEST (test_type1_32_bp_0hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i++) in[i] = 1.0; + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -135,7 +137,7 @@ GST_START_TEST (test_type1_32_bp_0hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -143,6 +145,8 @@ GST_START_TEST (test_type1_32_bp_0hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -175,17 +179,18 @@ GST_START_TEST (test_type1_32_bp_11025hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 4) { in[i] = 0.0; in[i + 1] = 1.0; in[i + 2] = 0.0; in[i + 3] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -195,7 +200,7 @@ GST_START_TEST (test_type1_32_bp_11025hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -203,6 +208,8 @@ GST_START_TEST (test_type1_32_bp_11025hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.6); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -235,15 +242,16 @@ GST_START_TEST (test_type1_32_bp_22050hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 2) { in[i] = 1.0; in[i + 1] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -253,7 +261,7 @@ GST_START_TEST (test_type1_32_bp_22050hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -261,6 +269,8 @@ GST_START_TEST (test_type1_32_bp_22050hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -293,13 +303,14 @@ GST_START_TEST (test_type1_32_br_0hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i++) in[i] = 1.0; + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -309,7 +320,7 @@ GST_START_TEST (test_type1_32_br_0hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -317,6 +328,8 @@ GST_START_TEST (test_type1_32_br_0hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.9); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -349,17 +362,18 @@ GST_START_TEST (test_type1_32_br_11025hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 4) { in[i] = 0.0; in[i + 1] = 1.0; in[i + 2] = 0.0; in[i + 3] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -369,7 +383,7 @@ GST_START_TEST (test_type1_32_br_11025hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -377,6 +391,8 @@ GST_START_TEST (test_type1_32_br_11025hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -409,15 +425,16 @@ GST_START_TEST (test_type1_32_br_22050hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 2) { in[i] = 1.0; in[i + 1] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -427,7 +444,7 @@ GST_START_TEST (test_type1_32_br_22050hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -435,6 +452,8 @@ GST_START_TEST (test_type1_32_br_22050hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.9); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -468,12 +487,13 @@ GST_START_TEST (test_type1_64_bp_0hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i++) in[i] = 1.0; + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -483,7 +503,7 @@ GST_START_TEST (test_type1_64_bp_0hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -491,6 +511,8 @@ GST_START_TEST (test_type1_64_bp_0hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -524,16 +546,17 @@ GST_START_TEST (test_type1_64_bp_11025hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 4) { in[i] = 0.0; in[i + 1] = 1.0; in[i + 2] = 0.0; in[i + 3] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -543,7 +566,7 @@ GST_START_TEST (test_type1_64_bp_11025hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -551,6 +574,8 @@ GST_START_TEST (test_type1_64_bp_11025hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.6); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -584,14 +609,15 @@ GST_START_TEST (test_type1_64_bp_22050hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 2) { in[i] = 1.0; in[i + 1] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -601,7 +627,7 @@ GST_START_TEST (test_type1_64_bp_22050hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -609,6 +635,8 @@ GST_START_TEST (test_type1_64_bp_22050hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -642,12 +670,13 @@ GST_START_TEST (test_type1_64_br_0hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i++) in[i] = 1.0; + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -657,7 +686,7 @@ GST_START_TEST (test_type1_64_br_0hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -665,6 +694,8 @@ GST_START_TEST (test_type1_64_br_0hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.9); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -698,16 +729,17 @@ GST_START_TEST (test_type1_64_br_11025hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 4) { in[i] = 0.0; in[i + 1] = 1.0; in[i + 2] = 0.0; in[i + 3] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -717,7 +749,7 @@ GST_START_TEST (test_type1_64_br_11025hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -725,6 +757,8 @@ GST_START_TEST (test_type1_64_br_11025hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -758,14 +792,15 @@ GST_START_TEST (test_type1_64_br_22050hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 2) { in[i] = 1.0; in[i + 1] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -775,7 +810,7 @@ GST_START_TEST (test_type1_64_br_22050hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -783,6 +818,8 @@ GST_START_TEST (test_type1_64_br_22050hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.9); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -815,13 +852,14 @@ GST_START_TEST (test_type2_32_bp_0hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i++) in[i] = 1.0; + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -831,7 +869,7 @@ GST_START_TEST (test_type2_32_bp_0hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -839,6 +877,8 @@ GST_START_TEST (test_type2_32_bp_0hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -871,17 +911,18 @@ GST_START_TEST (test_type2_32_bp_11025hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 4) { in[i] = 0.0; in[i + 1] = 1.0; in[i + 2] = 0.0; in[i + 3] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -891,7 +932,7 @@ GST_START_TEST (test_type2_32_bp_11025hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -899,6 +940,8 @@ GST_START_TEST (test_type2_32_bp_11025hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.6); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -931,15 +974,16 @@ GST_START_TEST (test_type2_32_bp_22050hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 2) { in[i] = 1.0; in[i + 1] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -949,7 +993,7 @@ GST_START_TEST (test_type2_32_bp_22050hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -957,6 +1001,8 @@ GST_START_TEST (test_type2_32_bp_22050hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -989,13 +1035,14 @@ GST_START_TEST (test_type2_32_br_0hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i++) in[i] = 1.0; + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -1005,7 +1052,7 @@ GST_START_TEST (test_type2_32_br_0hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -1013,6 +1060,8 @@ GST_START_TEST (test_type2_32_br_0hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.9); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -1045,17 +1094,18 @@ GST_START_TEST (test_type2_32_br_11025hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 4) { in[i] = 0.0; in[i + 1] = 1.0; in[i + 2] = 0.0; in[i + 3] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -1065,7 +1115,7 @@ GST_START_TEST (test_type2_32_br_11025hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -1073,6 +1123,8 @@ GST_START_TEST (test_type2_32_br_11025hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -1105,15 +1157,16 @@ GST_START_TEST (test_type2_32_br_22050hz) 44100 / 4.0 - 1000, NULL); g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat)); - in = (gfloat *) GST_BUFFER_DATA (inbuffer); + inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 2) { in[i] = 1.0; in[i + 1] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_32); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -1123,7 +1176,7 @@ GST_START_TEST (test_type2_32_br_22050hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gfloat *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -1131,6 +1184,8 @@ GST_START_TEST (test_type2_32_br_22050hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.9); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -1164,12 +1219,13 @@ GST_START_TEST (test_type2_64_bp_0hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i++) in[i] = 1.0; + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -1179,7 +1235,7 @@ GST_START_TEST (test_type2_64_bp_0hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -1187,6 +1243,8 @@ GST_START_TEST (test_type2_64_bp_0hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -1220,16 +1278,17 @@ GST_START_TEST (test_type2_64_bp_11025hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 4) { in[i] = 0.0; in[i + 1] = 1.0; in[i + 2] = 0.0; in[i + 3] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -1239,7 +1298,7 @@ GST_START_TEST (test_type2_64_bp_11025hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -1247,6 +1306,8 @@ GST_START_TEST (test_type2_64_bp_11025hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.6); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -1280,14 +1341,15 @@ GST_START_TEST (test_type2_64_bp_22050hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 2) { in[i] = 1.0; in[i + 1] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -1297,7 +1359,7 @@ GST_START_TEST (test_type2_64_bp_22050hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -1305,6 +1367,8 @@ GST_START_TEST (test_type2_64_bp_22050hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -1338,12 +1402,13 @@ GST_START_TEST (test_type2_64_br_0hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i++) in[i] = 1.0; + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -1353,7 +1418,7 @@ GST_START_TEST (test_type2_64_br_0hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -1361,6 +1426,8 @@ GST_START_TEST (test_type2_64_br_0hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.9); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -1394,16 +1461,17 @@ GST_START_TEST (test_type2_64_br_11025hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 4) { in[i] = 0.0; in[i + 1] = 1.0; in[i + 2] = 0.0; in[i + 3] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -1413,7 +1481,7 @@ GST_START_TEST (test_type2_64_br_11025hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -1421,6 +1489,8 @@ GST_START_TEST (test_type2_64_br_11025hz) rms = sqrt (rms / 1024.0); fail_unless (rms <= 0.1); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); } @@ -1454,14 +1524,15 @@ GST_START_TEST (test_type2_64_br_22050hz) g_object_set (G_OBJECT (audiochebband), "upper-frequency", 44100 / 4.0 + 1000, NULL); inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); + in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); for (i = 0; i < 1024; i += 2) { in[i] = 1.0; in[i + 1] = -1.0; } + gst_buffer_unmap (inbuffer, in, -1); caps = gst_caps_from_string (BUFFER_CAPS_STRING_64); - gst_buffer_set_caps (inbuffer, caps); + fail_unless (gst_pad_set_caps (mysrcpad, caps)); gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); @@ -1471,7 +1542,7 @@ GST_START_TEST (test_type2_64_br_22050hz) fail_unless_equals_int (g_list_length (buffers), 1); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - res = (gdouble *) GST_BUFFER_DATA (outbuffer); + res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ); rms = 0.0; for (i = 0; i < 1024; i++) @@ -1479,6 +1550,8 @@ GST_START_TEST (test_type2_64_br_22050hz) rms = sqrt (rms / 1024.0); fail_unless (rms >= 0.9); + gst_buffer_unmap (outbuffer, res, -1); + /* cleanup */ cleanup_audiochebband (audiochebband); }