MFH: r525108 r525155 r525478 r525512

www/firefox: update to 73.0

Changes:	https://www.mozilla.org/firefox/73.0/releasenotes/
PR:		243295
Security:	802e3138-b8af-4a89-a908-f103107e64b4
Approved by:	ports-secteam blanket
Differential Revision:	https://reviews.freebsd.org/D23146
This commit is contained in:
Jan Beich 2020-02-10 17:02:33 +00:00
parent 581ab60645
commit 3a80afeba6
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/branches/2020Q1/; revision=525721
9 changed files with 105 additions and 407 deletions

View File

@ -76,8 +76,8 @@ LDFLAGS+= -Wl,--as-needed
BUNDLE_LIBS= yes
BUILD_DEPENDS+= llvm${LLVM_DEFAULT}>0:devel/llvm${LLVM_DEFAULT} \
rust-cbindgen>=0.8.7:devel/rust-cbindgen \
${RUST_DEFAULT}>=1.35:lang/${RUST_DEFAULT} \
rust-cbindgen>=0.12.0:devel/rust-cbindgen \
${RUST_DEFAULT}>=1.39:lang/${RUST_DEFAULT} \
${LOCALBASE}/bin/python${PYTHON3_DEFAULT}:lang/python${PYTHON3_DEFAULT:S/.//g} \
node:www/node
MOZ_EXPORT+= ${CONFIGURE_ENV} \

View File

@ -2,18 +2,19 @@
# $FreeBSD$
PORTNAME= firefox
DISTVERSION= 72.0.2
DISTVERSION= 73.0
PORTREVISION= 2
PORTEPOCH= 1
CATEGORIES= www
MASTER_SITES= MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \
MOZILLA/${PORTNAME}/candidates/${DISTVERSION}-candidates/build1/source
MOZILLA/${PORTNAME}/candidates/${DISTVERSION}-candidates/build3/source
DISTFILES= ${DISTNAME}.source${EXTRACT_SUFX}
MAINTAINER= gecko@FreeBSD.org
COMMENT= Web browser based on the browser portion of Mozilla
BUILD_DEPENDS= nspr>=4.24:devel/nspr \
nss>=3.48:security/nss \
nss>=3.49.2:security/nss \
icu>=64.1,1:devel/icu \
libevent>=2.1.8:devel/libevent \
harfbuzz>=2.6.4:print/harfbuzz \

View File

@ -1,3 +1,3 @@
TIMESTAMP = 1579296956
SHA256 (firefox-72.0.2.source.tar.xz) = 77fd224bea885172d757aef587ad443f2171aa84e4297bca55df91a1951be389
SIZE (firefox-72.0.2.source.tar.xz) = 315848856
TIMESTAMP = 1581110080
SHA256 (firefox-73.0.source.tar.xz) = b57af802aae32d7f4624ce8b373701236b76904abcb893ded9e0cb5805ba6e17
SIZE (firefox-73.0.source.tar.xz) = 319387000

View File

@ -5,18 +5,18 @@ diff --git browser/app/profile/firefox.js browser/app/profile/firefox.js
index 75c2c5e435e35..4d8c09c02759b 100644
--- browser/app/profile/firefox.js
+++ browser/app/profile/firefox.js
@@ -45,8 +45,8 @@ pref("extensions.webextOptionalPermissionPrompts", tru
@@ -37,8 +37,8 @@ pref("extensions.webextOptionalPermissionPrompts", tru
// Preferences for AMO integration
pref("extensions.getAddons.cache.enabled", true);
pref("extensions.getAddons.get.url", "https://services.addons.mozilla.org/api/v3/addons/search/?guid=%IDS%&lang=%LOCALE%");
pref("extensions.getAddons.compatOverides.url", "https://services.addons.mozilla.org/api/v3/addons/compat-override/?guid=%IDS%&lang=%LOCALE%");
-pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/firefox/search?q=%TERMS%&platform=%OS%&appver=%VERSION%");
-pref("extensions.webservice.discoverURL", "https://discovery.addons.mozilla.org/%LOCALE%/firefox/discovery/pane/%VERSION%/%OS%/%COMPATIBILITY_MODE%");
+pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/firefox/search?q=%TERMS%&platform=Linux&appver=%VERSION%");
+pref("extensions.webservice.discoverURL", "https://discovery.addons.mozilla.org/%LOCALE%/firefox/discovery/pane/%VERSION%/Linux/%COMPATIBILITY_MODE%");
pref("extensions.getAddons.link.url", "https://addons.mozilla.org/%LOCALE%/firefox/");
pref("extensions.getAddons.themes.browseURL", "https://addons.mozilla.org/%LOCALE%/firefox/themes/?src=firefox");
@@ -186,8 +186,8 @@ pref("app.update.service.enabled", true);
pref("extensions.getAddons.langpacks.url", "https://services.addons.mozilla.org/api/v3/addons/language-tools/?app=firefox&type=language&appversion=%VERSION%");
pref("extensions.getAddons.discovery.api_url", "https://services.addons.mozilla.org/api/v4/discovery/?lang=%LOCALE%&edition=%DISTRIBUTION%");
@@ -169,8 +169,8 @@ pref("app.update.url", "https://aus5.mozilla.org/updat
// .. etc ..
//
pref("extensions.update.enabled", true);
@ -26,7 +26,7 @@ index 75c2c5e435e35..4d8c09c02759b 100644
+pref("extensions.update.background.url", "https://versioncheck-bg.addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=Linux&appABI=%APP_ABI%&locale=%APP_LOCALE%&currentAppVersion=%CURRENT_APP_VERSION%&updateType=%UPDATE_TYPE%&compatMode=%COMPATIBILITY_MODE%");
pref("extensions.update.interval", 86400); // Check for updates to Extensions and
// Themes every day
// Non-symmetric (not shared by extensions) extension-specific [update] preferences
diff --git toolkit/mozapps/extensions/internal/AddonRepository.jsm toolkit/mozapps/extensions/internal/AddonRepository.jsm
index f70fd8d7e3bd8..81e8cd7764fdf 100644
--- toolkit/mozapps/extensions/internal/AddonRepository.jsm

View File

@ -2,30 +2,15 @@ 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
@@ -165,16 +165,17 @@ option(env='PYTHON', nargs=1, help='Python interpreter')
# ==============================================================
@depends('PYTHON', check_build_environment, mozconfig, '--help')
@imports('os')
@imports('sys')
@imports('subprocess')
@imports(_from='mozbuild.configure.util', _import='LineIO')
@@ -211,6 +211,7 @@ option(env='PYTHON', nargs=1, help='Python 2.7 interpr
@imports(_from='mozbuild.virtualenv', _import='VirtualenvManager')
@imports(_from='mozbuild.virtualenv', _import='verify_python_version')
@imports(_from='mozbuild.virtualenv', _import='PY2')
+@imports(_from='__builtin__', _import='KeyError')
@imports('distutils.sysconfig')
def virtualenv_python(env_python, build_env, mozconfig, help):
def virtualenv_python2(env_python, build_env, mozconfig, help):
if help:
return
python = env_python[0] if env_python else None
# Ideally we'd rely on the mozconfig injection from mozconfig_options,
@@ -184,16 +185,22 @@ def virtualenv_python(env_python, build_env, mozconfig, help):
if 'PYTHON' in mozconfig['env']['added']:
python = mozconfig['env']['added']['PYTHON']
elif 'PYTHON' in mozconfig['env']['modified']:
python = mozconfig['env']['modified']['PYTHON'][1]
elif 'PYTHON' in mozconfig['vars']['added']:
@@ -242,6 +243,12 @@ def virtualenv_python2(env_python, build_env, mozconfi
python = mozconfig['vars']['added']['PYTHON']
elif 'PYTHON' in mozconfig['vars']['modified']:
python = mozconfig['vars']['modified']['PYTHON'][1]
@ -36,32 +21,50 @@ index 855214a..1e91d51 100644
+ except KeyError:
+ pass
with LineIO(lambda l: log.error(l)) as out:
verify_python_version(out)
topsrcdir, topobjdir = build_env.topsrcdir, build_env.topobjdir
if topobjdir.endswith('/js/src'):
topobjdir = topobjdir[:-7]
log.debug("python2: executable from configuration: %r" % python)
with LineIO(lambda l: log.info(l)) as out:
@@ -255,17 +262,20 @@ def virtualenv_python(env_python, build_env, mozconfig
log.info('Creating Python environment')
manager.build(python)
@@ -294,7 +301,10 @@ def virtualenv_python2(env_python, build_env, mozconfi
sys.executable, manager.python_path))
log.info('Reexecuting in the virtualenv')
if env_python:
- del os.environ['PYTHON']
+ try:
+ del os.environ['PYTHON']
+ except KeyError:
+ pass
# One would prefer to use os.execl, but that's completely borked on
# Windows.
sys.exit(subprocess.call([python] + sys.argv))
@@ -430,6 +440,7 @@ option(env='PYTHON3', nargs=1, help='Python 3 interpre
@imports(_from='mozbuild.virtualenv', _import='PY3')
@imports(_from='mozbuild.pythonutil', _import='find_python3_executable')
@imports(_from='mozbuild.pythonutil', _import='python_executable_version')
+@imports(_from='__builtin__', _import='KeyError')
def virtualenv_python3(env_python, build_env, mozillabuild, mozconfig, help):
if help:
return
@@ -465,6 +476,12 @@ def virtualenv_python3(env_python, build_env, mozillab
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']
+ except KeyError:
+ pass
python = normsep(manager.python_path)
if not normsep(sys.executable).startswith(normsep(virtualenvs_root)):
log.info('Reexecuting in the virtualenv')
if env_python:
- del os.environ['PYTHON']
+ try:
+ del os.environ['PYTHON']
+ except KeyError:
+ pass
# One would prefer to use os.execl, but that's completely borked on
# Windows.
sys.exit(subprocess.call([python] + sys.argv))
# We are now in the virtualenv
if not distutils.sysconfig.get_python_lib():
die('Could not determine python site packages directory')
log.debug("python3: executable from configuration: %r" % python)
@@ -545,7 +562,10 @@ def virtualenv_python3(env_python, build_env, mozillab
sys.executable, manager.python_path))
log.info('Re-executing in the virtualenv')
if env_python:
- del os.environ['PYTHON3']
+ try:
+ del os.environ['PYTHON3']
+ except KeyError:
+ pass
# One would prefer to use os.execl, but that's completely borked on
# Windows.
sys.exit(subprocess.call([python] + sys.argv))

View File

@ -1,238 +0,0 @@
commit 5f2329c58c1b
Author: myfreeweb <greg@unrelenting.technology>
Date: Wed Dec 18 20:25:00 2019 +0000
Bug 1556301 - Wayland-EGL/GLES support in glxtest
This allows GfxInfoX11 to get GLES3 and Mesa version from Wayland-EGL, which
allows automatic enablement of acceleration to work without Xwayland.
This also fixes bug 1578598 - WebRender did not work correctly
without this GL version information.
Differential Revision: https://phabricator.services.mozilla.com/D57474
---
toolkit/xre/glxtest.cpp | 132 +++++++++++++++++++++++++++++++++++--
widget/gtk/mozwayland/mozwayland.h | 1 +
2 files changed, 126 insertions(+), 7 deletions(-)
diff --git toolkit/xre/glxtest.cpp toolkit/xre/glxtest.cpp
index 7b33a5c2b08f0..a1e6036cb6002 100644
--- toolkit/xre/glxtest.cpp
+++ toolkit/xre/glxtest.cpp
@@ -36,6 +36,11 @@
#include "mozilla/Unused.h"
+#ifdef MOZ_WAYLAND
+#include "nsAppRunner.h" // for IsWaylandDisabled
+#include "mozilla/widget/mozwayland.h"
+#endif
+
// stuff from glx.h
typedef struct __GLXcontextRec* GLXContext;
typedef XID GLXPixmap;
@@ -74,6 +79,15 @@ typedef uint32_t GLenum;
#define GLX_RENDERER_ID_MESA 0x818E
// clang-format on
+// stuff from egl.h
+#define EGL_BLUE_SIZE 0x3022
+#define EGL_GREEN_SIZE 0x3023
+#define EGL_RED_SIZE 0x3024
+#define EGL_NONE 0x3038
+#define EGL_VENDOR 0x3053
+#define EGL_CONTEXT_CLIENT_VERSION 0x3098
+#define EGL_NO_CONTEXT nullptr
+
namespace mozilla {
namespace widget {
// the read end of the pipe, which will be used by GfxInfo
@@ -118,7 +132,10 @@ static int x_error_handler(Display*, XErrorEvent* ev) {
// care about leaking memory
extern "C" {
-static int get_egl_status(char* buf, int bufsize) {
+typedef void* EGLNativeDisplayType;
+
+static int get_egl_status(char* buf, int bufsize,
+ EGLNativeDisplayType native_dpy, bool gles_test) {
void* libegl = dlopen("libEGL.so.1", RTLD_LAZY);
if (!libegl) {
libegl = dlopen("libEGL.so", RTLD_LAZY);
@@ -164,7 +181,7 @@ static int get_egl_status(char* buf, int bufsize) {
return 0;
}
- EGLDisplay dpy = eglGetDisplay(nullptr);
+ EGLDisplay dpy = eglGetDisplay(native_dpy);
if (!dpy) {
dlclose(libegl);
return 0;
@@ -177,9 +194,87 @@ static int get_egl_status(char* buf, int bufsize) {
}
int length = 0;
+
+ if (gles_test) {
+ typedef void* EGLConfig;
+ typedef void* EGLContext;
+ typedef void* EGLSurface;
+
+ typedef EGLBoolean (*PFNEGLCHOOSECONFIGPROC)(
+ EGLDisplay dpy, EGLint const* attrib_list, EGLConfig* configs,
+ EGLint config_size, EGLint* num_config);
+ PFNEGLCHOOSECONFIGPROC eglChooseConfig =
+ cast<PFNEGLCHOOSECONFIGPROC>(eglGetProcAddress("eglChooseConfig"));
+
+ typedef EGLContext (*PFNEGLCREATECONTEXTPROC)(
+ EGLDisplay dpy, EGLConfig config, EGLContext share_context,
+ EGLint const* attrib_list);
+ PFNEGLCREATECONTEXTPROC eglCreateContext =
+ cast<PFNEGLCREATECONTEXTPROC>(eglGetProcAddress("eglCreateContext"));
+
+ typedef EGLSurface (*PFNEGLCREATEPBUFFERSURFACEPROC)(
+ EGLDisplay dpy, EGLConfig config, EGLint const* attrib_list);
+ PFNEGLCREATEPBUFFERSURFACEPROC eglCreatePbufferSurface =
+ cast<PFNEGLCREATEPBUFFERSURFACEPROC>(
+ eglGetProcAddress("eglCreatePbufferSurface"));
+
+ typedef EGLBoolean (*PFNEGLMAKECURRENTPROC)(
+ EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext context);
+ PFNEGLMAKECURRENTPROC eglMakeCurrent =
+ cast<PFNEGLMAKECURRENTPROC>(eglGetProcAddress("eglMakeCurrent"));
+
+ void* libgles = dlopen("libGLESv2.so.2", RTLD_LAZY);
+ if (!libgles) {
+ libgles = dlopen("libGLESv2.so", RTLD_LAZY);
+ }
+ if (!libgles) {
+ fatal_error("Unable to load libGLESv2");
+ }
+
+ typedef GLubyte* (*PFNGLGETSTRING)(GLenum);
+ PFNGLGETSTRING glGetString =
+ cast<PFNGLGETSTRING>(eglGetProcAddress("glGetString"));
+
+ if (!glGetString) {
+ // Implementations disagree about whether eglGetProcAddress or dlsym
+ // should be used for getting functions from the actual API, see
+ // https://github.com/anholt/libepoxy/commit/14f24485e33816139398d1bd170d617703473738
+ glGetString = cast<PFNGLGETSTRING>(dlsym(libgles, "glGetString"));
+ }
+
+ if (!glGetString) {
+ fatal_error("GLESv2 glGetString not found");
+ }
+
+ EGLint config_attrs[] = {EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8, EGL_NONE};
+ EGLConfig config;
+ EGLint num_config;
+ eglChooseConfig(dpy, config_attrs, &config, 1, &num_config);
+ EGLint ctx_attrs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
+ EGLContext ectx = eglCreateContext(dpy, config, EGL_NO_CONTEXT, ctx_attrs);
+ EGLSurface pbuf = eglCreatePbufferSurface(dpy, config, nullptr);
+ eglMakeCurrent(dpy, pbuf, pbuf, ectx);
+
+ const GLubyte* versionString = glGetString(GL_VERSION);
+ const GLubyte* vendorString = glGetString(GL_VENDOR);
+ const GLubyte* rendererString = glGetString(GL_RENDERER);
+
+ if (!versionString || !vendorString || !rendererString)
+ fatal_error("glGetString returned null");
+
+ length = snprintf(buf, bufsize,
+ "VENDOR\n%s\nRENDERER\n%s\nVERSION\n%s\nTFP\nTRUE\n",
+ vendorString, rendererString, versionString);
+ if (length >= bufsize) {
+ fatal_error("GL strings length too large for buffer size");
+ }
+ }
+
const char* driDriver = eglGetDisplayDriverName(dpy);
if (driDriver) {
- length = snprintf(buf, bufsize, "DRI_DRIVER\n%s\n", driDriver);
+ length +=
+ snprintf(buf + length, bufsize - length, "DRI_DRIVER\n%s\n", driDriver);
}
eglTerminate(dpy);
@@ -187,7 +282,7 @@ static int get_egl_status(char* buf, int bufsize) {
return length;
}
-void glxtest() {
+static void close_logging() {
// we want to redirect to /dev/null stdout, stderr, and while we're at it,
// any PR logging file descriptors. To that effect, we redirect all positive
// file descriptors up to what open() returns here. In particular, 1 is stdout
@@ -199,8 +294,32 @@ void glxtest() {
if (getenv("MOZ_AVOID_OPENGL_ALTOGETHER"))
fatal_error(
"The MOZ_AVOID_OPENGL_ALTOGETHER environment variable is defined");
+}
+
+#ifdef MOZ_WAYLAND
+bool wayland_egltest() {
+ // NOTE: returns false to fall back to X11 when the Wayland socket doesn't
+ // exist but fails with fatal_error if something actually went wrong
+ struct wl_display* dpy = wl_display_connect(nullptr);
+ if (!dpy) return false;
+
+ enum { bufsize = 2048 };
+ char buf[bufsize];
+
+ int length = get_egl_status(buf, bufsize, (EGLNativeDisplayType)dpy, true);
+ if (length >= bufsize) {
+ fatal_error("GL strings length too large for buffer size");
+ }
- ///// Open libGL and load needed symbols /////
+ ///// Finally write data to the pipe
+ mozilla::Unused << write(write_end_of_the_pipe, buf, length);
+
+ return true;
+}
+#endif
+
+void glxtest() {
+ ///// Open libGL and load needed symbols /////
#if defined(__OpenBSD__) || defined(__NetBSD__)
# define LIBGL_FILENAME "libGL.so"
#else
@@ -401,7 +520,7 @@ void glxtest() {
// If we failed to get the driver name from X, try via EGL_MESA_query_driver.
// We are probably using Wayland.
if (!gotDriDriver) {
- length += get_egl_status(buf + length, bufsize - length);
+ length += get_egl_status(buf + length, bufsize - length, nullptr, false);
if (length >= bufsize) {
fatal_error("GL strings length too large for buffer size");
}
@@ -431,7 +550,12 @@ bool fire_glxtest_process() {
if (pid == 0) {
close(pfd[0]);
write_end_of_the_pipe = pfd[1];
- glxtest();
+ close_logging();
+ // TODO: --display command line argument is not properly handled
+#ifdef MOZ_WAYLAND
+ if (IsWaylandDisabled() || !wayland_egltest())
+#endif
+ glxtest();
close(pfd[1]);
_exit(0);
}
diff --git widget/gtk/mozwayland/mozwayland.h widget/gtk/mozwayland/mozwayland.h
index b31742fb2bc33..8aa0ce6f4665a 100644
--- widget/gtk/mozwayland/mozwayland.h
+++ widget/gtk/mozwayland/mozwayland.h
@@ -20,6 +20,7 @@
extern "C" {
#endif
+MOZ_EXPORT struct wl_display* wl_display_connect(const char* name);
MOZ_EXPORT int wl_display_roundtrip_queue(struct wl_display* display,
struct wl_event_queue* queue);
MOZ_EXPORT uint32_t wl_proxy_get_version(struct wl_proxy* proxy);

View File

@ -0,0 +1,29 @@
Disable STL wrappers in some places to help libc++ 9
diff --git config/external/rlbox/moz.build config/external/rlbox/moz.build
index d216e62cad861..391bbdf566b88 100644
--- config/external/rlbox/moz.build
+++ config/external/rlbox/moz.build
@@ -26,4 +26,7 @@ SOURCES += [
'rlbox_thread_locals.cpp'
]
+# bug 1594027
+DisableStlWrapping()
+
FINAL_LIBRARY = 'xul'
\ No newline at end of file
diff --git gfx/graphite2/src/moz.build gfx/graphite2/src/moz.build
index 447cd861126a3..8a4fcd814e6fb 100755
--- gfx/graphite2/src/moz.build
+++ gfx/graphite2/src/moz.build
@@ -69,6 +69,9 @@ if CONFIG['MOZ_WASM_SANDBOXING_GRAPHITE']:
# thebes
DefineAndWasmDefine('GRAPHITE2_STATIC', True)
+# bug 1594027
+DisableStlWrapping()
+
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()

View File

@ -43,7 +43,7 @@ new file mode 100644
index 0000000000000..24e8d7a03274a
--- /dev/null
+++ gfx/graphite2/geckoextra/moz.build
@@ -0,0 +1,20 @@
@@ -0,0 +1,21 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
@ -52,6 +52,7 @@ index 0000000000000..24e8d7a03274a
+
+EXPORTS.graphite2 += [
+ 'include/GraphiteExtra.h',
+ 'include/GraphiteStructsForRLBox.h',
+]
+
+UNIFIED_SOURCES += [
@ -226,7 +227,7 @@ index 95a58b634593..b614eef85c89 100644
+ * 100 + GR2_VERSION_BUGFIX >= \
+ (major) * 10000 + (minor) * 100 + (bugfix) )
+ ], [
+ #if !GR2_VERSION_REQUIRE(1,3,12)
+ #if !GR2_VERSION_REQUIRE(1,3,13)
+ #error "Insufficient graphite2 version."
+ #endif
+ ], [],
@ -277,7 +278,7 @@ index 9297e4d6f501..d8e273887e4b 100644
+option('--with-system-harfbuzz',
+ help="Use system harfbuzz (located with pkgconfig)")
+
+system_harfbuzz = pkg_check_modules('MOZ_HARFBUZZ', 'harfbuzz >= 2.6.2',
+system_harfbuzz = pkg_check_modules('MOZ_HARFBUZZ', 'harfbuzz >= 2.6.4',
+ when='--with-system-harfbuzz')
+
+set_config('MOZ_SYSTEM_HARFBUZZ', depends_if(system_harfbuzz)(lambda _: True))

View File

@ -1,113 +1,15 @@
https://github.com/kinetiknz/cubeb/commit/a71f116501fe39962599c435ef65066f7e7ea9f5
https://github.com/kinetiknz/cubeb/commit/3025cbec70f3ed097ec9a2f33a4823316a29efc4
https://github.com/kinetiknz/cubeb/commit/bb2735fa2ff680fdc615edbb363b19ff4a759503
https://github.com/kinetiknz/cubeb/pull/564
https://github.com/kinetiknz/cubeb/commit/3ab507569153
diff --git a/src/cubeb_sndio.c b/src/cubeb_sndio.c
index 4a05bd84..34b3513d 100644
--- media/libcubeb/src/cubeb_sndio.c
+++ media/libcubeb/src/cubeb_sndio.c
@@ -32,6 +32,7 @@
X(sio_eof) \
X(sio_getpar) \
X(sio_initpar) \
+ X(sio_nfds) \
X(sio_onmove) \
X(sio_open) \
X(sio_pollfd) \
@@ -124,6 +125,23 @@ s16_to_float(void *ptr, long nsamp)
*(--dst) = (1. / 32768) * *(--src);
}
+static const char *
+sndio_get_device()
+{
@@ -128,7 +128,7 @@ s16_to_float(void *ptr, long nsamp)
static const char *
sndio_get_device()
{
-#ifndef __OpenBSD__
+#ifdef __linux__
+ /*
+ * On other platforms default to sndio devices,
+ * so cubebs other backends can be used instead.
+ */
+ const char *dev = getenv("AUDIODEVICE");
+ if (dev == NULL || *dev == '\0')
+ return "snd/0";
+ return dev;
+#else
+ return SIO_DEVANY;
+#endif
+}
+
static void
sndio_onmove(void *arg, int delta)
{
@@ -135,18 +153,23 @@ sndio_onmove(void *arg, int delta)
static void *
sndio_mainloop(void *arg)
{
-#define MAXFDS 8
- struct pollfd pfds[MAXFDS];
+ struct pollfd *pfds;
cubeb_stream *s = arg;
int n, eof = 0, prime, nfds, events, revents, state = CUBEB_STATE_STARTED;
size_t pstart = 0, pend = 0, rstart = 0, rend = 0;
long nfr;
+ nfds = WRAP(sio_nfds)(s->hdl);
+ pfds = calloc(nfds, sizeof (struct pollfd));
+ if (pfds == NULL)
+ return NULL;
+
DPR("sndio_mainloop()\n");
s->state_cb(s, s->arg, CUBEB_STATE_STARTED);
pthread_mutex_lock(&s->mtx);
if (!WRAP(sio_start)(s->hdl)) {
pthread_mutex_unlock(&s->mtx);
+ free(pfds);
return NULL;
}
DPR("sndio_mainloop(), started\n");
@@ -274,6 +297,7 @@ sndio_mainloop(void *arg)
s->hwpos = s->swpos;
pthread_mutex_unlock(&s->mtx);
s->state_cb(s, s->arg, state);
+ free(pfds);
return NULL;
}
@@ -281,6 +305,9 @@ sndio_mainloop(void *arg)
sndio_init(cubeb **context, char const *context_name)
{
void * libsndio = NULL;
+ struct sio_hdl *hdl;
+
+ assert(context);
#ifndef DISABLE_LIBSNDIO_DLOPEN
libsndio = dlopen("libsndio.so.7.0", RTLD_LAZY);
@@ -305,8 +332,17 @@ sndio_init(cubeb **context, char const *context_name)
#undef LOAD
#endif
+ /* test if sndio works */
+ hdl = WRAP(sio_open)(sndio_get_device(), SIO_PLAY, 1);
+ if (hdl == NULL) {
+ return CUBEB_ERROR;
+ }
+ WRAP(sio_close)(hdl);
+
DPR("sndio_init(%s)\n", context_name);
- *context = malloc(sizeof(*context));
+ *context = malloc(sizeof(**context));
+ if (*context == NULL)
+ return CUBEB_ERROR;
(*context)->libsndio = libsndio;
(*context)->ops = &sndio_ops;
(void)context_name;
@@ -377,7 +413,7 @@ sndio_stream_init(cubeb * context,
goto err;
}
s->context = context;
- s->hdl = WRAP(sio_open)(NULL, s->mode, 1);
+ s->hdl = WRAP(sio_open)(sndio_get_device(), s->mode, 1);
if (s->hdl == NULL) {
DPR("sndio_stream_init(), sio_open() failed\n");
goto err;
/*
* On other platforms default to sndio devices,
* so cubebs other backends can be used instead.