--- plugins/tracers/gstrusage.c.orig	2016-11-05 11:23:32.000000000 -0700
+++ plugins/tracers/gstrusage.c	2016-11-05 11:25:40.000000000 -0700
@@ -39,6 +39,22 @@
 #include <sys/resource.h>
 #endif
 
+#ifdef __APPLE__
+#ifndef MAC_OS_X_VERSION_MIN_REQUIRED
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
+#include <Availability.h>
+#else
+#include <AvailabilityMacros.h>
+#endif
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#endif
+#endif
+
 GST_DEBUG_CATEGORY_STATIC (gst_rusage_debug);
 #define GST_CAT_DEFAULT gst_rusage_debug
 
@@ -274,6 +290,32 @@
 
   gobject_class->finalize = gst_rusage_tracer_finalize;
 
+#ifdef __APPLE__
+#ifndef MAC_OS_X_VERSION_MIN_REQUIRED
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
+#include <Availability.h>
+#else
+#include <AvailabilityMacros.h>
+#endif
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+
+  int nm[2];
+  size_t len = 4;
+  uint32_t count;
+  
+  nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
+  sysctl(nm, 2, &count, &len, NULL, 0);
+  
+  if (count < 1) {
+  	nm[1] = HW_NCPU;
+  	sysctl(nm, 2, &count, &len, NULL, 0);
+  	if (count < 1) { count = 1; }
+  }
+  num_cpus = (glong)count;
+
+#else
+
   if ((num_cpus = sysconf (_SC_NPROCESSORS_ONLN)) == -1) {
     GST_WARNING ("failed to get number of cpus online");
     if ((num_cpus = sysconf (_SC_NPROCESSORS_CONF)) == -1) {
@@ -281,6 +323,10 @@
       num_cpus = 1;
     }
   }
+
+#endif
+#endif
+
   GST_DEBUG ("rusage: num_cpus=%ld", num_cpus);
 
   /* announce trace formats */
