firefox68: Update to 68.6.0

While here,

- Remove OSS support now that cubeb_sun has been stable for a long while
- Appease pkglint

Security fixes in this release:

#CVE-2020-6805: Use-after-free when removing data about origins
#CVE-2020-6806: BodyStream::OnInputStreamReady was missing protections
#CVE-2020-6807: Use-after-free in cubeb during stream destruction
#CVE-2020-6811: Devtools' 'Copy as cURL' feature did not fully escape
#CVE-2019-20503: Out of bounds reads in sctp_load_addresses_from_init
#CVE-2020-6812: The names of AirPods with personally identifiable
#CVE-2020-6814: Memory safety bugs fixed in Firefox 74 and Firefox ESR 68.6
This commit is contained in:
nia 2020-03-12 19:39:35 +00:00
parent 8bf4921c9b
commit 5d4d28f2d3
13 changed files with 49 additions and 630 deletions

View file

@ -1,12 +1,11 @@
# $NetBSD: Makefile,v 1.14 2020/03/10 22:11:10 wiz Exp $
# $NetBSD: Makefile,v 1.15 2020/03/12 19:39:35 nia Exp $
FIREFOX_VER= ${MOZ_BRANCH}${MOZ_BRANCH_MINOR}
MOZ_BRANCH= 68.5
MOZ_BRANCH= 68.6
MOZ_BRANCH_MINOR= .0esr
DISTNAME= firefox-${FIREFOX_VER}.source
PKGNAME= ${DISTNAME:S/.source//:S/b/beta/:S/esr//:S/firefox-/firefox68-/}
PKGREVISION= 3
CATEGORIES= www
MASTER_SITES+= ${MASTER_SITE_MOZILLA:=firefox/releases/${FIREFOX_VER}/source/}
EXTRACT_SUFX= .tar.xz

View file

@ -1,4 +1,4 @@
@comment $NetBSD: PLIST,v 1.4 2020/02/15 12:48:22 nia Exp $
@comment $NetBSD: PLIST,v 1.5 2020/03/12 19:39:35 nia Exp $
bin/firefox68
lib/firefox68/actors/AudioPlaybackChild.jsm
lib/firefox68/actors/AutoplayChild.jsm
@ -2887,13 +2887,13 @@ lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/loda
${PLIST.debug}lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dev.js
${PLIST.debug}lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dom-dev.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dom-factories.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dom-server.js
${PLIST.debug}lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dom-server-dev.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dom-test-utils.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dom-server.js
${PLIST.debug}lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dom-test-utils-dev.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dom-test-utils.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-dom.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-prop-types.js
${PLIST.debug}lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-prop-types-dev.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-prop-types.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-redux.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-router-dom.js
lib/firefox68/browser/chrome/devtools/modules/devtools/client/shared/vendor/react-test-renderer-shallow.js
@ -4271,6 +4271,7 @@ lib/firefox68/browser/features/webcompat@mozilla.org/injections/css/bug1577297-k
lib/firefox68/browser/features/webcompat@mozilla.org/injections/css/bug1605611-maps.google.com-directions-time.css
lib/firefox68/browser/features/webcompat@mozilla.org/injections/css/bug1609991-cracked.com-flex-basis-fix.css
lib/firefox68/browser/features/webcompat@mozilla.org/injections/css/bug1610016-gaana.com-input-position-fix.css
lib/firefox68/browser/features/webcompat@mozilla.org/injections/css/bug1610344-directv.com.co-hide-unsupported-message.css
lib/firefox68/browser/features/webcompat@mozilla.org/injections/js/bug0000000-testbed-js-injection.js
lib/firefox68/browser/features/webcompat@mozilla.org/injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js
lib/firefox68/browser/features/webcompat@mozilla.org/injections/js/bug1457335-histography.io-ua-change.js

View file

@ -1,14 +1,13 @@
$NetBSD: distinfo,v 1.10 2020/02/15 12:48:22 nia Exp $
$NetBSD: distinfo,v 1.11 2020/03/12 19:39:35 nia Exp $
SHA1 (firefox-68.5.0esr.source.tar.xz) = 5e74dc0335b09819b24285d23e7746ca70af1dae
RMD160 (firefox-68.5.0esr.source.tar.xz) = 34b2446b42e98de3e9f5798466bd4f49375dd44a
SHA512 (firefox-68.5.0esr.source.tar.xz) = 0acf4ecd47bccf062ab330231e36355f5d84e66ab411f653ae3160583613840925bb473c0f7dfa4b15311a543940293c4633516851c9466c4b0133c9271710d3
Size (firefox-68.5.0esr.source.tar.xz) = 314176068 bytes
SHA1 (patch-aa) = 1f292aae7d37bd480ba834324b737bfebee52503
SHA1 (firefox-68.6.0esr.source.tar.xz) = 85d35d0a0190d56585f93c9f117d5c0f52bcbc44
RMD160 (firefox-68.6.0esr.source.tar.xz) = d11d44f5400ca1f5c3b721dd974a77fbf7cf7e7a
SHA512 (firefox-68.6.0esr.source.tar.xz) = 84565d654ed8bd2d036d08de4d16e41ae8881f0b20b34424ab347d50a37384acf50c04f74269720e79db28028569dff79f2b910848939ff87c078f36684a75a3
Size (firefox-68.6.0esr.source.tar.xz) = 313814396 bytes
SHA1 (patch-aa) = 9f7200c411cd2217a80ec10a276c8877bc6b845c
SHA1 (patch-browser_app_profile_firefox.js) = 076cc2892547bac07fe907533f4e821f13f5738e
SHA1 (patch-build_moz.configure_old.configure) = 05963b12fd908d90e3378b30cff7e48291b8a447
SHA1 (patch-dom_base_nsAttrName.h) = ac7ba441a3b27df2855cf2673eea36b1cb44ad49
SHA1 (patch-dom_media_CubebUtils.cpp) = b1b4f981c4bede877e3bd092d2648d4b8cbc73a5
SHA1 (patch-dom_media_CubebUtils.cpp) = 3cd2c65ab281d802c56216565970450767a3fb24
SHA1 (patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp) = e458c9c8dc66edc69c1874734af28a77fc5e3993
SHA1 (patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h) = 2f73c76c48852613e0c55c1680fcc2a9eb3cf4ef
SHA1 (patch-gfx_gl_GLContextProviderGLX.cpp) = 2c909a10a341e600392417240ad0c556f495d6ba
@ -24,15 +23,14 @@ SHA1 (patch-js_src_threading_posix_Thread.cpp) = 47e612a676e614fd6dd43b8a3140218
SHA1 (patch-js_src_util_NativeStack.cpp) = 2c6f844d38343f40ebbc8fd665279256e4ae6d35
SHA1 (patch-media_ffvpx_libavutil_arm_bswap.h) = de58daa0fd23d4fec50426602b65c9ea5862558a
SHA1 (patch-media_libcubeb_gtest_moz.build) = ea6dcc7ceeb76ce1fb9d508cf43080a2eef3a9e4
SHA1 (patch-media_libcubeb_src_cubeb.c) = e3446562ed16ec9643df42ee0b9c46ee91f22913
SHA1 (patch-media_libcubeb_src_cubeb.c) = dcc173f0bef8b7b12c45739bf04577f3292a517e
SHA1 (patch-media_libcubeb_src_cubeb__alsa.c) = f359a66a22f11142d05746e15894d998d3e3bf5a
SHA1 (patch-media_libcubeb_src_cubeb__oss.c) = 103f751d5a7bc14a81a6ed43e1afc722bc092f7e
SHA1 (patch-media_libcubeb_src_moz.build) = dcca90cb5132442877712cd7b1f4e832c93d2655
SHA1 (patch-media_libcubeb_update.sh) = 4508319d8534a0cc983e4767c2142169af9e5033
SHA1 (patch-media_libcubeb_src_moz.build) = 7d66d9e0d7129b2106885201f88355262ee1a22a
SHA1 (patch-media_libcubeb_update.sh) = 8dcc4ca8e2812b4063f28e5d6308abbee0b1c9d9
SHA1 (patch-media_libpng_pngpriv.h) = c8084332560017cd7c9b519b61d125fa28af0dbc
SHA1 (patch-nsprpub_pr_src_pthreads_ptsynch.c) = c39a222c5ab16c26cb214e5e53a0b61291a00512
SHA1 (patch-toolkit_components_terminator_nsTerminator.cpp) = e5700d95302ef9672b404ab19e13ef7ba3ede5cf
SHA1 (patch-toolkit_library_moz.build) = 102e3713552c26f76e8b4e473846bb8fbc44b278
SHA1 (patch-toolkit_library_moz.build) = 57516a1cc888fdbaf39ba90f73e5de488ad1f01e
SHA1 (patch-toolkit_modules_subprocess_subprocess__shared__unix.js) = 22a39e54e042ab2270a3cb54e4e307c8900cad12
SHA1 (patch-toolkit_moz.configure) = 40ee147cc1d2c62dd6c83b3f67ce9e61f758ea57
SHA1 (patch-toolkit_mozapps_installer_packager.mk) = b2343fbad2556504dfd13601c02e6e2357c7d2bc

View file

@ -1,4 +1,4 @@
# $NetBSD: mozilla-common.mk,v 1.6 2019/12/22 14:33:58 gdt Exp $
# $NetBSD: mozilla-common.mk,v 1.7 2020/03/12 19:39:35 nia Exp $
#
# common Makefile fragment for mozilla packages based on gecko 2.0.
#
@ -38,8 +38,8 @@ BUILD_DEPENDS+= yasm>=1.1:../../devel/yasm
.endif
# For rustc/cargo detection
CONFIGURE_ARGS+= --target=${MACHINE_GNU_PLATFORM:Q}
CONFIGURE_ARGS+= --host=${MACHINE_GNU_PLATFORM:Q}
CONFIGURE_ARGS+= --target=${MACHINE_GNU_PLATFORM}
CONFIGURE_ARGS+= --host=${MACHINE_GNU_PLATFORM}
CONFIGURE_ENV+= BINDGEN_CFLAGS="-isystem${PREFIX}/include/nspr \
-isystem${X11BASE}/include/pixman-1"
@ -126,7 +126,7 @@ CONFIG_SUB_OVERRIDE+= ${MOZILLA_DIR}js/src/build/autoconf/config.sub
CONFIG_SUB_OVERRIDE+= ${MOZILLA_DIR}nsprpub/build/autoconf/config.sub
CONFIG_SUB_OVERRIDE+= ${MOZILLA_DIR}/js/ctypes/libffi/config.sub
CONFIGURE_ENV+= CPP=${CPP}
CONFIGURE_ENV+= CPP=${CPP:Q}
# Build outside ${WRKSRC}
# Try to avoid conflict with config/makefiles/xpidl/Makefile.in

View file

@ -1,10 +1,10 @@
# $NetBSD: options.mk,v 1.7 2020/02/27 11:06:30 nia Exp $
# $NetBSD: options.mk,v 1.8 2020/03/12 19:39:35 nia Exp $
PKG_OPTIONS_VAR= PKG_OPTIONS.firefox
PKG_SUPPORTED_OPTIONS= official-mozilla-branding
PKG_SUPPORTED_OPTIONS+= debug debug-info mozilla-jemalloc webrtc
PKG_SUPPORTED_OPTIONS+= alsa oss pulseaudio dbus wayland
PKG_SUPPORTED_OPTIONS+= alsa pulseaudio dbus wayland
PLIST_VARS+= jemalloc debug
.include "../../devel/wayland/platform.mk"
@ -15,7 +15,7 @@ PKG_SUGGESTED_OPTIONS+= wayland
.if ${OPSYS} == "Linux"
PKG_SUGGESTED_OPTIONS+= pulseaudio mozilla-jemalloc dbus webrtc
.else
PKG_SUGGESTED_OPTIONS+= oss dbus
PKG_SUGGESTED_OPTIONS+= dbus
.endif
.if ${OPSYS} == "NetBSD" && empty(OS_VERSION:M[0-8].*)
@ -31,11 +31,6 @@ CONFIGURE_ARGS+= --enable-alsa
CONFIGURE_ARGS+= --disable-alsa
.endif
.if !empty(PKG_OPTIONS:Moss)
CONFIGURE_ARGS+= --with-oss
.include "../../mk/oss.buildlink3.mk"
.endif
.if !empty(PKG_OPTIONS:Mmozilla-jemalloc)
PLIST.jemalloc= yes
CONFIGURE_ARGS+= --enable-jemalloc

View file

@ -1,79 +1,25 @@
$NetBSD: patch-aa,v 1.1 2019/09/21 07:31:44 ryoon Exp $
$NetBSD: patch-aa,v 1.2 2020/03/12 19:39:35 nia Exp $
* Add OSS audio support
* Add Sun audio support
* Disable libav-fft on SunOS (relocation errors)
--- old-configure.in.orig 2019-05-29 15:39:16.000000000 +0000
--- old-configure.in.orig 2020-03-05 20:57:20.000000000 +0000
+++ old-configure.in
@@ -2043,6 +2043,71 @@ MOZ_WEBM_ENCODER=1
@@ -1987,6 +1987,19 @@ MOZ_WEBM_ENCODER=1
AC_DEFINE(MOZ_WEBM_ENCODER)
AC_SUBST(MOZ_WEBM_ENCODER)
+dnl ==================================
+dnl = Check OSS/sunaudio availability
+dnl = Check sunaudio availability
+dnl ==================================
+
+dnl If using Linux, Solaris or BSDs, ensure that OSS/sunaudio is available
+dnl If using Solaris or NetBSD, ensure that sunaudio is available
+case "$OS_TARGET" in
+Linux|DragonFly|FreeBSD|GNU/kFreeBSD)
+ MOZ_OSS=1
+ ;;
+SunOS|NetBSD)
+ MOZ_SUNAUDIO=1
+ ;;
+esac
+
+MOZ_ARG_WITH_STRING(oss,
+[ --with-oss[=PFX] Enable OpenSoundSystem support [installed at prefix PFX]],
+ OSSPREFIX=$withval)
+
+if test -n "$OSSPREFIX"; then
+ if test "$OSSPREFIX" != "no"; then
+ MOZ_OSS=1
+ else
+ MOZ_OSS=
+ fi
+fi
+
+_SAVE_CFLAGS=$CFLAGS
+_SAVE_LIBS=$LIBS
+if test -n "$MOZ_OSS"; then
+ dnl Prefer 4Front implementation
+ AC_MSG_CHECKING([MOZ_OSS_CFLAGS])
+ if test "$OSSPREFIX" != "yes"; then
+ oss_conf=${OSSPREFIX%/usr}/etc/oss.conf
+ if test -f "$oss_conf"; then
+ . "$oss_conf"
+ else
+ OSSLIBDIR=$OSSPREFIX/lib/oss
+ fi
+ if test -d "$OSSLIBDIR"; then
+ MOZ_OSS_CFLAGS="$MOZ_OSS_CFLAGS -I$OSSLIBDIR/include"
+ fi
+ fi
+ AC_MSG_RESULT([$MOZ_OSS_CFLAGS])
+
+ CFLAGS="$CFLAGS $MOZ_OSS_CFLAGS"
+ MOZ_CHECK_HEADERS(sys/soundcard.h soundcard.h)
+
+ if test "$ac_cv_header_sys_soundcard_h" != "yes" -a \
+ "$ac_cv_header_soundcard_h" != "yes"; then
+ AC_MSG_ERROR([Need OSS for Ogg, Wave or WebM decoding on $OS_TARGET. Disable with --without-oss.])
+ fi
+
+ dnl Assume NetBSD implementation over SunAudio
+ AC_CHECK_LIB(ossaudio, _oss_ioctl,
+ [AC_DEFINE_UNQUOTED(CUBEB_OSS_DEFAULT_OUTPUT, "/dev/audio")
+ MOZ_OSS_LIBS="$MOZ_OSS_LIBS -lossaudio"])
+fi
+CFLAGS=$_SAVE_CFLAGS
+LIBS=$_SAVE_LIBS
+
+AC_SUBST(MOZ_SUNAUDIO)
+AC_SUBST(MOZ_OSS)
+AC_SUBST_LIST(MOZ_OSS_CFLAGS)
+AC_SUBST_LIST(MOZ_OSS_LIBS)
+
dnl ========================================================
dnl NegotiateAuth

