summaryrefslogtreecommitdiff
path: root/dom/media/systemservices
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2022-04-26 11:24:42 -0500
committerBrian Smith <brian@dbsoft.org>2022-04-26 11:24:42 -0500
commitc82b759d56454bcd3eac54c484569e1239f7d1cc (patch)
tree14b786bac9fd295d1fca6bd32683652b7ac9ef7e /dom/media/systemservices
parent9e2a89c71ddf67975da35eb100673f6b5546f292 (diff)
downloaduxp-c82b759d56454bcd3eac54c484569e1239f7d1cc.tar.gz
Issue #1829 - Revert "Issue #1751 -- Remove XP_MACOSX conditionals from /dom"
This reverts commit 0dd3424f774954627d6f53df9fb47379d9b5c871.
Diffstat (limited to 'dom/media/systemservices')
-rw-r--r--dom/media/systemservices/LoadMonitor.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/dom/media/systemservices/LoadMonitor.cpp b/dom/media/systemservices/LoadMonitor.cpp
index 9ef01999c0..c05d43b1e5 100644
--- a/dom/media/systemservices/LoadMonitor.cpp
+++ b/dom/media/systemservices/LoadMonitor.cpp
@@ -31,6 +31,12 @@
#include <unistd.h>
#endif
+#ifdef XP_MACOSX
+#include <mach/mach_host.h>
+#include <mach/mach_init.h>
+#include <mach/host_info.h>
+#endif
+
#if defined(__DragonFly__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/sysctl.h>
@@ -407,6 +413,27 @@ nsresult RTCLoadInfo::UpdateSystemLoad()
cpu_times,
&mSystemLoad);
return NS_OK;
+#elif defined(XP_MACOSX)
+ mach_msg_type_number_t info_cnt = HOST_CPU_LOAD_INFO_COUNT;
+ host_cpu_load_info_data_t load_info;
+ kern_return_t rv = host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO,
+ (host_info_t)(&load_info), &info_cnt);
+
+ if (rv != KERN_SUCCESS || info_cnt != HOST_CPU_LOAD_INFO_COUNT) {
+ LOG(("Error from mach/host_statistics call"));
+ return NS_ERROR_FAILURE;
+ }
+
+ const uint64_t cpu_times = load_info.cpu_ticks[CPU_STATE_NICE]
+ + load_info.cpu_ticks[CPU_STATE_SYSTEM]
+ + load_info.cpu_ticks[CPU_STATE_USER];
+ const uint64_t total_times = cpu_times + load_info.cpu_ticks[CPU_STATE_IDLE];
+
+ UpdateCpuLoad(mTicksPerInterval,
+ total_times,
+ cpu_times,
+ &mSystemLoad);
+ return NS_OK;
#elif defined(__DragonFly__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__NetBSD__)