Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2022-05-04 10:14:24 +08:00
commit 7f068ecce3
969 changed files with 96279 additions and 469 deletions

View file

@ -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>
@ -404,6 +410,27 @@ nsresult RTCLoadInfo::UpdateSystemLoad()
const uint64_t cpu_times = nice + system + user;
const uint64_t total_times = cpu_times + idle;
UpdateCpuLoad(mTicksPerInterval,
total_times,
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,

View file

@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "OSXRunLoopSingleton.h"
#include <mozilla/StaticMutex.h>
#include <AudioUnit/AudioUnit.h>
#include <CoreAudio/AudioHardware.h>
#include <CoreAudio/HostTime.h>
#include <CoreFoundation/CoreFoundation.h>
static bool gRunLoopSet = false;
static mozilla::StaticMutex gMutex;
void mozilla_set_coreaudio_notification_runloop_if_needed()
{
mozilla::StaticMutexAutoLock lock(gMutex);
if (gRunLoopSet) {
return;
}
/* This is needed so that AudioUnit listeners get called on this thread, and
* not the main thread. If we don't do that, they are not called, or a crash
* occur, depending on the OSX version. */
AudioObjectPropertyAddress runloop_address = {
kAudioHardwarePropertyRunLoop,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
CFRunLoopRef run_loop = nullptr;
OSStatus r;
r = AudioObjectSetPropertyData(kAudioObjectSystemObject,
&runloop_address,
0, NULL, sizeof(CFRunLoopRef), &run_loop);
if (r != noErr) {
NS_WARNING("Could not make global CoreAudio notifications use their own thread.");
}
gRunLoopSet = true;
}

View file

@ -0,0 +1,25 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef OSXRUNLOOPSINGLETON_H_
#define OSXRUNLOOPSINGLETON_H_
#include <mozilla/Types.h>
#if defined(__cplusplus)
extern "C" {
#endif
/* This function tells CoreAudio to use its own thread for device change
* notifications, and can be called from any thread without external
* synchronization. */
void MOZ_EXPORT
mozilla_set_coreaudio_notification_runloop_if_needed();
#if defined(__cplusplus)
}
#endif
#endif // OSXRUNLOOPSINGLETON_H_

View file

@ -45,6 +45,14 @@ if CONFIG['OS_TARGET'] == 'Android':
'OpenSLESProvider.cpp',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
EXPORTS += [
'OSXRunLoopSingleton.h'
]
SOURCES += [
'OSXRunLoopSingleton.cpp',
]
if CONFIG['_MSC_VER']:
DEFINES['__PRETTY_FUNCTION__'] = '__FUNCSIG__'