tests: audioecho: port to 0.11
authorRené Stadler <rene.stadler@collabora.co.uk>
Fri, 28 Oct 2011 19:19:42 +0000 (21:19 +0200)
committerRené Stadler <rene.stadler@collabora.co.uk>
Fri, 28 Oct 2011 19:22:38 +0000 (21:22 +0200)
tests/check/elements/audioecho.c

index fa88c3f..d75da51 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <gst/check/gstcheck.h>
+#include <gst/audio/audio.h>
 
 gboolean have_eos = FALSE;
 
@@ -28,28 +29,29 @@ gboolean have_eos = FALSE;
 GstPad *mysrcpad, *mysinkpad;
 
 #define ECHO_CAPS_STRING    \
-    "audio/x-raw-float, "               \
+    "audio/x-raw, "               \
     "channels = (int) 2, "              \
     "rate = (int) 100000, "             \
-    "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, 2 ], "
         "rate = (int) [ 1,  MAX ], "
-        "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, 2 ], "
         "rate = (int) [ 1,  MAX ], "
-        "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
-    );
+       "format = (string) { "
+       GST_AUDIO_NE(F32) ", "
+       GST_AUDIO_NE(F64) " }"));
 
 static GstElement *
 setup_echo (void)
@@ -88,7 +90,7 @@ GST_START_TEST (test_passthrough)
   GstBuffer *inbuffer, *outbuffer;
   GstCaps *caps;
   gdouble in[] = { 1.0, -1.0, 0.0, 0.5, -0.5, 0.0 };
-  gdouble *res;
+  gdouble res[6];
 
   echo = setup_echo ();
   g_object_set (G_OBJECT (echo), "delay", (GstClockTime) 1, "intensity", 0.0,
@@ -97,12 +99,12 @@ GST_START_TEST (test_passthrough)
           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
       "could not set to playing");
 
-  inbuffer = gst_buffer_new_and_alloc (sizeof (in));
-  memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in));
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0);
   caps = gst_caps_from_string (ECHO_CAPS_STRING);
-  gst_buffer_set_caps (inbuffer, caps);
+  fail_unless (gst_pad_set_caps (mysrcpad, caps));
   gst_caps_unref (caps);
+
+  inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, sizeof (in));
+  fail_unless (gst_buffer_memcmp (inbuffer, 0, in, sizeof (in)) == 0);
   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
 
   /* pushing gives away my reference ... */
@@ -111,12 +113,12 @@ GST_START_TEST (test_passthrough)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
 
-  res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+  fail_unless (gst_buffer_extract (outbuffer, 0, res, sizeof (res)) == sizeof (res));
   GST_INFO
       ("expected %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf",
       in[0], in[1], in[2], in[3], in[4], in[5], res[0], res[1], res[2], res[3],
       res[4], res[5]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, sizeof (in)) == 0);
+  fail_unless (gst_buffer_memcmp (outbuffer, 0, in, sizeof (in)) == 0);
 
   /* cleanup */
   cleanup_echo (echo);
@@ -131,7 +133,7 @@ GST_START_TEST (test_echo)
   GstCaps *caps;
   gdouble in[] = { 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, };
   gdouble out[] = { 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0 };
-  gdouble *res;
+  gdouble res[10];
 
   echo = setup_echo ();
   g_object_set (G_OBJECT (echo), "delay", (GstClockTime) 20000, "intensity",
@@ -140,12 +142,12 @@ GST_START_TEST (test_echo)
           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
       "could not set to playing");
 
-  inbuffer = gst_buffer_new_and_alloc (sizeof (in));
-  memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in));
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0);
   caps = gst_caps_from_string (ECHO_CAPS_STRING);
-  gst_buffer_set_caps (inbuffer, caps);
+  fail_unless (gst_pad_set_caps (mysrcpad, caps));
   gst_caps_unref (caps);
+
+  inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, sizeof (in));
+  fail_unless (gst_buffer_memcmp (inbuffer, 0, in, sizeof (in)) == 0);
   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
 
   /* pushing gives away my reference ... */
@@ -154,13 +156,13 @@ GST_START_TEST (test_echo)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
 
-  res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+  fail_unless (gst_buffer_extract (outbuffer, 0, res, sizeof (res)) == sizeof (res));
   GST_INFO
       ("expected %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf",
       out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8],
       out[9], res[0], res[1], res[2], res[3], res[4], res[5], res[6], res[7],
       res[8], res[9]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, sizeof (out)) == 0);
+  fail_unless (gst_buffer_memcmp (outbuffer, 0, out, sizeof (out)) == 0);
 
   /* cleanup */
   cleanup_echo (echo);
@@ -175,7 +177,7 @@ GST_START_TEST (test_feedback)
   GstCaps *caps;
   gdouble in[] = { 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, };
   gdouble out[] = { 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, 1.0, -1.0 };
-  gdouble *res;
+  gdouble res[10];
 
   echo = setup_echo ();
   g_object_set (G_OBJECT (echo), "delay", (GstClockTime) 20000, "intensity",
@@ -184,12 +186,12 @@ GST_START_TEST (test_feedback)
           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
       "could not set to playing");
 
-  inbuffer = gst_buffer_new_and_alloc (sizeof (in));
-  memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in));
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0);
   caps = gst_caps_from_string (ECHO_CAPS_STRING);
-  gst_buffer_set_caps (inbuffer, caps);
+  fail_unless (gst_pad_set_caps (mysrcpad, caps));
   gst_caps_unref (caps);
+
+  inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, sizeof (in));
+  fail_unless (gst_buffer_memcmp (inbuffer, 0, in, sizeof (in)) == 0);
   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
 
   /* pushing gives away my reference ... */
@@ -198,13 +200,13 @@ GST_START_TEST (test_feedback)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
 
-  res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+  fail_unless (gst_buffer_extract (outbuffer, 0, res, sizeof (res)) == sizeof (res));
   GST_INFO
       ("expected %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf",
       out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8],
       out[9], res[0], res[1], res[2], res[3], res[4], res[5], res[6], res[7],
       res[8], res[9]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, sizeof (out)) == 0);
+  fail_unless (gst_buffer_memcmp (outbuffer, 0, out, sizeof (out)) == 0);
 
   /* cleanup */
   cleanup_echo (echo);