]> code.delx.au - pulseaudio/blobdiff - src/tests/mix-test.c
tests: More useful output of make check
[pulseaudio] / src / tests / mix-test.c
index db8ac6e3ae7f1724fb3dddd1bf1885baec3257a4..19b5ea5ab0a2f7788fae61e5ab5075b0a3860e62 100644 (file)
@@ -3,7 +3,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
 #include <pulse/sample.h>
 #include <pulse/volume.h>
 
-#include <pulsecore/resampler.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/endianmacros.h>
 #include <pulsecore/memblock.h>
 #include <pulsecore/sample-util.h>
 
-#include <liboil/liboil.h>
-
-static float swap_float(float a) {
-    uint32_t *b = (uint32_t*) &a;
-    *b = PA_UINT32_SWAP(*b);
-    return a;
-}
-
 static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
     void *d;
     unsigned i;
 
+    if (getenv("MAKE_CHECK"))
+        return;
+
     d = pa_memblock_acquire(chunk->memblock);
 
     switch (ss->format) {
@@ -69,6 +63,8 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
             break;
         }
 
+        case PA_SAMPLE_S24_32NE:
+        case PA_SAMPLE_S24_32RE:
         case PA_SAMPLE_S32NE:
         case PA_SAMPLE_S32RE: {
             uint32_t *u = d;
@@ -79,12 +75,24 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
             break;
         }
 
+        case PA_SAMPLE_S24NE:
+        case PA_SAMPLE_S24RE: {
+            uint8_t *u = d;
+
+            for (i = 0; i < chunk->length / pa_frame_size(ss); i++) {
+                printf("0x%02x%02x%02xx ", *u, *(u+1), *(u+2));
+                u += 3;
+            }
+
+            break;
+        }
+
         case PA_SAMPLE_FLOAT32NE:
         case PA_SAMPLE_FLOAT32RE: {
             float *u = d;
 
             for (i = 0; i < chunk->length / pa_frame_size(ss); i++) {
-                printf("%1.5f ",  ss->format == PA_SAMPLE_FLOAT32NE ? *u : swap_float(*u));
+                printf("%1.5f ",  ss->format == PA_SAMPLE_FLOAT32NE ? *u : PA_FLOAT32_SWAP(*u));
                 u++;
             }
 
@@ -113,73 +121,72 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) {
         case PA_SAMPLE_U8:
         case PA_SAMPLE_ULAW:
         case PA_SAMPLE_ALAW: {
-            uint8_t *u = d;
+            static const uint8_t u8_samples[] = {
+                0x00, 0xFF, 0x7F, 0x80, 0x9f,
+                0x3f, 0x01, 0xF0, 0x20, 0x21
+            };
 
-            u[0] = 0x00;
-            u[1] = 0xFF;
-            u[2] = 0x7F;
-            u[3] = 0x80;
-            u[4] = 0x9f;
-            u[5] = 0x3f;
-            u[6] = 0x1;
-            u[7] = 0xF0;
-            u[8] = 0x20;
-            u[9] = 0x21;
+            memcpy(d, u8_samples, sizeof(u8_samples));
             break;
         }
 
         case PA_SAMPLE_S16NE:
         case PA_SAMPLE_S16RE: {
-            uint16_t *u = d;
+            static const uint16_t u16_samples[] = {
+                0x0000, 0xFFFF, 0x7FFF, 0x8000, 0x9fff,
+                0x3fff, 0x0001, 0xF000, 0x0020, 0x0021
+            };
 
-            u[0] = 0x0000;
-            u[1] = 0xFFFF;
-            u[2] = 0x7FFF;
-            u[3] = 0x8000;
-            u[4] = 0x9fff;
-            u[5] = 0x3fff;
-            u[6] = 0x1;
-            u[7] = 0xF000;
-            u[8] = 0x20;
-            u[9] = 0x21;
+            memcpy(d, u16_samples, sizeof(u16_samples));
             break;
         }
 
+        case PA_SAMPLE_S24_32NE:
+        case PA_SAMPLE_S24_32RE:
         case PA_SAMPLE_S32NE:
         case PA_SAMPLE_S32RE: {
-            uint32_t *u = d;
+            static const uint32_t u32_samples[] = {
+                0x00000001, 0xFFFF0002, 0x7FFF0003, 0x80000004, 0x9fff0005,
+                0x3fff0006, 0x00010007, 0xF0000008, 0x00200009, 0x0021000A
+            };
+
+            memcpy(d, u32_samples, sizeof(u32_samples));
+            break;
+        }
 
-            u[0] = 0x00000001;
-            u[1] = 0xFFFF0002;
-            u[2] = 0x7FFF0003;
-            u[3] = 0x80000004;
-            u[4] = 0x9fff0005;
-            u[5] = 0x3fff0006;
-            u[6] =    0x10007;
-            u[7] = 0xF0000008;
-            u[8] =   0x200009;
-            u[9] =   0x21000A;
+        case PA_SAMPLE_S24NE:
+        case PA_SAMPLE_S24RE: {
+            /* Need to be on a byte array because they are not aligned */
+            static const uint8_t u24_samples[] = {
+                0x00, 0x00, 0x01,
+                0xFF, 0xFF, 0x02,
+                0x7F, 0xFF, 0x03,
+                0x80, 0x00, 0x04,
+                0x9f, 0xff, 0x05,
+                0x3f, 0xff, 0x06,
+                0x01, 0x00, 0x07,
+                0xF0, 0x00, 0x08,
+                0x20, 0x00, 0x09,
+                0x21, 0x00, 0x0A
+            };
+
+            memcpy(d, u24_samples, sizeof(u24_samples));
             break;
         }
 
         case PA_SAMPLE_FLOAT32NE:
         case PA_SAMPLE_FLOAT32RE: {
             float *u = d;
+            static const float float_samples[] = {
+                0.0f, -1.0f, 1.0f, 4711.0f, 0.222f,
+                0.33f, -.3f, 99.0f, -0.555f, -.123f
+            };
 
-            u[0] = 0.0f;
-            u[1] = -1.0f;
-            u[2] = 1.0f;
-            u[3] = 4711.0f;
-            u[4] = 0.222f;
-            u[5] = 0.33f;
-            u[6] = -.3f;
-            u[7] = 99.0f;
-            u[8] = -0.555f;
-            u[9] = -.123f;
-
-            if (ss->format == PA_SAMPLE_FLOAT32RE)
+            if (ss->format == PA_SAMPLE_FLOAT32RE) {
                 for (i = 0; i < 10; i++)
-                    u[i] = swap_float(u[i]);
+                    u[i] = PA_FLOAT32_SWAP(float_samples[i]);
+            } else
+              memcpy(d, float_samples, sizeof(float_samples));
 
             break;
         }
@@ -198,8 +205,8 @@ int main(int argc, char *argv[]) {
     pa_sample_spec a;
     pa_cvolume v;
 
-    oil_init();
-    pa_log_set_level(PA_LOG_DEBUG);
+    if (!getenv("MAKE_CHECK"))
+        pa_log_set_level(PA_LOG_DEBUG);
 
     pa_assert_se(pool = pa_mempool_new(FALSE, 0));
 
@@ -214,7 +221,7 @@ int main(int argc, char *argv[]) {
         pa_mix_info m[2];
         void *ptr;
 
-        printf("=== mixing: %s\n", pa_sample_format_to_string(a.format));
+        pa_log_debug("=== mixing: %s\n", pa_sample_format_to_string(a.format));
 
         /* Generate block */
         i.memblock = generate_block(pool, &a);