diff --git a/spa/plugins/support/cpu.c b/spa/plugins/support/cpu.c index 67b83c222..d8978fad9 100644 --- a/spa/plugins/support/cpu.c +++ b/spa/plugins/support/cpu.c @@ -29,6 +29,10 @@ #include #include +#ifdef __FreeBSD__ +#include +#endif + #include #include #include @@ -75,6 +79,7 @@ impl_cpu_force_flags(void *object, uint32_t flags) return 0; } +#ifndef __FreeBSD__ static uint32_t get_count(struct impl *this) { cpu_set_t cpuset; @@ -83,6 +88,17 @@ static uint32_t get_count(struct impl *this) return CPU_COUNT(&cpuset); return 1; } +#else +static uint32_t get_count(struct impl *this) +{ + int mib[] = {CTL_HW, HW_NCPU}; + int r; + size_t rSize = sizeof(r); + if(-1 == sysctl(mib, 2, &r, &rSize, 0, 0)) + return 1; + return r; +} +#endif static uint32_t impl_cpu_get_count(void *object)