]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/svolume_arm.c
volume: Add explicit checks for ARMv6 instructions
[pulseaudio] / src / pulsecore / svolume_arm.c
index 0d39d10563616c6bb3ce793b7b69acf31afcd608..3973e5181f36e0c7230988696d72df7f8feacd93 100644 (file)
@@ -35,7 +35,7 @@
 #include "sample-util.h"
 #include "endianmacros.h"
 
-#if defined (__arm__)
+#if defined (__arm__) && defined (HAVE_ARMV6)
 
 #define MOD_INC() \
     " subs  r0, r6, %2              \n\t" \
@@ -47,7 +47,10 @@ pa_volume_s16ne_arm (int16_t *samples, int32_t *volumes, unsigned channels, unsi
 {
     int32_t *ve;
 
-    channels = MAX (4, channels);
+    /* Channels must be at least 4, and always a multiple of the original number.
+     * This is also the max amount we overread the volume array, which should
+     * have enough padding. */
+    channels = channels == 3 ? 6 : PA_MAX (4U, channels);
     ve = volumes + channels;
 
     __asm__ __volatile__ (
@@ -137,7 +140,7 @@ static void run_test (void) {
     int32_t volumes[CHANNELS + PADDING];
     int i, j, padding;
     pa_do_volume_func_t func;
-    struct timeval start, stop;
+    pa_usec_t start, stop;
 
     func = pa_get_volume_func (PA_SAMPLE_S16NE);
 
@@ -161,29 +164,29 @@ static void run_test (void) {
         }
     }
 
-    pa_gettimeofday(&start);
+    start = pa_rtclock_now();
     for (j = 0; j < TIMES; j++) {
         memcpy (samples, samples_orig, sizeof (samples));
         pa_volume_s16ne_arm (samples, volumes, CHANNELS, sizeof (samples));
     }
-    pa_gettimeofday(&stop);
-    pa_log_info("ARM: %llu usec.", (long long unsigned int)pa_timeval_diff (&stop, &start));
+    stop = pa_rtclock_now();
+    pa_log_info("ARM: %llu usec.", (long long unsigned int) (stop - start));
 
-    pa_gettimeofday(&start);
+    start = pa_rtclock_now();
     for (j = 0; j < TIMES; j++) {
         memcpy (samples_ref, samples_orig, sizeof (samples));
         func (samples_ref, volumes, CHANNELS, sizeof (samples));
     }
-    pa_gettimeofday(&stop);
-    pa_log_info("ref: %llu usec.", (long long unsigned int)pa_timeval_diff (&stop, &start));
+    stop = pa_rtclock_now();
+    pa_log_info("ref: %llu usec.", (long long unsigned int) (stop - start));
 }
 #endif
 
-#endif /* defined (__arm__) */
+#endif /* defined (__arm__) && defined (HAVE_ARMV6) */
 
 
 void pa_volume_func_init_arm (pa_cpu_arm_flag_t flags) {
-#if defined (__arm__)
+#if defined (__arm__) && defined (HAVE_ARMV6)
     pa_log_info("Initialising ARM optimized functions.");
 
 #ifdef RUN_TEST
@@ -191,5 +194,5 @@ void pa_volume_func_init_arm (pa_cpu_arm_flag_t flags) {
 #endif
 
     pa_set_volume_func (PA_SAMPLE_S16NE,     (pa_do_volume_func_t) pa_volume_s16ne_arm);
-#endif /* defined (__arm__) */
+#endif /* defined (__arm__) && defined (HAVE_ARMV6) */
 }