From c7357eee0c0ab56bba47ac655582c4769a2b7ffd Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Mon, 14 Dec 2020 18:08:02 +0000 Subject: MFH: r557394 r557754 r557767 r558100 www/firefox: update to 84.0 - Correct patch for powerpc64 [1] Changes: https://www.mozilla.org/firefox/84.0/releasenotes/ Submitted by: pkubaj --- www/firefox/Makefile | 6 +- www/firefox/distinfo | 6 +- www/firefox/files/patch-bug1288587 | 34 +- www/firefox/files/patch-bug1440203 | 788 --------------- www/firefox/files/patch-bug1504834_comment10 | 2 +- www/firefox/files/patch-bug1559213 | 60 +- www/firefox/files/patch-bug1618914 | 26 +- www/firefox/files/patch-bug1664115 | 8 +- www/firefox/files/patch-bug1670807 | 15 - www/firefox/files/patch-bug1676134 | 122 +++ www/firefox/files/patch-bug1677715 | 148 +++ www/firefox/files/patch-bug847568 | 140 +-- www/firefox/files/patch-cubeb-oss | 1327 -------------------------- www/firefox/files/patch-env-api-keys | 14 +- www/firefox/files/patch-freebsd11 | 21 + 15 files changed, 440 insertions(+), 2277 deletions(-) delete mode 100644 www/firefox/files/patch-bug1440203 delete mode 100644 www/firefox/files/patch-bug1670807 create mode 100644 www/firefox/files/patch-bug1676134 create mode 100644 www/firefox/files/patch-bug1677715 delete mode 100644 www/firefox/files/patch-cubeb-oss create mode 100644 www/firefox/files/patch-freebsd11 diff --git a/www/firefox/Makefile b/www/firefox/Makefile index d1f06b075b2f..b0edd089b085 100644 --- a/www/firefox/Makefile +++ b/www/firefox/Makefile @@ -2,12 +2,12 @@ # $FreeBSD$ PORTNAME= firefox -DISTVERSION= 83.0 -PORTREVISION= 3 +DISTVERSION= 84.0 +PORTREVISION= 2 PORTEPOCH= 2 CATEGORIES= www MASTER_SITES= MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \ - MOZILLA/${PORTNAME}/candidates/${DISTVERSION}-candidates/build2/source + MOZILLA/${PORTNAME}/candidates/${DISTVERSION}-candidates/build3/source DISTFILES= ${DISTNAME}.source${EXTRACT_SUFX} MAINTAINER= gecko@FreeBSD.org diff --git a/www/firefox/distinfo b/www/firefox/distinfo index b77a92c16c55..a0efcd3ec617 100644 --- a/www/firefox/distinfo +++ b/www/firefox/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1605204503 -SHA256 (firefox-83.0.source.tar.xz) = d69e84e8b8449f828683d274c24e03095858362bfed21b08bdd7fe715eea5398 -SIZE (firefox-83.0.source.tar.xz) = 351331940 +TIMESTAMP = 1607733349 +SHA256 (firefox-84.0.source.tar.xz) = 23273ef0165b243f5d0908c38e7854d38070282c9b526e8d93b7503cd5f69138 +SIZE (firefox-84.0.source.tar.xz) = 366395172 diff --git a/www/firefox/files/patch-bug1288587 b/www/firefox/files/patch-bug1288587 index a911043358c9..6130cf7e30da 100644 --- a/www/firefox/files/patch-bug1288587 +++ b/www/firefox/files/patch-bug1288587 @@ -2,34 +2,34 @@ diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.confi index 855214a..1e91d51 100644 --- build/moz.configure/init.configure +++ build/moz.configure/init.configure -@@ -240,6 +240,7 @@ option(env='VIRTUALENV_NAME', nargs=1, default='init_p - @imports(_from='mozbuild.pythonutil', _import='find_python3_executable') - @imports(_from='mozbuild.pythonutil', _import='python_executable_version') - @imports(_from='six', _import='ensure_text') -+@imports(_from='__builtin__', _import='KeyError') +@@ -238,6 +238,7 @@ option( + @imports(_from="mozbuild.pythonutil", _import="find_python3_executable") + @imports(_from="mozbuild.pythonutil", _import="python_executable_version") + @imports(_from="six", _import="ensure_text") ++@imports(_from="__builtin__", _import="KeyError") def virtualenv_python3(env_python, virtualenv_name, build_env, mozconfig, help): # Avoid re-executing python when running configure --help. if help: -@@ -273,6 +274,12 @@ def virtualenv_python3(env_python, virtualenv_name, bu - python = mozconfig['vars']['added']['PYTHON3'] - elif 'PYTHON3' in mozconfig['vars']['modified']: - python = mozconfig['vars']['modified']['PYTHON3'][1] -+ for i in ('env', 'vars'): -+ for j in ('added', 'modified'): +@@ -271,6 +272,12 @@ def virtualenv_python3(env_python, virtualenv_name, bu + python = mozconfig["vars"]["added"]["PYTHON3"] + elif "PYTHON3" in mozconfig["vars"]["modified"]: + python = mozconfig["vars"]["modified"]["PYTHON3"][1] ++ for i in ("env", "vars"): ++ for j in ("added", "modified"): + try: -+ del mozconfig[i][j]['PYTHON3'] ++ del mozconfig[i][j]["PYTHON3"] + except KeyError: + pass log.debug("python3: executable from configuration: %r" % python) -@@ -358,7 +365,10 @@ def virtualenv_python3(env_python, virtualenv_name, bu - sys.executable, manager.python_path)) - log.info('Re-executing in the virtualenv') +@@ -364,7 +371,10 @@ def virtualenv_python3(env_python, virtualenv_name, bu + ) + log.info("Re-executing in the virtualenv") if env_python: -- del os.environ['PYTHON3'] +- del os.environ["PYTHON3"] + try: -+ del os.environ['PYTHON3'] ++ del os.environ["PYTHON3"] + except KeyError: + pass # Homebrew on macOS will change Python's sys.executable to a custom diff --git a/www/firefox/files/patch-bug1440203 b/www/firefox/files/patch-bug1440203 deleted file mode 100644 index d66aebf5ff72..000000000000 --- a/www/firefox/files/patch-bug1440203 +++ /dev/null @@ -1,788 +0,0 @@ -commit cc6e7ab13380 -Author: Jed Davis -Date: Thu Oct 22 21:23:32 2020 +0000 - - Bug 1440203 - Support memfd_create in IPC shared memory. r=glandium - - This commit also allows `memfd_create` in the seccomp-bpf policy for all - process types. - - `memfd_create` is an API added in Linux 3.17 (and adopted by FreeBSD - for the upcoming version 13) for creating anonymous shared memory - not connected to any filesystem. Supporting it means that sandboxed - child processes on Linux can create shared memory directly instead of - messaging a broker, which is unavoidably slower, and it should avoid - the problems we'd been seeing with overly small `/dev/shm` in container - environments (which were causing serious problems for using Firefox for - automated testing of frontend projects). - - `memfd_create` also introduces the related operation of file seals: - irrevocably preventing types of modifications to a file. Unfortunately, - the most useful one, `F_SEAL_WRITE`, can't be relied on; see the large - comment in `SharedMemory:ReadOnlyCopy` for details. So we still use - the applicable seals as defense in depth, but read-only copies are - implemented on Linux by using procfs (and see the comments on the - `ReadOnlyCopy` function in `shared_memory_posix.cc` for the subtleties - there). - - There's also a FreeBSD implementation, using `cap_rights_limit` for - read-only copies, if the build host is new enough to have the - `memfd_create` function. - - The support code for Android, which doesn't support shm_open and can't - use the memfd backend because of issues with its SELinux policy (see bug - 1670277), has been reorganized to reflect that we'll always use its own - API, ashmem, in that case. - - Differential Revision: https://phabricator.services.mozilla.com/D90605 ---- - build/moz.configure/headers.configure | 8 + - config/system-headers.mozbuild | 5 + - ipc/chromium/src/base/linux_memfd_defs.h | 69 +++++ - ipc/chromium/src/base/shared_memory.h | 3 +- - ipc/chromium/src/base/shared_memory_posix.cc | 428 +++++++++++++++++++++------ - ipc/gtest/TestSharedMemory.cpp | 46 +++ - security/sandbox/linux/SandboxFilter.cpp | 9 +- - 7 files changed, 472 insertions(+), 96 deletions(-) - -diff --git build/moz.configure/headers.configure build/moz.configure/headers.configure -index 9445f10a4d53..0f4455d8eeea 100644 ---- build/moz.configure/headers.configure -+++ build/moz.configure/headers.configure -@@ -65,6 +65,14 @@ check_headers( - 'byteswap.h', - ) - -+# memfd_create(2) -- Note that older versions of the Linux man-pages -+# project incorrectly cite , which doesn't exist; this -+# was fixed in the man-pages-5.00 release. -+set_define('HAVE_MEMFD_CREATE', -+ try_compile(includes=['sys/mman.h'], -+ body='memfd_create("", 0);', -+ check_msg='for memfd_create in sys/mman.h')) -+ - # TODO: Move these checks to file specific to --enable-project=js. - have_perf_event_h = check_header('linux/perf_event.h', - when=building_linux) -diff --git config/system-headers.mozbuild config/system-headers.mozbuild -index 1dfd3f0a48b8..3c355e3f1d71 100644 ---- config/system-headers.mozbuild -+++ config/system-headers.mozbuild -@@ -1352,5 +1352,10 @@ if CONFIG['OS_TARGET'] == 'Linux' and CONFIG['CPU_ARCH'].startswith('mips'): - 'sys/cachectl.h', - ] - -+if CONFIG['OS_TARGET'] == 'FreeBSD': -+ system_headers += [ -+ 'sys/capsicum.h', -+ ] -+ - if CONFIG['MOZ_APP_SYSTEM_HEADERS']: - include("../" + CONFIG['MOZ_BUILD_APP'] + "/app-system-headers.mozbuild") -diff --git ipc/chromium/src/base/linux_memfd_defs.h ipc/chromium/src/base/linux_memfd_defs.h -new file mode 100644 -index 000000000000..f5b0de1de853 ---- /dev/null -+++ ipc/chromium/src/base/linux_memfd_defs.h -@@ -0,0 +1,69 @@ -+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -+/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -+/* 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 https://mozilla.org/MPL/2.0/. */ -+ -+#ifndef BASE_LINUX_MEMFD_DEFS_H -+#define BASE_LINUX_MEMFD_DEFS_H -+ -+#include -+ -+// glibc before 2.27 didn't have a memfd_create wrapper, and if the -+// build system is old enough then it won't have the syscall number -+// and various related constants either. -+ -+#if defined(__x86_64__) -+# define MEMFD_CREATE_NR 319 -+#elif defined(__i386__) -+# define MEMFD_CREATE_NR 356 -+#elif defined(__aarch64__) -+# define MEMFD_CREATE_NR 279 -+#elif defined(__arm__) -+# define MEMFD_CREATE_NR 385 -+#elif defined(__powerpc__) -+# define MEMFD_CREATE_NR 360 -+#elif defined(__s390__) -+# define MEMFD_CREATE_NR 350 -+#elif defined(__mips__) -+# include -+# if _MIPS_SIM == _MIPS_SIM_ABI32 -+# define MEMFD_CREATE_NR 4354 -+# elif _MIPS_SIM == _MIPS_SIM_ABI64 -+# define MEMFD_CREATE_NR 5314 -+# elif _MIPS_SIM == _MIPS_SIM_NABI32 -+# define MEMFD_CREATE_NR 6318 -+# endif // mips subarch -+#endif // arch -+ -+#ifdef MEMFD_CREATE_NR -+# ifdef SYS_memfd_create -+static_assert(MEMFD_CREATE_NR == SYS_memfd_create, -+ "MEMFD_CREATE_NR should match the actual SYS_memfd_create value"); -+# else // defined here but not in system headers -+# define SYS_memfd_create MEMFD_CREATE_NR -+# endif -+#endif -+ -+#ifndef MFD_CLOEXEC -+# define MFD_CLOEXEC 0x0001U -+# define MFD_ALLOW_SEALING 0x0002U -+#endif -+ -+#ifndef F_ADD_SEALS -+# ifndef F_LINUX_SPECIFIC_BASE -+# define F_LINUX_SPECIFIC_BASE 1024 -+# endif -+# define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) -+# define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) -+# define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ -+# define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ -+# define F_SEAL_GROW 0x0004 /* prevent file from growing */ -+# define F_SEAL_WRITE 0x0008 /* prevent writes */ -+#endif -+ -+#ifndef F_SEAL_FUTURE_WRITE -+# define F_SEAL_FUTURE_WRITE 0x0010 -+#endif -+ -+#endif // BASE_LINUX_MEMFD_DEFS_H -diff --git ipc/chromium/src/base/shared_memory.h ipc/chromium/src/base/shared_memory.h -index 93372f4ab333..49d614164a0b 100644 ---- ipc/chromium/src/base/shared_memory.h -+++ ipc/chromium/src/base/shared_memory.h -@@ -216,8 +216,9 @@ class SharedMemory { - // If true indicates this came from an external source so needs extra checks - // before being mapped. - bool external_section_ = false; --#elif defined(OS_POSIX) -+#elif defined(OS_POSIX) && !defined(ANDROID) - mozilla::UniqueFileHandle frozen_file_; -+ bool is_memfd_ = false; - #endif - bool read_only_ = false; - bool freezeable_ = false; -diff --git ipc/chromium/src/base/shared_memory_posix.cc ipc/chromium/src/base/shared_memory_posix.cc -index d5f734ac91b8..e36805aedb89 100644 ---- ipc/chromium/src/base/shared_memory_posix.cc -+++ ipc/chromium/src/base/shared_memory_posix.cc -@@ -16,6 +16,18 @@ - # include "mozilla/Ashmem.h" - #endif - -+#ifdef OS_LINUX -+# include "linux_memfd_defs.h" -+#endif -+ -+#ifdef __FreeBSD__ -+# include -+#endif -+ -+#ifdef MOZ_VALGRIND -+# include -+#endif -+ - #include "base/eintr_wrapper.h" - #include "base/logging.h" - #include "base/string_util.h" -@@ -46,11 +58,14 @@ SharedMemory::~SharedMemory() { - - bool SharedMemory::SetHandle(SharedMemoryHandle handle, bool read_only) { - DCHECK(!mapped_file_); -+#ifndef ANDROID - DCHECK(!frozen_file_); -+#endif - - freezeable_ = false; - mapped_file_.reset(handle.fd); - read_only_ = read_only; -+ // is_memfd_ only matters for freezing, which isn't possible - return true; - } - -@@ -62,11 +77,187 @@ bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { - // static - SharedMemoryHandle SharedMemory::NULLHandle() { return SharedMemoryHandle(); } - --// static -+#ifdef ANDROID -+ -+// Android has its own shared memory API, ashmem. It doesn't support -+// POSIX shm_open, and the memfd support (see below) also doesn't work -+// because its SELinux policy prevents the procfs operations we'd use -+// (see bug 1670277 for more details). -+ - bool SharedMemory::AppendPosixShmPrefix(std::string* str, pid_t pid) { --#if defined(ANDROID) - return false; --#else -+} -+ -+bool SharedMemory::CreateInternal(size_t size, bool freezeable) { -+ read_only_ = false; -+ -+ DCHECK(size > 0); -+ DCHECK(!mapped_file_); -+ -+ int fd = mozilla::android::ashmem_create(nullptr, size); -+ if (fd < 0) { -+ CHROMIUM_LOG(WARNING) << "failed to open shm: " << strerror(errno); -+ return false; -+ } -+ -+ mapped_file_.reset(fd); -+ max_size_ = size; -+ freezeable_ = freezeable; -+ return true; -+} -+ -+bool SharedMemory::ReadOnlyCopy(SharedMemory* ro_out) { -+ DCHECK(mapped_file_); -+ DCHECK(!read_only_); -+ CHECK(freezeable_); -+ -+ if (ro_out == this) { -+ DCHECK(!memory_); -+ } -+ -+ if (mozilla::android::ashmem_setProt(mapped_file_.get(), PROT_READ) != 0) { -+ CHROMIUM_LOG(WARNING) << "failed to set ashmem read-only: " -+ << strerror(errno); -+ return false; -+ } -+ -+ mozilla::UniqueFileHandle ro_file = std::move(mapped_file_); -+ -+ freezeable_ = false; -+ ro_out->Close(); -+ ro_out->mapped_file_ = std::move(ro_file); -+ ro_out->max_size_ = max_size_; -+ ro_out->read_only_ = true; -+ ro_out->freezeable_ = false; -+ -+ return true; -+} -+ -+#else // not Android -+ -+// memfd_create is a nonstandard interface for creating anonymous -+// shared memory accessible as a file descriptor but not tied to any -+// filesystem. It first appeared in Linux 3.17, and was adopted by -+// FreeBSD in version 13. -+ -+# if !defined(HAVE_MEMFD_CREATE) && defined(OS_LINUX) && \ -+ defined(SYS_memfd_create) -+ -+// Older libc versions (e.g., glibc before 2.27) don't have the -+// wrapper, but we can supply our own; see `linux_memfd_defs.h`. -+ -+static int memfd_create(const char* name, unsigned int flags) { -+ return syscall(SYS_memfd_create, name, flags); -+} -+ -+# define HAVE_MEMFD_CREATE 1 -+# endif -+ -+// memfd supports having "seals" applied to the file, to prevent -+// various types of changes (which apply to all fds referencing the -+// file). Unfortunately, we can't rely on F_SEAL_WRITE to implement -+// Freeze(); see the comments in ReadOnlyCopy() below. -+// -+// Instead, to prevent a child process from regaining write access to -+// a read-only copy, the OS must also provide a way to remove write -+// permissions at the file descriptor level. This next section -+// attempts to accomplish that. -+ -+# ifdef HAVE_MEMFD_CREATE -+# ifdef XP_LINUX -+# define USE_MEMFD_CREATE 1 -+ -+// To create a read-only duplicate of an fd, we can use procfs; the -+// same operation could restore write access, but sandboxing prevents -+// child processes from accessing /proc. -+// -+// (Note: if this ever changes to not use /proc, also reconsider how -+// and if HaveMemfd should check whether this works.) -+ -+static int DupReadOnly(int fd) { -+ std::string path = StringPrintf("/proc/self/fd/%d", fd); -+ // procfs opens probably won't EINTR, but checking for it can't hurt -+ return HANDLE_EINTR(open(path.c_str(), O_RDONLY | O_CLOEXEC)); -+} -+ -+# elif defined(__FreeBSD__) -+# define USE_MEMFD_CREATE 1 -+ -+// FreeBSD's Capsicum framework allows irrevocably restricting the -+// operations permitted on a file descriptor. -+ -+static int DupReadOnly(int fd) { -+ int rofd = dup(fd); -+ if (rofd < 0) { -+ return -1; -+ } -+ -+ cap_rights_t rights; -+ cap_rights_init(&rights, CAP_FSTAT, CAP_MMAP_R); -+ if (cap_rights_limit(rofd, &rights) < 0) { -+ int err = errno; -+ close(rofd); -+ errno = err; -+ return -1; -+ } -+ -+ return rofd; -+} -+ -+# else // unhandled OS -+# warning "OS has memfd_create but no DupReadOnly implementation" -+# endif // OS selection -+# endif // HAVE_MEMFD_CREATE -+ -+// Runtime detection for memfd support. -+static bool HaveMemfd() { -+# ifdef USE_MEMFD_CREATE -+ static const bool kHave = [] { -+ mozilla::UniqueFileHandle fd( -+ memfd_create("mozilla-ipc-test", MFD_CLOEXEC | MFD_ALLOW_SEALING)); -+ if (!fd) { -+ DCHECK_EQ(errno, ENOSYS); -+ return false; -+ } -+ -+ // Verify that DupReadOnly works; on Linux it's known to fail if: -+ // -+ // * SELinux assigns the memfd a type for which this process's -+ // domain doesn't have "open" permission; this is always the -+ // case on Android but could occur on desktop as well -+ // -+ // * /proc (used by the DupReadOnly implementation) isn't mounted, -+ // which is a configuration that the Tor Browser project is -+ // interested in as a way to reduce fingerprinting risk -+ // -+ // Sandboxed processes on Linux also can't use it if sandboxing -+ // has already been started, but that's expected. It should be -+ // safe for sandboxed child processes to use memfd even if an -+ // unsandboxed process couldn't freeze them, because freezing -+ // isn't allowed (or meaningful) for memory created by another -+ // process. -+ -+ if (!PR_GetEnv("MOZ_SANDBOXED")) { -+ mozilla::UniqueFileHandle rofd(DupReadOnly(fd.get())); -+ if (!rofd) { -+ CHROMIUM_LOG(WARNING) << "read-only dup failed (" << strerror(errno) -+ << "); not using memfd"; -+ return false; -+ } -+ } -+ return true; -+ }(); -+ return kHave; -+# else -+ return false; -+# endif // USE_MEMFD_CREATE -+} -+ -+// static -+bool SharedMemory::AppendPosixShmPrefix(std::string* str, pid_t pid) { -+ if (HaveMemfd()) { -+ return false; -+ } - *str += '/'; - # ifdef OS_LINUX - // The Snap package environment doesn't provide a private /dev/shm -@@ -90,7 +281,6 @@ bool SharedMemory::AppendPosixShmPrefix(std::string* str, pid_t pid) { - // enough for this. - StringAppendF(str, "org.mozilla.ipc.%d.", static_cast(pid)); - return true; --#endif // !ANDROID - } - - bool SharedMemory::CreateInternal(size_t size, bool freezeable) { -@@ -102,104 +292,118 @@ bool SharedMemory::CreateInternal(size_t size, bool freezeable) { - - mozilla::UniqueFileHandle fd; - mozilla::UniqueFileHandle frozen_fd; -- bool needs_truncate = true; -+ bool is_memfd = false; -+ -+# ifdef USE_MEMFD_CREATE -+ if (HaveMemfd()) { -+ const unsigned flags = MFD_CLOEXEC | (freezeable ? MFD_ALLOW_SEALING : 0); -+ fd.reset(memfd_create("mozilla-ipc", flags)); -+ if (!fd) { -+ // In general it's too late to fall back here -- in a sandboxed -+ // child process, shm_open is already blocked. And it shouldn't -+ // be necessary. -+ CHROMIUM_LOG(WARNING) << "failed to create memfd: " << strerror(errno); -+ return false; -+ } -+ is_memfd = true; -+ if (freezeable) { -+ frozen_fd.reset(DupReadOnly(fd.get())); -+ if (!frozen_fd) { -+ CHROMIUM_LOG(WARNING) -+ << "failed to create read-only memfd: " << strerror(errno); -+ return false; -+ } -+ } -+ } -+# endif - --#ifdef ANDROID -- // Android has its own shared memory facility: -- fd.reset(mozilla::android::ashmem_create(nullptr, size)); - if (!fd) { -- CHROMIUM_LOG(WARNING) << "failed to open shm: " << strerror(errno); -- return false; -- } -- needs_truncate = false; --#else -- // Generic Unix: shm_open + shm_unlink -- do { -- // The names don't need to be unique, but it saves time if they -- // usually are. -- static mozilla::Atomic sNameCounter; -- std::string name; -- CHECK(AppendPosixShmPrefix(&name, getpid())); -- StringAppendF(&name, "%zu", sNameCounter++); -- // O_EXCL means the names being predictable shouldn't be a problem. -- fd.reset( -- HANDLE_EINTR(shm_open(name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600))); -- if (fd) { -- if (freezeable) { -- frozen_fd.reset(HANDLE_EINTR(shm_open(name.c_str(), O_RDONLY, 0400))); -- if (!frozen_fd) { -- int open_err = errno; -- shm_unlink(name.c_str()); -- DLOG(FATAL) << "failed to re-open freezeable shm: " -- << strerror(open_err); -+ // Generic Unix: shm_open + shm_unlink -+ do { -+ // The names don't need to be unique, but it saves time if they -+ // usually are. -+ static mozilla::Atomic sNameCounter; -+ std::string name; -+ CHECK(AppendPosixShmPrefix(&name, getpid())); -+ StringAppendF(&name, "%zu", sNameCounter++); -+ // O_EXCL means the names being predictable shouldn't be a problem. -+ fd.reset(HANDLE_EINTR( -+ shm_open(name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600))); -+ if (fd) { -+ if (freezeable) { -+ frozen_fd.reset(HANDLE_EINTR(shm_open(name.c_str(), O_RDONLY, 0400))); -+ if (!frozen_fd) { -+ int open_err = errno; -+ shm_unlink(name.c_str()); -+ DLOG(FATAL) << "failed to re-open freezeable shm: " -+ << strerror(open_err); -+ return false; -+ } -+ } -+ if (shm_unlink(name.c_str()) != 0) { -+ // This shouldn't happen, but if it does: assume the file is -+ // in fact leaked, and bail out now while it's still 0-length. -+ DLOG(FATAL) << "failed to unlink shm: " << strerror(errno); - return false; - } - } -- if (shm_unlink(name.c_str()) != 0) { -- // This shouldn't happen, but if it does: assume the file is -- // in fact leaked, and bail out now while it's still 0-length. -- DLOG(FATAL) << "failed to unlink shm: " << strerror(errno); -- return false; -- } -- } -- } while (!fd && errno == EEXIST); --#endif -+ } while (!fd && errno == EEXIST); -+ } - - if (!fd) { - CHROMIUM_LOG(WARNING) << "failed to open shm: " << strerror(errno); - return false; - } - -- if (needs_truncate) { --#if defined(HAVE_POSIX_FALLOCATE) -- // Using posix_fallocate will ensure that there's actually space for this -- // file. Otherwise we end up with a sparse file that can give SIGBUS if we -- // run out of space while writing to it. -- int rv; -- { -- // Avoid repeated interruptions of posix_fallocate by the profiler's -- // SIGPROF sampling signal. Indicating "thread sleep" here means we'll -- // get up to one interruption but not more. See bug 1658847 for more. -- // This has to be scoped outside the HANDLE_RV_EINTR retry loop. -- AUTO_PROFILER_THREAD_SLEEP; -- rv = HANDLE_RV_EINTR( -- posix_fallocate(fd.get(), 0, static_cast(size))); -- } -- if (rv != 0) { -- if (rv == EOPNOTSUPP || rv == EINVAL || rv == ENODEV) { -- // Some filesystems have trouble with posix_fallocate. For now, we must -- // fallback ftruncate and accept the allocation failures like we do -- // without posix_fallocate. -- // See https://bugzilla.mozilla.org/show_bug.cgi?id=1618914 -- int fallocate_errno = rv; -- rv = HANDLE_EINTR(ftruncate(fd.get(), static_cast(size))); -- if (rv != 0) { -- CHROMIUM_LOG(WARNING) << "fallocate failed to set shm size: " -- << strerror(fallocate_errno); -- CHROMIUM_LOG(WARNING) -- << "ftruncate failed to set shm size: " << strerror(errno); -- return false; -- } -- } else { -+# if defined(HAVE_POSIX_FALLOCATE) -+ // Using posix_fallocate will ensure that there's actually space for this -+ // file. Otherwise we end up with a sparse file that can give SIGBUS if we -+ // run out of space while writing to it. -+ int rv; -+ { -+ // Avoid repeated interruptions of posix_fallocate by the profiler's -+ // SIGPROF sampling signal. Indicating "thread sleep" here means we'll -+ // get up to one interruption but not more. See bug 1658847 for more. -+ // This has to be scoped outside the HANDLE_RV_EINTR retry loop. -+ AUTO_PROFILER_THREAD_SLEEP; -+ rv = -+ HANDLE_RV_EINTR(posix_fallocate(fd.get(), 0, static_cast(size))); -+ } -+ if (rv != 0) { -+ if (rv == EOPNOTSUPP || rv == EINVAL || rv == ENODEV) { -+ // Some filesystems have trouble with posix_fallocate. For now, we must -+ // fallback ftruncate and accept the allocation failures like we do -+ // without posix_fallocate. -+ // See https://bugzilla.mozilla.org/show_bug.cgi?id=1618914 -+ int fallocate_errno = rv; -+ rv = HANDLE_EINTR(ftruncate(fd.get(), static_cast(size))); -+ if (rv != 0) { -+ CHROMIUM_LOG(WARNING) << "fallocate failed to set shm size: " -+ << strerror(fallocate_errno); - CHROMIUM_LOG(WARNING) -- << "fallocate failed to set shm size: " << strerror(rv); -+ << "ftruncate failed to set shm size: " << strerror(errno); - return false; - } -- } --#else -- int rv = HANDLE_EINTR(ftruncate(fd.get(), static_cast(size))); -- if (rv != 0) { -+ } else { - CHROMIUM_LOG(WARNING) -- << "ftruncate failed to set shm size: " << strerror(errno); -+ << "fallocate failed to set shm size: " << strerror(rv); - return false; - } --#endif - } -+# else -+ int rv = HANDLE_EINTR(ftruncate(fd.get(), static_cast(size))); -+ if (rv != 0) { -+ CHROMIUM_LOG(WARNING) << "ftruncate failed to set shm size: " -+ << strerror(errno); -+ return false; -+ } -+# endif - - mapped_file_ = std::move(fd); - frozen_file_ = std::move(frozen_fd); - max_size_ = size; - freezeable_ = freezeable; -+ is_memfd_ = is_memfd; - return true; - } - -@@ -212,23 +416,63 @@ bool SharedMemory::ReadOnlyCopy(SharedMemory* ro_out) { - DCHECK(!memory_); - } - -- mozilla::UniqueFileHandle ro_file; --#ifdef ANDROID -- ro_file = std::move(mapped_file_); -- if (mozilla::android::ashmem_setProt(ro_file.get(), PROT_READ) != 0) { -- CHROMIUM_LOG(WARNING) << "failed to set ashmem read-only: " -- << strerror(errno); -- return false; -+# ifdef USE_MEMFD_CREATE -+# ifdef MOZ_VALGRIND -+ // Valgrind allows memfd_create but doesn't understand F_ADD_SEALS. -+ static const bool haveSeals = RUNNING_ON_VALGRIND == 0; -+# else -+ static const bool haveSeals = true; -+# endif -+ static const bool useSeals = !PR_GetEnv("MOZ_SHM_NO_SEALS"); -+ if (is_memfd_ && haveSeals && useSeals) { -+ // Seals are added to the file as defense-in-depth. The primary -+ // method of access control is creating a read-only fd (using -+ // procfs in this case) and requiring that sandboxes processes not -+ // have access to /proc/self/fd to regain write permission; this -+ // is the same as with shm_open. -+ // -+ // Unfortunately, F_SEAL_WRITE is unreliable: if the process -+ // forked while there was a writeable mapping, it will inherit a -+ // copy of the mapping, which causes the seal to fail. -+ // -+ // (Also, in the future we may want to split this into separate -+ // classes for mappings and shared memory handles, which would -+ // complicate identifying the case where `F_SEAL_WRITE` would be -+ // possible even in the absence of races with fork.) -+ // -+ // However, Linux 5.1 added F_SEAL_FUTURE_WRITE, which prevents -+ // write operations afterwards, but existing writeable mappings -+ // are unaffected (similar to ashmem protection semantics). -+ -+ const int seals = F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL; -+ int sealError = EINVAL; -+ -+# ifdef F_SEAL_FUTURE_WRITE -+ sealError = -+ fcntl(mapped_file_.get(), F_ADD_SEALS, seals | F_SEAL_FUTURE_WRITE) == 0 -+ ? 0 -+ : errno; -+# endif // F_SEAL_FUTURE_WRITE -+ if (sealError == EINVAL) { -+ sealError = -+ fcntl(mapped_file_.get(), F_ADD_SEALS, seals) == 0 ? 0 : errno; -+ } -+ if (sealError != 0) { -+ CHROMIUM_LOG(WARNING) << "failed to seal memfd: " << strerror(errno); -+ return false; -+ } - } --#else -+# else // !USE_MEMFD_CREATE -+ DCHECK(!is_memfd_); -+# endif -+ - DCHECK(frozen_file_); -+ DCHECK(mapped_file_); - mapped_file_ = nullptr; -- ro_file = std::move(frozen_file_); --#endif -+ mozilla::UniqueFileHandle ro_file = std::move(frozen_file_); - - DCHECK(ro_file); - freezeable_ = false; -- - ro_out->Close(); - ro_out->mapped_file_ = std::move(ro_file); - ro_out->max_size_ = max_size_; -@@ -238,6 +482,8 @@ bool SharedMemory::ReadOnlyCopy(SharedMemory* ro_out) { - return true; - } - -+#endif // not Android -+ - bool SharedMemory::Map(size_t bytes, void* fixed_address) { - if (!mapped_file_) { - return false; -@@ -292,10 +538,12 @@ void SharedMemory::Close(bool unmap_view) { - } - - mapped_file_ = nullptr; -+#ifndef ANDROID - if (frozen_file_) { - CHROMIUM_LOG(WARNING) << "freezeable shared memory was never frozen"; - frozen_file_ = nullptr; - } -+#endif - } - - } // namespace base -diff --git ipc/gtest/TestSharedMemory.cpp ipc/gtest/TestSharedMemory.cpp -index 4c8ab0c77592..1474be0ea0d9 100644 ---- ipc/gtest/TestSharedMemory.cpp -+++ ipc/gtest/TestSharedMemory.cpp -@@ -13,6 +13,15 @@ - #include "mozilla/ipc/SharedMemory.h" - #include "mozilla/ipc/SharedMemoryBasic.h" - -+#ifdef XP_LINUX -+# include -+# include -+# include -+# include -+# include -+# include -+#endif -+ - #ifdef XP_WIN - # include - #endif -@@ -293,4 +302,41 @@ TEST(IPCSharedMemory, BasicIsZero) - } - #endif - -+#if defined(XP_LINUX) && !defined(ANDROID) -+// Test that memfd_create is used where expected. -+// -+// More precisely: if memfd_create support is expected, verify that -+// shared memory isn't subject to a filesystem size limit. -+TEST(IPCSharedMemory, IsMemfd) -+{ -+ static constexpr int kMajor = 3; -+ static constexpr int kMinor = 17; -+ -+ struct utsname uts; -+ ASSERT_EQ(uname(&uts), 0) << strerror(errno); -+ ASSERT_STREQ(uts.sysname, "Linux"); -+ int major, minor; -+ ASSERT_EQ(sscanf(uts.release, "%d.%d", &major, &minor), 2); -+ bool expectMemfd = major > kMajor || (major == kMajor && minor >= kMinor); -+ -+ base::SharedMemory shm; -+ ASSERT_TRUE(shm.Create(1)); -+ UniqueFileHandle fd = shm.TakeHandle(); -+ ASSERT_TRUE(fd); -+ -+ struct statfs fs; -+ ASSERT_EQ(fstatfs(fd.get(), &fs), 0) << strerror(errno); -+ EXPECT_EQ(fs.f_type, TMPFS_MAGIC); -+ static constexpr decltype(fs.f_blocks) kNoLimit = 0; -+ if (expectMemfd) { -+ EXPECT_EQ(fs.f_blocks, kNoLimit); -+ } else { -+ // On older kernels, we expect the memfd / no-limit test to fail. -+ // (In theory it could succeed if backported memfd support exists; -+ // if that ever happens, this check can be removed.) -+ EXPECT_NE(fs.f_blocks, kNoLimit); -+ } -+} -+#endif -+ - } // namespace mozilla -diff --git security/sandbox/linux/SandboxFilter.cpp security/sandbox/linux/SandboxFilter.cpp -index b337a513791e..3017cd967766 100644 ---- security/sandbox/linux/SandboxFilter.cpp -+++ security/sandbox/linux/SandboxFilter.cpp -@@ -704,6 +704,10 @@ class SandboxPolicyCommon : public SandboxPolicyBase { - case __NR_munmap: - return Allow(); - -+ // Shared memory -+ case __NR_memfd_create: -+ return Allow(); -+ - // ipc::Shmem; also, glibc when creating threads: - case __NR_mprotect: - return Allow(); -@@ -1395,11 +1399,6 @@ class ContentSandboxPolicy : public SandboxPolicyCommon { - case __NR_eventfd2: - return Allow(); - --# ifdef __NR_memfd_create -- case __NR_memfd_create: -- return Allow(); --# endif -- - # ifdef __NR_rt_tgsigqueueinfo - // Only allow to send signals within the process. - case __NR_rt_tgsigqueueinfo: { diff --git a/www/firefox/files/patch-bug1504834_comment10 b/www/firefox/files/patch-bug1504834_comment10 index 4f423518b970..e8e28bace434 100644 --- a/www/firefox/files/patch-bug1504834_comment10 +++ b/www/firefox/files/patch-bug1504834_comment10 @@ -21,7 +21,7 @@ diff -r 46ea866ca3ac -r 6ef20eee3f8f gfx/2d/DrawTargetSkia.cpp SkCanvas::kPreserveLCDText_SaveLayerFlag | (aCopyBackground ? SkCanvas::kInitWithPrevious_SaveLayerFlag : 0)); -+#if MOZ_BIG_ENDIAN ++#if MOZ_BIG_ENDIAN() + // Pushing a layer where an aMask is defined produces wrong output. + // We _should_ endian swap the data, but I couldn't find a workable way to do so + // Therefore I deactivate those layers in the meantime. diff --git a/www/firefox/files/patch-bug1559213 b/www/firefox/files/patch-bug1559213 index 0100df8d09b0..f16af4cd83ba 100644 --- a/www/firefox/files/patch-bug1559213 +++ b/www/firefox/files/patch-bug1559213 @@ -14,24 +14,24 @@ diff --git config/external/moz.build config/external/moz.build index 03e4fa143bd1..a67d10b11fe6 100644 --- config/external/moz.build +++ config/external/moz.build -@@ -37,8 +37,9 @@ if not CONFIG['MOZ_SYSTEM_LIBVPX']: - external_dirs += ['media/libvpx'] +@@ -40,8 +40,9 @@ if not CONFIG["MOZ_SYSTEM_LIBVPX"]: + external_dirs += ["media/libvpx"] - if CONFIG['MOZ_AV1']: -- external_dirs += ['media/libaom'] -- external_dirs += ['media/libdav1d'] -+ if not CONFIG['MOZ_SYSTEM_AV1']: -+ external_dirs += ['media/libaom'] -+ external_dirs += ['media/libdav1d'] + if CONFIG["MOZ_AV1"]: +- external_dirs += ["media/libaom"] +- external_dirs += ["media/libdav1d"] ++ if not CONFIG["MOZ_SYSTEM_AV1"]: ++ external_dirs += ["media/libaom"] ++ external_dirs += ["media/libdav1d"] - if not CONFIG['MOZ_SYSTEM_PNG']: - external_dirs += ['media/libpng'] + if not CONFIG["MOZ_SYSTEM_PNG"]: + external_dirs += ["media/libpng"] diff --git config/system-headers.mozbuild config/system-headers.mozbuild index bcf5c4925564..48964a999a9b 100644 --- config/system-headers.mozbuild +++ config/system-headers.mozbuild -@@ -1304,6 +1304,14 @@ if CONFIG['MOZ_ENABLE_CONTENTMANAGER']: - 'SelectSingleContentItemPage.h', +@@ -1305,6 +1305,14 @@ if CONFIG['MOZ_SYSTEM_HARFBUZZ']: + 'harfbuzz/hb.h', ] +if CONFIG['MOZ_SYSTEM_AV1']: @@ -49,9 +49,9 @@ diff --git dom/media/platforms/moz.build dom/media/platforms/moz.build index 092cee0c9b66..38e45de5b5f0 100644 --- dom/media/platforms/moz.build +++ dom/media/platforms/moz.build -@@ -80,6 +80,11 @@ if CONFIG['MOZ_AV1']: - 'agnostic/AOMDecoder.cpp', - 'agnostic/DAV1DDecoder.cpp', +@@ -78,6 +78,11 @@ if CONFIG["MOZ_AV1"]: + "agnostic/AOMDecoder.cpp", + "agnostic/DAV1DDecoder.cpp", ] + if CONFIG['MOZ_SYSTEM_AV1']: + CXXFLAGS += CONFIG['MOZ_SYSTEM_LIBAOM_CFLAGS'] @@ -59,25 +59,25 @@ index 092cee0c9b66..38e45de5b5f0 100644 + CXXFLAGS += CONFIG['MOZ_SYSTEM_LIBDAV1D_CFLAGS'] + OS_LIBS += CONFIG['MOZ_SYSTEM_LIBDAV1D_LIBS'] - if CONFIG['MOZ_OMX']: + if CONFIG["MOZ_OMX"]: EXPORTS += [ diff --git toolkit/moz.configure toolkit/moz.configure index 82b5a59acf42..e2329560b42b 100644 --- toolkit/moz.configure +++ toolkit/moz.configure -@@ -441,7 +441,23 @@ def av1(value): - if value: +@@ -553,7 +553,23 @@ def av1(value): return True + -@depends(target, nasm_version, when=av1 & compile_environment) -+option('--with-system-av1', ++option("--with-system-av1", + help="Use system av1 (located with pkgconfig)") + -+system_libaom_info = pkg_check_modules('MOZ_SYSTEM_LIBAOM', 'aom >= 1.0.0', -+ when='--with-system-av1') ++system_libaom_info = pkg_check_modules("MOZ_SYSTEM_LIBAOM", "aom >= 1.0.0", ++ when="--with-system-av1") + -+system_libdav1d_info = pkg_check_modules('MOZ_SYSTEM_LIBDAV1D', 'dav1d >= 0.1.1', -+ when='--with-system-av1') ++system_libdav1d_info = pkg_check_modules("MOZ_SYSTEM_LIBDAV1D", "dav1d >= 0.1.1", ++ when="--with-system-av1") + +@depends(system_libaom_info, system_libdav1d_info) +def system_av1(system_libaom_info, system_libdav1d_info): @@ -88,13 +88,13 @@ index 82b5a59acf42..e2329560b42b 100644 + +@depends(target, nasm_version, when=av1 & depends(system_av1)(lambda v: not v) & compile_environment) def dav1d_asm(target, nasm_version): - if target.os != 'Android': - if target.cpu == 'aarch64': -@@ -457,6 +473,7 @@ set_config('MOZ_DAV1D_ASM', dav1d_asm) - set_define('MOZ_DAV1D_ASM', dav1d_asm) - set_config('MOZ_AV1', av1) - set_define('MOZ_AV1', av1) -+set_config('MOZ_SYSTEM_AV1', depends_if(system_av1)(lambda _: True)) + if target.cpu == "aarch64": + return True +@@ -570,6 +586,7 @@ set_config("MOZ_DAV1D_ASM", dav1d_asm) + set_define("MOZ_DAV1D_ASM", dav1d_asm) + set_config("MOZ_AV1", av1) + set_define("MOZ_AV1", av1) ++set_config("MOZ_SYSTEM_AV1", depends_if(system_av1)(lambda _: True)) # Built-in fragmented MP4 support. # ============================================================== diff --git a/www/firefox/files/patch-bug1618914 b/www/firefox/files/patch-bug1618914 index 817d00032222..94b7aa8d38e1 100644 --- a/www/firefox/files/patch-bug1618914 +++ b/www/firefox/files/patch-bug1618914 @@ -4,8 +4,7 @@ diff --git widget/gtk/WindowSurfaceWayland.cpp widget/gtk/WindowSurfaceWayland.c index 9a73326399bd5..9e42a7f1c5d18 100644 --- widget/gtk/WindowSurfaceWayland.cpp +++ widget/gtk/WindowSurfaceWayland.cpp -@@ -222,20 +222,21 @@ static int WaylandAllocateShmMemory(int aSize) { - #ifdef HAVE_POSIX_FALLOCATE +@@ -221,7 +221,9 @@ static int WaylandAllocateShmMemory(int aSize) { do { ret = posix_fallocate(fd, 0, aSize); } while (ret == EINTR); @@ -13,29 +12,32 @@ index 9a73326399bd5..9e42a7f1c5d18 100644 + if (ret == 0) { + return fd; + } else if (ret != ENODEV && ret != EINVAL && ret != EOPNOTSUPP) { + NS_WARNING( + nsPrintfCString("posix_fallocate() fails to allocate shm memory: %s", + strerror(ret)) +@@ -229,7 +231,7 @@ static int WaylandAllocateShmMemory(int aSize) { close(fd); - MOZ_CRASH("posix_fallocate() fails to allocate shm memory"); + return -1; } -#else +#endif do { ret = ftruncate(fd, aSize); } while (ret < 0 && errno == EINTR); - if (ret < 0) { +@@ -240,7 +242,6 @@ static int WaylandAllocateShmMemory(int aSize) { close(fd); - MOZ_CRASH("ftruncate() fails to allocate shm memory"); + fd = -1; } -#endif return fd; } -@@ -265,8 +266,8 @@ bool WaylandShmPool::Resize(int aSize) { - #ifdef HAVE_POSIX_FALLOCATE +@@ -253,7 +254,7 @@ static bool WaylandReAllocateShmMemory(int aFd, int aSize) { do { - errno = posix_fallocate(mShmPoolFd, 0, aSize); + errno = posix_fallocate(aFd, 0, aSize); } while (errno == EINTR); -- if (errno != 0) return false; -+ if (errno != 0 && errno != ENODEV && errno != EINVAL && errno != EOPNOTSUPP) return false; +- if (errno != 0) { ++ if (errno != 0 && errno != ENODEV && errno != EINVAL && errno != EOPNOTSUPP) { + return false; + } #endif - - wl_shm_pool_resize(mShmPool, aSize); diff --git a/www/firefox/files/patch-bug1664115 b/www/firefox/files/patch-bug1664115 index 4b089b52e203..6672aa67459d 100644 --- a/www/firefox/files/patch-bug1664115 +++ b/www/firefox/files/patch-bug1664115 @@ -62,7 +62,7 @@ diff --git dom/media/AudioStream.h dom/media/AudioStream.h index 933e4cb3bfdb5..5d2181e632af9 100644 --- dom/media/AudioStream.h +++ dom/media/AudioStream.h -@@ -304,7 +304,6 @@ +@@ -307,7 +307,6 @@ class AudioStream final template int InvokeCubeb(Function aFunction, Args&&... aArgs); @@ -70,13 +70,13 @@ index 933e4cb3bfdb5..5d2181e632af9 100644 // The monitor is held to protect all access to member variables. Monitor mMonitor; -@@ -338,9 +337,6 @@ +@@ -341,9 +340,6 @@ class AudioStream final // the default device is used. It is set // during the Init() in decoder thread. RefPtr mSinkInfo; - /* Contains the id of the audio thread, from profiler_get_thread_id. */ - std::atomic mAudioThreadId; - const bool mSandboxed = false; - }; - } // namespace mozilla + MozPromiseHolder mEndedPromise; + Atomic mPlaybackComplete; diff --git a/www/firefox/files/patch-bug1670807 b/www/firefox/files/patch-bug1670807 deleted file mode 100644 index 71c71454ab0a..000000000000 --- a/www/firefox/files/patch-bug1670807 +++ /dev/null @@ -1,15 +0,0 @@ -Look for gm4 in addition to m4 - -diff --git build/moz.configure/old.configure build/moz.configure/old.configure -index 8c807c0794fab..5132228960f3d 100644 ---- build/moz.configure/old.configure -+++ build/moz.configure/old.configure -@@ -5,7 +5,7 @@ - # file, You can obtain one at http://mozilla.org/MPL/2.0/. - - --m4 = check_prog('M4', ('m4',)) -+m4 = check_prog('M4', ('gm4', 'm4',)) - - - @depends(mozconfig) diff --git a/www/firefox/files/patch-bug1676134 b/www/firefox/files/patch-bug1676134 new file mode 100644 index 000000000000..9abd1a03c7a4 --- /dev/null +++ b/www/firefox/files/patch-bug1676134 @@ -0,0 +1,122 @@ +Enable Pipewire on BSDs + +diff --git third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build +index a0e116195e0e..cbe27e94108b 100644 +--- third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build ++++ third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build +@@ -87,8 +87,13 @@ if CONFIG["OS_TARGET"] == "DragonFly": + DEFINES["USE_X11"] = "1" + DEFINES["WEBRTC_BSD"] = True + DEFINES["WEBRTC_POSIX"] = True ++ DEFINES["WEBRTC_USE_PIPEWIRE"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" + ++ LOCAL_INCLUDES += [ ++ "/third_party/pipewire/" ++ ] ++ + OS_LIBS += [ + "X11", + "X11-xcb", +@@ -103,11 +108,14 @@ if CONFIG["OS_TARGET"] == "DragonFly": + ] + + UNIFIED_SOURCES += [ ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/desktop_device_info_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/mouse_cursor_monitor_x11.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/shared_x_display.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/shared_x_util.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_finder_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_list_utils.cc", +@@ -124,8 +132,13 @@ if CONFIG["OS_TARGET"] == "FreeBSD": + DEFINES["USE_X11"] = "1" + DEFINES["WEBRTC_BSD"] = True + DEFINES["WEBRTC_POSIX"] = True ++ DEFINES["WEBRTC_USE_PIPEWIRE"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" + ++ LOCAL_INCLUDES += [ ++ "/third_party/pipewire/" ++ ] ++ + OS_LIBS += [ + "X11", + "X11-xcb", +@@ -140,11 +153,14 @@ if CONFIG["OS_TARGET"] == "FreeBSD": + ] + + UNIFIED_SOURCES += [ ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/desktop_device_info_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/mouse_cursor_monitor_x11.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/shared_x_display.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/shared_x_util.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_finder_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_list_utils.cc", +@@ -200,8 +216,13 @@ if CONFIG["OS_TARGET"] == "NetBSD": + DEFINES["USE_X11"] = "1" + DEFINES["WEBRTC_BSD"] = True + DEFINES["WEBRTC_POSIX"] = True ++ DEFINES["WEBRTC_USE_PIPEWIRE"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" + ++ LOCAL_INCLUDES += [ ++ "/third_party/pipewire/" ++ ] ++ + OS_LIBS += [ + "X11", + "X11-xcb", +@@ -216,11 +237,14 @@ if CONFIG["OS_TARGET"] == "NetBSD": + ] + + UNIFIED_SOURCES += [ ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/desktop_device_info_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/mouse_cursor_monitor_x11.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/shared_x_display.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/shared_x_util.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_finder_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_list_utils.cc", +@@ -237,8 +261,13 @@ if CONFIG["OS_TARGET"] == "OpenBSD": + DEFINES["USE_X11"] = "1" + DEFINES["WEBRTC_BSD"] = True + DEFINES["WEBRTC_POSIX"] = True ++ DEFINES["WEBRTC_USE_PIPEWIRE"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" + ++ LOCAL_INCLUDES += [ ++ "/third_party/pipewire/" ++ ] ++ + OS_LIBS += [ + "X11", + "X11-xcb", +@@ -253,11 +282,14 @@ if CONFIG["OS_TARGET"] == "OpenBSD": + ] + + UNIFIED_SOURCES += [ ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/desktop_device_info_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/mouse_cursor_monitor_x11.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/shared_x_display.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/shared_x_util.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_finder_x11.cc", + "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_list_utils.cc", diff --git a/www/firefox/files/patch-bug1677715 b/www/firefox/files/patch-bug1677715 new file mode 100644 index 000000000000..59de649b898e --- /dev/null +++ b/www/firefox/files/patch-bug1677715 @@ -0,0 +1,148 @@ +commit 16e7bdc29390 +Author: Dan Minor +Date: Thu Nov 19 14:14:40 2020 +0000 + + Bug 1677715 - Build libpipewire as a dependency of libwebrtc; r=ng + + Differential Revision: https://phabricator.services.mozilla.com/D97431 +--- + dom/media/webrtc/third_party_build/moz.build | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git dom/media/webrtc/third_party_build/moz.build dom/media/webrtc/third_party_build/moz.build +index db10dab7ff21..dc0df3ba1b6c 100644 +--- dom/media/webrtc/third_party_build/moz.build ++++ dom/media/webrtc/third_party_build/moz.build +@@ -56,6 +56,9 @@ webrtc_non_unified_sources = [ + "../../../../third_party/libwebrtc/webrtc/video/overuse_frame_detector.cc", # Because of name clash with call_stats.cc on kWeightFactor + ] + ++if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": ++ DIRS += ["../../../../third_party/pipewire/libpipewire"] ++ + GN_DIRS += ["../../../../third_party/libwebrtc/webrtc"] + + gn_vars_copy = gn_vars.copy() +commit 553093ff0fa7 +Author: Dan Minor +Date: Thu Nov 19 14:14:50 2020 +0000 + + Bug 1677715 - Regenerate moz.build files; r=ng + + Differential Revision: https://phabricator.services.mozilla.com/D97433 +--- + .../desktop_capture_generic_gn/moz.build | 51 +++++++++++++++++----- + third_party/libwebrtc/webrtc/moz.build | 3 -- + 2 files changed, 40 insertions(+), 14 deletions(-) + +diff --git third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build +index 8df8b8b993f9..a0e116195e0e 100644 +--- third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build ++++ third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build +@@ -5,6 +5,8 @@ + + ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ### + ### DO NOT edit it by hand. ### ++if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": ++ CXXFLAGS += CONFIG["TK_CFLAGS"] + + COMPILE_FLAGS["OS_INCLUDES"] = [] + AllowCompilerWarnings() +@@ -25,8 +27,7 @@ LOCAL_INCLUDES += [ + "/ipc/chromium/src", + "/ipc/glue", + "/media/libyuv/libyuv/include/", +- "/third_party/libwebrtc/webrtc/", +- "/third_party/pipewire" ++ "/third_party/libwebrtc/webrtc/" + ] + + UNIFIED_SOURCES += [ +@@ -162,7 +163,6 @@ if CONFIG["OS_TARGET"] == "Linux": + DEFINES["WEBRTC_LINUX"] = True + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" +- DEFINES["WEBRTC_USE_PIPEWIRE"] = "1" + + OS_LIBS += [ + "rt", +@@ -195,14 +195,6 @@ if CONFIG["OS_TARGET"] == "Linux": + "/third_party/libwebrtc/webrtc/modules/desktop_capture/window_capturer_linux.cc" + ] + +- CXXFLAGS += CONFIG['TK_CFLAGS'] +- +- UNIFIED_SOURCES += [ +- "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc", +- "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc", +- "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc" +- ] +- + if CONFIG["OS_TARGET"] == "NetBSD": + + DEFINES["USE_X11"] = "1" +@@ -393,6 +385,17 @@ if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux": + + DEFINES["DISABLE_NACL"] = True + DEFINES["NO_TCMALLOC"] = True ++ DEFINES["WEBRTC_USE_PIPEWIRE"] = True ++ ++ LOCAL_INCLUDES += [ ++ "/third_party/pipewire/" ++ ] ++ ++ UNIFIED_SOURCES += [ ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc" ++ ] + + if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux": + +@@ -400,6 +403,32 @@ if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux": + "-msse2" + ] + ++ DEFINES["WEBRTC_USE_PIPEWIRE"] = True ++ ++ LOCAL_INCLUDES += [ ++ "/third_party/pipewire/" ++ ] ++ ++ UNIFIED_SOURCES += [ ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc" ++ ] ++ ++if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux": ++ ++ DEFINES["WEBRTC_USE_PIPEWIRE"] = True ++ ++ LOCAL_INCLUDES += [ ++ "/third_party/pipewire/" ++ ] ++ ++ UNIFIED_SOURCES += [ ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc", ++ "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc" ++ ] ++ + if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "NetBSD": + + CXXFLAGS += [ +diff --git third_party/libwebrtc/webrtc/moz.build third_party/libwebrtc/webrtc/moz.build +index 53af3e5786bf..295247899372 100644 +--- third_party/libwebrtc/webrtc/moz.build ++++ third_party/libwebrtc/webrtc/moz.build +@@ -186,9 +186,6 @@ if CONFIG["OS_TARGET"] == "Linux": + "/third_party/libwebrtc/webrtc/modules/video_capture/video_capture_internal_impl_gn", + "/third_party/libwebrtc/webrtc/system_wrappers/cpu_features_linux_gn" + ] +- DIRS += [ +- "/third_party/pipewire/libpipewire" +- ] + + if CONFIG["OS_TARGET"] == "NetBSD": + diff --git a/www/firefox/files/patch-bug847568 b/www/firefox/files/patch-bug847568 index b24638761af6..f1a005b360b6 100644 --- a/www/firefox/files/patch-bug847568 +++ b/www/firefox/files/patch-bug847568 @@ -4,7 +4,7 @@ diff --git config/system-headers.mozbuild config/system-headers.mozbuild index 7620b4d00623..09d3db5ca8c0 100644 --- config/system-headers.mozbuild +++ config/system-headers.mozbuild -@@ -1299,6 +1299,19 @@ if CONFIG['MOZ_ENABLE_LIBPROXY']: +@@ -1292,6 +1292,19 @@ if CONFIG['MOZ_ENABLE_LIBPROXY']: 'proxy.h', ] @@ -28,16 +28,16 @@ diff --git dom/base/moz.build dom/base/moz.build index 8e19020315ae..2fcdbb6f7b42 100644 --- dom/base/moz.build +++ dom/base/moz.build -@@ -543,6 +543,9 @@ if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']: - if CONFIG['MOZ_X11']: - CXXFLAGS += CONFIG['TK_CFLAGS'] +@@ -546,6 +546,9 @@ if CONFIG["MOZ_BUILD_APP"] in ["browser", "mobile/android", "xulrunner"]: + if CONFIG["MOZ_X11"]: + CXXFLAGS += CONFIG["TK_CFLAGS"] -+if CONFIG['MOZ_SYSTEM_HARFBUZZ']: -+ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS'] ++if CONFIG["MOZ_SYSTEM_HARFBUZZ"]: ++ CXXFLAGS += CONFIG["MOZ_HARFBUZZ_CFLAGS"] + - GeneratedFile('UseCounterList.h', script='gen-usecounters.py', - entry_point='use_counter_list', inputs=['UseCounters.conf']) - + GeneratedFile( + "UseCounterList.h", + script="gen-usecounters.py", diff --git gfx/graphite2/geckoextra/moz.build gfx/graphite2/geckoextra/moz.build new file mode 100644 index 0000000000000..24e8d7a03274a @@ -112,35 +112,35 @@ diff --git gfx/moz.build gfx/moz.build index 771f652e837a..3b358d84e384 100644 --- gfx/moz.build +++ gfx/moz.build -@@ -13,6 +13,14 @@ with Files('wr/**'): - if CONFIG['MOZ_TREE_CAIRO']: - DIRS += ['cairo'] +@@ -13,6 +13,14 @@ with Files("wr/**"): + if CONFIG["MOZ_TREE_CAIRO"]: + DIRS += ["cairo"] -+if CONFIG['MOZ_SYSTEM_GRAPHITE2']: -+ DIRS += ['graphite2/geckoextra'] ++if CONFIG["MOZ_SYSTEM_GRAPHITE2"]: ++ DIRS += ["graphite2/geckoextra"] +else: -+ DIRS += ['graphite2/src' ] ++ DIRS += ["graphite2/src" ] + -+if not CONFIG['MOZ_SYSTEM_HARFBUZZ']: -+ DIRS += ['harfbuzz/src'] ++if not CONFIG["MOZ_SYSTEM_HARFBUZZ"]: ++ DIRS += ["harfbuzz/src"] + DIRS += [ - '2d', - 'ycbcr', + "2d", + "ycbcr", @@ -21,8 +29,6 @@ DIRS += [ - 'qcms', - 'gl', - 'layers', -- 'graphite2/src', -- 'harfbuzz/src', - 'ots/src', - 'thebes', - 'ipc', + "qcms", + "gl", + "layers", +- "graphite2/src", +- "harfbuzz/src", + "ots/src", + "thebes", + "ipc", diff --git gfx/skia/generate_mozbuild.py gfx/skia/generate_mozbuild.py index e06ae3457a47..93faa61594a3 100755 --- gfx/skia/generate_mozbuild.py +++ gfx/skia/generate_mozbuild.py -@@ -117,6 +117,9 @@ if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'): +@@ -98,6 +98,9 @@ if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'): '-Wno-unused-private-field', ] @@ -154,7 +154,7 @@ diff --git gfx/skia/moz.build gfx/skia/moz.build index 2118677ca3a8..e4978b413784 100644 --- gfx/skia/moz.build +++ gfx/skia/moz.build -@@ -493,6 +493,9 @@ if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'): +@@ -490,6 +490,9 @@ if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'): '-Wno-unused-private-field', ] @@ -168,49 +168,49 @@ diff --git gfx/thebes/moz.build gfx/thebes/moz.build index 56f1b9fe3f4b..0ac1100b0df3 100644 --- gfx/thebes/moz.build +++ gfx/thebes/moz.build -@@ -284,7 +284,13 @@ if CONFIG['MOZ_WAYLAND']: +@@ -287,7 +287,13 @@ if CONFIG["MOZ_WAYLAND"]: - LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES'] + LOCAL_INCLUDES += CONFIG["SKIA_INCLUDES"] --DEFINES['GRAPHITE2_STATIC'] = True -+if CONFIG['MOZ_SYSTEM_GRAPHITE2']: -+ CXXFLAGS += CONFIG['MOZ_GRAPHITE2_CFLAGS'] +-DEFINES["GRAPHITE2_STATIC"] = True ++if CONFIG["MOZ_SYSTEM_GRAPHITE2"]: ++ CXXFLAGS += CONFIG["MOZ_GRAPHITE2_CFLAGS"] +else: -+ DEFINES['GRAPHITE2_STATIC'] = True ++ DEFINES["GRAPHITE2_STATIC"] = True + -+if CONFIG['MOZ_SYSTEM_HARFBUZZ']: -+ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS'] ++if CONFIG["MOZ_SYSTEM_HARFBUZZ"]: ++ CXXFLAGS += CONFIG["MOZ_HARFBUZZ_CFLAGS"] - if CONFIG['CC_TYPE'] == 'clang': + if CONFIG["CC_TYPE"] == "clang": # Suppress warnings from Skia header files. diff --git intl/unicharutil/util/moz.build intl/unicharutil/util/moz.build index cb1233c56d7e..06fb1f9f174b 100644 --- intl/unicharutil/util/moz.build +++ intl/unicharutil/util/moz.build @@ -25,4 +25,7 @@ UNIFIED_SOURCES += [ - 'nsUnicodeProperties.cpp', + "nsUnicodeProperties.cpp", ] -+if CONFIG['MOZ_SYSTEM_HARFBUZZ']: -+ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS'] ++if CONFIG["MOZ_SYSTEM_HARFBUZZ"]: ++ CXXFLAGS += CONFIG["MOZ_HARFBUZZ_CFLAGS"] + - FINAL_LIBRARY = 'xul' + FINAL_LIBRARY = "xul" diff --git netwerk/dns/moz.build netwerk/dns/moz.build index 79c26e3e7001..c4d93bc5f7dc 100644 --- netwerk/dns/moz.build +++ netwerk/dns/moz.build -@@ -86,3 +86,6 @@ USE_LIBS += ['icu'] +@@ -105,3 +105,6 @@ USE_LIBS += ["icu"] - if CONFIG['CC_TYPE'] in ('clang', 'gcc'): - CXXFLAGS += ['-Wno-error=shadow'] + if CONFIG["CC_TYPE"] in ("clang", "gcc"): + CXXFLAGS += ["-Wno-error=shadow"] + -+if CONFIG['MOZ_SYSTEM_HARFBUZZ']: -+ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS'] ++if CONFIG["MOZ_SYSTEM_HARFBUZZ"]: ++ CXXFLAGS += CONFIG["MOZ_HARFBUZZ_CFLAGS"] diff --git old-configure.in old-configure.in index 95a58b634593..b614eef85c89 100644 --- old-configure.in +++ old-configure.in -@@ -2639,6 +2639,27 @@ dnl ======================================================== +@@ -2303,6 +2303,27 @@ dnl ======================================================== AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR) @@ -242,46 +242,46 @@ diff --git toolkit/library/moz.build toolkit/library/moz.build index 24f940e1ed7e..079a575adec3 100644 --- toolkit/library/moz.build +++ toolkit/library/moz.build -@@ -248,6 +248,12 @@ if CONFIG['MOZ_SYSTEM_PNG']: - if CONFIG['MOZ_SYSTEM_WEBP']: - OS_LIBS += CONFIG['MOZ_WEBP_LIBS'] +@@ -247,6 +247,12 @@ if CONFIG["MOZ_SYSTEM_PNG"]: + if CONFIG["MOZ_SYSTEM_WEBP"]: + OS_LIBS += CONFIG["MOZ_WEBP_LIBS"] -+if CONFIG['MOZ_SYSTEM_GRAPHITE2']: -+ OS_LIBS += CONFIG['MOZ_GRAPHITE2_LIBS'] ++if CONFIG["MOZ_SYSTEM_GRAPHITE2"]: ++ OS_LIBS += CONFIG["MOZ_GRAPHITE2_LIBS"] + -+if CONFIG['MOZ_SYSTEM_HARFBUZZ']: -+ OS_LIBS += CONFIG['MOZ_HARFBUZZ_LIBS'] ++if CONFIG["MOZ_SYSTEM_HARFBUZZ"]: ++ OS_LIBS += CONFIG["MOZ_HARFBUZZ_LIBS"] + - if CONFIG['MOZ_SYSTEM_LIBEVENT']: - OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS'] + if CONFIG["MOZ_SYSTEM_LIBEVENT"]: + OS_LIBS += CONFIG["MOZ_LIBEVENT_LIBS"] diff --git toolkit/moz.configure toolkit/moz.configure index 9297e4d6f501..d8e273887e4b 100644 --- toolkit/moz.configure +++ toolkit/moz.configure -@@ -937,6 +937,25 @@ add_old_configure_assignment('FT2_LIBS', - add_old_configure_assignment('FT2_CFLAGS', - ft2_info.cflags) +@@ -1055,6 +1055,25 @@ set_config("FT2_LIBS", ft2_info.libs) + add_old_configure_assignment("FT2_LIBS", ft2_info.libs) + add_old_configure_assignment("FT2_CFLAGS", ft2_info.cflags) +# Graphite2 +# ============================================================== -+option('--with-system-graphite2', ++option("--with-system-graphite2", + help="Use system graphite2 (located with pkgconfig)") + -+system_graphite2 = pkg_check_modules('MOZ_GRAPHITE2', 'graphite2', -+ when='--with-system-graphite2') ++system_graphite2 = pkg_check_modules("MOZ_GRAPHITE2", "graphite2", ++ when="--with-system-graphite2") + -+set_config('MOZ_SYSTEM_GRAPHITE2', depends_if(system_graphite2)(lambda _: True)) ++set_config("MOZ_SYSTEM_GRAPHITE2", depends_if(system_graphite2)(lambda _: True)) + +# HarfBuzz +# ============================================================== -+option('--with-system-harfbuzz', ++option("--with-system-harfbuzz", + help="Use system harfbuzz (located with pkgconfig)") + -+system_harfbuzz = pkg_check_modules('MOZ_HARFBUZZ', 'harfbuzz >= 2.6.8', -+ when='--with-system-harfbuzz') ++system_harfbuzz = pkg_check_modules("MOZ_HARFBUZZ", "harfbuzz >= 2.6.8", ++ when="--with-system-harfbuzz") + -+set_config('MOZ_SYSTEM_HARFBUZZ', depends_if(system_harfbuzz)(lambda _: True)) ++set_config("MOZ_SYSTEM_HARFBUZZ", depends_if(system_harfbuzz)(lambda _: True)) - # Remote agent (part of CDP based remote protocol) - # ============================================================== + # Remote agent + # (partial implementation of Chromium Remote Debugging Protocol) diff --git a/www/firefox/files/patch-cubeb-oss b/www/firefox/files/patch-cubeb-oss deleted file mode 100644 index 2b151a07fb20..000000000000 --- a/www/firefox/files/patch-cubeb-oss +++ /dev/null @@ -1,1327 +0,0 @@ -https://github.com/kinetiknz/cubeb/pull/600 - ---- dom/media/CubebUtils.cpp.orig 2020-08-19 02:08:51 UTC -+++ dom/media/CubebUtils.cpp -@@ -126,7 +126,7 @@ const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties"; - - const char* AUDIOSTREAM_BACKEND_ID_STR[] = { - "jack", "pulse", "alsa", "audiounit", "audioqueue", "wasapi", -- "winmm", "directsound", "sndio", "opensl", "audiotrack", "kai"}; -+ "winmm", "directsound", "sndio", "opensl", "oss", "audiotrack", "kai"}; - /* Index for failures to create an audio stream the first time. */ - const int CUBEB_BACKEND_INIT_FAILURE_FIRST = - ArrayLength(AUDIOSTREAM_BACKEND_ID_STR); ---- media/libcubeb/src/moz.build.orig 2020-08-19 02:09:19 UTC -+++ media/libcubeb/src/moz.build -@@ -40,6 +40,12 @@ if CONFIG['MOZ_JACK']: - ] - DEFINES['USE_JACK'] = True - -+if CONFIG['OS_ARCH'] in ('DragonFly', 'FreeBSD', 'SunOS'): -+ SOURCES += [ -+ 'cubeb_oss.c', -+ ] -+ DEFINES['USE_OSS'] = True -+ - if CONFIG['OS_ARCH'] == 'OpenBSD': - SOURCES += [ - 'cubeb_sndio.c', ---- media/libcubeb/src/cubeb.c.orig 2020-08-19 02:09:26 UTC -+++ media/libcubeb/src/cubeb.c -@@ -60,6 +60,9 @@ int sun_init(cubeb ** context, char const * context_name); - #if defined(USE_OPENSL) - int opensl_init(cubeb ** context, char const * context_name); - #endif -+#if defined(USE_OSS) -+int oss_init(cubeb ** context, char const * context_name); -+#endif - #if defined(USE_AUDIOTRACK) - int audiotrack_init(cubeb ** context, char const * context_name); - #endif -@@ -165,6 +168,10 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam - #if defined(USE_OPENSL) - init_oneshot = opensl_init; - #endif -+ } else if (!strcmp(backend_name, "oss")) { -+#if defined(USE_OSS) -+ init_oneshot = oss_init; -+#endif - } else if (!strcmp(backend_name, "audiotrack")) { - #if defined(USE_AUDIOTRACK) - init_oneshot = audiotrack_init; -@@ -200,6 +207,9 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam - #if defined(USE_ALSA) - alsa_init, - #endif -+#if defined (USE_OSS) -+ oss_init, -+#endif - #if defined(USE_AUDIOUNIT_RUST) - audiounit_rust_init, - #endif ---- /dev/null -+++ media/libcubeb/src/cubeb_oss.c -@@ -0,0 +1,1263 @@ -+/* -+ * Copyright © 2019-2020 Nia Alarie -+ * Copyright © 2020 Ka Ho Ng -+ * Copyright © 2020 The FreeBSD Foundation -+ * -+ * Portions of this software were developed by Ka Ho Ng -+ * under sponsorship from the FreeBSD Foundation. -+ * -+ * This program is made available under an ISC-style license. See the -+ * accompanying file LICENSE for details. -+ */ -+ -+#if defined(__FreeBSD__) && __FreeBSD__ < 12 -+#define _WITH_GETLINE -+#endif -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "cubeb/cubeb.h" -+#include "cubeb_mixer.h" -+#include "cubeb_strings.h" -+#include "cubeb-internal.h" -+ -+/* Supported well by most hardware. */ -+#ifndef OSS_PREFER_RATE -+#define OSS_PREFER_RATE (48000) -+#endif -+ -+/* Standard acceptable minimum. */ -+#ifndef OSS_LATENCY_MS -+#define OSS_LATENCY_MS (8) -+#endif -+ -+#ifndef OSS_NFRAGS -+#define OSS_NFRAGS (4) -+#endif -+ -+#ifndef OSS_DEFAULT_DEVICE -+#define OSS_DEFAULT_DEVICE "/dev/dsp" -+#endif -+ -+#ifndef OSS_DEFAULT_MIXER -+#define OSS_DEFAULT_MIXER "/dev/mixer" -+#endif -+ -+#define ENV_AUDIO_DEVICE "AUDIO_DEVICE" -+ -+#ifndef OSS_MAX_CHANNELS -+# if defined(__FreeBSD__) || defined(__DragonFly__) -+/* -+ * The current maximum number of channels supported -+ * on FreeBSD is 8. -+ * -+ * Reference: FreeBSD 12.1-RELEASE -+ */ -+# define OSS_MAX_CHANNELS (8) -+# elif defined(__sun__) -+/* -+ * The current maximum number of channels supported -+ * on Illumos is 16. -+ * -+ * Reference: PSARC 2008/318 -+ */ -+# define OSS_MAX_CHANNELS (16) -+# else -+# define OSS_MAX_CHANNELS (2) -+# endif -+#endif -+ -+#if defined(__FreeBSD__) || defined(__DragonFly__) -+#define SNDSTAT_BEGIN_STR "Installed devices:" -+#define SNDSTAT_USER_BEGIN_STR "Installed devices from userspace:" -+#define SNDSTAT_FV_BEGIN_STR "File Versions:" -+#endif -+ -+static struct cubeb_ops const oss_ops; -+ -+struct cubeb { -+ struct cubeb_ops const * ops; -+ -+ /* Our intern string store */ -+ pthread_mutex_t mutex; /* protects devid_strs */ -+ cubeb_strings *devid_strs; -+}; -+ -+struct oss_stream { -+ oss_devnode_t name; -+ int fd; -+ void * buf; -+ -+ struct stream_info { -+ int channels; -+ int sample_rate; -+ int fmt; -+ int precision; -+ } info; -+ -+ unsigned int frame_size; /* precision in bytes * channels */ -+ bool floating; -+}; -+ -+struct cubeb_stream { -+ struct cubeb * context; -+ void * user_ptr; -+ pthread_t thread; -+ bool doorbell; /* (m) */ -+ pthread_cond_t doorbell_cv; /* (m) */ -+ pthread_cond_t stopped_cv; /* (m) */ -+ pthread_mutex_t mtx; /* Members protected by this should be marked (m) */ -+ bool thread_created; /* (m) */ -+ bool running; /* (m) */ -+ bool destroying; /* (m) */ -+ cubeb_state state; /* (m) */ -+ float volume /* (m) */; -+ struct oss_stream play; -+ struct oss_stream record; -+ cubeb_data_callback data_cb; -+ cubeb_state_callback state_cb; -+ uint64_t frames_written /* (m) */; -+ unsigned int nfr; /* Number of frames allocated */ -+ unsigned int nfrags; -+ unsigned int bufframes; -+}; -+ -+static char const * -+oss_cubeb_devid_intern(cubeb *context, char const * devid) -+{ -+ char const *is; -+ pthread_mutex_lock(&context->mutex); -+ is = cubeb_strings_intern(context->devid_strs, devid); -+ pthread_mutex_unlock(&context->mutex); -+ return is; -+} -+ -+int -+oss_init(cubeb **context, char const *context_name) { -+ cubeb * c; -+ -+ (void)context_name; -+ if ((c = calloc(1, sizeof(cubeb))) == NULL) { -+ return CUBEB_ERROR; -+ } -+ -+ if (cubeb_strings_init(&c->devid_strs) == CUBEB_ERROR) { -+ goto fail; -+ } -+ -+ if (pthread_mutex_init(&c->mutex, NULL) != 0) { -+ goto fail; -+ } -+ -+ c->ops = &oss_ops; -+ *context = c; -+ return CUBEB_OK; -+ -+fail: -+ cubeb_strings_destroy(c->devid_strs); -+ free(c); -+ return CUBEB_ERROR; -+} -+ -+static void -+oss_destroy(cubeb * context) -+{ -+ pthread_mutex_destroy(&context->mutex); -+ cubeb_strings_destroy(context->devid_strs); -+ free(context); -+} -+ -+static char const * -+oss_get_backend_id(cubeb * context) -+{ -+ return "oss"; -+} -+ -+static int -+oss_get_preferred_sample_rate(cubeb * context, uint32_t * rate) -+{ -+ (void)context; -+ -+ *rate = OSS_PREFER_RATE; -+ return CUBEB_OK; -+} -+ -+static int -+oss_get_max_channel_count(cubeb * context, uint32_t * max_channels) -+{ -+ (void)context; -+ -+ *max_channels = OSS_MAX_CHANNELS; -+ return CUBEB_OK; -+} -+ -+static int -+oss_get_min_latency(cubeb * context, cubeb_stream_params params, -+ uint32_t * latency_frames) -+{ -+ (void)context; -+ -+ *latency_frames = (OSS_LATENCY_MS * params.rate) / 1000; -+ return CUBEB_OK; -+} -+ -+static void -+oss_free_cubeb_device_info_strings(cubeb_device_info *cdi) -+{ -+ free((char *)cdi->device_id); -+ free((char *)cdi->friendly_name); -+ free((char *)cdi->group_id); -+ cdi->device_id = NULL; -+ cdi->friendly_name = NULL; -+ cdi->group_id = NULL; -+} -+ -+#if defined(__FreeBSD__) || defined(__DragonFly__) -+/* -+ * Check if the specified DSP is okay for the purpose specified -+ * in type. Here type can only specify one operation each time -+ * this helper is called. -+ * -+ * Return 0 if OK, otherwise 1. -+ */ -+static int -+oss_probe_open(const char *dsppath, cubeb_device_type type, -+ int *fdp, oss_audioinfo *resai) -+{ -+ oss_audioinfo ai; -+ int error; -+ int oflags = (type == CUBEB_DEVICE_TYPE_INPUT) ? O_RDONLY : O_WRONLY; -+ int dspfd = open(dsppath, oflags); -+ if (dspfd == -1) -+ return 1; -+ -+ ai.dev = -1; -+ error = ioctl(dspfd, SNDCTL_AUDIOINFO, &ai); -+ if (error < 0) { -+ close(dspfd); -+ return 1; -+ } -+ -+ if (resai) -+ *resai = ai; -+ if (fdp) -+ *fdp = dspfd; -+ else -+ close(dspfd); -+ return 0; -+} -+ -+struct sndstat_info { -+ oss_devnode_t devname; -+ const char *desc; -+ cubeb_device_type type; -+ int preferred; -+}; -+ -+static int -+oss_sndstat_line_parse(char *line, int is_ud, struct sndstat_info *sinfo) -+{ -+ char *matchptr = line, *n = NULL; -+ struct sndstat_info res; -+ -+ memset(&res, 0, sizeof(res)); -+ -+ n = strchr(matchptr, ':'); -+ if (n == NULL) -+ goto fail; -+ if (is_ud == 0) { -+ unsigned int devunit; -+ -+ if (sscanf(matchptr, "pcm%u: ", &devunit) < 1) -+ goto fail; -+ -+ if (snprintf(res.devname, sizeof(res.devname), "/dev/dsp%u", devunit) < 1) -+ goto fail; -+ } else { -+ if (n - matchptr >= (ssize_t)(sizeof(res.devname) - strlen("/dev/"))) -+ goto fail; -+ -+ strlcpy(res.devname, "/dev/", sizeof(res.devname)); -+ strncat(res.devname, matchptr, n - matchptr); -+ } -+ matchptr = n + 1; -+ -+ n = strchr(matchptr, '<'); -+ if (n == NULL) -+ goto fail; -+ matchptr = n + 1; -+ n = strrchr(matchptr, '>'); -+ if (n == NULL) -+ goto fail; -+ *n = 0; -+ res.desc = matchptr; -+ matchptr = n + 1; -+ -+ n = strchr(matchptr, '('); -+ if (n == NULL) -+ goto fail; -+ matchptr = n + 1; -+ n = strrchr(matchptr, ')'); -+ if (n == NULL) -+ goto fail; -+ *n = 0; -+ if (!isdigit(matchptr[0])) { -+ if (strstr(matchptr, "play") != NULL) -+ res.type |= CUBEB_DEVICE_TYPE_OUTPUT; -+ if (strstr(matchptr, "rec") != NULL) -+ res.type |= CUBEB_DEVICE_TYPE_INPUT; -+ } else { -+ int p, r; -+ if (sscanf(matchptr, "%dp:%*dv/%dr:%*dv", &p, &r) != 2) -+ goto fail; -+ if (p > 0) -+ res.type |= CUBEB_DEVICE_TYPE_OUTPUT; -+ if (r > 0) -+ res.type |= CUBEB_DEVICE_TYPE_INPUT; -+ } -+ matchptr = n + 1; -+ if (strstr(matchptr, "default") != NULL) -+ res.preferred = 1; -+ -+ *sinfo = res; -+ return 0; -+ -+fail: -+ return 1; -+} -+ -+/* -+ * XXX: On FreeBSD we have to rely on SNDCTL_CARDINFO to get all -+ * the usable audio devices currently, as SNDCTL_AUDIOINFO will -+ * never return directly usable audio device nodes. -+ */ -+static int -+oss_enumerate_devices(cubeb * context, cubeb_device_type type, -+ cubeb_device_collection * collection) -+{ -+ cubeb_device_info *devinfop = NULL; -+ char *line = NULL; -+ size_t linecap = 0; -+ FILE *sndstatfp = NULL; -+ int collection_cnt = 0; -+ int is_ud = 0; -+ int skipall = 0; -+ -+ devinfop = calloc(1, sizeof(cubeb_device_info)); -+ if (devinfop == NULL) -+ goto fail; -+ -+ sndstatfp = fopen("/dev/sndstat", "r"); -+ if (sndstatfp == NULL) -+ goto fail; -+ while (getline(&line, &linecap, sndstatfp) > 0) { -+ const char *devid = NULL; -+ struct sndstat_info sinfo; -+ oss_audioinfo ai; -+ -+ if (!strncmp(line, SNDSTAT_FV_BEGIN_STR, strlen(SNDSTAT_FV_BEGIN_STR))) { -+ skipall = 1; -+ continue; -+ } -+ if (!strncmp(line, SNDSTAT_BEGIN_STR, strlen(SNDSTAT_BEGIN_STR))) { -+ is_ud = 0; -+ skipall = 0; -+ continue; -+ } -+ if (!strncmp(line, SNDSTAT_USER_BEGIN_STR, strlen(SNDSTAT_USER_BEGIN_STR))) { -+ is_ud = 1; -+ skipall = 0; -+ continue; -+ } -+ if (skipall || isblank(line[0])) -+ continue; -+ -+ if (oss_sndstat_line_parse(line, is_ud, &sinfo)) -+ continue; -+ -+ devinfop[collection_cnt].type = 0; -+ switch (sinfo.type) { -+ case CUBEB_DEVICE_TYPE_INPUT: -+ if (type & CUBEB_DEVICE_TYPE_OUTPUT) -+ continue; -+ break; -+ case CUBEB_DEVICE_TYPE_OUTPUT: -+ if (type & CUBEB_DEVICE_TYPE_INPUT) -+ continue; -+ break; -+ case 0: -+ continue; -+ } -+ -+ if (oss_probe_open(sinfo.devname, type, NULL, &ai)) -+ continue; -+ -+ devid = oss_cubeb_devid_intern(context, sinfo.devname); -+ if (devid == NULL) -+ continue; -+ -+ devinfop[collection_cnt].device_id = strdup(sinfo.devname); -+ asprintf((char **)&devinfop[collection_cnt].friendly_name, "%s: %s", -+ sinfo.devname, sinfo.desc); -+ devinfop[collection_cnt].group_id = strdup(sinfo.devname); -+ devinfop[collection_cnt].vendor_name = NULL; -+ if (devinfop[collection_cnt].device_id == NULL || -+ devinfop[collection_cnt].friendly_name == NULL || -+ devinfop[collection_cnt].group_id == NULL) { -+ oss_free_cubeb_device_info_strings(&devinfop[collection_cnt]); -+ continue; -+ } -+ -+ devinfop[collection_cnt].type = type; -+ devinfop[collection_cnt].devid = devid; -+ devinfop[collection_cnt].state = CUBEB_DEVICE_STATE_ENABLED; -+ devinfop[collection_cnt].preferred = -+ (sinfo.preferred) ? CUBEB_DEVICE_PREF_ALL : CUBEB_DEVICE_PREF_NONE; -+ devinfop[collection_cnt].format = CUBEB_DEVICE_FMT_S16NE; -+ devinfop[collection_cnt].default_format = CUBEB_DEVICE_FMT_S16NE; -+ devinfop[collection_cnt].max_channels = ai.max_channels; -+ devinfop[collection_cnt].default_rate = OSS_PREFER_RATE; -+ devinfop[collection_cnt].max_rate = ai.max_rate; -+ devinfop[collection_cnt].min_rate = ai.min_rate; -+ devinfop[collection_cnt].latency_lo = 0; -+ devinfop[collection_cnt].latency_hi = 0; -+ -+ collection_cnt++; -+ -+ void *newp = reallocarray(devinfop, collection_cnt + 1, -+ sizeof(cubeb_device_info)); -+ if (newp == NULL) -+ goto fail; -+ devinfop = newp; -+ } -+ -+ free(line); -+ fclose(sndstatfp); -+ -+ collection->count = collection_cnt; -+ collection->device = devinfop; -+ -+ return CUBEB_OK; -+ -+fail: -+ free(line); -+ if (sndstatfp) -+ fclose(sndstatfp); -+ free(devinfop); -+ return CUBEB_ERROR; -+} -+ -+#else -+ -+static int -+oss_enumerate_devices(cubeb * context, cubeb_device_type type, -+ cubeb_device_collection * collection) -+{ -+ oss_sysinfo si; -+ int error, i; -+ cubeb_device_info *devinfop = NULL; -+ int collection_cnt = 0; -+ int mixer_fd = -1; -+ -+ mixer_fd = open(OSS_DEFAULT_MIXER, O_RDWR); -+ if (mixer_fd == -1) { -+ LOG("Failed to open mixer %s. errno: %d", OSS_DEFAULT_MIXER, errno); -+ return CUBEB_ERROR; -+ } -+ -+ error = ioctl(mixer_fd, SNDCTL_SYSINFO, &si); -+ if (error) { -+ LOG("Failed to run SNDCTL_SYSINFO on mixer %s. errno: %d", OSS_DEFAULT_MIXER, errno); -+ goto fail; -+ } -+ -+ devinfop = calloc(si.numaudios, sizeof(cubeb_device_info)); -+ if (devinfop == NULL) -+ goto fail; -+ -+ collection->count = 0; -+ for (i = 0; i < si.numaudios; i++) { -+ oss_audioinfo ai; -+ cubeb_device_info cdi = { 0 }; -+ const char *devid = NULL; -+ -+ ai.dev = i; -+ error = ioctl(mixer_fd, SNDCTL_AUDIOINFO, &ai); -+ if (error) -+ goto fail; -+ -+ assert(ai.dev < si.numaudios); -+ if (!ai.enabled) -+ continue; -+ -+ cdi.type = 0; -+ switch (ai.caps & DSP_CAP_DUPLEX) { -+ case DSP_CAP_INPUT: -+ if (type & CUBEB_DEVICE_TYPE_OUTPUT) -+ continue; -+ break; -+ case DSP_CAP_OUTPUT: -+ if (type & CUBEB_DEVICE_TYPE_INPUT) -+ continue; -+ break; -+ case 0: -+ continue; -+ } -+ cdi.type = type; -+ -+ devid = oss_cubeb_devid_intern(context, ai.devnode); -+ cdi.device_id = strdup(ai.name); -+ cdi.friendly_name = strdup(ai.name); -+ cdi.group_id = strdup(ai.name); -+ if (devid == NULL || cdi.device_id == NULL || cdi.friendly_name == NULL || -+ cdi.group_id == NULL) { -+ oss_free_cubeb_device_info_strings(&cdi); -+ continue; -+ } -+ -+ cdi.devid = devid; -+ cdi.vendor_name = NULL; -+ cdi.state = CUBEB_DEVICE_STATE_ENABLED; -+ cdi.preferred = CUBEB_DEVICE_PREF_NONE; -+ cdi.format = CUBEB_DEVICE_FMT_S16NE; -+ cdi.default_format = CUBEB_DEVICE_FMT_S16NE; -+ cdi.max_channels = ai.max_channels; -+ cdi.default_rate = OSS_PREFER_RATE; -+ cdi.max_rate = ai.max_rate; -+ cdi.min_rate = ai.min_rate; -+ cdi.latency_lo = 0; -+ cdi.latency_hi = 0; -+ -+ devinfop[collection_cnt++] = cdi; -+ } -+ -+ collection->count = collection_cnt; -+ collection->device = devinfop; -+ -+ if (mixer_fd != -1) -+ close(mixer_fd); -+ return CUBEB_OK; -+ -+fail: -+ if (mixer_fd != -1) -+ close(mixer_fd); -+ free(devinfop); -+ return CUBEB_ERROR; -+} -+ -+#endif -+ -+static int -+oss_device_collection_destroy(cubeb * context, -+ cubeb_device_collection * collection) -+{ -+ size_t i; -+ for (i = 0; i < collection->count; i++) { -+ oss_free_cubeb_device_info_strings(&collection->device[i]); -+ } -+ free(collection->device); -+ collection->device = NULL; -+ collection->count = 0; -+ return 0; -+} -+ -+static unsigned int -+oss_chn_from_cubeb(cubeb_channel chn) -+{ -+ switch (chn) { -+ case CHANNEL_FRONT_LEFT: -+ return CHID_L; -+ case CHANNEL_FRONT_RIGHT: -+ return CHID_R; -+ case CHANNEL_FRONT_CENTER: -+ return CHID_C; -+ case CHANNEL_LOW_FREQUENCY: -+ return CHID_LFE; -+ case CHANNEL_BACK_LEFT: -+ return CHID_LR; -+ case CHANNEL_BACK_RIGHT: -+ return CHID_RR; -+ case CHANNEL_SIDE_LEFT: -+ return CHID_LS; -+ case CHANNEL_SIDE_RIGHT: -+ return CHID_RS; -+ default: -+ return CHID_UNDEF; -+ } -+} -+ -+static unsigned long long -+oss_cubeb_layout_to_chnorder(cubeb_channel_layout layout) -+{ -+ unsigned int i, nchns = 0; -+ unsigned long long chnorder = 0; -+ -+ for (i = 0; layout; i++, layout >>= 1) { -+ unsigned long long chid = oss_chn_from_cubeb((layout & 1) << i); -+ if (chid == CHID_UNDEF) -+ continue; -+ -+ chnorder |= (chid & 0xf) << nchns * 4; -+ nchns++; -+ } -+ -+ return chnorder; -+} -+ -+static int -+oss_copy_params(int fd, cubeb_stream * stream, cubeb_stream_params * params, -+ struct stream_info * sinfo) -+{ -+ unsigned long long chnorder; -+ -+ sinfo->channels = params->channels; -+ sinfo->sample_rate = params->rate; -+ switch (params->format) { -+ case CUBEB_SAMPLE_S16LE: -+ sinfo->fmt = AFMT_S16_LE; -+ sinfo->precision = 16; -+ break; -+ case CUBEB_SAMPLE_S16BE: -+ sinfo->fmt = AFMT_S16_BE; -+ sinfo->precision = 16; -+ break; -+ case CUBEB_SAMPLE_FLOAT32NE: -+ sinfo->fmt = AFMT_S32_NE; -+ sinfo->precision = 32; -+ break; -+ default: -+ LOG("Unsupported format"); -+ return CUBEB_ERROR_INVALID_FORMAT; -+ } -+ if (ioctl(fd, SNDCTL_DSP_CHANNELS, &sinfo->channels) == -1) { -+ return CUBEB_ERROR; -+ } -+ if (ioctl(fd, SNDCTL_DSP_SETFMT, &sinfo->fmt) == -1) { -+ return CUBEB_ERROR; -+ } -+ if (ioctl(fd, SNDCTL_DSP_SPEED, &sinfo->sample_rate) == -1) { -+ return CUBEB_ERROR; -+ } -+ /* Mono layout is an exception */ -+ if (params->layout != CUBEB_LAYOUT_UNDEFINED && params->layout != CUBEB_LAYOUT_MONO) { -+ chnorder = oss_cubeb_layout_to_chnorder(params->layout); -+ if (ioctl(fd, SNDCTL_DSP_SET_CHNORDER, &chnorder) == -1) -+ LOG("Non-fatal error %d occured when setting channel order.", errno); -+ } -+ return CUBEB_OK; -+} -+ -+static int -+oss_stream_stop(cubeb_stream * s) -+{ -+ pthread_mutex_lock(&s->mtx); -+ if (s->thread_created && s->running) { -+ s->running = false; -+ s->doorbell = false; -+ pthread_cond_wait(&s->stopped_cv, &s->mtx); -+ } -+ if (s->state != CUBEB_STATE_STOPPED) { -+ s->state = CUBEB_STATE_STOPPED; -+ pthread_mutex_unlock(&s->mtx); -+ s->state_cb(s, s->user_ptr, CUBEB_STATE_STOPPED); -+ } else { -+ pthread_mutex_unlock(&s->mtx); -+ } -+ return CUBEB_OK; -+} -+ -+static void -+oss_stream_destroy(cubeb_stream * s) -+{ -+ pthread_mutex_lock(&s->mtx); -+ if (s->thread_created) { -+ s->destroying = true; -+ s->doorbell = true; -+ pthread_cond_signal(&s->doorbell_cv); -+ } -+ pthread_mutex_unlock(&s->mtx); -+ pthread_join(s->thread, NULL); -+ -+ pthread_cond_destroy(&s->doorbell_cv); -+ pthread_cond_destroy(&s->stopped_cv); -+ pthread_mutex_destroy(&s->mtx); -+ if (s->play.fd != -1) { -+ close(s->play.fd); -+ } -+ if (s->record.fd != -1) { -+ close(s->record.fd); -+ } -+ free(s->play.buf); -+ free(s->record.buf); -+ free(s); -+} -+ -+static void -+oss_float_to_linear32(void * buf, unsigned sample_count, float vol) -+{ -+ float * in = buf; -+ int32_t * out = buf; -+ int32_t * tail = out + sample_count; -+ -+ while (out < tail) { -+ int64_t f = *(in++) * vol * 0x80000000LL; -+ if (f < -INT32_MAX) -+ f = -INT32_MAX; -+ else if (f > INT32_MAX) -+ f = INT32_MAX; -+ *(out++) = f; -+ } -+} -+ -+static void -+oss_linear32_to_float(void * buf, unsigned sample_count) -+{ -+ int32_t * in = buf; -+ float * out = buf; -+ float * tail = out + sample_count; -+ -+ while (out < tail) { -+ *(out++) = (1.0 / 0x80000000LL) * *(in++); -+ } -+} -+ -+static void -+oss_linear16_set_vol(int16_t * buf, unsigned sample_count, float vol) -+{ -+ unsigned i; -+ int32_t multiplier = vol * 0x8000; -+ -+ for (i = 0; i < sample_count; ++i) { -+ buf[i] = (buf[i] * multiplier) >> 15; -+ } -+} -+ -+/* 1 - Stopped by cubeb_stream_stop, otherwise 0 */ -+static int -+oss_audio_loop(cubeb_stream * s, cubeb_state *new_state) -+{ -+ cubeb_state state = CUBEB_STATE_STOPPED; -+ int trig = 0; -+ int drain = 0; -+ struct pollfd pfds[2]; -+ unsigned int ppending, rpending; -+ -+ pfds[0].fd = s->play.fd; -+ pfds[0].events = POLLOUT; -+ pfds[1].fd = s->record.fd; -+ pfds[1].events = POLLIN; -+ -+ ppending = 0; -+ rpending = s->bufframes; -+ -+ if (s->record.fd != -1) { -+ if (ioctl(s->record.fd, SNDCTL_DSP_SETTRIGGER, &trig)) { -+ LOG("Error %d occured when setting trigger on record fd", errno); -+ state = CUBEB_STATE_ERROR; -+ goto breakdown; -+ } -+ trig |= PCM_ENABLE_INPUT; -+ if (ioctl(s->record.fd, SNDCTL_DSP_SETTRIGGER, &trig)) { -+ LOG("Error %d occured when setting trigger on record fd", errno); -+ state = CUBEB_STATE_ERROR; -+ goto breakdown; -+ } -+ memset(s->record.buf, 0, s->bufframes * s->record.frame_size); -+ } -+ -+ while (1) { -+ long nfr = 0; -+ -+ pthread_mutex_lock(&s->mtx); -+ if (!s->running || s->destroying) { -+ pthread_mutex_unlock(&s->mtx); -+ break; -+ } -+ pthread_mutex_unlock(&s->mtx); -+ if (s->play.fd == -1 && s->record.fd == -1) { -+ /* -+ * Stop here if the stream is not play & record stream, -+ * play-only stream or record-only stream -+ */ -+ -+ goto breakdown; -+ } -+ -+ while ((s->bufframes - ppending) >= s->nfr && rpending >= s->nfr) { -+ long n = ((s->bufframes - ppending) < rpending) ? s->bufframes - ppending : rpending; -+ char *rptr = NULL, *pptr = NULL; -+ if (s->record.fd != -1) -+ rptr = (char *)s->record.buf; -+ if (s->play.fd != -1) -+ pptr = (char *)s->play.buf + ppending * s->play.frame_size; -+ if (s->record.fd != -1 && s->record.floating) { -+ oss_linear32_to_float(s->record.buf, s->record.info.channels * n); -+ } -+ nfr = s->data_cb(s, s->user_ptr, rptr, pptr, n); -+ if (nfr == CUBEB_ERROR) { -+ state = CUBEB_STATE_ERROR; -+ goto breakdown; -+ } -+ if (pptr) { -+ float vol; -+ -+ pthread_mutex_lock(&s->mtx); -+ vol = s->volume; -+ pthread_mutex_unlock(&s->mtx); -+ -+ if (s->play.floating) { -+ oss_float_to_linear32(pptr, s->play.info.channels * nfr, vol); -+ } else { -+ oss_linear16_set_vol((int16_t *)pptr, s->play.info.channels * nfr, vol); -+ } -+ } -+ if (pptr) { -+ ppending += nfr; -+ assert(ppending <= s->bufframes); -+ } -+ if (rptr) { -+ assert(rpending >= nfr); -+ rpending -= nfr; -+ memmove(rptr, rptr + nfr * s->record.frame_size, -+ (s->bufframes - nfr) * s->record.frame_size); -+ } -+ if (nfr < n) { -+ if (s->play.fd != -1) { -+ drain = 1; -+ break; -+ } else { -+ /* -+ * This is a record-only stream and number of frames -+ * returned from data_cb() is smaller than number -+ * of frames required to read. Stop here. -+ */ -+ -+ state = CUBEB_STATE_STOPPED; -+ goto breakdown; -+ } -+ } -+ } -+ -+ ssize_t n, frames; -+ int nfds; -+ -+ pfds[0].revents = 0; -+ pfds[1].revents = 0; -+ -+ nfds = poll(pfds, 2, 1000); -+ if (nfds == -1) { -+ if (errno == EINTR) -+ continue; -+ LOG("Error %d occured when polling playback and record fd", errno); -+ state = CUBEB_STATE_ERROR; -+ goto breakdown; -+ } else if (nfds == 0) -+ continue; -+ -+ if ((pfds[0].revents & (POLLERR | POLLHUP)) || -+ (pfds[1].revents & (POLLERR | POLLHUP))) { -+ LOG("Error occured on playback, record fds"); -+ state = CUBEB_STATE_ERROR; -+ goto breakdown; -+ } -+ -+ if (pfds[0].revents) { -+ while (ppending > 0) { -+ size_t bytes = ppending * s->play.frame_size; -+ if ((n = write(s->play.fd, (uint8_t *)s->play.buf, bytes)) < 0) { -+ if (errno == EINTR) -+ continue; -+ if (errno == EAGAIN) { -+ if (drain) -+ continue; -+ break; -+ } -+ state = CUBEB_STATE_ERROR; -+ goto breakdown; -+ } -+ frames = n / s->play.frame_size; -+ pthread_mutex_lock(&s->mtx); -+ s->frames_written += frames; -+ pthread_mutex_unlock(&s->mtx); -+ ppending -= frames; -+ memmove(s->play.buf, (uint8_t *)s->play.buf + n, -+ (s->bufframes - frames) * s->play.frame_size); -+ } -+ } -+ if (pfds[1].revents) { -+ while (s->bufframes - rpending > 0) { -+ size_t bytes = (s->bufframes - rpending) * s->record.frame_size; -+ size_t read_ofs = rpending * s->record.frame_size; -+ if ((n = read(s->record.fd, (uint8_t *)s->record.buf + read_ofs, bytes)) < 0) { -+ if (errno == EINTR) -+ continue; -+ if (errno == EAGAIN) -+ break; -+ state = CUBEB_STATE_ERROR; -+ goto breakdown; -+ } -+ frames = n / s->record.frame_size; -+ rpending += frames; -+ } -+ } -+ if (drain) { -+ state = CUBEB_STATE_DRAINED; -+ goto breakdown; -+ } -+ } -+ -+ return 1; -+ -+breakdown: -+ pthread_mutex_lock(&s->mtx); -+ *new_state = s->state = state; -+ s->running = false; -+ pthread_mutex_unlock(&s->mtx); -+ return 0; -+} -+ -+static void * -+oss_io_routine(void *arg) -+{ -+ cubeb_stream *s = arg; -+ cubeb_state new_state; -+ int stopped; -+ -+ do { -+ pthread_mutex_lock(&s->mtx); -+ if (s->destroying) { -+ pthread_mutex_unlock(&s->mtx); -+ break; -+ } -+ pthread_mutex_unlock(&s->mtx); -+ -+ stopped = oss_audio_loop(s, &new_state); -+ if (s->record.fd != -1) -+ ioctl(s->record.fd, SNDCTL_DSP_HALT_INPUT, NULL); -+ if (!stopped) -+ s->state_cb(s, s->user_ptr, new_state); -+ -+ pthread_mutex_lock(&s->mtx); -+ pthread_cond_signal(&s->stopped_cv); -+ if (s->destroying) { -+ pthread_mutex_unlock(&s->mtx); -+ break; -+ } -+ while (!s->doorbell) { -+ pthread_cond_wait(&s->doorbell_cv, &s->mtx); -+ } -+ s->doorbell = false; -+ pthread_mutex_unlock(&s->mtx); -+ } while (1); -+ -+ pthread_mutex_lock(&s->mtx); -+ s->thread_created = false; -+ pthread_mutex_unlock(&s->mtx); -+ return NULL; -+} -+ -+static inline int -+oss_calc_frag_shift(unsigned int frames, unsigned int frame_size) -+{ -+ int n = 4; -+ int blksize = (frames * frame_size + OSS_NFRAGS - 1) / OSS_NFRAGS; -+ while ((1 << n) < blksize) -+ n++; -+ return n; -+} -+ -+static inline int -+oss_get_frag_params(unsigned int shift) -+{ -+ return (OSS_NFRAGS << 16) | shift; -+} -+ -+static int -+oss_stream_init(cubeb * context, -+ cubeb_stream ** stream, -+ char const * stream_name, -+ cubeb_devid input_device, -+ cubeb_stream_params * input_stream_params, -+ cubeb_devid output_device, -+ cubeb_stream_params * output_stream_params, -+ unsigned int latency_frames, -+ cubeb_data_callback data_callback, -+ cubeb_state_callback state_callback, -+ void * user_ptr) -+{ -+ int ret = CUBEB_OK; -+ unsigned int playnfr = 0, recnfr = 0; -+ cubeb_stream *s = NULL; -+ const char *defdsp; -+ -+ if (!(defdsp = getenv(ENV_AUDIO_DEVICE)) || *defdsp == '\0') -+ defdsp = OSS_DEFAULT_DEVICE; -+ -+ (void)stream_name; -+ if ((s = calloc(1, sizeof(cubeb_stream))) == NULL) { -+ ret = CUBEB_ERROR; -+ goto error; -+ } -+ s->state = CUBEB_STATE_STOPPED; -+ s->record.fd = s->play.fd = -1; -+ s->nfr = latency_frames; -+ if (input_device != NULL) { -+ strlcpy(s->record.name, input_device, sizeof(s->record.name)); -+ } else { -+ strlcpy(s->record.name, defdsp, sizeof(s->record.name)); -+ } -+ if (output_device != NULL) { -+ strlcpy(s->play.name, output_device, sizeof(s->play.name)); -+ } else { -+ strlcpy(s->play.name, defdsp, sizeof(s->play.name)); -+ } -+ if (input_stream_params != NULL) { -+ unsigned int nb_channels; -+ if (input_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) { -+ LOG("Loopback not supported"); -+ ret = CUBEB_ERROR_NOT_SUPPORTED; -+ goto error; -+ } -+ nb_channels = cubeb_channel_layout_nb_channels(input_stream_params->layout); -+ if (input_stream_params->layout != CUBEB_LAYOUT_UNDEFINED && -+ nb_channels != input_stream_params->channels) { -+ LOG("input_stream_params->layout does not match input_stream_params->channels"); -+ ret = CUBEB_ERROR_INVALID_PARAMETER; -+ goto error; -+ } -+ if (s->record.fd == -1) { -+ if ((s->record.fd = open(s->record.name, O_RDONLY | O_NONBLOCK)) == -1) { -+ LOG("Audio device \"%s\" could not be opened as read-only", -+ s->record.name); -+ ret = CUBEB_ERROR_DEVICE_UNAVAILABLE; -+ goto error; -+ } -+ } -+ if ((ret = oss_copy_params(s->record.fd, s, input_stream_params, -+ &s->record.info)) != CUBEB_OK) { -+ LOG("Setting record params failed"); -+ goto error; -+ } -+ s->record.floating = (input_stream_params->format == CUBEB_SAMPLE_FLOAT32NE); -+ s->record.frame_size = s->record.info.channels * (s->record.info.precision / 8); -+ recnfr = (1 << oss_calc_frag_shift(s->nfr, s->record.frame_size)) / s->record.frame_size; -+ } -+ if (output_stream_params != NULL) { -+ unsigned int nb_channels; -+ if (output_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) { -+ LOG("Loopback not supported"); -+ ret = CUBEB_ERROR_NOT_SUPPORTED; -+ goto error; -+ } -+ nb_channels = cubeb_channel_layout_nb_channels(output_stream_params->layout); -+ if (output_stream_params->layout != CUBEB_LAYOUT_UNDEFINED && -+ nb_channels != output_stream_params->channels) { -+ LOG("output_stream_params->layout does not match output_stream_params->channels"); -+ ret = CUBEB_ERROR_INVALID_PARAMETER; -+ goto error; -+ } -+ if (s->play.fd == -1) { -+ if ((s->play.fd = open(s->play.name, O_WRONLY | O_NONBLOCK)) == -1) { -+ LOG("Audio device \"%s\" could not be opened as write-only", -+ s->play.name); -+ ret = CUBEB_ERROR_DEVICE_UNAVAILABLE; -+ goto error; -+ } -+ } -+ if ((ret = oss_copy_params(s->play.fd, s, output_stream_params, -+ &s->play.info)) != CUBEB_OK) { -+ LOG("Setting play params failed"); -+ goto error; -+ } -+ s->play.floating = (output_stream_params->format == CUBEB_SAMPLE_FLOAT32NE); -+ s->play.frame_size = s->play.info.channels * (s->play.info.precision / 8); -+ playnfr = (1 << oss_calc_frag_shift(s->nfr, s->play.frame_size)) / s->play.frame_size; -+ } -+ /* Use the largest nframes among playing and recording streams */ -+ s->nfr = (playnfr > recnfr) ? playnfr : recnfr; -+ s->nfrags = OSS_NFRAGS; -+ s->bufframes = s->nfr * s->nfrags; -+ if (s->play.fd != -1) { -+ int frag = oss_get_frag_params(oss_calc_frag_shift(s->nfr, s->play.frame_size)); -+ if (ioctl(s->record.fd, SNDCTL_DSP_SETFRAGMENT, &frag)) -+ LOG("Failed to set record fd with SNDCTL_DSP_SETFRAGMENT. frag: 0x%x", -+ frag); -+ } -+ if (s->record.fd != -1) { -+ int frag = oss_get_frag_params(oss_calc_frag_shift(s->nfr, s->record.frame_size)); -+ if (ioctl(s->record.fd, SNDCTL_DSP_SETFRAGMENT, &frag)) -+ LOG("Failed to set record fd with SNDCTL_DSP_SETFRAGMENT. frag: 0x%x", -+ frag); -+ } -+ s->context = context; -+ s->volume = 1.0; -+ s->state_cb = state_callback; -+ s->data_cb = data_callback; -+ s->user_ptr = user_ptr; -+ -+ if (pthread_mutex_init(&s->mtx, NULL) != 0) { -+ LOG("Failed to create mutex"); -+ goto error; -+ } -+ if (pthread_cond_init(&s->doorbell_cv, NULL) != 0) { -+ LOG("Failed to create cv"); -+ goto error; -+ } -+ if (pthread_cond_init(&s->stopped_cv, NULL) != 0) { -+ LOG("Failed to create cv"); -+ goto error; -+ } -+ s->doorbell = false; -+ -+ if (s->play.fd != -1) { -+ if ((s->play.buf = calloc(s->bufframes, s->play.frame_size)) == NULL) { -+ ret = CUBEB_ERROR; -+ goto error; -+ } -+ } -+ if (s->record.fd != -1) { -+ if ((s->record.buf = calloc(s->bufframes, s->record.frame_size)) == NULL) { -+ ret = CUBEB_ERROR; -+ goto error; -+ } -+ } -+ -+ *stream = s; -+ return CUBEB_OK; -+error: -+ if (s != NULL) { -+ oss_stream_destroy(s); -+ } -+ return ret; -+} -+ -+static int -+oss_stream_thr_create(cubeb_stream * s) -+{ -+ if (s->thread_created) { -+ s->doorbell = true; -+ pthread_cond_signal(&s->doorbell_cv); -+ return CUBEB_OK; -+ } -+ -+ if (pthread_create(&s->thread, NULL, oss_io_routine, s) != 0) { -+ LOG("Couldn't create thread"); -+ return CUBEB_ERROR; -+ } -+ -+ return CUBEB_OK; -+} -+ -+static int -+oss_stream_start(cubeb_stream * s) -+{ -+ s->state_cb(s, s->user_ptr, CUBEB_STATE_STARTED); -+ pthread_mutex_lock(&s->mtx); -+ /* Disallow starting an already started stream */ -+ assert(!s->running && s->state != CUBEB_STATE_STARTED); -+ if (oss_stream_thr_create(s) != CUBEB_OK) { -+ pthread_mutex_unlock(&s->mtx); -+ s->state_cb(s, s->user_ptr, CUBEB_STATE_ERROR); -+ return CUBEB_ERROR; -+ } -+ s->state = CUBEB_STATE_STARTED; -+ s->thread_created = true; -+ s->running = true; -+ pthread_mutex_unlock(&s->mtx); -+ return CUBEB_OK; -+} -+ -+static int -+oss_stream_get_position(cubeb_stream * s, uint64_t * position) -+{ -+ pthread_mutex_lock(&s->mtx); -+ *position = s->frames_written; -+ pthread_mutex_unlock(&s->mtx); -+ return CUBEB_OK; -+} -+ -+static int -+oss_stream_get_latency(cubeb_stream * s, uint32_t * latency) -+{ -+ int delay; -+ -+ if (ioctl(s->play.fd, SNDCTL_DSP_GETODELAY, &delay) == -1) { -+ return CUBEB_ERROR; -+ } -+ -+ /* Return number of frames there */ -+ *latency = delay / s->play.frame_size; -+ return CUBEB_OK; -+} -+ -+static int -+oss_stream_set_volume(cubeb_stream * stream, float volume) -+{ -+ if (volume < 0.0) -+ volume = 0.0; -+ else if (volume > 1.0) -+ volume = 1.0; -+ pthread_mutex_lock(&stream->mtx); -+ stream->volume = volume; -+ pthread_mutex_unlock(&stream->mtx); -+ return CUBEB_OK; -+} -+ -+static int -+oss_get_current_device(cubeb_stream * stream, cubeb_device ** const device) -+{ -+ *device = calloc(1, sizeof(cubeb_device)); -+ if (*device == NULL) { -+ return CUBEB_ERROR; -+ } -+ (*device)->input_name = stream->record.fd != -1 ? -+ strdup(stream->record.name) : NULL; -+ (*device)->output_name = stream->play.fd != -1 ? -+ strdup(stream->play.name) : NULL; -+ return CUBEB_OK; -+} -+ -+static int -+oss_stream_device_destroy(cubeb_stream * stream, cubeb_device * device) -+{ -+ (void)stream; -+ free(device->input_name); -+ free(device->output_name); -+ free(device); -+ return CUBEB_OK; -+} -+ -+static struct cubeb_ops const oss_ops = { -+ .init = oss_init, -+ .get_backend_id = oss_get_backend_id, -+ .get_max_channel_count = oss_get_max_channel_count, -+ .get_min_latency = oss_get_min_latency, -+ .get_preferred_sample_rate = oss_get_preferred_sample_rate, -+ .enumerate_devices = oss_enumerate_devices, -+ .device_collection_destroy = oss_device_collection_destroy, -+ .destroy = oss_destroy, -+ .stream_init = oss_stream_init, -+ .stream_destroy = oss_stream_destroy, -+ .stream_start = oss_stream_start, -+ .stream_stop = oss_stream_stop, -+ .stream_reset_default_device = NULL, -+ .stream_get_position = oss_stream_get_position, -+ .stream_get_latency = oss_stream_get_latency, -+ .stream_get_input_latency = NULL, -+ .stream_set_volume = oss_stream_set_volume, -+ .stream_get_current_device = oss_get_current_device, -+ .stream_device_destroy = oss_stream_device_destroy, -+ .stream_register_device_changed_callback = NULL, -+ .register_device_collection_changed = NULL}; diff --git a/www/firefox/files/patch-env-api-keys b/www/firefox/files/patch-env-api-keys index e20b012f27cf..a97a99d6b54a 100644 --- a/www/firefox/files/patch-env-api-keys +++ b/www/firefox/files/patch-env-api-keys @@ -2,20 +2,20 @@ --- build/moz.configure/keyfiles.configure +++ build/moz.configure/keyfiles.configure -@@ -18,6 +18,7 @@ def keyfile(desc, help=None, callback=lambda x: x): - @checking('for the %s key' % desc, lambda x: x and x is not no_key) - @imports(_from='__builtin__', _import='open') - @imports(_from='__builtin__', _import='IOError') -+ @imports(_from='os', _import='environ') +@@ -19,6 +19,7 @@ def keyfile(desc, default=None, help=None, callback=lambda x: x): + @checking("for the %s key" % desc, lambda x: x and x is not no_key) + @imports(_from="__builtin__", _import="open") + @imports(_from="__builtin__", _import="IOError") ++ @imports(_from="os", _import="environ") def keyfile(value): if value: try: -@@ -28,7 +29,7 @@ def keyfile(desc, help=None, callback=lambda x: x): +@@ -29,7 +30,7 @@ def keyfile(desc, default=None, help=None, callback=lambda x: x): raise FatalCheckError("'%s' is empty." % value[0]) except IOError as e: raise FatalCheckError("'%s': %s." % (value[0], e.strerror)) - return no_key -+ return environ.get('MOZ_%s_KEY' % desc.upper().replace(' ', '_')) or no_key ++ return environ.get("MOZ_%s_KEY" % desc.upper().replace(" ", "_")) or no_key return keyfile diff --git a/www/firefox/files/patch-freebsd11 b/www/firefox/files/patch-freebsd11 new file mode 100644 index 000000000000..5478a3f12a3c --- /dev/null +++ b/www/firefox/files/patch-freebsd11 @@ -0,0 +1,21 @@ +Drop after FreeBSD 11 EOL, see https://svnweb.freebsd.org/changeset/base/303524 + +media/libcubeb/src/cubeb_oss.c:362:10: error: implicit declaration of function 'getline' is invalid in C99 [-Werror,-Wimplicit-function-declaration] + while (getline(&line, &linecap, sndstatfp) > 0) { + ^ +media/libcubeb/src/cubeb_oss.c:850:13: warning: comparison of integers of different signs: 'long' and 'unsigned int' [-Wsign-compare] + if (nfr > s->bufframes) { + ~~~ ^ ~~~~~~~~~~~~ + +--- media/libcubeb/src/cubeb_oss.c.orig 2020-12-07 23:35:05 UTC ++++ media/libcubeb/src/cubeb_oss.c +@@ -10,6 +10,9 @@ + * accompanying file LICENSE for details. + */ + ++#if defined(__FreeBSD__) && __FreeBSD__ < 12 ++#define _WITH_GETLINE ++#endif + #include + #include + #include -- cgit v1.2.3