www/firefox: update to 71.0

Changes:	https://www.mozilla.org/firefox/71.0/releasenotes/
PR:		241840
Security:	13b6433c-7aaf-477b-b96b-164924a005bb
MFH:		2019Q4
Differential Revision:	https://reviews.freebsd.org/D22296
This commit is contained in:
Jan Beich 2019-11-26 01:01:18 +00:00
parent d2c29e3616
commit 21aaaafc33
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=518439
7 changed files with 44 additions and 987 deletions

View File

@ -264,10 +264,8 @@ MOZ_OPTIONS+= --disable-pulseaudio
BUILD_DEPENDS+= ${LOCALBASE}/include/sndio.h:audio/sndio
post-patch-SNDIO-on:
@${REINPLACE_CMD} -e 's|OpenBSD|${OPSYS}|g' \
${MOZSRC}/media/libcubeb/src/moz.build \
${MOZSRC}/toolkit/library/moz.build
@${REINPLACE_CMD} -e 's|OpenBSD|${OPSYS}|g' \
${MOZSRC}/media/libcubeb/gtest/moz.build
-e '/DISABLE_LIBSNDIO_DLOPEN/d' \
${MOZSRC}/media/libcubeb/src/moz.build
.endif
.if ${PORT_OPTIONS:MDEBUG}

View File

@ -2,22 +2,21 @@
# $FreeBSD$
PORTNAME= firefox
DISTVERSION= 70.0.1
PORTREVISION= 3
DISTVERSION= 71.0
PORTEPOCH= 1
CATEGORIES= www
MASTER_SITES= MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \
MOZILLA/${PORTNAME}/candidates/${DISTVERSION}-candidates/build1/source
MOZILLA/${PORTNAME}/candidates/${DISTVERSION}-candidates/build2/source
DISTFILES= ${DISTNAME}.source${EXTRACT_SUFX}
MAINTAINER= gecko@FreeBSD.org
COMMENT= Web browser based on the browser portion of Mozilla
BUILD_DEPENDS= nspr>=4.21:devel/nspr \
nss>=3.46.1:security/nss \
nss>=3.47:security/nss \
icu>=64.1,1:devel/icu \
libevent>=2.1.8:devel/libevent \
harfbuzz>=2.6.1:print/harfbuzz \
harfbuzz>=2.6.2:print/harfbuzz \
graphite2>=1.3.13:graphics/graphite2 \
png>=1.6.35:graphics/png \
libvpx>=1.5.0:multimedia/libvpx \

View File

@ -1,3 +1,3 @@
TIMESTAMP = 1572457039
SHA256 (firefox-70.0.1.source.tar.xz) = f2e9bb26af7682b31e82fdfc3a4b3e04fd1caa8b004469ea608185d33e35691b
SIZE (firefox-70.0.1.source.tar.xz) = 326335800
TIMESTAMP = 1574726570
SHA256 (firefox-71.0.source.tar.xz) = e67c448f9e82a19c737a72f9af1ccd325ba9e86fcbb1cd6839e6eda37d0f5410
SIZE (firefox-71.0.source.tar.xz) = 313865012

View File

@ -0,0 +1,22 @@
Don't force mach after https://bugzilla.mozilla.org/show_bug.cgi?id=1496746
diff --git Makefile.in Makefile.in
index 407e373573fb..16b8bb162d39 100644
--- Makefile.in
+++ Makefile.in
@@ -55,15 +55,8 @@ $(RUNNABLE_TIERS) binaries:: CLOBBER $(BUILD_BACKEND_FILES)
endif
endif
-ifdef JS_STANDALONE
.PHONY: CLOBBER
CLOBBER:
-else
-CLOBBER: $(topsrcdir)/CLOBBER
- @echo 'STOP! The CLOBBER file has changed.'
- @echo 'Please run the build through "mach build".'
- @exit 1
-endif
install_manifests := \
$(addprefix dist/,branding include public private xpi-stage) \

View File

