]> code.delx.au - pulseaudio/blobdiff - src/tests/voltest.c
tests: More useful output of make check
[pulseaudio] / src / tests / voltest.c
index b45a468301462abd011be7f4c018667fb2ea61af..f7405ffe6e3477d2bfcca9886de33d96e2d29c42 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <pulse/volume.h>
 
+#include <pulsecore/log.h>
 #include <pulsecore/macro.h>
 
 int main(int argc, char *argv[]) {
@@ -36,15 +37,18 @@ int main(int argc, char *argv[]) {
     pa_volume_t md = 0;
     unsigned mdn = 0;
 
-    printf("Attenuation of sample 1 against 32767: %g dB\n", 20.0*log10(1.0/32767.0));
-    printf("Smallest possible attenuation > 0 applied to 32767: %li\n", lrint(32767.0*pa_sw_volume_to_linear(1)));
+    if (!getenv("MAKE_CHECK"))
+        pa_log_set_level(PA_LOG_DEBUG);
+
+    pa_log("Attenuation of sample 1 against 32767: %g dB", 20.0*log10(1.0/32767.0));
+    pa_log("Smallest possible attenuation > 0 applied to 32767: %li", lrint(32767.0*pa_sw_volume_to_linear(1)));
 
     for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 256) {
 
         double dB = pa_sw_volume_to_dB(v);
         double f = pa_sw_volume_to_linear(v);
 
-        printf("Volume: %3i; percent: %i%%; decibel %0.2f; linear = %0.2f; volume(decibel): %3i; volume(linear): %3i\n",
+        pa_log_debug("Volume: %3i; percent: %i%%; decibel %0.2f; linear = %0.2f; volume(decibel): %3i; volume(linear): %3i",
                v, (v*100)/PA_VOLUME_NORM, dB, f, pa_sw_volume_from_dB(dB), pa_sw_volume_from_linear(f));
     }
 
@@ -53,11 +57,7 @@ int main(int argc, char *argv[]) {
 
         pa_cvolume_set(&cv, 2, v);
 
-        printf("Volume: %3i [%s] [%s]\n",
-               v,
-               pa_cvolume_snprint(s, sizeof(s), &cv),
-               pa_sw_cvolume_snprint_dB(t, sizeof(t), &cv));
-
+        pa_log_debug("Volume: %3i [%s] [%s]", v, pa_cvolume_snprint(s, sizeof(s), &cv), pa_sw_cvolume_snprint_dB(t, sizeof(t), &cv));
     }
 
     map.channels = cv.channels = 2;
@@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
         for (cv.values[1] = PA_VOLUME_MUTED; cv.values[1] <= PA_VOLUME_NORM*2; cv.values[1] += 4096) {
             char s[PA_CVOLUME_SNPRINT_MAX];
 
-            printf("Volume: [%s]; balance: %2.1f\n", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map));
+            pa_log_debug("Volume: [%s]; balance: %2.1f", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map));
         }
 
     for (cv.values[0] = PA_VOLUME_MUTED+4096; cv.values[0] <= PA_VOLUME_NORM*2; cv.values[0] += 4096)
@@ -78,13 +78,13 @@ int main(int argc, char *argv[]) {
                 pa_cvolume r;
                 float k;
 
-                printf("Before: volume: [%s]; balance: %2.1f\n", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map));
+                pa_log_debug("Before: volume: [%s]; balance: %2.1f", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map));
 
                 r = cv;
                 pa_cvolume_set_balance(&r, &map,b);
 
                 k = pa_cvolume_get_balance(&r, &map);
-                printf("After: volume: [%s]; balance: %2.1f (intended: %2.1f) %s\n", pa_cvolume_snprint(s, sizeof(s), &r), k, b, k < b-.05 || k > b+.5 ? "MISMATCH" : "");
+                pa_log_debug("After: volume: [%s]; balance: %2.1f (intended: %2.1f) %s", pa_cvolume_snprint(s, sizeof(s), &r), k, b, k < b-.05 || k > b+.5 ? "MISMATCH" : "");
             }
 
     for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 51) {
@@ -125,7 +125,7 @@ int main(int argc, char *argv[]) {
         }
     }
 
-    printf("max deviation: %lu n=%lu\n", (unsigned long) md, (unsigned long) mdn);
+    pa_log("max deviation: %lu n=%lu", (unsigned long) md, (unsigned long) mdn);
 
     pa_assert(md <= 1);
     pa_assert(mdn <= 251);