View file

@ -1,12 +0,0 @@
$NetBSD: patch-build_moz.configure_old.configure,v 1.1 2019/09/21 07:31:44 ryoon Exp $
--- build/moz.configure/old.configure.orig 2019-07-06 01:48:30.000000000 +0000
+++ build/moz.configure/old.configure
@@ -248,6 +248,7 @@ def old_configure_options(*options):
'--with-nspr-prefix',
'--with-nss-exec-prefix',
'--with-nss-prefix',
+ '--with-oss',
'--with-qemu-exe',
'--with-sixgill',
'--with-system-bz2',

View file

@ -1,4 +1,6 @@
$NetBSD: patch-dom_media_CubebUtils.cpp,v 1.1 2019/09/21 07:31:44 ryoon Exp $
$NetBSD: patch-dom_media_CubebUtils.cpp,v 1.2 2020/03/12 19:39:35 nia Exp $
Add Sun audio support.
--- dom/media/CubebUtils.cpp.orig 2019-07-06 01:48:31.000000000 +0000
+++ dom/media/CubebUtils.cpp
@ -7,7 +9,7 @@ $NetBSD: patch-dom_media_CubebUtils.cpp,v 1.1 2019/09/21 07:31:44 ryoon Exp $
const char* AUDIOSTREAM_BACKEND_ID_STR[] = {
"jack", "pulse", "alsa", "audiounit", "audioqueue", "wasapi",
- "winmm", "directsound", "sndio", "opensl", "audiotrack", "kai"};
+ "winmm", "directsound", "sndio", "opensl", "audiotrack", "kai", "oss", "sun"};
+ "winmm", "directsound", "sndio", "opensl", "audiotrack", "kai", "sun"};
/* Index for failures to create an audio stream the first time. */
const int CUBEB_BACKEND_INIT_FAILURE_FIRST =
ArrayLength(AUDIOSTREAM_BACKEND_ID_STR);