@ -1,170 +0,0 @@
From 9696bc1795c75b1b527e2b70d9baf3ced9e3c154 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
Date: Mon, 23 Sep 2019 17:54:37 +0200
Subject: [PATCH] ir: Make Ord and PartialOrd implementations agree.
See https://github.com/rust-lang/rust/issues/64710.
Bogus implementations were introduced in 230545e7c, d3e39dc62, and 379bb1663.
--- third_party/rust/bindgen/.cargo-checksum.json.orig 2019-11-05 18:32:47 UTC
+++ third_party/rust/bindgen/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"a970d1a9e47f029fe3e3ce43ae4292054ad60c4490e035b86b669fcf32015624","LICENSE":"c23953d9deb0a3312dbeaf6c128a657f3591acee45067612fa68405eaa4525db","README.md":"5a1f556c6a57c0a6ccc65e19c27718e0f4b32381a8efcc80f6601b33c58c5d59","build.rs":"a9f6915c54d75f357ce32f96327bf4df53dc81a505b70831978f9dac6f43841d","csmith-fuzzing/README.md":"7107b70fedb0c0a0cadb3c439a49c1bd0119a6d38dc63b1aecc74d1942256ef2","src/callbacks.rs":"b24d7982332c6a35928f134184ddf4072fe4545a45546b97b9b0e0c1fbb77c08","src/clang.rs":"0009b8b6e3f6c33ec2776ec4cb8de2625ae8be22c9f0433c39b06bdd9fc7db4d","src/codegen/bitfield_unit.rs":"87be2d7f7774327a1608c2c4d64df869e17fb34b7efdacb4030b6794d98e40f3","src/codegen/bitfield_unit_tests.rs":"2073ac6a36e0bc9afaef5b1207966817c8fb7a1a9f6368c3b1b8f79822efbfba","src/codegen/error.rs":"2613af1d833377fd4a70719f4a09951d9d45dc9227827b9a2a938a1bcaaea2dd","src/codegen/helpers.rs":"aa0daff2061c6de31acfbd113190889e0f7ca2d2b8d4f46740bfd5832c33e4d2","src/codegen/impl_debug.rs":"f82969461d522fb758eca552ceaf189122a404cbb47fcc16008bfe52fc62aefa","src/codegen/impl_partialeq.rs":"d40d9ee2849c4d3d557b033c4d3af5e6de4a44347f67c0f016198086338811af","src/codegen/mod.rs":"ad116e2af755219bd556e8ee00ca48562f64a161d0b2c94846ae01297446ea0d","src/codegen/struct_layout.rs":"3fa5524aff82365ce292b0cc85080514c85a6dbd31bce90f001773b995dda28e","src/extra_assertions.rs":"494534bd4f18b80d89b180c8a93733e6617edcf7deac413e9a73fd6e7bc9ced7","src/features.rs":"82511f1bb8cbd04d98f57b000903b0264237962af93a72a58220437213eba1ef","src/ir/analysis/derive.rs":"325d4c1c1e6194e743f42a2316f1501b0ef852fe309f2e9cac3434825ad235f0","src/ir/analysis/has_destructor.rs":"63644f479738df35e531d3324ff892614083c3656e0747aa34d9f20dada878ec","src/ir/analysis/has_float.rs":"76162a309e4285a806755a08c687a3e7bc894a100a63da4e88584035e215b11d","src/ir/analysis/has_type_param_in_array.rs":"fdbc0af28a144c88ea2de83e6e6da5e1ffb40e3dd63fd7a708095d085bb06f94","src/ir/analysis/has_vtable.rs":"5788372d27bdbaaf0454bc17be31a5480918bc41a8a1c4832e8c61185c07f9cd","src/ir/analysis/mod.rs":"1f218e15c19f6666512908abc853fa7ff9ca5d0fafd94f026d9e4b0ce287ec3c","src/ir/analysis/sizedness.rs":"b73865b6689d4f3546edd91909a47c329c4ae630ea97715d29bc683ae1dc17ad","src/ir/analysis/template_params.rs":"6312c008bbc80f50e72a766756c8daddea0b6eeb31ec924b83a231df931e170e","src/ir/annotations.rs":"39a5ab19f4d5dfa617577e4a0d0d2b67b5369d480c7cca4b14d172458c9843f0","src/ir/comment.rs":"c48abe01c5af0f09f583a89f1394bc6c161b40f6c8f0f600bbfe3c907b47969b","src/ir/comp.rs":"78e245835efcd22b5cc878a8a7031171116c708408bdb48b0c9284a067041e56","src/ir/context.rs":"8fd64654343295e0e4a43efe5db6f64315dcd50a5015c3d86e90aae992e2fa9f","src/ir/derive.rs":"34f9aa76b6c9c05136bb69dcd6455397faef571a567254d2c541d50a962994db","src/ir/dot.rs":"95ed2968fc3239d87892e9f1edf1ed6dd18630d949564961765967ea1d16960c","src/ir/enum_ty.rs":"7658cf68c00b1732dfa599c2d6b6a93a82de8401142591c3afe5fcb27d901a66","src/ir/function.rs":"c2feb2e26d47aa96a74af9912ada26be077e2b0c36d46fa10167da7109590500","src/ir/int.rs":"5b8d5bcedb04f39dc2d7e571bc04114b1f1e09cf294afe944c2e7879451c4378","src/ir/item.rs":"3bcdb69b793350e5744aec3577cdbb1e5068ece5220c38763cecd82dfb5e8f03","src/ir/item_kind.rs":"dbeae8c4fd0e5c9485d325aea040e056a1f2cd6d43fc927dee8fe1c0c59a7197","src/ir/layout.rs":"d49582081f5f86f7595afbe4845f38fb3b969a840b568f4a49b265e7d790bb5b","src/ir/mod.rs":"2eae90f207fad2e45957ec9287064992a419e3fc916aba84faff2ea25cbeb5ee","src/ir/module.rs":"c4d90bf38fe3672e01923734ccbdb7951ea929949d5f413a9c2aee12395a5094","src/ir/objc.rs":"758aa955a0c5d6ad82606c88a1f4cd1d93e666b71e82d43b18b1aaae96cf888a","src/ir/template.rs":"c0f8570b927dfd6a421fc4ce3094ec837a3ed936445225dbfac961e8e0842ae5","src/ir/traversal.rs":"ea751379a5aec02f93f8d2c61e18232776b1f000dbeae64b9a7195ba21a19dd6","src/ir/ty.rs":"e6771c8102b9f01b0c4b664bf1151b4773b599634a83895376ce122ca9f74f8b","src/ir/var.rs":"8bdafb6d02f2c55ae11c28d88b19fb7a65ba8466da12ff039ae4c16c790b291e","src/lib.rs":"a07ef7a3d099493555ae5a58b7b4bf9106a978e38a23b5ff445a83b92727ab62","src/log_stubs.rs":"6dfdd908b7c6453da416cf232893768f9480e551ca4add0858ef88bf71ee6ceb","src/main.rs":"8c96cd2a051e3f09b1b87b75cd9ed77e82e889c8309ebd3e4bc782960cf63e58","src/options.rs":"5b309b225cc51e665bd42ed3e7965a7cd73d984e4455a2d76987fc42ab271ff8","src/parse.rs":"be7d13cc84fae79ec7b3aa9e77063fa475a48d74a854423e2c72d75006a25202","src/regex_set.rs":"5cb72fc3714c0d79e9e942d003349c0775fafd7cd0c9603c65f5261883bbf9cf","src/time.rs":"3b763e6fee51d0eb01228dfe28bc28a9f692aff73b2a7b90a030902e0238fca6"},"package":"18270cdd7065ec045a6bb4bdcd5144d14a78b3aedb3bc5111e688773ac8b9ad0"}
\ No newline at end of file
+{"files":{},"package":"18270cdd7065ec045a6bb4bdcd5144d14a78b3aedb3bc5111e688773ac8b9ad0"}
--- third_party/rust/bindgen/src/ir/analysis/has_vtable.rs.orig 2019-10-30 17:36:44 UTC
+++ third_party/rust/bindgen/src/ir/analysis/has_vtable.rs
@@ -9,37 +9,22 @@ use std::ops;
use {HashMap, Entry};
/// The result of the `HasVtableAnalysis` for an individual item.
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum HasVtableResult {
- /// The item has a vtable, but the actual vtable pointer is in a base
- /// member.
- BaseHasVtable,
+ /// The item does not have a vtable pointer.
+ No,
/// The item has a vtable and the actual vtable pointer is within this item.
SelfHasVtable,
- /// The item does not have a vtable pointer.
- No
+ /// The item has a vtable, but the actual vtable pointer is in a base
+ /// member.
+ BaseHasVtable,
}
impl Default for HasVtableResult {
fn default() -> Self {
HasVtableResult::No
- }
-}
-
-impl cmp::PartialOrd for HasVtableResult {
- fn partial_cmp(&self, rhs: &Self) -> Option<cmp::Ordering> {
- use self::HasVtableResult::*;
-
- match (*self, *rhs) {
- (x, y) if x == y => Some(cmp::Ordering::Equal),
- (BaseHasVtable, _) => Some(cmp::Ordering::Greater),
- (_, BaseHasVtable) => Some(cmp::Ordering::Less),
- (SelfHasVtable, _) => Some(cmp::Ordering::Greater),
- (_, SelfHasVtable) => Some(cmp::Ordering::Less),
- _ => unreachable!(),
- }
}
}
--- third_party/rust/bindgen/src/ir/analysis/sizedness.rs.orig 2019-10-30 17:36:21 UTC
+++ third_party/rust/bindgen/src/ir/analysis/sizedness.rs
@@ -22,13 +22,14 @@ use {HashMap, Entry};
///
/// We initially assume that all types are `ZeroSized` and then update our
/// understanding as we learn more about each type.
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum SizednessResult {
- /// Has some size that is known to be greater than zero. That doesn't mean
- /// it has a static size, but it is not zero sized for sure. In other words,
- /// it might contain an incomplete array or some other dynamically sized
- /// type.
- NonZeroSized,
+ /// The type is zero-sized.
+ ///
+ /// This means that if it is a C++ type, and is not being used as a base
+ /// member, then we must add an `_address` byte to enforce the
+ /// unique-address-per-distinct-object-instance rule.
+ ZeroSized,
/// Whether this type is zero-sized or not depends on whether a type
/// parameter is zero-sized or not.
@@ -52,32 +53,16 @@ pub enum SizednessResult {
/// https://github.com/rust-lang/rust-bindgen/issues/586
DependsOnTypeParam,
- /// The type is zero-sized.
- ///
- /// This means that if it is a C++ type, and is not being used as a base
- /// member, then we must add an `_address` byte to enforce the
- /// unique-address-per-distinct-object-instance rule.
- ZeroSized,
+ /// Has some size that is known to be greater than zero. That doesn't mean
+ /// it has a static size, but it is not zero sized for sure. In other words,
+ /// it might contain an incomplete array or some other dynamically sized
+ /// type.
+ NonZeroSized,
}
impl Default for SizednessResult {
fn default() -> Self {
SizednessResult::ZeroSized
- }
-}
-
-impl cmp::PartialOrd for SizednessResult {
- fn partial_cmp(&self, rhs: &Self) -> Option<cmp::Ordering> {
- use self::SizednessResult::*;
-
- match (*self, *rhs) {
- (x, y) if x == y => Some(cmp::Ordering::Equal),
- (NonZeroSized, _) => Some(cmp::Ordering::Greater),
- (_, NonZeroSized) => Some(cmp::Ordering::Less),
- (DependsOnTypeParam, _) => Some(cmp::Ordering::Greater),
- (_, DependsOnTypeParam) => Some(cmp::Ordering::Less),
- _ => unreachable!(),
- }
}
}
--- third_party/rust/bindgen/src/ir/derive.rs.orig 2019-10-30 17:36:44 UTC
+++ third_party/rust/bindgen/src/ir/derive.rs
@@ -92,10 +92,10 @@ pub trait CanDeriveOrd {
///
/// Initially we assume that we can derive trait for all types and then
/// update our understanding as we learn more about each type.
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum CanDerive {
- /// No, we cannot.
- No,
+ /// Yes, we can derive automatically.
+ Yes,
/// The only thing that stops us from automatically deriving is that
/// array with more than maximum number of elements is used.
@@ -103,29 +103,13 @@ pub enum CanDerive {
/// This means we probably can "manually" implement such trait.
Manually,
- /// Yes, we can derive automatically.
- Yes,
+ /// No, we cannot.
+ No,
}
impl Default for CanDerive {
fn default() -> CanDerive {
CanDerive::Yes
- }
-}
-
-impl cmp::PartialOrd for CanDerive {
- fn partial_cmp(&self, rhs: &Self) -> Option<cmp::Ordering> {
- use self::CanDerive::*;
-
- let ordering = match (*self, *rhs) {
- (x, y) if x == y => cmp::Ordering::Equal,
- (No, _) => cmp::Ordering::Greater,
- (_, No) => cmp::Ordering::Less,
- (Manually, _) => cmp::Ordering::Greater,
- (_, Manually) => cmp::Ordering::Less,
- _ => unreachable!()
- };
- Some(ordering)
}
}

View File

@ -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
@@ -1295,6 +1295,19 @@ if CONFIG['MOZ_ENABLE_LIBPROXY']:
@@ -1299,6 +1299,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
@@ -539,6 +539,9 @@ if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/andr
@@ -543,6 +543,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']
+
GENERATED_FILES += [
'PropertyUseCounterMap.inc',
'UseCounterList.h',
GeneratedFile('UseCounterList.h', script='gen-usecounters.py',
entry_point='use_counter_list', inputs=['UseCounters.conf'])
diff --git gfx/graphite2/moz-gr-update.sh gfx/graphite2/moz-gr-update.sh
index faaab1b17971..04eff5f09882 100644
--- gfx/graphite2/moz-gr-update.sh
@ -170,7 +170,7 @@ diff --git netwerk/dns/moz.build netwerk/dns/moz.build
index 79c26e3e7001..c4d93bc5f7dc 100644
--- netwerk/dns/moz.build
+++ netwerk/dns/moz.build
@@ -90,3 +90,6 @@ USE_LIBS += ['icu']
@@ -86,3 +86,6 @@ USE_LIBS += ['icu']
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
@ -181,10 +181,11 @@ diff --git old-configure.in old-configure.in
index 95a58b634593..b614eef85c89 100644
--- old-configure.in
+++ old-configure.in
@@ -2665,5 +2665,26 @@ dnl ==================================================
@@ -2639,6 +2639,27 @@ dnl ========================================================
AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
dnl ========================================================
+dnl ========================================================
+dnl Check for graphite2
+dnl ========================================================
+if test -n "$MOZ_SYSTEM_GRAPHITE2"; then
@ -205,14 +206,14 @@ index 95a58b634593..b614eef85c89 100644
+ CFLAGS=$_SAVE_CFLAGS
+fi
+
+dnl ========================================================
dnl ========================================================
dnl Check for pixman and cairo
dnl ========================================================
diff --git toolkit/library/moz.build toolkit/library/moz.build
index 24f940e1ed7e..079a575adec3 100644
--- toolkit/library/moz.build
+++ toolkit/library/moz.build
@@ -254,6 +254,12 @@ if CONFIG['MOZ_SYSTEM_PNG']:
@@ -248,6 +248,12 @@ if CONFIG['MOZ_SYSTEM_PNG']:
if CONFIG['MOZ_SYSTEM_WEBP']:
OS_LIBS += CONFIG['MOZ_WEBP_LIBS']
@ -229,7 +230,7 @@ diff --git toolkit/moz.configure toolkit/moz.configure
index 9297e4d6f501..d8e273887e4b 100644
--- toolkit/moz.configure
+++ toolkit/moz.configure
@@ -927,6 +927,25 @@ add_old_configure_assignment('FT2_LIBS',
@@ -937,6 +937,25 @@ add_old_configure_assignment('FT2_LIBS',
add_old_configure_assignment('FT2_CFLAGS',
ft2_info.cflags)
@ -248,7 +249,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.1',
+system_harfbuzz = pkg_check_modules('MOZ_HARFBUZZ', 'harfbuzz >= 2.6.2',
+ when='--with-system-harfbuzz')
+
+set_config('MOZ_SYSTEM_HARFBUZZ', depends_if(system_harfbuzz)(lambda _: True))

View File

@ -1,793 +0,0 @@
https://github.com/kinetiknz/cubeb/pull/539
diff --git media/libcubeb/gtest/moz.build media/libcubeb/gtest/moz.build
index 1ff0c02545251..ca364d1ef7845 100644
--- media/libcubeb/gtest/moz.build
+++ media/libcubeb/gtest/moz.build
@@ -67,13 +67,6 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit':
'-framework CoreFoundation',
'-framework AudioToolbox',
]
-elif CONFIG['OS_TARGET'] == 'OpenBSD':
- OS_LIBS += [
- 'sndio',
- ]
-else:
- OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
- OS_LIBS += CONFIG['MOZ_PULSEAUDIO_LIBS']
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
diff --git media/libcubeb/src/cubeb.c media/libcubeb/src/cubeb.c
index 422f7c6..caac869 100644
--- media/libcubeb/src/cubeb.c
+++ media/libcubeb/src/cubeb.c
@@ -194,6 +194,9 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
#if defined(USE_JACK)
jack_init,
#endif
+#if defined(USE_SNDIO)
+ sndio_init,
+#endif
#if defined(USE_ALSA)
alsa_init,
#endif
@@ -209,9 +212,6 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
#if defined(USE_WINMM)
winmm_init,
#endif
-#if defined(USE_SNDIO)
- sndio_init,
-#endif
#if defined(USE_SUN)
sun_init,
#endif
diff --git media/libcubeb/src/cubeb_alsa.c media/libcubeb/src/cubeb_alsa.c
index bfd4d8f..a29eed0 100644
--- media/libcubeb/src/cubeb_alsa.c
+++ media/libcubeb/src/cubeb_alsa.c
@@ -14,10 +14,58 @@
#include <limits.h>
#include <poll.h>
#include <unistd.h>
+#include <dlfcn.h>
#include <alsa/asoundlib.h>
#include "cubeb/cubeb.h"
#include "cubeb-internal.h"
+#ifdef DISABLE_LIBASOUND_DLOPEN
+#define WRAP(x) x
+#else
+#define WRAP(x) cubeb_##x
+#define LIBASOUND_API_VISIT(X) \
+ X(snd_config) \
+ X(snd_config_add) \
+ X(snd_config_copy) \
+ X(snd_config_delete) \
+ X(snd_config_get_id) \
+ X(snd_config_get_string) \
+ X(snd_config_imake_integer) \
+ X(snd_config_search) \
+ X(snd_config_search_definition) \
+ X(snd_lib_error_set_handler) \
+ X(snd_pcm_avail_update) \
+ X(snd_pcm_close) \
+ X(snd_pcm_delay) \
+ X(snd_pcm_drain) \
+ X(snd_pcm_frames_to_bytes) \
+ X(snd_pcm_get_params) \
+ X(snd_pcm_hw_params_any) \
+ X(snd_pcm_hw_params_get_channels_max) \
+ X(snd_pcm_hw_params_get_rate) \
+ X(snd_pcm_hw_params_set_rate_near) \
+ X(snd_pcm_hw_params_sizeof) \
+ X(snd_pcm_nonblock) \
+ X(snd_pcm_open) \
+ X(snd_pcm_open_lconf) \
+ X(snd_pcm_pause) \
+ X(snd_pcm_poll_descriptors) \
+ X(snd_pcm_poll_descriptors_count) \
+ X(snd_pcm_poll_descriptors_revents) \
+ X(snd_pcm_readi) \
+ X(snd_pcm_recover) \
+ X(snd_pcm_set_params) \
+ X(snd_pcm_start) \
+ X(snd_pcm_state) \
+ X(snd_pcm_writei) \
+
+#define MAKE_TYPEDEF(x) static typeof(x) * cubeb_##x;
+LIBASOUND_API_VISIT(MAKE_TYPEDEF);
+#undef MAKE_TYPEDEF
+/* snd_pcm_hw_params_alloca is actually a macro */
+#define snd_pcm_hw_params_sizeof cubeb_snd_pcm_hw_params_sizeof
+#endif
+
#define CUBEB_STREAM_MAX 16
#define CUBEB_WATCHDOG_MS 10000
@@ -36,6 +84,7 @@ static struct cubeb_ops const alsa_ops;
struct cubeb {
struct cubeb_ops const * ops;
+ void * libasound;
pthread_t thread;
@@ -245,8 +294,8 @@ set_timeout(struct timeval * timeout, unsigned int ms)
static void
stream_buffer_decrement(cubeb_stream * stm, long count)
{
- char * bufremains = stm->buffer + snd_pcm_frames_to_bytes(stm->pcm, count);
- memmove(stm->buffer, bufremains, snd_pcm_frames_to_bytes(stm->pcm, stm->bufframes - count));
+ char * bufremains = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, count);
+ memmove(stm->buffer, bufremains, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->bufframes - count));
stm->bufframes -= count;
}
@@ -278,9 +327,9 @@ alsa_process_stream(cubeb_stream * stm)
/* Call _poll_descriptors_revents() even if we don't use it
to let underlying plugins clear null events. Otherwise poll()
may wake up again and again, producing unnecessary CPU usage. */
- snd_pcm_poll_descriptors_revents(stm->pcm, stm->fds, stm->nfds, &revents);
+ WRAP(snd_pcm_poll_descriptors_revents)(stm->pcm, stm->fds, stm->nfds, &revents);
- avail = snd_pcm_avail_update(stm->pcm);
+ avail = WRAP(snd_pcm_avail_update)(stm->pcm);
/* Got null event? Bail and wait for another wakeup. */
if (avail == 0) {
@@ -303,7 +352,7 @@ alsa_process_stream(cubeb_stream * stm)
// TODO: should it be marked as DRAINING?
}
- got = snd_pcm_readi(stm->pcm, stm->buffer+stm->bufframes, avail);
+ got = WRAP(snd_pcm_readi)(stm->pcm, stm->buffer+stm->bufframes, avail);
if (got < 0) {
avail = got; // the error handler below will recover us
@@ -347,7 +396,7 @@ alsa_process_stream(cubeb_stream * stm)
(!stm->other_stream || stm->other_stream->bufframes > 0)) {
long got = avail - stm->bufframes;
void * other_buffer = stm->other_stream ? stm->other_stream->buffer : NULL;
- char * buftail = stm->buffer + snd_pcm_frames_to_bytes(stm->pcm, stm->bufframes);
+ char * buftail = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->bufframes);
/* Correct read size to the other stream available frames */
if (stm->other_stream && got > (snd_pcm_sframes_t) stm->other_stream->bufframes) {
@@ -374,8 +423,8 @@ alsa_process_stream(cubeb_stream * stm)
long drain_frames = avail - stm->bufframes;
double drain_time = (double) drain_frames / stm->params.rate;
- char * buftail = stm->buffer + snd_pcm_frames_to_bytes(stm->pcm, stm->bufframes);
- memset(buftail, 0, snd_pcm_frames_to_bytes(stm->pcm, drain_frames));
+ char * buftail = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->bufframes);
+ memset(buftail, 0, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, drain_frames));
stm->bufframes = avail;
/* Mark as draining, unless we're waiting for capture */
@@ -402,7 +451,7 @@ alsa_process_stream(cubeb_stream * stm)
}
}
- wrote = snd_pcm_writei(stm->pcm, stm->buffer, avail);
+ wrote = WRAP(snd_pcm_writei)(stm->pcm, stm->buffer, avail);
if (wrote < 0) {
avail = wrote; // the error handler below will recover us
} else {
@@ -415,13 +464,13 @@ alsa_process_stream(cubeb_stream * stm)
/* Got some error? Let's try to recover the stream. */
if (avail < 0) {
- avail = snd_pcm_recover(stm->pcm, avail, 0);
+ avail = WRAP(snd_pcm_recover)(stm->pcm, avail, 0);
/* Capture pcm must be started after initial setup/recover */
if (avail >= 0 &&
stm->stream_type == SND_PCM_STREAM_CAPTURE &&
- snd_pcm_state(stm->pcm) == SND_PCM_STATE_PREPARED) {
- avail = snd_pcm_start(stm->pcm);
+ WRAP(snd_pcm_state)(stm->pcm) == SND_PCM_STATE_PREPARED) {
+ avail = WRAP(snd_pcm_start)(stm->pcm);
}
}
@@ -537,26 +586,26 @@ get_slave_pcm_node(snd_config_t * lconf, snd_config_t * root_pcm)
slave_def = NULL;
- r = snd_config_search(root_pcm, "slave", &slave_pcm);
+ r = WRAP(snd_config_search)(root_pcm, "slave", &slave_pcm);
if (r < 0) {
return NULL;
}
- r = snd_config_get_string(slave_pcm, &string);
+ r = WRAP(snd_config_get_string)(slave_pcm, &string);
if (r >= 0) {
- r = snd_config_search_definition(lconf, "pcm_slave", string, &slave_def);
+ r = WRAP(snd_config_search_definition)(lconf, "pcm_slave", string, &slave_def);
if (r < 0) {
return NULL;
}
}
do {
- r = snd_config_search(slave_def ? slave_def : slave_pcm, "pcm", &pcm);
+ r = WRAP(snd_config_search)(slave_def ? slave_def : slave_pcm, "pcm", &pcm);
if (r < 0) {
break;
}
- r = snd_config_get_string(slave_def ? slave_def : slave_pcm, &string);
+ r = WRAP(snd_config_get_string)(slave_def ? slave_def : slave_pcm, &string);
if (r < 0) {
break;
}
@@ -565,7 +614,7 @@ get_slave_pcm_node(snd_config_t * lconf, snd_config_t * root_pcm)
if (r < 0 || r > (int) sizeof(node_name)) {
break;
}
- r = snd_config_search(lconf, node_name, &pcm);
+ r = WRAP(snd_config_search)(lconf, node_name, &pcm);
if (r < 0) {
break;
}
@@ -574,7 +623,7 @@ get_slave_pcm_node(snd_config_t * lconf, snd_config_t * root_pcm)
} while (0);
if (slave_def) {
- snd_config_delete(slave_def);
+ WRAP(snd_config_delete)(slave_def);
}
return NULL;
@@ -597,22 +646,22 @@ init_local_config_with_workaround(char const * pcm_name)
lconf = NULL;
- if (snd_config == NULL) {
+ if (*WRAP(snd_config) == NULL) {
return NULL;
}
- r = snd_config_copy(&lconf, snd_config);
+ r = WRAP(snd_config_copy)(&lconf, *WRAP(snd_config));
if (r < 0) {
return NULL;
}
do {
- r = snd_config_search_definition(lconf, "pcm", pcm_name, &pcm_node);
+ r = WRAP(snd_config_search_definition)(lconf, "pcm", pcm_name, &pcm_node);
if (r < 0) {
break;
}
- r = snd_config_get_id(pcm_node, &string);
+ r = WRAP(snd_config_get_id)(pcm_node, &string);
if (r < 0) {
break;
}
@@ -621,7 +670,7 @@ init_local_config_with_workaround(char const * pcm_name)
if (r < 0 || r > (int) sizeof(node_name)) {
break;
}
- r = snd_config_search(lconf, node_name, &pcm_node);
+ r = WRAP(snd_config_search)(lconf, node_name, &pcm_node);
if (r < 0) {
break;
}
@@ -632,12 +681,12 @@ init_local_config_with_workaround(char const * pcm_name)
}
/* Fetch the PCM node's type, and bail out if it's not the PulseAudio plugin. */
- r = snd_config_search(pcm_node, "type", &node);
+ r = WRAP(snd_config_search)(pcm_node, "type", &node);
if (r < 0) {
break;
}
- r = snd_config_get_string(node, &string);
+ r = WRAP(snd_config_get_string)(node, &string);
if (r < 0) {
break;
}
@@ -648,18 +697,18 @@ init_local_config_with_workaround(char const * pcm_name)
/* Don't clobber an explicit existing handle_underrun value, set it only
if it doesn't already exist. */
- r = snd_config_search(pcm_node, "handle_underrun", &node);
+ r = WRAP(snd_config_search)(pcm_node, "handle_underrun", &node);
if (r != -ENOENT) {
break;
}
/* Disable pcm_pulse's asynchronous underrun handling. */
- r = snd_config_imake_integer(&node, "handle_underrun", 0);
+ r = WRAP(snd_config_imake_integer)(&node, "handle_underrun", 0);
if (r < 0) {
break;
}
- r = snd_config_add(pcm_node, node);
+ r = WRAP(snd_config_add)(pcm_node, node);
if (r < 0) {
break;
}
@@ -667,7 +716,7 @@ init_local_config_with_workaround(char const * pcm_name)
return lconf;
} while (0);
- snd_config_delete(lconf);
+ WRAP(snd_config_delete)(lconf);
return NULL;
}
@@ -679,9 +728,9 @@ alsa_locked_pcm_open(snd_pcm_t ** pcm, char const * pcm_name, snd_pcm_stream_t s
pthread_mutex_lock(&cubeb_alsa_mutex);
if (local_config) {
- r = snd_pcm_open_lconf(pcm, pcm_name, stream, SND_PCM_NONBLOCK, local_config);
+ r = WRAP(snd_pcm_open_lconf)(pcm, pcm_name, stream, SND_PCM_NONBLOCK, local_config);
} else {
- r = snd_pcm_open(pcm, pcm_name, stream, SND_PCM_NONBLOCK);
+ r = WRAP(snd_pcm_open)(pcm, pcm_name, stream, SND_PCM_NONBLOCK);
}
pthread_mutex_unlock(&cubeb_alsa_mutex);
@@ -694,7 +743,7 @@ alsa_locked_pcm_close(snd_pcm_t * pcm)
int r;
pthread_mutex_lock(&cubeb_alsa_mutex);
- r = snd_pcm_close(pcm);
+ r = WRAP(snd_pcm_close)(pcm);
pthread_mutex_unlock(&cubeb_alsa_mutex);
return r;
@@ -750,6 +799,7 @@ silent_error_handler(char const * file, int line, char const * function,
alsa_init(cubeb ** context, char const * context_name)
{
(void)context_name;
+ void * libasound = NULL;
cubeb * ctx;
int r;
int i;
@@ -760,9 +810,27 @@ alsa_init(cubeb ** context, char const * context_name)
assert(context);
*context = NULL;
+#ifndef DISABLE_LIBASOUND_DLOPEN
+ libasound = dlopen("libasound.so", RTLD_LAZY);
+ if (!libasound) {
+ return CUBEB_ERROR;
+ }
+
+#define LOAD(x) { \
+ cubeb_##x = dlsym(libasound, #x); \
+ if (!cubeb_##x) { \
+ dlclose(libasound); \
+ return CUBEB_ERROR; \
+ } \
+ }
+
+ LIBASOUND_API_VISIT(LOAD);
+#undef LOAD
+#endif
+
pthread_mutex_lock(&cubeb_alsa_mutex);
if (!cubeb_alsa_error_handler_set) {
- snd_lib_error_set_handler(silent_error_handler);
+ WRAP(snd_lib_error_set_handler)(silent_error_handler);
cubeb_alsa_error_handler_set = 1;
}
pthread_mutex_unlock(&cubeb_alsa_mutex);
@@ -771,6 +839,7 @@ alsa_init(cubeb ** context, char const * context_name)
assert(ctx);
ctx->ops = &alsa_ops;
+ ctx->libasound = libasound;
r = pthread_mutex_init(&ctx->mutex, NULL);
assert(r == 0);
@@ -819,7 +888,7 @@ alsa_init(cubeb ** context, char const * context_name)
config fails with EINVAL, the PA PCM is too old for this workaround. */
if (r == -EINVAL) {
pthread_mutex_lock(&cubeb_alsa_mutex);
- snd_config_delete(ctx->local_config);
+ WRAP(snd_config_delete)(ctx->local_config);
pthread_mutex_unlock(&cubeb_alsa_mutex);
ctx->local_config = NULL;
} else if (r >= 0) {
@@ -861,10 +930,14 @@ alsa_destroy(cubeb * ctx)
if (ctx->local_config) {
pthread_mutex_lock(&cubeb_alsa_mutex);
- snd_config_delete(ctx->local_config);
+ WRAP(snd_config_delete)(ctx->local_config);
pthread_mutex_unlock(&cubeb_alsa_mutex);
}
+ if (ctx->libasound) {
+ dlclose(ctx->libasound);
+ }
+
free(ctx);
}
@@ -948,7 +1021,7 @@ alsa_stream_init_single(cubeb * ctx, cubeb_stream ** stream, char const * stream
return CUBEB_ERROR;
}
- r = snd_pcm_nonblock(stm->pcm, 1);
+ r = WRAP(snd_pcm_nonblock)(stm->pcm, 1);
assert(r == 0);
latency_us = latency_frames * 1e6 / stm->params.rate;
@@ -961,7 +1034,7 @@ alsa_stream_init_single(cubeb * ctx, cubeb_stream ** stream, char const * stream
latency_us = latency_us < min_latency ? min_latency: latency_us;
}
- r = snd_pcm_set_params(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
+ r = WRAP(snd_pcm_set_params)(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
stm->params.channels, stm->params.rate, 1,
latency_us);
if (r < 0) {
@@ -969,20 +1042,20 @@ alsa_stream_init_single(cubeb * ctx, cubeb_stream ** stream, char const * stream
return CUBEB_ERROR_INVALID_FORMAT;
}
- r = snd_pcm_get_params(stm->pcm, &stm->buffer_size, &period_size);
+ r = WRAP(snd_pcm_get_params)(stm->pcm, &stm->buffer_size, &period_size);
assert(r == 0);
/* Double internal buffer size to have enough space when waiting for the other side of duplex connection */
stm->buffer_size *= 2;
- stm->buffer = calloc(1, snd_pcm_frames_to_bytes(stm->pcm, stm->buffer_size));
+ stm->buffer = calloc(1, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->buffer_size));
assert(stm->buffer);
- stm->nfds = snd_pcm_poll_descriptors_count(stm->pcm);
+ stm->nfds = WRAP(snd_pcm_poll_descriptors_count)(stm->pcm);
assert(stm->nfds > 0);
stm->saved_fds = calloc(stm->nfds, sizeof(struct pollfd));
assert(stm->saved_fds);
- r = snd_pcm_poll_descriptors(stm->pcm, stm->saved_fds, stm->nfds);
+ r = WRAP(snd_pcm_poll_descriptors)(stm->pcm, stm->saved_fds, stm->nfds);
assert((nfds_t) r == stm->nfds);
if (alsa_register_stream(ctx, stm) != 0) {
@@ -1054,7 +1127,7 @@ alsa_stream_destroy(cubeb_stream * stm)
pthread_mutex_lock(&stm->mutex);
if (stm->pcm) {
if (stm->state == DRAINING) {
- snd_pcm_drain(stm->pcm);
+ WRAP(snd_pcm_drain)(stm->pcm);
}
alsa_locked_pcm_close(stm->pcm);
stm->pcm = NULL;
@@ -1100,12 +1173,12 @@ alsa_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
assert(stm);
- r = snd_pcm_hw_params_any(stm->pcm, hw_params);
+ r = WRAP(snd_pcm_hw_params_any)(stm->pcm, hw_params);
if (r < 0) {
return CUBEB_ERROR;
}
- r = snd_pcm_hw_params_get_channels_max(hw_params, max_channels);
+ r = WRAP(snd_pcm_hw_params_get_channels_max)(hw_params, max_channels);
if (r < 0) {
return CUBEB_ERROR;
}
@@ -1126,34 +1199,34 @@ alsa_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate) {
/* get a pcm, disabling resampling, so we get a rate the
* hardware/dmix/pulse/etc. supports. */
- r = snd_pcm_open(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE);
+ r = WRAP(snd_pcm_open)(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE);
if (r < 0) {
return CUBEB_ERROR;
}
- r = snd_pcm_hw_params_any(pcm, hw_params);
+ r = WRAP(snd_pcm_hw_params_any)(pcm, hw_params);
if (r < 0) {
- snd_pcm_close(pcm);
+ WRAP(snd_pcm_close)(pcm);
return CUBEB_ERROR;
}
- r = snd_pcm_hw_params_get_rate(hw_params, rate, &dir);
+ r = WRAP(snd_pcm_hw_params_get_rate)(hw_params, rate, &dir);
if (r >= 0) {
/* There is a default rate: use it. */
- snd_pcm_close(pcm);
+ WRAP(snd_pcm_close)(pcm);
return CUBEB_OK;
}
/* Use a common rate, alsa may adjust it based on hw/etc. capabilities. */
*rate = 44100;
- r = snd_pcm_hw_params_set_rate_near(pcm, hw_params, rate, NULL);
+ r = WRAP(snd_pcm_hw_params_set_rate_near)(pcm, hw_params, rate, NULL);
if (r < 0) {
- snd_pcm_close(pcm);
+ WRAP(snd_pcm_close)(pcm);
return CUBEB_ERROR;
}
- snd_pcm_close(pcm);
+ WRAP(snd_pcm_close)(pcm);
return CUBEB_OK;
}
@@ -1186,10 +1259,10 @@ alsa_stream_start(cubeb_stream * stm)
pthread_mutex_lock(&stm->mutex);
/* Capture pcm must be started after initial setup/recover */
if (stm->stream_type == SND_PCM_STREAM_CAPTURE &&
- snd_pcm_state(stm->pcm) == SND_PCM_STATE_PREPARED) {
- snd_pcm_start(stm->pcm);
+ WRAP(snd_pcm_state)(stm->pcm) == SND_PCM_STATE_PREPARED) {
+ WRAP(snd_pcm_start)(stm->pcm);
}
- snd_pcm_pause(stm->pcm, 0);
+ WRAP(snd_pcm_pause)(stm->pcm, 0);
gettimeofday(&stm->last_activity, NULL);
pthread_mutex_unlock(&stm->mutex);
@@ -1229,7 +1302,7 @@ alsa_stream_stop(cubeb_stream * stm)
pthread_mutex_unlock(&ctx->mutex);
pthread_mutex_lock(&stm->mutex);
- snd_pcm_pause(stm->pcm, 1);
+ WRAP(snd_pcm_pause)(stm->pcm, 1);
pthread_mutex_unlock(&stm->mutex);
return CUBEB_OK;
@@ -1245,8 +1318,8 @@ alsa_stream_get_position(cubeb_stream * stm, uint64_t * position)
pthread_mutex_lock(&stm->mutex);
delay = -1;
- if (snd_pcm_state(stm->pcm) != SND_PCM_STATE_RUNNING ||
- snd_pcm_delay(stm->pcm, &delay) != 0) {
+ if (WRAP(snd_pcm_state)(stm->pcm) != SND_PCM_STATE_RUNNING ||
+ WRAP(snd_pcm_delay)(stm->pcm, &delay) != 0) {
*position = stm->last_position;
pthread_mutex_unlock(&stm->mutex);
return CUBEB_OK;
@@ -1271,7 +1344,7 @@ alsa_stream_get_latency(cubeb_stream * stm, uint32_t * latency)
snd_pcm_sframes_t delay;
/* This function returns the delay in frames until a frame written using
snd_pcm_writei is sent to the DAC. The DAC delay should be < 1ms anyways. */
- if (snd_pcm_delay(stm->pcm, &delay)) {
+ if (WRAP(snd_pcm_delay)(stm->pcm, &delay)) {
return CUBEB_ERROR;
}
diff --git media/libcubeb/src/cubeb_sndio.c media/libcubeb/src/cubeb_sndio.c
index 9e99b2c..0559af4 100644
--- media/libcubeb/src/cubeb_sndio.c
+++ media/libcubeb/src/cubeb_sndio.c
@@ -12,6 +12,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
+#include <dlfcn.h>
#include <assert.h>
#include "cubeb/cubeb.h"
#include "cubeb-internal.h"
@@ -22,10 +23,35 @@
#define DPR(...) do {} while(0)
#endif
+#ifdef DISABLE_LIBSNDIO_DLOPEN
+#define WRAP(x) x
+#else
+#define WRAP(x) cubeb_##x
+#define LIBSNDIO_API_VISIT(X) \
+ X(sio_close) \
+ X(sio_eof) \
+ X(sio_getpar) \
+ X(sio_initpar) \
+ X(sio_onmove) \
+ X(sio_open) \
+ X(sio_pollfd) \
+ X(sio_read) \
+ X(sio_revents) \
+ X(sio_setpar) \
+ X(sio_start) \
+ X(sio_stop) \
+ X(sio_write) \
+
+#define MAKE_TYPEDEF(x) static typeof(x) * cubeb_##x;
+LIBSNDIO_API_VISIT(MAKE_TYPEDEF);
+#undef MAKE_TYPEDEF
+#endif
+
static struct cubeb_ops const sndio_ops;
struct cubeb {
struct cubeb_ops const * ops;
+ void * libsndio;
};
struct cubeb_stream {
@@ -119,7 +145,7 @@ sndio_mainloop(void *arg)
DPR("sndio_mainloop()\n");
s->state_cb(s, s->arg, CUBEB_STATE_STARTED);
pthread_mutex_lock(&s->mtx);
- if (!sio_start(s->hdl)) {
+ if (!WRAP(sio_start)(s->hdl)) {
pthread_mutex_unlock(&s->mtx);
return NULL;
}
@@ -203,7 +229,7 @@ sndio_mainloop(void *arg)
events |= POLLIN;
if ((s->mode & SIO_PLAY) && pstart < pend)
events |= POLLOUT;
- nfds = sio_pollfd(s->hdl, pfds, events);
+ nfds = WRAP(sio_pollfd)(s->hdl, pfds, events);
if (nfds > 0) {
pthread_mutex_unlock(&s->mtx);
@@ -213,7 +239,7 @@ sndio_mainloop(void *arg)
continue;
}
- revents = sio_revents(s->hdl, pfds);
+ revents = WRAP(sio_revents)(s->hdl, pfds);
if (revents & POLLHUP) {
state = CUBEB_STATE_ERROR;
@@ -221,8 +247,8 @@ sndio_mainloop(void *arg)
}
if (revents & POLLOUT) {
- n = sio_write(s->hdl, s->pbuf + pstart, pend - pstart);
- if (n == 0 && sio_eof(s->hdl)) {
+ n = WRAP(sio_write)(s->hdl, s->pbuf + pstart, pend - pstart);
+ if (n == 0 && WRAP(sio_eof)(s->hdl)) {
DPR("sndio_mainloop() werr\n");
state = CUBEB_STATE_ERROR;
break;
@@ -231,8 +257,8 @@ sndio_mainloop(void *arg)
}
if (revents & POLLIN) {
- n = sio_read(s->hdl, s->rbuf + rstart, rend - rstart);
- if (n == 0 && sio_eof(s->hdl)) {
+ n = WRAP(sio_read)(s->hdl, s->rbuf + rstart, rend - rstart);
+ if (n == 0 && WRAP(sio_eof)(s->hdl)) {
DPR("sndio_mainloop() rerr\n");
state = CUBEB_STATE_ERROR;
break;
@@ -244,7 +270,7 @@ sndio_mainloop(void *arg)
if (prime > 0 && (s->mode & SIO_REC))
rstart = rend;
}
- sio_stop(s->hdl);
+ WRAP(sio_stop)(s->hdl);
s->hwpos = s->swpos;
pthread_mutex_unlock(&s->mtx);
s->state_cb(s, s->arg, state);
@@ -254,8 +280,31 @@ sndio_mainloop(void *arg)
/*static*/ int
sndio_init(cubeb **context, char const *context_name)
{
+ void * libsndio = NULL;
+
+#ifndef DISABLE_LIBSNDIO_DLOPEN
+ libsndio = dlopen("libsndio.so", RTLD_LAZY);
+ if (!libsndio) {
+ DPR("sndio_init(%s) failed dlopen(libsndio.so)\n", context_name);
+ return CUBEB_ERROR;
+ }
+
+#define LOAD(x) { \
+ cubeb_##x = dlsym(libsndio, #x); \
+ if (!cubeb_##x) { \
+ DPR("sndio_init(%s) failed dlsym(%s)\n", context_name, #x); \
+ dlclose(libsndio); \
+ return CUBEB_ERROR; \
+ } \
+ }
+
+ LIBSNDIO_API_VISIT(LOAD);
+#undef LOAD
+#endif
+
DPR("sndio_init(%s)\n", context_name);
*context = malloc(sizeof(*context));
+ (*context)->libsndio = libsndio;
(*context)->ops = &sndio_ops;
(void)context_name;
return CUBEB_OK;
@@ -271,6 +320,8 @@ static void
sndio_destroy(cubeb *context)
{
DPR("sndio_destroy()\n");
+ if (context->libsndio)
+ dlclose(context->libsndio);
free(context);
}
@@ -323,12 +374,12 @@ sndio_stream_init(cubeb * context,
goto err;
}
s->context = context;
- s->hdl = sio_open(NULL, s->mode, 1);
+ s->hdl = WRAP(sio_open)(NULL, s->mode, 1);
if (s->hdl == NULL) {
DPR("sndio_stream_init(), sio_open() failed\n");
goto err;
}
- sio_initpar(&wpar);
+ WRAP(sio_initpar)(&wpar);
wpar.sig = 1;
wpar.bits = 16;
switch (format) {
@@ -351,7 +402,7 @@ sndio_stream_init(cubeb * context,
if (s->mode & SIO_PLAY)
wpar.pchan = output_stream_params->channels;
wpar.appbufsz = latency_frames;
- if (!sio_setpar(s->hdl, &wpar) || !sio_getpar(s->hdl, &rpar)) {
+ if (!WRAP(sio_setpar)(s->hdl, &wpar) || !WRAP(sio_getpar)(s->hdl, &rpar)) {
DPR("sndio_stream_init(), sio_setpar() failed\n");
goto err;
}
@@ -362,7 +413,7 @@ sndio_stream_init(cubeb * context,
DPR("sndio_stream_init() unsupported params\n");
goto err;
}
- sio_onmove(s->hdl, sndio_onmove, s);
+ WRAP(sio_onmove)(s->hdl, sndio_onmove, s);
s->active = 0;
s->nfr = rpar.round;
s->rbpf = rpar.bps * rpar.rchan;
@@ -400,7 +451,7 @@ sndio_stream_init(cubeb * context,
return CUBEB_OK;
err:
if (s->hdl)
- sio_close(s->hdl);
+ WRAP(sio_close)(s->hdl);
if (s->pbuf)
free(s->pbuf);
if (s->rbuf)
@@ -446,7 +497,7 @@ static void
sndio_stream_destroy(cubeb_stream *s)
{
DPR("sndio_stream_destroy()\n");
- sio_close(s->hdl);
+ WRAP(sio_close)(s->hdl);
if (s->mode & SIO_PLAY)
free(s->pbuf);
if (s->mode & SIO_REC)
diff --git toolkit/library/moz.build toolkit/library/moz.build
index 8ce595ff96bff..c318e96a1fdfc 100644
--- toolkit/library/moz.build
+++ toolkit/library/moz.build
@@ -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['HAVE_CLOCK_MONOTONIC']:
OS_LIBS += CONFIG['REALTIME_LIBS']
@@ -242,11 +239,6 @@ OS_LIBS += CONFIG['ICONV_LIBS']
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
OS_LIBS += CONFIG['TK_LIBS']
-if CONFIG['OS_ARCH'] == 'OpenBSD':
- OS_LIBS += [
- 'sndio',
- ]
-
if CONFIG['MOZ_ENABLE_DBUS']:
OS_LIBS += CONFIG['MOZ_DBUS_GLIB_LIBS']