From 9bcba871ea2dcaed6d7da254f3eacb584e4b4e3b Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 14 Mar 2004 21:34:03 +0000 Subject: [PATCH] funcify macros Original commit message from CVS: funcify macros --- tests/old/testsuite/alsa/formats.c | 119 +++++++++++++++-------------- tests/old/testsuite/alsa/sinesrc.c | 17 +++-- testsuite/alsa/formats.c | 119 +++++++++++++++-------------- testsuite/alsa/sinesrc.c | 17 +++-- 4 files changed, 140 insertions(+), 132 deletions(-) diff --git a/tests/old/testsuite/alsa/formats.c b/tests/old/testsuite/alsa/formats.c index 1a2bc0b82d..4cc5824c7c 100644 --- a/tests/old/testsuite/alsa/formats.c +++ b/tests/old/testsuite/alsa/formats.c @@ -37,25 +37,25 @@ gint counter = 0; static void create_pipeline (void); -static void -pre_get_func (SineSrc *src) +static void +pre_get_func (SineSrc * src) { - counter ++; + counter++; }; static void create_pipeline (void) { - GstElement *src; + GstElement *src; SineSrc *sinesrc; GstElement *alsasink; - + pipeline = gst_pipeline_new ("pipeline"); src = sinesrc_new (); alsasink = gst_element_factory_make ("alsasink", "alsasink"); - + gst_bin_add_many (GST_BIN (pipeline), src, alsasink, NULL); gst_element_link (src, alsasink); - + /* prepare our sinesrc */ sinesrc = (SineSrc *) src; sinesrc->pre_get_func = pre_get_func; @@ -64,77 +64,80 @@ create_pipeline (void) if (last < NUMBER_OF_INT_TESTS) { sinesrc->type = SINE_SRC_INT; sinesrc->sign = ((last % 2) == 0) ? TRUE : FALSE; - sinesrc->endianness = ((last / 2) % 2 == 0) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN; + sinesrc->endianness = + ((last / 2) % 2 == 0) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN; switch ((last / 4) % 8) { case 0: - sinesrc->depth = 8; - sinesrc->width = 8; - break; + sinesrc->depth = 8; + sinesrc->width = 8; + break; case 1: - sinesrc->depth = 16; - sinesrc->width = 16; - break; + sinesrc->depth = 16; + sinesrc->width = 16; + break; case 2: - sinesrc->depth = 24; - sinesrc->width = 32; - break; + sinesrc->depth = 24; + sinesrc->width = 32; + break; case 3: - sinesrc->depth = 32; - sinesrc->width = 32; - break; - /* nomore tests below until i know what 24bit width means to alsa wrt endianness */ + sinesrc->depth = 32; + sinesrc->width = 32; + break; + /* nomore tests below until i know what 24bit width means to alsa wrt endianness */ case 4: - sinesrc->depth = 24; - sinesrc->width = 24; - break; + sinesrc->depth = 24; + sinesrc->width = 24; + break; case 5: - sinesrc->depth = 20; - sinesrc->width = 24; - break; + sinesrc->depth = 20; + sinesrc->width = 24; + break; case 6: - sinesrc->depth = 18; - sinesrc->width = 24; - break; + sinesrc->depth = 18; + sinesrc->width = 24; + break; case 7: - /* not used yet */ - sinesrc->depth = 8; - sinesrc->width = 8; - break; + /* not used yet */ + sinesrc->depth = 8; + sinesrc->width = 8; + break; default: - g_assert_not_reached(); + g_assert_not_reached (); } - + g_print ("Setting format to: format: \"int\"\n" - " sign: %s\n" - " endianness: %d\n" - " width: %d\n" - " depth: %d\n", - sinesrc->sign ? "TRUE" : "FALSE", sinesrc->endianness, - sinesrc->width, sinesrc->depth); + " sign: %s\n" + " endianness: %d\n" + " width: %d\n" + " depth: %d\n", + sinesrc->sign ? "TRUE" : "FALSE", sinesrc->endianness, + sinesrc->width, sinesrc->depth); } else if (last < NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS) { gint temp = last - NUMBER_OF_INT_TESTS; + sinesrc->type = SINE_SRC_FLOAT; switch (temp) { case 0: - sinesrc->width = 32; - break; + sinesrc->width = 32; + break; case 1: - sinesrc->width = 64; - break; + sinesrc->width = 64; + break; default: - g_assert_not_reached (); + g_assert_not_reached (); } g_print ("Setting format to float width %d\n", sinesrc->width); - } else if (last < NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS + NUMBER_OF_LAW_TESTS) { + } else if (last < + NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS + NUMBER_OF_LAW_TESTS) { gint temp = last - NUMBER_OF_INT_TESTS - NUMBER_OF_FLOAT_TESTS; GstElement *law; - + sinesrc->type = SINE_SRC_INT; sinesrc->sign = TRUE; sinesrc->endianness = G_BYTE_ORDER; sinesrc->depth = 16; sinesrc->width = 16; - + if (temp == 0) { g_assert ((law = gst_element_factory_make ("mulawenc", "mulaw"))); } else { @@ -154,18 +157,18 @@ create_pipeline (void) } gst_element_set_state (pipeline, GST_STATE_PLAYING); } -gint -main (gint argc, gchar *argv[]) + +gint +main (gint argc, gchar * argv[]) { gst_init (&argc, &argv); g_print ("\n" - "This test will test the various formats ALSA and GStreamer support.\n" - "You will hear a short sine tone on your default ALSA soundcard for every\n" - "format tested. They should all sound the same (incl. volume).\n" - "\n"); + "This test will test the various formats ALSA and GStreamer support.\n" + "You will hear a short sine tone on your default ALSA soundcard for every\n" + "format tested. They should all sound the same (incl. volume).\n" "\n"); create_pipeline (); - + while (pipeline) { gst_bin_iterate (GST_BIN (pipeline)); if ((counter / 200) > last) { @@ -174,6 +177,6 @@ main (gint argc, gchar *argv[]) create_pipeline (); } } - + return 0; } diff --git a/tests/old/testsuite/alsa/sinesrc.c b/tests/old/testsuite/alsa/sinesrc.c index 3cc865b61e..25053cfa48 100644 --- a/tests/old/testsuite/alsa/sinesrc.c +++ b/tests/old/testsuite/alsa/sinesrc.c @@ -146,7 +146,7 @@ sinesrc_force_caps (SineSrc *src) { */ static guint8 UIDENTITY(guint8 x) { return x; }; static gint8 IDENTITY(gint8 x) { return x; }; -#define POPULATE(format, be_func, le_func) {\ +#define POPULATE(format, be_func, le_func) G_STMT_START {\ format val = (format) int_value;\ format *p = data;\ switch (src->endianness) {\ @@ -164,7 +164,8 @@ static gint8 IDENTITY(gint8 x) { return x; }; p ++;\ }\ data = p;\ -} +} G_STMT_END + static GstData * sinesrc_get (GstPad *pad) { @@ -193,15 +194,15 @@ sinesrc_get (GstPad *pad) switch (src->width) { case 8: if (src->sign) - POPULATE (gint8, IDENTITY, IDENTITY) + POPULATE (gint8, IDENTITY, IDENTITY); else - POPULATE (guint8, UIDENTITY, UIDENTITY) + POPULATE (guint8, UIDENTITY, UIDENTITY); break; case 16: if (src->sign) - POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE) + POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE); else - POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE) + POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE); break; case 24: if (src->sign) { @@ -248,9 +249,9 @@ sinesrc_get (GstPad *pad) break; case 32: if (src->sign) - POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE) + POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE); else - POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE) + POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE); break; default: g_assert_not_reached (); diff --git a/testsuite/alsa/formats.c b/testsuite/alsa/formats.c index 1a2bc0b82d..4cc5824c7c 100644 --- a/testsuite/alsa/formats.c +++ b/testsuite/alsa/formats.c @@ -37,25 +37,25 @@ gint counter = 0; static void create_pipeline (void); -static void -pre_get_func (SineSrc *src) +static void +pre_get_func (SineSrc * src) { - counter ++; + counter++; }; static void create_pipeline (void) { - GstElement *src; + GstElement *src; SineSrc *sinesrc; GstElement *alsasink; - + pipeline = gst_pipeline_new ("pipeline"); src = sinesrc_new (); alsasink = gst_element_factory_make ("alsasink", "alsasink"); - + gst_bin_add_many (GST_BIN (pipeline), src, alsasink, NULL); gst_element_link (src, alsasink); - + /* prepare our sinesrc */ sinesrc = (SineSrc *) src; sinesrc->pre_get_func = pre_get_func; @@ -64,77 +64,80 @@ create_pipeline (void) if (last < NUMBER_OF_INT_TESTS) { sinesrc->type = SINE_SRC_INT; sinesrc->sign = ((last % 2) == 0) ? TRUE : FALSE; - sinesrc->endianness = ((last / 2) % 2 == 0) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN; + sinesrc->endianness = + ((last / 2) % 2 == 0) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN; switch ((last / 4) % 8) { case 0: - sinesrc->depth = 8; - sinesrc->width = 8; - break; + sinesrc->depth = 8; + sinesrc->width = 8; + break; case 1: - sinesrc->depth = 16; - sinesrc->width = 16; - break; + sinesrc->depth = 16; + sinesrc->width = 16; + break; case 2: - sinesrc->depth = 24; - sinesrc->width = 32; - break; + sinesrc->depth = 24; + sinesrc->width = 32; + break; case 3: - sinesrc->depth = 32; - sinesrc->width = 32; - break; - /* nomore tests below until i know what 24bit width means to alsa wrt endianness */ + sinesrc->depth = 32; + sinesrc->width = 32; + break; + /* nomore tests below until i know what 24bit width means to alsa wrt endianness */ case 4: - sinesrc->depth = 24; - sinesrc->width = 24; - break; + sinesrc->depth = 24; + sinesrc->width = 24; + break; case 5: - sinesrc->depth = 20; - sinesrc->width = 24; - break; + sinesrc->depth = 20; + sinesrc->width = 24; + break; case 6: - sinesrc->depth = 18; - sinesrc->width = 24; - break; + sinesrc->depth = 18; + sinesrc->width = 24; + break; case 7: - /* not used yet */ - sinesrc->depth = 8; - sinesrc->width = 8; - break; + /* not used yet */ + sinesrc->depth = 8; + sinesrc->width = 8; + break; default: - g_assert_not_reached(); + g_assert_not_reached (); } - + g_print ("Setting format to: format: \"int\"\n" - " sign: %s\n" - " endianness: %d\n" - " width: %d\n" - " depth: %d\n", - sinesrc->sign ? "TRUE" : "FALSE", sinesrc->endianness, - sinesrc->width, sinesrc->depth); + " sign: %s\n" + " endianness: %d\n" + " width: %d\n" + " depth: %d\n", + sinesrc->sign ? "TRUE" : "FALSE", sinesrc->endianness, + sinesrc->width, sinesrc->depth); } else if (last < NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS) { gint temp = last - NUMBER_OF_INT_TESTS; + sinesrc->type = SINE_SRC_FLOAT; switch (temp) { case 0: - sinesrc->width = 32; - break; + sinesrc->width = 32; + break; case 1: - sinesrc->width = 64; - break; + sinesrc->width = 64; + break; default: - g_assert_not_reached (); + g_assert_not_reached (); } g_print ("Setting format to float width %d\n", sinesrc->width); - } else if (last < NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS + NUMBER_OF_LAW_TESTS) { + } else if (last < + NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS + NUMBER_OF_LAW_TESTS) { gint temp = last - NUMBER_OF_INT_TESTS - NUMBER_OF_FLOAT_TESTS; GstElement *law; - + sinesrc->type = SINE_SRC_INT; sinesrc->sign = TRUE; sinesrc->endianness = G_BYTE_ORDER; sinesrc->depth = 16; sinesrc->width = 16; - + if (temp == 0) { g_assert ((law = gst_element_factory_make ("mulawenc", "mulaw"))); } else { @@ -154,18 +157,18 @@ create_pipeline (void) } gst_element_set_state (pipeline, GST_STATE_PLAYING); } -gint -main (gint argc, gchar *argv[]) + +gint +main (gint argc, gchar * argv[]) { gst_init (&argc, &argv); g_print ("\n" - "This test will test the various formats ALSA and GStreamer support.\n" - "You will hear a short sine tone on your default ALSA soundcard for every\n" - "format tested. They should all sound the same (incl. volume).\n" - "\n"); + "This test will test the various formats ALSA and GStreamer support.\n" + "You will hear a short sine tone on your default ALSA soundcard for every\n" + "format tested. They should all sound the same (incl. volume).\n" "\n"); create_pipeline (); - + while (pipeline) { gst_bin_iterate (GST_BIN (pipeline)); if ((counter / 200) > last) { @@ -174,6 +177,6 @@ main (gint argc, gchar *argv[]) create_pipeline (); } } - + return 0; } diff --git a/testsuite/alsa/sinesrc.c b/testsuite/alsa/sinesrc.c index 3cc865b61e..25053cfa48 100644 --- a/testsuite/alsa/sinesrc.c +++ b/testsuite/alsa/sinesrc.c @@ -146,7 +146,7 @@ sinesrc_force_caps (SineSrc *src) { */ static guint8 UIDENTITY(guint8 x) { return x; }; static gint8 IDENTITY(gint8 x) { return x; }; -#define POPULATE(format, be_func, le_func) {\ +#define POPULATE(format, be_func, le_func) G_STMT_START {\ format val = (format) int_value;\ format *p = data;\ switch (src->endianness) {\ @@ -164,7 +164,8 @@ static gint8 IDENTITY(gint8 x) { return x; }; p ++;\ }\ data = p;\ -} +} G_STMT_END + static GstData * sinesrc_get (GstPad *pad) { @@ -193,15 +194,15 @@ sinesrc_get (GstPad *pad) switch (src->width) { case 8: if (src->sign) - POPULATE (gint8, IDENTITY, IDENTITY) + POPULATE (gint8, IDENTITY, IDENTITY); else - POPULATE (guint8, UIDENTITY, UIDENTITY) + POPULATE (guint8, UIDENTITY, UIDENTITY); break; case 16: if (src->sign) - POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE) + POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE); else - POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE) + POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE); break; case 24: if (src->sign) { @@ -248,9 +249,9 @@ sinesrc_get (GstPad *pad) break; case 32: if (src->sign) - POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE) + POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE); else - POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE) + POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE); break; default: g_assert_not_reached ();