View file

@ -1,9 +1,8 @@
$NetBSD: patch-media_libcubeb_src_cubeb.c,v 1.1 2019/09/21 07:31:44 ryoon Exp $
$NetBSD: patch-media_libcubeb_src_cubeb.c,v 1.2 2020/03/12 19:39:35 nia Exp $
* Support OSS audio
* Support Sun audio
--- media/libcubeb/src/cubeb.c.orig 2019-06-09 08:15:58.000000000 +0000
--- media/libcubeb/src/cubeb.c.orig 2020-03-05 20:57:11.000000000 +0000
+++ media/libcubeb/src/cubeb.c
@@ -51,6 +51,9 @@ int wasapi_init(cubeb ** context, char c
#if defined(USE_SNDIO)
@ -15,28 +14,7 @@ $NetBSD: patch-media_libcubeb_src_cubeb.c,v 1.1 2019/09/21 07:31:44 ryoon Exp $
#if defined(USE_OPENSL)
int opensl_init(cubeb ** context, char const * context_name);
#endif
@@ -60,6 +63,9 @@ int audiotrack_init(cubeb ** context, ch
#if defined(USE_KAI)
int kai_init(cubeb ** context, char const * context_name);
#endif
+#if defined(USE_OSS)
+int oss_init(cubeb ** context, char const * context_name);
+#endif
static int
validate_stream_params(cubeb_stream_params * input_stream_params,
@@ -160,6 +166,10 @@ cubeb_init(cubeb ** context, char const
#if defined(USE_KAI)
init_oneshot = kai_init;
#endif
+ } else if (!strcmp(backend_name, "oss")) {
+#if defined(USE_OSS)
+ init_oneshot = oss_init;
+#endif
} else {
/* Already set */
}
@@ -195,6 +205,9 @@ cubeb_init(cubeb ** context, char const
@@ -195,6 +198,9 @@ cubeb_init(cubeb ** context, char const
#if defined(USE_SNDIO)
sndio_init,
#endif
@ -46,13 +24,3 @@ $NetBSD: patch-media_libcubeb_src_cubeb.c,v 1.1 2019/09/21 07:31:44 ryoon Exp $
#if defined(USE_OPENSL)
opensl_init,
#endif
@@ -204,6 +217,9 @@ cubeb_init(cubeb ** context, char const
#if defined(USE_KAI)
kai_init,
#endif
+#if defined(USE_OSS)
+ oss_init,
+#endif
};
int i;

View file

@ -1,461 +0,0 @@
$NetBSD: patch-media_libcubeb_src_cubeb__oss.c,v 1.1 2019/09/21 07:31:44 ryoon Exp $
* Restore OSS audio support code
* fix wrong latency values in stream_init (PR pkg/54206)
--- media/libcubeb/src/cubeb_oss.c.orig 2019-05-24 13:05:19.117086384 +0000
+++ media/libcubeb/src/cubeb_oss.c
@@ -0,0 +1,453 @@
+/*
+ * Copyright © 2014 Mozilla Foundation
+ *
+ * This program is made available under an ISC-style license. See the
+ * accompanying file LICENSE for details.
+ */
+#if defined(HAVE_SYS_SOUNDCARD_H)
+#include <sys/soundcard.h>
+#else
+#include <soundcard.h>
+#endif
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <assert.h>
+
+#include "cubeb/cubeb.h"
+#include "cubeb-internal.h"
+
+#ifndef CUBEB_OSS_DEFAULT_OUTPUT
+#define CUBEB_OSS_DEFAULT_OUTPUT "/dev/dsp"
+#endif
+
+#define OSS_BUFFER_SIZE 1024
+
+struct cubeb {
+ struct cubeb_ops const * ops;
+};
+
+struct cubeb_stream {
+ /* Note: Must match cubeb_stream layout in cubeb.c. */
+ cubeb * context;
+ void * user_ptr;
+ /**/
+
+ cubeb_data_callback data_callback;
+ cubeb_state_callback state_callback;
+ float volume;
+ float panning;
+
+ pthread_mutex_t state_mutex;
+ pthread_cond_t state_cond;
+
+ int running;
+ int stopped;
+ int floating;
+
+ /* These two vars are needed to support old versions of OSS */
+ unsigned int position_bytes;
+ unsigned int last_position_bytes;
+
+ uint64_t written_frags; /* The number of fragments written to /dev/dsp */
+ uint64_t missed_frags; /* fragments output with stopped stream */
+
+ cubeb_stream_params params;
+ int fd;
+ pthread_t th;
+};
+
+static struct cubeb_ops const oss_ops;
+
+int oss_init(cubeb ** context, char const * context_name)
+{
+ cubeb* ctx = (cubeb*)malloc(sizeof(cubeb));
+ ctx->ops = &oss_ops;
+ *context = ctx;
+ return CUBEB_OK;
+}
+
+static void oss_destroy(cubeb *ctx)
+{
+ free(ctx);
+}
+
+static char const * oss_get_backend_id(cubeb * context)
+{
+ static char oss_name[] = "oss";
+ return oss_name;
+}
+
+static int oss_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
+{
+ *max_channels = 2; /* Let's support only stereo for now */
+ return CUBEB_OK;
+}
+
+static int oss_get_min_latency(cubeb * context, cubeb_stream_params params,
+ uint32_t * latency_frames)
+{
+ (void)context;
+ /* 40ms is a big enough number to work ok */
+ *latency_frames = 40 * params.rate / 1000;
+ return CUBEB_OK;
+}
+
+static int oss_get_preferred_sample_rate(cubeb *context, uint32_t * rate)
+{
+ /* 48000 seems a prefered choice for most audio devices
+ * and a good choice for OSS */
+ *rate = 48000;
+ return CUBEB_OK;
+}
+
+static void run_state_callback(cubeb_stream *stream, cubeb_state state)
+{
+ if (stream->state_callback) {
+ stream->state_callback(stream, stream->user_ptr, state);
+ }
+}
+
+static long run_data_callback(cubeb_stream *stream, void *buffer, long nframes)
+{
+ long got = 0;
+ pthread_mutex_lock(&stream->state_mutex);
+ if (stream->data_callback && stream->running && !stream->stopped) {
+ pthread_mutex_unlock(&stream->state_mutex);
+ got = stream->data_callback(stream, stream->user_ptr, NULL, buffer, nframes);
+ } else {
+ pthread_mutex_unlock(&stream->state_mutex);
+ }
+ return got;
+}
+
+static void apply_volume_int(int16_t* buffer, unsigned int n,
+ float volume, float panning)
+{
+ float left = volume;
+ float right = volume;
+ unsigned int i;
+ int pan[2];
+ if (panning<0) {
+ right *= (1+panning);
+ } else {
+ left *= (1-panning);
+ }
+ pan[0] = 128.0*left;
+ pan[1] = 128.0*right;
+ for(i=0; i<n; i++){
+ buffer[i] = ((int)buffer[i])*pan[i%2]/128;
+ }
+}
+
+static void apply_volume_float(float* buffer, unsigned int n,
+ float volume, float panning)
+{
+ float left = volume;
+ float right = volume;
+ unsigned int i;
+ float pan[2];
+ if (panning<0) {
+ right *= (1+panning);
+ } else {
+ left *= (1-panning);
+ }
+ pan[0] = left;
+ pan[1] = right;
+ for(i=0; i<n; i++){
+ buffer[i] = buffer[i]*pan[i%2];
+ }
+}
+
+
+static void *writer(void *stm)
+{
+ cubeb_stream* stream = (cubeb_stream*)stm;
+ int16_t buffer[OSS_BUFFER_SIZE];
+ float f_buffer[OSS_BUFFER_SIZE];
+ int got;
+ unsigned long i;
+ while (stream->running) {
+ pthread_mutex_lock(&stream->state_mutex);
+ if (stream->stopped) {
+ pthread_mutex_unlock(&stream->state_mutex);
+ run_state_callback(stream, CUBEB_STATE_STOPPED);
+ pthread_mutex_lock(&stream->state_mutex);
+ while (stream->stopped) {
+ pthread_cond_wait(&stream->state_cond, &stream->state_mutex);
+ }
+ pthread_mutex_unlock(&stream->state_mutex);
+ run_state_callback(stream, CUBEB_STATE_STARTED);
+ continue;
+ }
+ pthread_mutex_unlock(&stream->state_mutex);
+ if (stream->floating) {
+ got = run_data_callback(stream, f_buffer,
+ OSS_BUFFER_SIZE/stream->params.channels);
+ apply_volume_float(f_buffer, got*stream->params.channels,
+ stream->volume, stream->panning);
+ for (i=0; i<((unsigned long)got)*stream->params.channels; i++) {
+ /* Clipping is prefered to overflow */
+ if(f_buffer[i]>=1.0){
+ f_buffer[i]=1.0;
+ }
+ if(f_buffer[i]<=-1.0){
+ f_buffer[i]=-1.0;
+ }
+ /* One might think that multipling by 32767.0 is logical but results in clipping */
+ buffer[i] = f_buffer[i]*32767.0;
+ }
+ } else {
+ got = run_data_callback(stream, buffer,
+ OSS_BUFFER_SIZE/stream->params.channels);
+ apply_volume_int(buffer, got*stream->params.channels,
+ stream->volume, stream->panning);
+ }
+ if (got<0) {
+ run_state_callback(stream, CUBEB_STATE_ERROR);
+ break;
+ }
+ if (!got) {
+ run_state_callback(stream, CUBEB_STATE_DRAINED);
+ }
+ if (got) {
+ size_t i = 0;
+ size_t s = got*stream->params.channels*sizeof(int16_t);
+ while (i < s) {
+ ssize_t n = write(stream->fd, ((char*)buffer) + i, s - i);
+ if (n<=0) {
+ run_state_callback(stream, CUBEB_STATE_ERROR);
+ break;
+ }
+ i+=n;
+ }
+ stream->written_frags+=got;
+ }
+ }
+ return NULL;
+}
+
+static void oss_try_set_latency(cubeb_stream* stream, unsigned int latency_frames)
+{
+ unsigned int latency_bytes, n_frag;
+ int frag;
+ /* fragment size of 1024 is a good choice with good chances to be accepted */
+ unsigned int frag_log=10; /* 2^frag_log = fragment size */
+ latency_bytes =
+ latency_frames*stream->params.channels*sizeof(uint16_t);
+ n_frag = latency_bytes>>frag_log;
+ frag = (n_frag<<16) | frag_log;
+ /* Even if this fails we wish to continue, not checking for errors */
+ ioctl(stream->fd, SNDCTL_DSP_SETFRAGMENT, &frag);
+}
+
+static int oss_stream_init(cubeb * context, cubeb_stream ** stm,
+ 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)
+{
+ cubeb_stream* stream = (cubeb_stream*)malloc(sizeof(cubeb_stream));
+ stream->context = context;
+ stream->data_callback = data_callback;
+ stream->state_callback = state_callback;
+ stream->user_ptr = user_ptr;
+
+ assert(!input_stream_params && "not supported.");
+ if (input_device || output_device) {
+ /* Device selection not yet implemented. */
+ return CUBEB_ERROR_DEVICE_UNAVAILABLE;
+ }
+
+ if ((input_stream_params && input_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) ||
+ (output_stream_params && output_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK)) {
+ return CUBEB_ERROR_NOT_SUPPORTED;
+ }
+
+ if ((stream->fd = open(CUBEB_OSS_DEFAULT_OUTPUT, O_WRONLY)) == -1) {
+ free(stream);
+ return CUBEB_ERROR;
+ }
+#define SET(what, to) do { unsigned int i = to; \
+ int j = ioctl(stream->fd, what, &i); \
+ if (j == -1 || i != to) { \
+ close(stream->fd); \
+ free(stream); \
+ return CUBEB_ERROR_INVALID_FORMAT; } } while (0)
+
+ stream->params = *output_stream_params;
+ stream->volume = 1.0;
+ stream->panning = 0.0;
+
+ oss_try_set_latency(stream, latency_frames);
+
+ stream->floating = 0;
+ SET(SNDCTL_DSP_CHANNELS, stream->params.channels);
+ SET(SNDCTL_DSP_SPEED, stream->params.rate);
+ switch (stream->params.format) {
+ case CUBEB_SAMPLE_S16LE:
+ SET(SNDCTL_DSP_SETFMT, AFMT_S16_LE);
+ break;
+ case CUBEB_SAMPLE_S16BE:
+ SET(SNDCTL_DSP_SETFMT, AFMT_S16_BE);
+ break;
+ case CUBEB_SAMPLE_FLOAT32LE:
+ SET(SNDCTL_DSP_SETFMT, AFMT_S16_NE);
+ stream->floating = 1;
+ break;
+ default:
+ close(stream->fd);
+ free(stream);
+ return CUBEB_ERROR;
+ }
+
+
+ pthread_mutex_init(&stream->state_mutex, NULL);
+ pthread_cond_init(&stream->state_cond, NULL);
+
+ stream->running = 1;
+ stream->stopped = 1;
+ stream->position_bytes = 0;
+ stream->last_position_bytes = 0;
+ stream->written_frags = 0;
+ stream->missed_frags = 0;
+
+ pthread_create(&stream->th, NULL, writer, (void*)stream);
+
+ *stm = stream;
+
+ return CUBEB_OK;
+}
+
+static void oss_stream_destroy(cubeb_stream * stream)
+{
+ pthread_mutex_lock(&stream->state_mutex);
+
+ stream->running = 0;
+ stream->stopped = 0;
+ pthread_cond_signal(&stream->state_cond);
+
+ pthread_mutex_unlock(&stream->state_mutex);
+
+ pthread_join(stream->th, NULL);
+
+ pthread_mutex_destroy(&stream->state_mutex);
+ pthread_cond_destroy(&stream->state_cond);
+ close(stream->fd);
+ free(stream);
+}
+
+static int oss_stream_get_latency(cubeb_stream * stream, uint32_t * latency)
+{
+ if (ioctl(stream->fd, SNDCTL_DSP_GETODELAY, latency)==-1) {
+ return CUBEB_ERROR;
+ }
+ /* Convert latency from bytes to frames */
+ *latency /= stream->params.channels*sizeof(int16_t);
+ return CUBEB_OK;
+}
+
+
+static int oss_stream_current_optr(cubeb_stream * stream, uint64_t * position)
+{
+ count_info ci;
+ /* Unfortunately, this ioctl is only available in OSS 4.x */
+#ifdef SNDCTL_DSP_CURRENT_OPTR
+ oss_count_t count;
+ if (ioctl(stream->fd, SNDCTL_DSP_CURRENT_OPTR, &count) != -1) {
+ *position = count.samples;// + count.fifo_samples;
+ return CUBEB_OK;
+ }
+#endif
+ /* Fall back to this ioctl in case the previous one fails */
+ if (ioctl(stream->fd, SNDCTL_DSP_GETOPTR, &ci) == -1) {
+ return CUBEB_ERROR;
+ }
+ /* ci.bytes is only 32 bit and will start to wrap after arithmetic overflow */
+ stream->position_bytes += ci.bytes - stream->last_position_bytes;
+ stream->last_position_bytes = ci.bytes;
+ *position = stream->position_bytes/stream->params.channels/sizeof(int16_t);
+ return CUBEB_OK;
+}
+
+static int oss_stream_get_position(cubeb_stream * stream, uint64_t * position)
+{
+ if ( oss_stream_current_optr(stream, position) == CUBEB_OK ){
+ *position -= stream->missed_frags;
+ return CUBEB_OK;
+ }
+ /* If no correct method to get position works we resort to this */
+ *position = stream->written_frags;
+ return CUBEB_OK;
+}
+
+
+static int oss_stream_start(cubeb_stream * stream)
+{
+ pthread_mutex_lock(&stream->state_mutex);
+ if (stream->stopped) {
+ uint64_t ptr;
+ oss_stream_current_optr(stream, &ptr);
+ stream->missed_frags = ptr - stream->written_frags;
+ stream->stopped = 0;
+ pthread_cond_signal(&stream->state_cond);
+ }
+ pthread_mutex_unlock(&stream->state_mutex);
+ return CUBEB_OK;
+}
+
+static int oss_stream_stop(cubeb_stream * stream)
+{
+ pthread_mutex_lock(&stream->state_mutex);
+ stream->stopped = 1;
+ pthread_mutex_unlock(&stream->state_mutex);
+ return CUBEB_OK;
+}
+
+int oss_stream_set_panning(cubeb_stream * stream, float panning)
+{
+ if (stream->params.channels == 2) {
+ stream->panning=panning;
+ }
+ return CUBEB_OK;
+}
+
+int oss_stream_set_volume(cubeb_stream * stream, float volume)
+{
+ stream->volume=volume;
+ 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 = NULL,
+ .device_collection_destroy = NULL,
+ .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_set_volume = oss_stream_set_volume,
+ .stream_set_panning = oss_stream_set_panning,
+ .stream_get_current_device = NULL,
+ .stream_device_destroy = NULL,
+ .stream_register_device_changed_callback = NULL,
+ .register_device_collection_changed = NULL
+};

View file

@ -1,20 +1,13 @@
$NetBSD: patch-media_libcubeb_src_moz.build,v 1.1 2019/09/21 07:31:44 ryoon Exp $
$NetBSD: patch-media_libcubeb_src_moz.build,v 1.2 2020/03/12 19:39:35 nia Exp $
* Add OSS audio support
* Add Sun audio support
--- media/libcubeb/src/moz.build.orig 2019-05-29 15:39:06.000000000 +0000
--- media/libcubeb/src/moz.build.orig 2020-03-05 20:57:11.000000000 +0000
+++ media/libcubeb/src/moz.build
@@ -23,6 +23,18 @@ if CONFIG['MOZ_ALSA']:
@@ -23,6 +23,12 @@ if CONFIG['MOZ_ALSA']:
]
DEFINES['USE_ALSA'] = True
+if CONFIG['MOZ_OSS']:
+ SOURCES += [
+ 'cubeb_oss.c',
+ ]
+ DEFINES['USE_OSS'] = True
+
+if CONFIG['MOZ_SUNAUDIO']:
+ SOURCES += [
+ 'cubeb_sun.c',
@ -24,11 +17,3 @@ $NetBSD: patch-media_libcubeb_src_moz.build,v 1.1 2019/09/21 07:31:44 ryoon Exp
if CONFIG['MOZ_PULSEAUDIO'] or CONFIG['MOZ_JACK']:
SOURCES += [
'cubeb_resampler.cpp',
@@ -89,6 +101,7 @@ FINAL_LIBRARY = 'gkmedias'
CFLAGS += CONFIG['MOZ_ALSA_CFLAGS']
CFLAGS += CONFIG['MOZ_JACK_CFLAGS']
+CFLAGS += CONFIG['MOZ_OSS_CFLAGS']
CFLAGS += CONFIG['MOZ_PULSEAUDIO_CFLAGS']
# We allow warnings for third-party code that can be updated from upstream.

View file

@ -1,12 +1,13 @@
$NetBSD: patch-media_libcubeb_update.sh,v 1.1 2019/09/21 07:31:44 ryoon Exp $
$NetBSD: patch-media_libcubeb_update.sh,v 1.2 2020/03/12 19:39:35 nia Exp $
Add Sun audio support.
--- media/libcubeb/update.sh.orig 2019-05-29 15:39:11.000000000 +0000
+++ media/libcubeb/update.sh
@@ -25,6 +25,8 @@ cp $1/src/cubeb_log.h src
@@ -25,6 +25,7 @@ cp $1/src/cubeb_log.h src
cp $1/src/cubeb_mixer.cpp src
cp $1/src/cubeb_mixer.h src
cp $1/src/cubeb_opensl.c src
+cp $1/src/cubeb_oss.c src
+cp $1/src/cubeb_sun.c src
cp $1/src/cubeb-jni.cpp src
cp $1/src/cubeb-jni.h src

View file

@ -1,17 +1,14 @@
$NetBSD: patch-toolkit_library_moz.build,v 1.1 2019/09/21 07:31:44 ryoon Exp $
$NetBSD: patch-toolkit_library_moz.build,v 1.2 2020/03/12 19:39:35 nia Exp $
* Restore OSS support
--- toolkit/library/moz.build.orig 2018-10-18 20:06:16.000000000 +0000
--- toolkit/library/moz.build.orig 2020-03-05 20:57:55.000000000 +0000
+++ toolkit/library/moz.build
@@ -232,8 +232,8 @@ if CONFIG['MOZ_SYSTEM_LIBVPX']:
@@ -231,9 +231,6 @@ if CONFIG['MOZ_SYSTEM_LIBVPX']:
if not CONFIG['MOZ_TREE_PIXMAN']:
OS_LIBS += CONFIG['MOZ_PIXMAN_LIBS']
-if CONFIG['MOZ_ALSA']:
- OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
+if CONFIG['MOZ_OSS']:
+ OS_LIBS += CONFIG['MOZ_OSS_LIBS']
-
if CONFIG['HAVE_CLOCK_MONOTONIC']:
OS_LIBS += CONFIG['REALTIME_LIBS']