diff --git a/audio/utils.c b/audio/utils.c index a0637a5382..16cd4cbc32 100644 --- a/audio/utils.c +++ b/audio/utils.c @@ -17,6 +17,7 @@ #include "utils.h" #include "../general.h" +#include "../performance.h" #if defined(__SSE2__) #include @@ -138,7 +139,7 @@ void audio_convert_float_to_s16_altivec(int16_t *out, } #elif defined(HAVE_NEON) void audio_convert_s16_float_asm(float *out, const int16_t *in, size_t samples); -void audio_convert_s16_to_float_neon(float *out, const int16_t *in, size_t samples, +static void audio_convert_s16_to_float_neon(float *out, const int16_t *in, size_t samples, float gain) { (void)gain; // gain is ignored for now. @@ -153,7 +154,7 @@ void audio_convert_s16_to_float_neon(float *out, const int16_t *in, size_t sampl } void audio_convert_float_s16_asm(int16_t *out, const float *in, size_t samples); -void audio_convert_float_to_s16_neon(int16_t *out, const float *in, size_t samples) +static void audio_convert_float_to_s16_neon(int16_t *out, const float *in, size_t samples) { size_t aligned_samples = samples & ~7; if (aligned_samples) @@ -164,6 +165,18 @@ void audio_convert_float_to_s16_neon(int16_t *out, const float *in, size_t sampl } #endif +void audio_convert_init_simd(void) +{ +#ifdef HAVE_NEON + struct rarch_cpu_features cpu; + rarch_get_cpu_features(&cpu); + audio_convert_s16_to_float_arm = cpu.simd & RARCH_SIMD_NEON ? + audio_convert_s16_to_float_neon : audio_convert_s16_to_float_C; + audio_convert_float_to_s16_arm = cpu.simd & RARCH_SIMD_NEON ? + audio_convert_float_to_s16_neon : audio_convert_float_to_s16_C; +#endif +} + #ifdef HAVE_RSOUND bool rarch_rsound_start(const char *ip) diff --git a/audio/utils.h b/audio/utils.h index a4c7e1d219..38d15e4667 100644 --- a/audio/utils.h +++ b/audio/utils.h @@ -44,13 +44,12 @@ void audio_convert_float_to_s16_altivec(int16_t *out, const float *in, size_t samples); #elif defined(HAVE_NEON) -#define audio_convert_s16_to_float audio_convert_s16_to_float_neon -#define audio_convert_float_to_s16 audio_convert_float_to_s16_neon +#define audio_convert_s16_to_float audio_convert_s16_to_float_arm +#define audio_convert_float_to_s16 audio_convert_float_to_s16_arm -void audio_convert_s16_to_float_neon(float *out, +void (*audio_convert_s16_to_float_arm)(float *out, const int16_t *in, size_t samples, float gain); - -void audio_convert_float_to_s16_neon(int16_t *out, +void (*audio_convert_float_to_s16_arm)(int16_t *out, const float *in, size_t samples); #else @@ -63,6 +62,8 @@ void audio_convert_s16_to_float_C(float *out, void audio_convert_float_to_s16_C(int16_t *out, const float *in, size_t samples); +void audio_convert_init_simd(void); + #ifdef HAVE_RSOUND bool rarch_rsound_start(const char *ip); void rarch_rsound_stop(void); diff --git a/driver.c b/driver.c index 28a360c2cf..0ebdb6b595 100644 --- a/driver.c +++ b/driver.c @@ -21,6 +21,7 @@ #include #include #include "compat/posix_string.h" +#include "audio/utils.h" #ifdef HAVE_X11 #include "gfx/context/x11_common.h" @@ -359,6 +360,8 @@ static void deinit_dsp_plugin(void) void init_audio(void) { + audio_convert_init_simd(); + // Resource leaks will follow if audio is initialized twice. if (driver.audio_data) return;