pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/www
Module Name: pkgsrc
Committed By: nia
Date: Fri Jul 26 08:05:23 UTC 2024
Modified Files:
pkgsrc/www: Makefile
Added Files:
pkgsrc/www/palemoon: DESCR Makefile PLIST distinfo options.mk
pkgsrc/www/palemoon/patches: patch-palemoon_app_profile_palemoon.js
patch-platform_build_moz.build
patch-platform_gfx_angle_src_libANGLE_renderer_gl_glx_FunctionsGLX.cpp
patch-platform_gfx_gl_GLContextProviderGLX.cpp
patch-platform_intl_icu_source_configure
patch-platform_js_src_jit_ProcessExecutableMemory.cpp
patch-platform_js_src_vm_ArrayBufferObject.cpp
patch-platform_media_libcubeb_src_cubeb__sun.c
patch-platform_media_libcubeb_src_moz.build
patch-platform_security_generate__mapfile.py
patch-platform_toolkit_xre_glxtest.cpp
Log Message:
import www/palemoon
A customizable, privacy-respecting web browser derived from the
independent Pale Moon(tm) codebase, in turn derived from community
code from the Mozilla project.
This package is an UNOFFICIAL build and not to be confused with
official Pale Moon software available from palemoon.org.
No support is provided from Moonchild Productions - all
responsibility for this package falls on the pkgsrc community.
Pale Moon does not support NetBSD and this software has been
modified to enhance NetBSD compatibility.
Pale Moon is a trademark of Moonchild Productions.
To generate a diff of this commit:
cvs rdiff -u -r1.1798 -r1.1799 pkgsrc/www/Makefile
cvs rdiff -u -r0 -r1.1 pkgsrc/www/palemoon/DESCR pkgsrc/www/palemoon/Makefile \
pkgsrc/www/palemoon/PLIST pkgsrc/www/palemoon/distinfo \
pkgsrc/www/palemoon/options.mk
cvs rdiff -u -r0 -r1.1 \
pkgsrc/www/palemoon/patches/patch-palemoon_app_profile_palemoon.js \
pkgsrc/www/palemoon/patches/patch-platform_build_moz.build \
pkgsrc/www/palemoon/patches/patch-platform_gfx_angle_src_libANGLE_renderer_gl_glx_FunctionsGLX.cpp \
pkgsrc/www/palemoon/patches/patch-platform_gfx_gl_GLContextProviderGLX.cpp \
pkgsrc/www/palemoon/patches/patch-platform_intl_icu_source_configure \
pkgsrc/www/palemoon/patches/patch-platform_js_src_jit_ProcessExecutableMemory.cpp \
pkgsrc/www/palemoon/patches/patch-platform_js_src_vm_ArrayBufferObject.cpp \
pkgsrc/www/palemoon/patches/patch-platform_media_libcubeb_src_cubeb__sun.c \
pkgsrc/www/palemoon/patches/patch-platform_media_libcubeb_src_moz.build \
pkgsrc/www/palemoon/patches/patch-platform_security_generate__mapfile.py \
pkgsrc/www/palemoon/patches/patch-platform_toolkit_xre_glxtest.cpp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/www/Makefile
diff -u pkgsrc/www/Makefile:1.1798 pkgsrc/www/Makefile:1.1799
--- pkgsrc/www/Makefile:1.1798 Thu Jul 18 12:21:27 2024
+++ pkgsrc/www/Makefile Fri Jul 26 08:05:23 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1798 2024/07/18 12:21:27 ryoon Exp $
+# $NetBSD: Makefile,v 1.1799 2024/07/26 08:05:23 nia Exp $
#
COMMENT= Packages related to the World Wide Web
@@ -632,6 +632,7 @@ SUBDIR+= p5-Web-Scraper
SUBDIR+= p5-WordPress-XMLRPC
SUBDIR+= p5-libapreq2
SUBDIR+= p5-libwww
+SUBDIR+= palemoon
SUBDIR+= paros
SUBDIR+= passenger
SUBDIR+= pear-HTML_Common
Added files:
Index: pkgsrc/www/palemoon/DESCR
diff -u /dev/null pkgsrc/www/palemoon/DESCR:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/DESCR Fri Jul 26 08:05:23 2024
@@ -0,0 +1,14 @@
+A customizable, privacy-respecting web browser derived from the
+independent Pale Moon(tm) codebase, in turn derived from community
+code from the Mozilla project.
+
+This package is an UNOFFICIAL build and not to be confused with
+official Pale Moon software available from palemoon.org.
+
+No support is provided from Moonchild Productions - all
+responsibility for this package falls on the pkgsrc community.
+
+Pale Moon does not support NetBSD and this software has been
+modified to enhance NetBSD compatibility.
+
+Pale Moon is a trademark of Moonchild Productions.
Index: pkgsrc/www/palemoon/Makefile
diff -u /dev/null pkgsrc/www/palemoon/Makefile:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/Makefile Fri Jul 26 08:05:23 2024
@@ -0,0 +1,155 @@
+# $NetBSD: Makefile,v 1.1 2024/07/26 08:05:23 nia Exp $
+# for build instructions see
+# https://developer.palemoon.org/build/linux/
+
+PKGNAME= palemoon-33.2.1
+CATEGORIES= www
+
+DIST_SUBDIR= palemoon-${PKGVERSION_NOREV}
+DISTFILES+= palemoon.tar.gz
+DISTFILES+= uxp.tar.gz
+DISTFILES+= psutil.tar.gz
+
+SITES.palemoon.tar.gz= \
+ -https://repo.palemoon.org/MoonchildProductions/Pale-Moon/archive/${PKGVERSION_NOREV}_Release.tar.gz
+
+SITES.uxp.tar.gz= \
+ -https://repo.palemoon.org/MoonchildProductions/UXP/archive/RB_20240715.tar.gz
+
+SITES.psutil.tar.gz= \
+ -https://files.pythonhosted.org/packages/7b/58/2675697b6831e6ac4b7b7bc4e5dcdb24a2f39f8411186573eb0de16eb6d5/psutil-3.4.2.tar.gz
+
+MAINTAINER= pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE= https://repo.palemoon.org/MoonchildProductions/Pale-Moon
+COMMENT= Customizable web browser (unofficial distribution of Pale Moon)
+LICENSE= mpl-2.0
+
+USE_TOOLS+= perl pkg-config autoconf213
+USE_TOOLS+= zip unzip gmake
+
+HAS_CONFIGURE= yes
+USE_LANGUAGES= c c++
+
+USE_CXX_FEATURES+= c++17
+
+WRKSRC= ${WRKDIR}/pale-moon
+
+CONFIG_GUESS_OVERRIDE+= platform/build/autoconf/config.guess
+CONFIG_GUESS_OVERRIDE+= platform/intl/icu/source/config.guess
+CONFIG_GUESS_OVERRIDE+= platform/ipc/chromium/src/third_party/libevent/config.guess
+CONFIG_GUESS_OVERRIDE+= platform/js/src/ctypes/libffi/config.guess
+CONFIG_GUESS_OVERRIDE+= platform/nsprpub/build/autoconf/config.guess
+
+CONFIG_SUB_OVERRIDE+= platform/build/autoconf/config.sub
+CONFIG_SUB_OVERRIDE+= platform/intl/icu/source/config.sub
+CONFIG_SUB_OVERRIDE+= platform/ipc/chromium/src/third_party/libevent/config.sub
+CONFIG_SUB_OVERRIDE+= platform/js/src/ctypes/libffi/config.sub
+CONFIG_SUB_OVERRIDE+= platform/nsprpub/build/autoconf/config.sub
+
+CONFIGURE_DIRS= ${WRKDIR}/build
+CONFIGURE_SCRIPT= ${WRKSRC}/configure
+
+# recommended flags from upstream
+CONFIGURE_ARGS+= --enable-application=palemoon
+CONFIGURE_ARGS+= --enable-default-toolkit=cairo-gtk2
+CONFIGURE_ARGS+= --enable-devtools
+CONFIGURE_ARGS+= --enable-av1
+CONFIGURE_ARGS+= --enable-jxl
+CONFIGURE_ARGS+= --disable-webrtc
+CONFIGURE_ARGS+= --disable-gamepad
+CONFIGURE_ARGS+= --disable-tests
+CONFIGURE_ARGS+= --disable-debug
+CONFIGURE_ARGS+= --disable-necko-wifi
+CONFIGURE_ARGS+= --disable-updater
+CONFIGURE_ARGS+= --with-pthreads
+
+# non-default: upstream is very strict about trademark usage
+CONFIGURE_ARGS+= --with-branding=palemoon/branding/unofficial
+
+# non-default: causes build failures on NetBSD
+CONFIGURE_ARGS+= --disable-precompiled-startupcache
+
+# non-default: do not override system memory allocator
+CONFIGURE_ARGS+= --disable-jemalloc
+
+# non-default options to integrate better with pkgsrc
+CONFIGURE_ARGS+= --prefix=${PREFIX}
+CONFIGURE_ARGS+= --enable-optimize=-O2
+CONFIGURE_ARGS+= --with-system-bz2
+CONFIGURE_ARGS+= --with-system-zlib
+CONFIGURE_ARGS+= --enable-system-cairo
+CONFIGURE_ARGS+= --enable-system-pixman
+
+CWRAPPERS_APPEND.cc+= ${COMPILER_RPATH_FLAG}${PREFIX}/lib/${PKGNAME_NOREV}
+CWRAPPERS_APPEND.cxx+= ${COMPILER_RPATH_FLAG}${PREFIX}/lib/${PKGNAME_NOREV}
+CWRAPPERS_APPEND.ld+= ${LINKER_RPATH_FLAG}${PREFIX}/lib/${PKGNAME_NOREV}
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
+TOOL_DEPENDS+= yasm>=1.1:../../devel/yasm
+.endif
+
+INSTALLATION_DIRS+= share/applications
+INSTALLATION_DIRS+= share/icons/hicolor/16x16/apps
+INSTALLATION_DIRS+= share/icons/hicolor/32x32/apps
+INSTALLATION_DIRS+= share/icons/hicolor/48x48/apps
+INSTALLATION_DIRS+= share/icons/hicolor/128x128/apps
+
+CHECK_PORTABILITY_SKIP+= platform/js/src/tests/*.sh
+CHECK_PORTABILITY_SKIP+= platform/memory/jemalloc/src/configure
+CHECK_PORTABILITY_SKIP+= platform/security/nss/tests/*/*.sh
+
+PYTHON_VERSIONS_ACCEPTED= 27
+PYTHON_FOR_BUILD_ONLY= tool
+
+pre-configure:
+ ${MKDIR} ${CONFIGURE_DIRS}
+ cd ${WRKSRC} && autoconf-2.13
+ cd ${WRKSRC}/palemoon && autoconf-2.13
+ cd ${WRKSRC}/platform/js/src && autoconf-2.13
+
+pre-patch:
+ ${MV} ${WRKDIR}/uxp/* ${WRKSRC}/platform/
+ ${RM} -rf ${WRKSRC}/platform/python/psutil
+ ${MV} ${WRKDIR}/psutil-3.4.2 ${WRKSRC}/platform/python/psutil
+
+pre-build:
+ ${TOUCH} ${WRKSRC}/platform/configure
+ ${TOUCH} ${WRKDIR}/build/config.status
+
+post-install:
+ ${FIND} ${DESTDIR}${PREFIX} -name '*.a' -exec ${RM} '{}' ';'
+ ${RM} -rf ${DESTDIR}${PREFIX}/include
+ ${RM} -rf ${DESTDIR}${PREFIX}/share/idl
+ ${RM} -rf ${DESTDIR}${PREFIX}/lib/palemoon-devel-${PKGVERSION_NOREV}
+ ${INSTALL_DATA} ${WRKSRC}/palemoon/branding/unofficial/default16.png \
+ ${DESTDIR}${PREFIX}/share/icons/hicolor/16x16/apps/palemoon.png
+ ${INSTALL_DATA} ${WRKSRC}/palemoon/branding/unofficial/default32.png \
+ ${DESTDIR}${PREFIX}/share/icons/hicolor/32x32/apps/palemoon.png
+ ${INSTALL_DATA} ${WRKSRC}/palemoon/branding/unofficial/default48.png \
+ ${DESTDIR}${PREFIX}/share/icons/hicolor/48x48/apps/palemoon.png
+ ${INSTALL_DATA} ${WRKSRC}/palemoon/branding/unofficial/mozicon128.png \
+ ${DESTDIR}${PREFIX}/share/icons/hicolor/128x128/apps/palemoon.png
+ ${INSTALL_DATA} ${WRKSRC}/palemoon/branding/unofficial/browser.desktop \
+ ${DESTDIR}${PREFIX}/share/applications/palemoon.desktop
+
+.include "options.mk"
+.include "../../archivers/bzip2/buildlink3.mk"
+.if ${OPSYS} == "Linux"
+. include "../../audio/alsa-lib/buildlink3.mk"
+.endif
+.include "../../devel/GConf/buildlink3.mk"
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../graphics/cairo/buildlink3.mk"
+.include "../../graphics/hicolor-icon-theme/buildlink3.mk"
+.include "../../lang/python/batteries-included.mk"
+.include "../../lang/python/application.mk"
+.include "../../lang/python/tool.mk"
+.include "../../multimedia/ffmpeg6/buildlink3.mk"
+.include "../../security/openssl/buildlink3.mk"
+.include "../../sysutils/desktop-file-utils/desktopdb.mk"
+.include "../../x11/gtk2/buildlink3.mk"
+.include "../../x11/pixman/buildlink3.mk"
+.include "../../x11/libXt/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/www/palemoon/PLIST
diff -u /dev/null pkgsrc/www/palemoon/PLIST:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/PLIST Fri Jul 26 08:05:23 2024
@@ -0,0 +1,60 @@
+@comment $NetBSD: PLIST,v 1.1 2024/07/26 08:05:23 nia Exp $
+bin/palemoon
+lib/${PKGNAME}/application.ini
+lib/${PKGNAME}/browser/blocklist.xml
+lib/${PKGNAME}/browser/chrome.manifest
+lib/${PKGNAME}/browser/chrome/icons/default/default16.png
+lib/${PKGNAME}/browser/chrome/icons/default/default32.png
+lib/${PKGNAME}/browser/chrome/icons/default/default48.png
+lib/${PKGNAME}/browser/components/components.manifest
+lib/${PKGNAME}/browser/components/libbrowsercomps.so
+lib/${PKGNAME}/browser/defaults/profile/chrome/userChrome-example.css
+lib/${PKGNAME}/browser/defaults/profile/chrome/userContent-example.css
+lib/${PKGNAME}/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi
+lib/${PKGNAME}/browser/icons/mozicon128.png
+lib/${PKGNAME}/browser/palemoon.res
+lib/${PKGNAME}/browser/searchplugins/bing.xml
+lib/${PKGNAME}/browser/searchplugins/duckduckgo-palemoon.xml
+lib/${PKGNAME}/browser/searchplugins/ecosia.xml
+lib/${PKGNAME}/browser/searchplugins/ekoru.xml
+lib/${PKGNAME}/browser/searchplugins/mojeek.xml
+lib/${PKGNAME}/browser/searchplugins/twitter.xml
+lib/${PKGNAME}/browser/searchplugins/wikipedia.xml
+lib/${PKGNAME}/browser/searchplugins/yahoo.xml
+lib/${PKGNAME}/browser/ua-update.json
+lib/${PKGNAME}/chrome.manifest
+lib/${PKGNAME}/defaults/pref/channel-prefs.js
+lib/${PKGNAME}/dependentlibs.list
+lib/${PKGNAME}/dictionaries/en-US.aff
+lib/${PKGNAME}/dictionaries/en-US.dic
+lib/${PKGNAME}/fonts/TwemojiMozilla.ttf
+lib/${PKGNAME}/icudt63l.dat
+lib/${PKGNAME}/libfreebl3.so
+lib/${PKGNAME}/libhunspell.so
+lib/${PKGNAME}/liblgpllibs.so
+lib/${PKGNAME}/libmozavcodec.so
+lib/${PKGNAME}/libmozavutil.so
+lib/${PKGNAME}/libmozsqlite3.so
+lib/${PKGNAME}/libnspr4.so
+lib/${PKGNAME}/libnss3.so
+lib/${PKGNAME}/libnssckbi.so
+lib/${PKGNAME}/libnssutil3.so
+lib/${PKGNAME}/libplc4.so
+lib/${PKGNAME}/libplds4.so
+lib/${PKGNAME}/libsmime3.so
+lib/${PKGNAME}/libsoftokn3.so
+lib/${PKGNAME}/libssl3.so
+lib/${PKGNAME}/libxul.so
+lib/${PKGNAME}/license.txt
+lib/${PKGNAME}/palemoon
+lib/${PKGNAME}/palemoon-bin
+lib/${PKGNAME}/palemoon.res
+lib/${PKGNAME}/platform.ini
+lib/${PKGNAME}/plugin-container
+lib/${PKGNAME}/removed-files
+lib/${PKGNAME}/run-mozilla.sh
+share/applications/palemoon.desktop
+share/icons/hicolor/128x128/apps/palemoon.png
+share/icons/hicolor/16x16/apps/palemoon.png
+share/icons/hicolor/32x32/apps/palemoon.png
+share/icons/hicolor/48x48/apps/palemoon.png
Index: pkgsrc/www/palemoon/distinfo
diff -u /dev/null pkgsrc/www/palemoon/distinfo:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/distinfo Fri Jul 26 08:05:23 2024
@@ -0,0 +1,22 @@
+$NetBSD: distinfo,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+BLAKE2s (palemoon-33.2.1/palemoon.tar.gz) = 5963bc12be28b07ded0558bb20bc27108f3aebd1895e4730e6a6ac2013a7ae9d
+SHA512 (palemoon-33.2.1/palemoon.tar.gz) = 72e6a4858af679a88fd079ed28020a8d845366d0b3ea5cb00b5a17dd9d6b7a4171397ceaa156b3e9f1d185e39e7ba8c82864641bd21f704350ef4b6473cc693d
+Size (palemoon-33.2.1/palemoon.tar.gz) = 8567974 bytes
+BLAKE2s (palemoon-33.2.1/psutil.tar.gz) = 7a2c5c938910795453cf1cdfd5fbfa4dc8cac15e6eb43a5e9aba91ac032b37ce
+SHA512 (palemoon-33.2.1/psutil.tar.gz) = 95c246ed4ce68a476f83868312101d88dafa9d4cef96ff60af646a443c00e6cc447d37cc1ac4e85224db16c24390575174bb7ef76f48cb839fe2e93749107ffb
+Size (palemoon-33.2.1/psutil.tar.gz) = 274361 bytes
+BLAKE2s (palemoon-33.2.1/uxp.tar.gz) = 1776ecd102d0db4b65cfb41c1055d4320f9b559268585356d0794ffa868df5f3
+SHA512 (palemoon-33.2.1/uxp.tar.gz) = 37621d572bdd3fcf043f5edce3d0ac1dd089a1ed1ccf5126a4052b74e47b0032761c25e6192b96adfe6fe96f131881f43415150fcd68e543e9f05d89a4dd19af
+Size (palemoon-33.2.1/uxp.tar.gz) = 264109377 bytes
+SHA1 (patch-palemoon_app_profile_palemoon.js) = 5169b1ffdb764277a4ab2b6e73e9070d329eef47
+SHA1 (patch-platform_build_moz.build) = 7b45929d58ad0963423f7c859922df6d98413c67
+SHA1 (patch-platform_gfx_angle_src_libANGLE_renderer_gl_glx_FunctionsGLX.cpp) = 502d79eb3ef41e08328bbac9fbb5048b96660bbb
+SHA1 (patch-platform_gfx_gl_GLContextProviderGLX.cpp) = 56685c8c5f176b0660a6208437d81085f6ad00a5
+SHA1 (patch-platform_intl_icu_source_configure) = 87d19e9212b4340d9b052b5a89be84432ad1cff2
+SHA1 (patch-platform_js_src_jit_ProcessExecutableMemory.cpp) = 5cf5a2205a2b38fb8785e6c255231fbcdbd13949
+SHA1 (patch-platform_js_src_vm_ArrayBufferObject.cpp) = 652db4b78ecaba840c0cba945b4af39a6b1362b9
+SHA1 (patch-platform_media_libcubeb_src_cubeb__sun.c) = ce27774d772d65fa60b6be5bee82fbe4f787f3d1
+SHA1 (patch-platform_media_libcubeb_src_moz.build) = 5f9f7656bf9d251edb395cb19fae8cd614c0b287
+SHA1 (patch-platform_security_generate__mapfile.py) = ae457a8e85c4ce95014dff442b8afd0e20ded543
+SHA1 (patch-platform_toolkit_xre_glxtest.cpp) = f8bd5705f5cf87651df59ba22f4566136e3bc4ef
Index: pkgsrc/www/palemoon/options.mk
diff -u /dev/null pkgsrc/www/palemoon/options.mk:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/options.mk Fri Jul 26 08:05:23 2024
@@ -0,0 +1,20 @@
+# $NetBSD: options.mk,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+PKG_OPTIONS_VAR= PKG_OPTIONS.palemoon
+PKG_SUPPORTED_OPTIONS= dbus pulseaudio
+
+.include "../../mk/bsd.options.mk"
+
+.if !empty(PKG_OPTIONS:Mdbus)
+CONFIGURE_ARGS+= --enable-dbus
+. include "../../sysutils/dbus/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-dbus
+.endif
+
+.if !empty(PKG_OPTIONS:Mpulseaudio)
+CONFIGURE_ARGS+= --enable-pulseaudio
+. include "../../audio/pulseaudio/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-pulseaudio
+.endif
Index: pkgsrc/www/palemoon/patches/patch-palemoon_app_profile_palemoon.js
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-palemoon_app_profile_palemoon.js:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-palemoon_app_profile_palemoon.js Fri Jul 26 08:05:23 2024
@@ -0,0 +1,16 @@
+$NetBSD: patch-palemoon_app_profile_palemoon.js,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+Modify some defaults to provide a better initial experience on NetBSD.
+
+--- palemoon/app/profile/palemoon.js.orig 2024-07-10 12:35:09.000000000 +0000
++++ palemoon/app/profile/palemoon.js
+@@ -1255,3 +1255,9 @@ pref("status4evar.status.toolbar.maxLeng
+
+ pref("status4evar.status.popup.invertMirror", false);
+ pref("status4evar.status.popup.mouseMirror", true);
++
++// ** pkgsrc specific preferences **
++
++// Otherwise handshake fails on some sites,
++// see various posts on the pale moon forums
++pref("security.tls.version.max", 2);
Index: pkgsrc/www/palemoon/patches/patch-platform_build_moz.build
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_build_moz.build:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_build_moz.build Fri Jul 26 08:05:23 2024
@@ -0,0 +1,29 @@
+$NetBSD: patch-platform_build_moz.build,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+Avoid configure errors.
+
+--- platform/build/moz.build.orig 2024-07-25 09:37:43.581267584 +0000
++++ platform/build/moz.build
+@@ -52,12 +52,6 @@ if CONFIG['ENABLE_TESTS']:
+ if CONFIG['OS_ARCH'] == 'Linux':
+ FINAL_TARGET_FILES += ['/tools/rb/fix_linux_stack.py']
+
+-# Put a useful .gdbinit in the bin directory, to be picked up automatically
+-# by GDB when we debug executables there.
+-FINAL_TARGET_FILES += ['/.gdbinit']
+-FINAL_TARGET_PP_FILES += ['.gdbinit_python.in']
+-OBJDIR_FILES += ['!/dist/bin/.gdbinit_python']
+-
+ # Install the clang runtime library for ASAN next to the binaries we produce.
+ if CONFIG['MOZ_ASAN'] and CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']:
+ FINAL_TARGET_FILES += [CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']]
+@@ -78,9 +72,6 @@ if CONFIG['MOZ_APP_BASENAME']:
+ DEFINES['TOPSRCDIR'] = TOPSRCDIR
+ DEFINES['TOPOBJDIR'] = TOPOBJDIR
+
+-# NOTE: Keep .gdbinit in the topsrcdir for people who run gdb from the topsrcdir.
+-OBJDIR_FILES += ['/.gdbinit']
+-
+ # Put a .lldbinit in the bin directory and the objdir, to be picked up
+ # automatically by LLDB when we debug executables using either of those two
+ # directories as the current working directory. The .lldbinit file will
Index: pkgsrc/www/palemoon/patches/patch-platform_gfx_angle_src_libANGLE_renderer_gl_glx_FunctionsGLX.cpp
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_gfx_angle_src_libANGLE_renderer_gl_glx_FunctionsGLX.cpp:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_gfx_angle_src_libANGLE_renderer_gl_glx_FunctionsGLX.cpp Fri Jul 26 08:05:23 2024
@@ -0,0 +1,18 @@
+$NetBSD: patch-platform_gfx_angle_src_libANGLE_renderer_gl_glx_FunctionsGLX.cpp,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+NetBSD also does not have the libGL.so.1 version.
+
+--- platform/gfx/angle/src/libANGLE/renderer/gl/glx/FunctionsGLX.cpp.orig 2024-07-25 22:12:46.396663262 +0000
++++ platform/gfx/angle/src/libANGLE/renderer/gl/glx/FunctionsGLX.cpp
+@@ -130,7 +130,11 @@ bool FunctionsGLX::initialize(Display *x
+ // which a GLXWindow was ever created.
+ if (!sLibHandle)
+ {
++#if defined(__NetBSD__) || defined(__OpenBSD__)
++ sLibHandle = dlopen("libGL.so", RTLD_NOW);
++#else
+ sLibHandle = dlopen("libGL.so.1", RTLD_NOW);
++#endif
+ if (!sLibHandle)
+ {
+ *errorString = std::string("Could not dlopen libGL.so.1: ") + dlerror();
Index: pkgsrc/www/palemoon/patches/patch-platform_gfx_gl_GLContextProviderGLX.cpp
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_gfx_gl_GLContextProviderGLX.cpp:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_gfx_gl_GLContextProviderGLX.cpp Fri Jul 26 08:05:23 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-platform_gfx_gl_GLContextProviderGLX.cpp,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+NetBSD also does not have the libGL.so.1 version.
+
+--- platform/gfx/gl/GLContextProviderGLX.cpp.orig 2024-07-25 14:39:31.230121830 +0000
++++ platform/gfx/gl/GLContextProviderGLX.cpp
+@@ -84,7 +84,7 @@ GLXLibrary::EnsureInitialized()
+ // see e.g. bug 608526: it is intrinsically interesting to know whether we have dynamically linked to libGL.so.1
+ // because at least the NVIDIA implementation requires an executable stack, which causes mprotect calls,
+ // which trigger glibc bug http://sourceware.org/bugzilla/show_bug.cgi?id=12225
+-#ifdef __OpenBSD__
++#if defined(__OpenBSD__) || defined(__NetBSD__)
+ libGLfilename = "libGL.so";
+ #else
+ libGLfilename = "libGL.so.1";
Index: pkgsrc/www/palemoon/patches/patch-platform_intl_icu_source_configure
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_intl_icu_source_configure:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_intl_icu_source_configure Fri Jul 26 08:05:23 2024
@@ -0,0 +1,22 @@
+$NetBSD: patch-platform_intl_icu_source_configure,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+Shell portability.
+
+--- platform/intl/icu/source/configure.orig 2024-07-10 08:54:53.000000000 +0000
++++ platform/intl/icu/source/configure
+@@ -7867,13 +7867,13 @@ fi
+ # Now that we're done using CPPFLAGS etc. for tests, we can change it
+ # for build.
+
+-if test "${CC}" == "clang"; then
++if test "${CC}" = "clang"; then
+ CLANGCFLAGS="-Qunused-arguments -Wno-parentheses-equality"
+ else
+ CLANGCFLAGS=""
+ fi
+
+-if test "${CXX}" == "clang++"; then
++if test "${CXX}" = "clang++"; then
+ CLANGCXXFLAGS="-Qunused-arguments -Wno-parentheses-equality"
+ else
+ CLANGCXXFLAGS=""
Index: pkgsrc/www/palemoon/patches/patch-platform_js_src_jit_ProcessExecutableMemory.cpp
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_js_src_jit_ProcessExecutableMemory.cpp:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_js_src_jit_ProcessExecutableMemory.cpp Fri Jul 26 08:05:23 2024
@@ -0,0 +1,37 @@
+$NetBSD: patch-platform_js_src_jit_ProcessExecutableMemory.cpp,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+PaX MPROTECT safety for NetBSD.
+
+--- platform/js/src/jit/ProcessExecutableMemory.cpp.orig 2024-07-25 14:18:46.578160361 +0000
++++ platform/js/src/jit/ProcessExecutableMemory.cpp
+@@ -287,8 +287,15 @@ ReserveProcessExecutableMemory(size_t by
+ // Note that randomAddr is just a hint: if the address is not available
+ // mmap will pick a different address.
+ void* randomAddr = ComputeRandomAllocationAddress();
++#ifdef PROT_MPROTECT
++ void* p = MozTaggedAnonymousMmap(randomAddr, bytes,
++ PROT_MPROTECT(PROT_EXEC | PROT_WRITE | PROT_READ),
++ MAP_PRIVATE | MAP_ANON,
++ -1, 0, "js-executable-memory");
++#else
+ void* p = MozTaggedAnonymousMmap(randomAddr, bytes, PROT_NONE, MAP_PRIVATE | MAP_ANON,
+ -1, 0, "js-executable-memory");
++#endif
+ if (p == MAP_FAILED)
+ return nullptr;
+ return p;
+@@ -315,7 +322,13 @@ ProtectionSettingToFlags(ProtectionSetti
+ static void
+ CommitPages(void* addr, size_t bytes, ProtectionSetting protection)
+ {
+- void* p = MozTaggedAnonymousMmap(addr, bytes, ProtectionSettingToFlags(protection),
++ void* p = MozTaggedAnonymousMmap(addr, bytes,
++#ifdef PROT_MPROTECT
++ ProtectionSettingToFlags(protection) |
++ PROT_MPROTECT(PROT_EXEC | PROT_WRITE | PROT_READ),
++#else
++ ProtectionSettingToFlags(protection),
++#endif
+ MAP_FIXED | MAP_PRIVATE | MAP_ANON,
+ -1, 0, "js-executable-memory");
+ MOZ_RELEASE_ASSERT(addr == p);
Index: pkgsrc/www/palemoon/patches/patch-platform_js_src_vm_ArrayBufferObject.cpp
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_js_src_vm_ArrayBufferObject.cpp:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_js_src_vm_ArrayBufferObject.cpp Fri Jul 26 08:05:23 2024
@@ -0,0 +1,20 @@
+$NetBSD: patch-platform_js_src_vm_ArrayBufferObject.cpp,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+PaX MPROTECT safety for NetBSD.
+
+--- platform/js/src/vm/ArrayBufferObject.cpp.orig 2024-07-25 14:21:16.217887303 +0000
++++ platform/js/src/vm/ArrayBufferObject.cpp
+@@ -644,7 +644,12 @@ WasmArrayRawBuffer::Allocate(uint32_t nu
+ return nullptr;
+ }
+ # else // XP_WIN
+- void* data = MozTaggedAnonymousMmap(nullptr, (size_t) mappedSizeWithHeader, PROT_NONE,
++ void* data = MozTaggedAnonymousMmap(nullptr, (size_t) mappedSizeWithHeader,
++#ifdef PROT_MPROTECT
++ PROT_MPROTECT(PROT_EXEC | PROT_WRITE | PROT_READ),
++#else
++ PROT_NONE,
++#endif
+ MAP_PRIVATE | MAP_ANON, -1, 0, "wasm-reserved");
+ if (data == MAP_FAILED)
+ return nullptr;
Index: pkgsrc/www/palemoon/patches/patch-platform_media_libcubeb_src_cubeb__sun.c
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_media_libcubeb_src_cubeb__sun.c:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_media_libcubeb_src_cubeb__sun.c Fri Jul 26 08:05:23 2024
@@ -0,0 +1,1134 @@
+$NetBSD: patch-platform_media_libcubeb_src_cubeb__sun.c,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+Replace with modern version of the driver from current-ish firefox.
+
+Fixes playback artifacts on NetBSD.
+
+--- platform/media/libcubeb/src/cubeb_sun.c.orig 2024-07-25 20:59:35.023700095 +0000
++++ platform/media/libcubeb/src/cubeb_sun.c
+@@ -1,81 +1,74 @@
+ /*
+- * Copyright (c) 2013, 2017 Ginn Chen <ginnchen%gmail.com@localhost>
++ * Copyright © 2019-2024 Nia Alarie
+ *
+ * This program is made available under an ISC-style license. See the
+ * accompanying file LICENSE for details.
+ */
+-#include <poll.h>
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++#include <fcntl.h>
++#include <unistd.h>
+ #include <pthread.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+-#include <errno.h>
+-#include <fcntl.h>
+-#include <sys/audio.h>
+-#include <sys/stat.h>
+-#include <unistd.h>
+-#include <sys/stropts.h>
++#include <string.h>
++#include <math.h>
+ #include "cubeb/cubeb.h"
+ #include "cubeb-internal.h"
+
+-/* Macros copied from audio_oss.h */
+-/*
+- * CDDL HEADER START
+- *
+- * The contents of this file are subject to the terms of the
+- * Common Development and Distribution License (the "License").
+- * You may not use this file except in compliance with the License.
+- *
+- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+- * or http://www.opensolaris.org/os/licensing.
+- * See the License for the specific language governing permissions
+- * and limitations under the License.
+- *
+- * When distributing Covered Code, include this CDDL HEADER in each
+- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+- * If applicable, add the following below this CDDL HEADER, with the
+- * fields enclosed by brackets "[]" replaced with your own identifying
+- * information: Portions Copyright [yyyy] [name of copyright owner]
+- *
+- * CDDL HEADER END
+- */
++#define CUBEB_OLD_API /* seamonkey and older firefox */
++
++#define BYTES_TO_FRAMES(bytes, channels) \
++ (bytes / (channels * sizeof(int16_t)))
++
++#define FRAMES_TO_BYTES(frames, channels) \
++ (frames * (channels * sizeof(int16_t)))
++
++/* Default to 4 + 1 for the default device. */
++#ifndef SUN_DEVICE_COUNT
++#define SUN_DEVICE_COUNT (5)
++#endif
++
++/* Supported well by most hardware. */
++#ifndef SUN_PREFER_RATE
++#define SUN_PREFER_RATE (48000)
++#endif
++
++/* Standard acceptable minimum. */
++#ifndef SUN_LATENCY_MS
++#define SUN_LATENCY_MS (40)
++#endif
++
++#ifndef SUN_DEFAULT_DEVICE
++#define SUN_DEFAULT_DEVICE "/dev/audio"
++#endif
++
++#ifndef SUN_POLL_TIMEOUT
++#define SUN_POLL_TIMEOUT (1000)
++#endif
++
++#ifndef SUN_BUFFER_FRAMES
++#define SUN_BUFFER_FRAMES (32)
++#endif
++
+ /*
+- * Copyright (C) 4Front Technologies 1996-2008.
+- *
+- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+- * Use is subject to license terms.
++ * Supported on NetBSD regardless of hardware.
+ */
+-#define OSSIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */
+-#define OSSIOC_VOID 0x00000000 /* no parameters */
+-#define OSSIOC_OUT 0x20000000 /* copy out parameters */
+-#define OSSIOC_IN 0x40000000 /* copy in parameters */
+-#define OSSIOC_INOUT (OSSIOC_IN|OSSIOC_OUT)
+-#define OSSIOC_SZ(t) ((sizeof (t) & OSSIOCPARM_MASK) << 16)
+-#define __OSSIO(x, y) ((int)(OSSIOC_VOID|(x<<8)|y))
+-#define __OSSIOR(x, y, t) ((int)(OSSIOC_OUT|OSSIOC_SZ(t)|(x<<8)|y))
+-#define __OSSIOWR(x, y, t) ((int)(OSSIOC_INOUT|OSSIOC_SZ(t)|(x<<8)|y))
+-#define SNDCTL_DSP_SPEED __OSSIOWR('P', 2, int)
+-#define SNDCTL_DSP_CHANNELS __OSSIOWR('P', 6, int)
+-#define SNDCTL_DSP_SETFMT __OSSIOWR('P', 5, int) /* Selects ONE fmt */
+-#define SNDCTL_DSP_GETODELAY __OSSIOR('P', 23, int)
+-#define SNDCTL_DSP_HALT_OUTPUT __OSSIO('P', 34)
+-#define AFMT_S16_LE 0x00000010
+-#define AFMT_S16_BE 0x00000020
+
+-#if defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__)
+-#define AFMT_S16_NE AFMT_S16_BE
+-#else
+-#define AFMT_S16_NE AFMT_S16_LE
++#ifndef SUN_MAX_CHANNELS
++# ifdef __NetBSD__
++# define SUN_MAX_CHANNELS (12)
++# else
++# define SUN_MAX_CHANNELS (2)
++# endif
+ #endif
+
+-#define DEFAULT_AUDIO_DEVICE "/dev/audio"
+-#define DEFAULT_DSP_DEVICE "/dev/dsp"
+-
+-#define BUF_SIZE_MS 10
++#ifndef SUN_MIN_RATE
++#define SUN_MIN_RATE (1000)
++#endif
+
+-#if defined(CUBEB_SUNAUDIO_DEBUG)
+-#define DPR(...) fprintf(stderr, __VA_ARGS__);
+-#else
+-#define DPR(...) do {} while(0)
++#ifndef SUN_MAX_RATE
++#define SUN_MAX_RATE (192000)
+ #endif
+
+ static struct cubeb_ops const sunaudio_ops;
+@@ -85,420 +78,680 @@ struct cubeb {
+ };
+
+ struct cubeb_stream {
+- cubeb * context;
+- pthread_t th; /* to run real-time audio i/o */
+- pthread_mutex_t mutex; /* protects fd and frm_played */
+- int fd; /* link us to sunaudio */
+- int active; /* cubec_start() called */
+- int conv; /* need float->s16 conversion */
+- int using_oss;
+- unsigned char *buf; /* data is prepared here */
+- unsigned int rate;
+- unsigned int n_channles;
+- unsigned int bytes_per_ch;
+- unsigned int n_frm;
+- unsigned int buffer_size;
+- int64_t frm_played;
+- cubeb_data_callback data_cb; /* cb to preapare data */
+- cubeb_state_callback state_cb; /* cb to notify about state changes */
+- void *arg; /* user arg to {data,state}_cb */
++ struct cubeb * context;
++ void * user_ptr;
++ pthread_t thread;
++ pthread_mutex_t mutex; /* protects running, volume, frames_written */
++ int floating;
++ int running;
++ int play_fd;
++ int record_fd;
++ float volume;
++ struct audio_info p_info; /* info for the play fd */
++ struct audio_info r_info; /* info for the record fd */
++ cubeb_data_callback data_cb;
++ cubeb_state_callback state_cb;
++ int16_t * play_buf;
++ int16_t * record_buf;
++ float * f_play_buf;
++ float * f_record_buf;
++ char input_name[32];
++ char output_name[32];
++ uint64_t frames_written;
++ uint64_t blocks_written;
+ };
+
++int
++sunaudio_init(cubeb ** context, char const * context_name)
++{
++ cubeb * c;
++
++ (void)context_name;
++ if ((c = calloc(1, sizeof(cubeb))) == NULL) {
++ return CUBEB_ERROR;
++ }
++ c->ops = &sunaudio_ops;
++ *context = c;
++ return CUBEB_OK;
++}
++
+ static void
+-float_to_s16(void *ptr, long nsamp)
++sunaudio_destroy(cubeb * context)
+ {
+- int16_t *dst = ptr;
+- float *src = ptr;
++ free(context);
++}
+
+- while (nsamp-- > 0)
+- *(dst++) = *(src++) * 32767;
++static char const *
++sunaudio_get_backend_id(cubeb * context)
++{
++ return "sun";
+ }
+
+-static void *
+-sunaudio_mainloop(void *arg)
++static int
++sunaudio_get_preferred_sample_rate(cubeb * context, uint32_t * rate)
+ {
+- struct cubeb_stream *s = arg;
+- int state;
++ (void)context;
+
+- DPR("sunaudio_mainloop()\n");
++ *rate = SUN_PREFER_RATE;
++ return CUBEB_OK;
++}
+
+- s->state_cb(s, s->arg, CUBEB_STATE_STARTED);
++static int
++sunaudio_get_max_channel_count(cubeb * context, uint32_t * max_channels)
++{
++ (void)context;
+
+- pthread_mutex_lock(&s->mutex);
+- DPR("sunaudio_mainloop(), started\n");
++ *max_channels = SUN_MAX_CHANNELS;
++ return CUBEB_OK;
++}
+
+- for (;;) {
+- if (!s->active) {
+- DPR("sunaudio_mainloop() stopped\n");
+- state = CUBEB_STATE_STOPPED;
+- break;
+- }
++static int
++sunaudio_get_min_latency(cubeb * context, cubeb_stream_params params,
++ uint32_t * latency_frames)
++{
++ (void)context;
+
+- if (!s->using_oss) {
+- audio_info_t info;
+- ioctl(s->fd, AUDIO_GETINFO, &info);
+- if (s->frm_played > info.play.samples + 3 * s->n_frm) {
+- pthread_mutex_unlock(&s->mutex);
+- struct timespec ts = {0, 10000}; // 10 ms
+- nanosleep(&ts, NULL);
+- pthread_mutex_lock(&s->mutex);
+- continue;
+- }
+- }
++ *latency_frames = SUN_LATENCY_MS * params.rate / 1000;
++ return CUBEB_OK;
++}
+
+- pthread_mutex_unlock(&s->mutex);
+- unsigned int got = s->data_cb(s, s->arg, NULL, s->buf, s->n_frm);
+- DPR("sunaudio_mainloop() ask %d got %d\n", s->n_frm, got);
+- pthread_mutex_lock(&s->mutex);
++static int
++sunaudio_get_hwinfo(const char * device, struct audio_info * format,
++ int * props, struct audio_device * dev)
++{
++ int fd = -1;
+
+- if (got < 0) {
+- DPR("sunaudio_mainloop() cb err\n");
+- state = CUBEB_STATE_ERROR;
+- break;
+- }
++ if ((fd = open(device, O_RDONLY)) == -1) {
++ goto error;
++ }
++#ifdef AUDIO_GETFORMAT
++ if (ioctl(fd, AUDIO_GETFORMAT, format) != 0) {
++ goto error;
++ }
++#endif
++#ifdef AUDIO_GETPROPS
++ if (ioctl(fd, AUDIO_GETPROPS, props) != 0) {
++ goto error;
++ }
++#endif
++ if (ioctl(fd, AUDIO_GETDEV, dev) != 0) {
++ goto error;
++ }
++ close(fd);
++ return CUBEB_OK;
++error:
++ if (fd != -1) {
++ close(fd);
++ }
++ return CUBEB_ERROR;
++}
+
+- if (s->conv) {
+- float_to_s16(s->buf, got * s->n_channles);
+- }
++/*
++ * XXX: PR kern/54264
++ */
++static int
++sunaudio_prinfo_verify_sanity(struct audio_prinfo * prinfo)
++{
++ return prinfo->precision >= 8 && prinfo->precision <= 32 &&
++ prinfo->channels >= 1 && prinfo->channels < SUN_MAX_CHANNELS &&
++ prinfo->sample_rate < SUN_MAX_RATE && prinfo->sample_rate > SUN_MIN_RATE;
++}
++
++#ifndef CUBEB_OLD_API
++static int
++sunaudio_enumerate_devices(cubeb * context, cubeb_device_type type,
++ cubeb_device_collection * collection)
++{
++ unsigned i;
++ cubeb_device_info device = {0};
++ char dev[16] = SUN_DEFAULT_DEVICE;
++ char dev_friendly[64];
++ struct audio_info hwfmt;
++ struct audio_device hwname;
++ struct audio_prinfo *prinfo = NULL;
++ int hwprops;
+
+- unsigned int avail = got * 2 * s->n_channles; // coverted to s16
+- unsigned int pos = 0;
++ collection->device = calloc(SUN_DEVICE_COUNT, sizeof(cubeb_device_info));
++ if (collection->device == NULL) {
++ return CUBEB_ERROR;
++ }
++ collection->count = 0;
+
+- while (avail > 0 && s->active) {
+- int written = write(s->fd, s->buf + pos, avail);
+- if (written == -1) {
+- if (errno != EINTR && errno != EWOULDBLOCK) {
+- DPR("sunaudio_mainloop() write err\n");
+- state = CUBEB_STATE_ERROR;
+- break;
+- }
+- pthread_mutex_unlock(&s->mutex);
+- struct timespec ts = {0, 10000}; // 10 ms
+- nanosleep(&ts, NULL);
+- pthread_mutex_lock(&s->mutex);
+- } else {
+- pos += written;
+- DPR("sunaudio_mainloop() write %d pos %d\n", written, pos);
+- s->frm_played += written / 2 / s->n_channles;
+- avail -= written;
++ for (i = 0; i < SUN_DEVICE_COUNT; ++i) {
++ if (i > 0) {
++ (void)snprintf(dev, sizeof(dev), "/dev/audio%u", i - 1);
++ }
++ if (sunaudio_get_hwinfo(dev, &hwfmt, &hwprops, &hwname) != CUBEB_OK) {
++ continue;
++ }
++#ifdef AUDIO_GETPROPS
++ device.type = 0;
++ if ((hwprops & AUDIO_PROP_CAPTURE) != 0 &&
++ sunaudio_prinfo_verify_sanity(&hwfmt.record)) {
++ /* the device supports recording, probably */
++ device.type |= CUBEB_DEVICE_TYPE_INPUT;
++ }
++ if ((hwprops & AUDIO_PROP_PLAYBACK) != 0 &&
++ sunaudio_prinfo_verify_sanity(&hwfmt.play)) {
++ /* the device supports playback, probably */
++ device.type |= CUBEB_DEVICE_TYPE_OUTPUT;
++ }
++ switch (device.type) {
++ case 0:
++ /* device doesn't do input or output, aliens probably involved */
++ continue;
++ case CUBEB_DEVICE_TYPE_INPUT:
++ if ((type & CUBEB_DEVICE_TYPE_INPUT) == 0) {
++ /* this device is input only, not scanning for those, skip it */
++ continue;
+ }
+- }
+-
+- if ((got < s->n_frm)) {
+- DPR("sunaudio_mainloop() drained\n");
+- state = CUBEB_STATE_DRAINED;
+ break;
++ case CUBEB_DEVICE_TYPE_OUTPUT:
++ if ((type & CUBEB_DEVICE_TYPE_OUTPUT) == 0) {
++ /* this device is output only, not scanning for those, skip it */
++ continue;
++ }
++ break;
++ }
++ if ((type & CUBEB_DEVICE_TYPE_INPUT) != 0) {
++ prinfo = &hwfmt.record;
+ }
++ if ((type & CUBEB_DEVICE_TYPE_OUTPUT) != 0) {
++ prinfo = &hwfmt.play;
++ }
++#endif
++ if (i > 0) {
++ (void)snprintf(dev_friendly, sizeof(dev_friendly), "%s %s %s (%d)",
++ hwname.name, hwname.version, hwname.config, i - 1);
++ } else {
++ (void)snprintf(dev_friendly, sizeof(dev_friendly), "%s %s %s (default)",
++ hwname.name, hwname.version, hwname.config);
++ }
++ device.devid = (void *)(uintptr_t)i;
++ device.device_id = strdup(dev);
++ device.friendly_name = strdup(dev_friendly);
++ device.group_id = strdup(dev);
++ device.vendor_name = strdup(hwname.name);
++ device.type = type;
++ device.state = CUBEB_DEVICE_STATE_ENABLED;
++ device.preferred = (i == 0) ? CUBEB_DEVICE_PREF_ALL : CUBEB_DEVICE_PREF_NONE;
++#ifdef AUDIO_GETFORMAT
++ device.max_channels = prinfo->channels;
++ device.default_rate = prinfo->sample_rate;
++#else
++ device.max_channels = 2;
++ device.default_rate = SUN_PREFER_RATE;
++#endif
++ device.default_format = CUBEB_DEVICE_FMT_S16NE;
++ device.format = CUBEB_DEVICE_FMT_S16NE;
++ device.min_rate = SUN_MIN_RATE;
++ device.max_rate = SUN_MAX_RATE;
++ device.latency_lo = SUN_LATENCY_MS * SUN_MIN_RATE / 1000;
++ device.latency_hi = SUN_LATENCY_MS * SUN_MAX_RATE / 1000;
++ collection->device[collection->count++] = device;
+ }
++ return CUBEB_OK;
++}
++#endif
+
+- pthread_mutex_unlock(&s->mutex);
+- s->state_cb(s, s->arg, state);
++#ifndef CUBEB_OLD_API
++static int
++sunaudio_device_collection_destroy(cubeb * context,
++ cubeb_device_collection * collection)
++{
++ unsigned i;
+
+- return NULL;
++ for (i = 0; i < collection->count; ++i) {
++ free((char *)collection->device[i].device_id);
++ free((char *)collection->device[i].friendly_name);
++ free((char *)collection->device[i].group_id);
++ free((char *)collection->device[i].vendor_name);
++ }
++ free(collection->device);
++ return CUBEB_OK;
+ }
++#endif
+
+-/*static*/ int
+-sunaudio_init(cubeb **context, char const *context_name)
++static int
++sunaudio_copy_params(int fd, cubeb_stream * stream, cubeb_stream_params * params,
++ struct audio_info * info, struct audio_prinfo * prinfo)
+ {
+- DPR("sunaudio_init(%s)\n", context_name);
+- *context = malloc(sizeof(*context));
+- (*context)->ops = &sunaudio_ops;
+- (void)context_name;
++ prinfo->channels = params->channels;
++ prinfo->sample_rate = params->rate;
++ prinfo->precision = 16;
++#ifdef AUDIO_ENCODING_SLINEAR_LE
++ switch (params->format) {
++ case CUBEB_SAMPLE_S16LE:
++ prinfo->encoding = AUDIO_ENCODING_SLINEAR_LE;
++ break;
++ case CUBEB_SAMPLE_S16BE:
++ prinfo->encoding = AUDIO_ENCODING_SLINEAR_BE;
++ break;
++ case CUBEB_SAMPLE_FLOAT32NE:
++ stream->floating = 1;
++ prinfo->encoding = AUDIO_ENCODING_SLINEAR;
++ break;
++ default:
++ return CUBEB_ERROR_INVALID_FORMAT;
++ }
++#else
++ switch (params->format) {
++ case CUBEB_SAMPLE_S16NE:
++ prinfo->encoding = AUDIO_ENCODING_LINEAR;
++ break;
++ case CUBEB_SAMPLE_FLOAT32NE:
++ stream->floating = 1;
++ prinfo->encoding = AUDIO_ENCODING_LINEAR;
++ break;
++ default:
++ return CUBEB_ERROR_INVALID_FORMAT;
++ }
++#endif
++ if (ioctl(fd, AUDIO_SETINFO, info) == -1) {
++ return CUBEB_ERROR;
++ }
++ if (ioctl(fd, AUDIO_GETINFO, info) == -1) {
++ return CUBEB_ERROR;
++ }
+ return CUBEB_OK;
+ }
+
+-static char const *
+-sunaudio_get_backend_id(cubeb *context)
++static int
++sunaudio_stream_stop(cubeb_stream * s)
+ {
+- return "sunaudio";
++ pthread_mutex_lock(&s->mutex);
++ if (s->running) {
++ s->running = 0;
++ pthread_mutex_unlock(&s->mutex);
++ pthread_join(s->thread, NULL);
++ } else {
++ pthread_mutex_unlock(&s->mutex);
++ }
++ return CUBEB_OK;
+ }
+
+ static void
+-sunaudio_destroy(cubeb *context)
++sunaudio_stream_destroy(cubeb_stream * s)
+ {
+- DPR("sunaudio_destroy()\n");
+- free(context);
++ pthread_mutex_destroy(&s->mutex);
++ sunaudio_stream_stop(s);
++ if (s->play_fd != -1) {
++ close(s->play_fd);
++ }
++ if (s->record_fd != -1) {
++ close(s->record_fd);
++ }
++ free(s->f_play_buf);
++ free(s->f_record_buf);
++ free(s->play_buf);
++ free(s->record_buf);
++ free(s);
+ }
+
+-static int
+-sunaudio_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,
+- cubeb_data_callback data_callback,
+- cubeb_state_callback state_callback,
+- void *user_ptr)
+-{
+- struct cubeb_stream *s;
+- DPR("sunaudio_stream_init(%s)\n", stream_name);
+- size_t size;
+-
+- s = malloc(sizeof(struct cubeb_stream));
+- if (s == NULL)
+- return CUBEB_ERROR;
+- s->context = context;
++static void
++sunaudio_float_to_linear(float * in, int16_t * out,
++ unsigned channels, long frames, float vol)
++{
++ unsigned i, sample_count = frames * channels;
++ float multiplier = vol * 0x8000;
+
+- // If UTAUDIODEV is set, use it with Sun Audio interface
+- char * sa_device_name = getenv("UTAUDIODEV");
+- char * dsp_device_name = NULL;
+- if (!sa_device_name) {
+- dsp_device_name = getenv("AUDIODSP");
+- if (!dsp_device_name) {
+- dsp_device_name = DEFAULT_DSP_DEVICE;
+- }
+- sa_device_name = getenv("AUDIODEV");
+- if (!sa_device_name) {
+- sa_device_name = DEFAULT_AUDIO_DEVICE;
++ for (i = 0; i < sample_count; ++i) {
++ int32_t sample = lrintf(in[i] * multiplier);
++ if (sample < -0x8000) {
++ out[i] = -0x8000;
++ } else if (sample > 0x7fff) {
++ out[i] = 0x7fff;
++ } else {
++ out[i] = sample;
+ }
+ }
++}
+
+- s->using_oss = 0;
+- // Try to use OSS if available
+- if (dsp_device_name) {
+- s->fd = open(dsp_device_name, O_WRONLY | O_NONBLOCK);
+- if (s->fd >= 0) {
+- s->using_oss = 1;
+- }
+- }
++static void
++sunaudio_linear_to_float(int16_t * in, float * out,
++ unsigned channels, long frames)
++{
++ unsigned i, sample_count = frames * channels;
+
+- // Try Sun Audio
+- if (!s->using_oss) {
+- s->fd = open(sa_device_name, O_WRONLY | O_NONBLOCK);
++ for (i = 0; i < sample_count; ++i) {
++ out[i] = (1.0 / 0x8000) * in[i];
+ }
++}
+
+- if (s->fd < 0) {
+- free(s);
+- DPR("sunaudio_stream_init(), open() failed\n");
+- return CUBEB_ERROR;
+- }
++static void
++sunaudio_linear_set_vol(int16_t * buf, unsigned channels, long frames, float vol)
++{
++ unsigned i, sample_count = frames * channels;
++ int32_t multiplier = vol * 0x8000;
+
+- if (s->using_oss) {
+- if (ioctl(s->fd, SNDCTL_DSP_SPEED, &output_stream_params->rate) < 0) {
+- DPR("ioctl SNDCTL_DSP_SPEED failed.\n");
+- close(s->fd);
+- free(s);
+- return CUBEB_ERROR_INVALID_FORMAT;
+- }
+-
+- if (ioctl(s->fd, SNDCTL_DSP_CHANNELS, &output_stream_params->channels) < 0) {
+- DPR("ioctl SNDCTL_DSP_CHANNELS failed.\n");
+- close(s->fd);
+- free(s);
+- return CUBEB_ERROR_INVALID_FORMAT;
+- }
+-
+- int format = AFMT_S16_NE;
+- if (ioctl(s->fd, SNDCTL_DSP_SETFMT, &format) < 0) {
+- DPR("ioctl SNDCTL_DSP_SETFMT failed.\n");
+- close(s->fd);
+- free(s);
+- return CUBEB_ERROR_INVALID_FORMAT;
+- }
+- } else {
+- audio_info_t audio_info;
+- AUDIO_INITINFO(&audio_info)
+- audio_info.play.sample_rate = output_stream_params->rate;
+- audio_info.play.channels = output_stream_params->channels;
+- audio_info.play.encoding = AUDIO_ENCODING_LINEAR;
+- audio_info.play.precision = 16;
+- if (ioctl(s->fd, AUDIO_SETINFO, &audio_info) == -1) {
+- DPR("ioctl AUDIO_SETINFO failed.\n");
+- close(s->fd);
+- free(s);
+- return CUBEB_ERROR_INVALID_FORMAT;
+- }
++ for (i = 0; i < sample_count; ++i) {
++ buf[i] = (buf[i] * multiplier) >> 15;
+ }
++}
+
+- s->conv = 0;
+- switch (output_stream_params->format) {
+- case CUBEB_SAMPLE_S16NE:
+- s->bytes_per_ch = 2;
++static void *
++sunaudio_io_routine(void * arg)
++{
++ cubeb_stream *s = arg;
++ cubeb_state state = CUBEB_STATE_STARTED;
++ size_t to_read = 0;
++ long to_write = 0;
++ size_t write_ofs = 0;
++ size_t read_ofs = 0;
++ int drain = 0;
++
++ s->state_cb(s, s->user_ptr, CUBEB_STATE_STARTED);
++ while (state != CUBEB_STATE_ERROR) {
++ pthread_mutex_lock(&s->mutex);
++ if (!s->running) {
++ pthread_mutex_unlock(&s->mutex);
++ state = CUBEB_STATE_STOPPED;
+ break;
+- case CUBEB_SAMPLE_FLOAT32NE:
+- s->bytes_per_ch = 4;
+- s->conv = 1;
++ }
++ pthread_mutex_unlock(&s->mutex);
++ if (s->floating) {
++ if (s->record_fd != -1) {
++ sunaudio_linear_to_float(s->record_buf, s->f_record_buf,
++ s->r_info.record.channels, SUN_BUFFER_FRAMES);
++ }
++ to_write = s->data_cb(s, s->user_ptr,
++ s->f_record_buf, s->f_play_buf, SUN_BUFFER_FRAMES);
++ if (to_write == CUBEB_ERROR) {
++ state = CUBEB_STATE_ERROR;
++ break;
++ }
++ if (s->play_fd != -1) {
++ pthread_mutex_lock(&s->mutex);
++ sunaudio_float_to_linear(s->f_play_buf, s->play_buf,
++ s->p_info.play.channels, to_write, s->volume);
++ pthread_mutex_unlock(&s->mutex);
++ }
++ } else {
++ to_write = s->data_cb(s, s->user_ptr,
++ s->record_buf, s->play_buf, SUN_BUFFER_FRAMES);
++ if (to_write == CUBEB_ERROR) {
++ state = CUBEB_STATE_ERROR;
++ break;
++ }
++ if (s->play_fd != -1) {
++ pthread_mutex_lock(&s->mutex);
++ sunaudio_linear_set_vol(s->play_buf, s->p_info.play.channels, to_write, s->volume);
++ pthread_mutex_unlock(&s->mutex);
++ }
++ }
++ if (to_write < SUN_BUFFER_FRAMES) {
++ drain = 1;
++ }
++ to_write = s->play_fd != -1 ? to_write : 0;
++ to_read = s->record_fd != -1 ? SUN_BUFFER_FRAMES : 0;
++ write_ofs = 0;
++ read_ofs = 0;
++ while (to_write > 0 || to_read > 0) {
++ size_t bytes;
++ ssize_t n, frames;
++
++ if (to_write > 0) {
++ bytes = FRAMES_TO_BYTES(to_write, s->p_info.play.channels);
++ if ((n = write(s->play_fd, s->play_buf + write_ofs, bytes)) < 0) {
++ state = CUBEB_STATE_ERROR;
++ break;
++ }
++ frames = BYTES_TO_FRAMES(n, s->p_info.play.channels);
++ pthread_mutex_lock(&s->mutex);
++ s->frames_written += frames;
++ pthread_mutex_unlock(&s->mutex);
++ to_write -= frames;
++ write_ofs += frames;
++ }
++ if (to_read > 0) {
++ bytes = FRAMES_TO_BYTES(to_read, s->r_info.record.channels);
++ if ((n = read(s->record_fd, s->record_buf + read_ofs, bytes)) < 0) {
++ state = CUBEB_STATE_ERROR;
++ break;
++ }
++ frames = BYTES_TO_FRAMES(n, s->r_info.record.channels);
++ to_read -= frames;
++ read_ofs += frames;
++ }
++ }
++ if (drain && state != CUBEB_STATE_ERROR) {
++ state = CUBEB_STATE_DRAINED;
+ break;
+- default:
+- DPR("sunaudio_stream_init() unsupported format\n");
+- close(s->fd);
+- free(s);
+- return CUBEB_ERROR_INVALID_FORMAT;
++ }
+ }
++ s->state_cb(s, s->user_ptr, state);
++ return NULL;
++}
+
+- s->active = 0;
+- s->rate = output_stream_params->rate;
+- s->n_channles = output_stream_params->channels;
+- s->data_cb = data_callback;
++static int
++sunaudio_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 latency_frames,
++ cubeb_data_callback data_callback,
++ cubeb_state_callback state_callback,
++ void * user_ptr)
++{
++ int ret = CUBEB_OK;
++ cubeb_stream *s = NULL;
++
++ (void)stream_name;
++ (void)latency_frames;
++ if ((s = calloc(1, sizeof(cubeb_stream))) == NULL) {
++ ret = CUBEB_ERROR;
++ goto error;
++ }
++ s->record_fd = -1;
++ s->play_fd = -1;
++ if (input_device != 0) {
++ snprintf(s->input_name, sizeof(s->input_name),
++ "/dev/audio%zu", (uintptr_t)input_device - 1);
++ } else {
++ snprintf(s->input_name, sizeof(s->input_name), "%s", SUN_DEFAULT_DEVICE);
++ }
++ if (output_device != 0) {
++ snprintf(s->output_name, sizeof(s->output_name),
++ "/dev/audio%zu", (uintptr_t)output_device - 1);
++ } else {
++ snprintf(s->output_name, sizeof(s->output_name), "%s", SUN_DEFAULT_DEVICE);
++ }
++ if (input_stream_params != NULL) {
++#ifndef CUBEB_OLD_API
++ if (input_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) {
++ ret = CUBEB_ERROR_NOT_SUPPORTED;
++ goto error;
++ }
++#endif
++ if (s->record_fd == -1) {
++ if ((s->record_fd = open(s->input_name, O_RDONLY)) == -1) {
++ ret = CUBEB_ERROR_DEVICE_UNAVAILABLE;
++ goto error;
++ }
++ }
++ AUDIO_INITINFO(&s->r_info);
++#ifdef AUMODE_RECORD
++ s->r_info.mode = AUMODE_RECORD;
++#endif
++ if ((ret = sunaudio_copy_params(s->record_fd, s, input_stream_params,
++ &s->r_info, &s->r_info.record)) != CUBEB_OK) {
++ goto error;
++ }
++ }
++ if (output_stream_params != NULL) {
++#ifndef CUBEB_OLD_API
++ if (output_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) {
++ ret = CUBEB_ERROR_NOT_SUPPORTED;
++ goto error;
++ }
++#endif
++ if (s->play_fd == -1) {
++ if ((s->play_fd = open(s->output_name, O_WRONLY)) == -1) {
++ ret = CUBEB_ERROR_DEVICE_UNAVAILABLE;
++ goto error;
++ }
++ }
++ AUDIO_INITINFO(&s->p_info);
++#ifdef AUMODE_PLAY
++ s->p_info.mode = AUMODE_PLAY;
++#endif
++ if ((ret = sunaudio_copy_params(s->play_fd, s, output_stream_params,
++ &s->p_info, &s->p_info.play)) != CUBEB_OK) {
++ goto error;
++ }
++ }
++ s->context = context;
++ s->volume = 1.0;
+ s->state_cb = state_callback;
+- s->arg = user_ptr;
++ s->data_cb = data_callback;
++ s->user_ptr = user_ptr;
+ if (pthread_mutex_init(&s->mutex, NULL) != 0) {
+- free(s);
+- return CUBEB_ERROR;
++ goto error;
+ }
+- s->frm_played = 0;
+- s->n_frm = s->rate * BUF_SIZE_MS / 1000;
+- s->buffer_size = s->bytes_per_ch * s->n_channles * s->n_frm;
+- s->buf = malloc(s->buffer_size);
+- if (s->buf == NULL) {
+- close(s->fd);
+- free(s);
+- return CUBEB_ERROR;
++ if (s->play_fd != -1 && (s->play_buf = calloc(SUN_BUFFER_FRAMES,
++ s->p_info.play.channels * sizeof(int16_t))) == NULL) {
++ ret = CUBEB_ERROR;
++ goto error;
++ }
++ if (s->record_fd != -1 && (s->record_buf = calloc(SUN_BUFFER_FRAMES,
++ s->r_info.record.channels * sizeof(int16_t))) == NULL) {
++ ret = CUBEB_ERROR;
++ goto error;
++ }
++ if (s->floating) {
++ if (s->play_fd != -1 && (s->f_play_buf = calloc(SUN_BUFFER_FRAMES,
++ s->p_info.play.channels * sizeof(float))) == NULL) {
++ ret = CUBEB_ERROR;
++ goto error;
++ }
++ if (s->record_fd != -1 && (s->f_record_buf = calloc(SUN_BUFFER_FRAMES,
++ s->r_info.record.channels * sizeof(float))) == NULL) {
++ ret = CUBEB_ERROR;
++ goto error;
++ }
+ }
+-
+ *stream = s;
+- DPR("sunaudio_stream_init() end, ok\n");
+ return CUBEB_OK;
+-}
+-
+-static void
+-sunaudio_stream_destroy(cubeb_stream *s)
+-{
+- DPR("sunaudio_stream_destroy()\n");
+- if (s->fd > 0) {
+- // Flush buffer
+- if (s->using_oss) {
+- ioctl(s->fd, SNDCTL_DSP_HALT_OUTPUT);
+- } else {
+- ioctl(s->fd, I_FLUSH);
+- }
+- close(s->fd);
++error:
++ if (s != NULL) {
++ sunaudio_stream_destroy(s);
+ }
+- free(s->buf);
+- free(s);
++ return ret;
+ }
+
+ static int
+-sunaudio_stream_start(cubeb_stream *s)
++sunaudio_stream_start(cubeb_stream * s)
+ {
+- int err;
+-
+- DPR("sunaudio_stream_start()\n");
+- s->active = 1;
+- err = pthread_create(&s->th, NULL, sunaudio_mainloop, s);
+- if (err) {
+- s->active = 0;
++ s->running = 1;
++ if (pthread_create(&s->thread, NULL, sunaudio_io_routine, s) != 0) {
+ return CUBEB_ERROR;
+ }
+ return CUBEB_OK;
+ }
+
+ static int
+-sunaudio_stream_stop(cubeb_stream *s)
++sunaudio_stream_get_position(cubeb_stream * s, uint64_t * position)
+ {
+- void *dummy;
++#ifdef AUDIO_GETOOFFS
++ struct audio_offset offset;
+
+- DPR("sunaudio_stream_stop()\n");
+- if (s->active) {
+- s->active = 0;
+- pthread_join(s->th, &dummy);
++ if (ioctl(s->play_fd, AUDIO_GETOOFFS, &offset) == -1) {
++ return CUBEB_ERROR;
+ }
++ s->blocks_written += offset.deltablks;
++ *position = BYTES_TO_FRAMES(s->blocks_written * s->p_info.blocksize,
++ s->p_info.play.channels);
+ return CUBEB_OK;
+-}
+-
+-static int
+-sunaudio_stream_get_position(cubeb_stream *s, uint64_t *p)
+-{
+- int rv = CUBEB_OK;
++#else
+ pthread_mutex_lock(&s->mutex);
+- if (s->active && s->fd > 0) {
+- if (s->using_oss) {
+- int delay;
+- ioctl(s->fd, SNDCTL_DSP_GETODELAY, &delay);
+- int64_t t = s->frm_played - delay / s->n_channles / 2;
+- if (t < 0) {
+- *p = 0;
+- } else {
+- *p = t;
+- }
+- } else {
+- audio_info_t info;
+- ioctl(s->fd, AUDIO_GETINFO, &info);
+- *p = info.play.samples;
+- }
+- DPR("sunaudio_stream_get_position() %lld\n", *p);
+- } else {
+- rv = CUBEB_ERROR;
+- }
++ *position = s->frames_written;
+ pthread_mutex_unlock(&s->mutex);
+- return rv;
++ return CUBEB_OK;
++#endif
+ }
+
+ static int
+-sunaudio_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
++sunaudio_stream_get_latency(cubeb_stream * stream, uint32_t * latency)
+ {
+- if (!ctx || !max_channels)
+- return CUBEB_ERROR;
++#ifdef AUDIO_GETBUFINFO
++ struct audio_info info;
+
+- *max_channels = 2;
++ if (ioctl(stream->play_fd, AUDIO_GETBUFINFO, &info) == -1) {
++ return CUBEB_ERROR;
++ }
+
++ *latency = BYTES_TO_FRAMES(info.play.seek + info.blocksize,
++ info.play.channels);
+ return CUBEB_OK;
++#else
++ cubeb_stream_params params;
++
++ params.rate = stream->p_info.play.sample_rate;
++
++ return sunaudio_get_min_latency(NULL, params, latency);
++#endif
+ }
+
+ static int
+-sunaudio_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate)
++sunaudio_stream_set_volume(cubeb_stream * stream, float volume)
+ {
+- if (!ctx || !rate)
+- return CUBEB_ERROR;
+-
+- // XXX Not yet implemented.
+- *rate = 44100;
+-
++ pthread_mutex_lock(&stream->mutex);
++ stream->volume = volume;
++ pthread_mutex_unlock(&stream->mutex);
+ return CUBEB_OK;
+ }
+
+ static int
+-sunaudio_get_min_latency(cubeb * ctx, cubeb_stream_params params, uint32_t * latency_ms)
++sunaudio_get_current_device(cubeb_stream * stream, cubeb_device ** const device)
+ {
+- if (!ctx || !latency_ms)
++ *device = calloc(1, sizeof(cubeb_device));
++ if (*device == NULL) {
+ return CUBEB_ERROR;
+-
+- // XXX Not yet implemented.
+- *latency_ms = 20;
+-
++ }
++ (*device)->input_name = stream->record_fd != -1 ?
++ strdup(stream->input_name) : NULL;
++ (*device)->output_name = stream->play_fd != -1 ?
++ strdup(stream->output_name) : NULL;
+ return CUBEB_OK;
+ }
+
+ static int
+-sunaudio_stream_get_latency(cubeb_stream * s, uint32_t * latency)
++sunaudio_stream_device_destroy(cubeb_stream * stream, cubeb_device * device)
+ {
+- if (!s || !latency)
+- return CUBEB_ERROR;
+-
+- int rv = CUBEB_OK;
+- pthread_mutex_lock(&s->mutex);
+- if (s->active && s->fd > 0) {
+- if (s->using_oss) {
+- int delay;
+- ioctl(s->fd, SNDCTL_DSP_GETODELAY, &delay);
+- *latency = delay / s->n_channles / 2 / s->rate;
+- } else {
+- audio_info_t info;
+- ioctl(s->fd, AUDIO_GETINFO, &info);
+- *latency = (s->frm_played - info.play.samples) / s->rate;
+- }
+- DPR("sunaudio_stream_get_position() %lld\n", *p);
+- } else {
+- rv = CUBEB_ERROR;
+- }
+- pthread_mutex_unlock(&s->mutex);
+- return rv;
++ (void)stream;
++ free(device->input_name);
++ free(device->output_name);
++ free(device);
++ return CUBEB_OK;
+ }
+
+ static struct cubeb_ops const sunaudio_ops = {
+ .init = sunaudio_init,
+ .get_backend_id = sunaudio_get_backend_id,
+- .destroy = sunaudio_destroy,
++ .get_max_channel_count = sunaudio_get_max_channel_count,
++ .get_min_latency = sunaudio_get_min_latency,
+ .get_preferred_sample_rate = sunaudio_get_preferred_sample_rate,
++#ifndef CUBEB_OLD_API
++ .enumerate_devices = sunaudio_enumerate_devices,
++ .device_collection_destroy = sunaudio_device_collection_destroy,
++#endif
++ .destroy = sunaudio_destroy,
+ .stream_init = sunaudio_stream_init,
+ .stream_destroy = sunaudio_stream_destroy,
+ .stream_start = sunaudio_stream_start,
+ .stream_stop = sunaudio_stream_stop,
++#ifndef CUBEB_OLD_API
++ .stream_reset_default_device = NULL,
++#endif
+ .stream_get_position = sunaudio_stream_get_position,
+- .get_max_channel_count = sunaudio_get_max_channel_count,
+- .get_min_latency = sunaudio_get_min_latency,
+- .stream_get_latency = sunaudio_stream_get_latency
++ .stream_get_latency = sunaudio_stream_get_latency,
++ .stream_set_volume = sunaudio_stream_set_volume,
++ .stream_set_panning = NULL,
++ .stream_get_current_device = sunaudio_get_current_device,
++ .stream_device_destroy = sunaudio_stream_device_destroy,
++ .stream_register_device_changed_callback = NULL,
++ .register_device_collection_changed = NULL
+ };
Index: pkgsrc/www/palemoon/patches/patch-platform_media_libcubeb_src_moz.build
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_media_libcubeb_src_moz.build:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_media_libcubeb_src_moz.build Fri Jul 26 08:05:23 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-platform_media_libcubeb_src_moz.build,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+Also enable the Sun backend on NetBSD.
+
+--- platform/media/libcubeb/src/moz.build.orig 2024-07-25 15:45:52.334596032 +0000
++++ platform/media/libcubeb/src/moz.build
+@@ -44,7 +44,7 @@ if CONFIG['MOZ_SNDIO']:
+ ]
+ DEFINES['USE_SNDIO'] = True
+
+-if CONFIG['OS_ARCH'] == 'SunOS':
++if CONFIG['OS_ARCH'] in ('SunOS', 'NetBSD'):
+ SOURCES += [
+ 'cubeb_sun.c',
+ ]
Index: pkgsrc/www/palemoon/patches/patch-platform_security_generate__mapfile.py
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_security_generate__mapfile.py:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_security_generate__mapfile.py Fri Jul 26 08:05:23 2024
@@ -0,0 +1,26 @@
+$NetBSD: patch-platform_security_generate__mapfile.py,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+Add NetBSD support.
+
+--- platform/security/generate_mapfile.py.orig 2024-07-25 11:47:02.692533986 +0000
++++ platform/security/generate_mapfile.py
+@@ -17,10 +17,10 @@ import buildconfig
+
+
+ def main(output, input):
+- if buildconfig.substs['OS_ARCH'] not in ('Linux', 'SunOS', 'Darwin', 'FreeBSD'):
++ if buildconfig.substs['OS_ARCH'] not in ('Linux', 'SunOS', 'Darwin', 'FreeBSD', 'NetBSD'):
+ print "Error: unhandled OS_ARCH %s" % buildconfig.substs['OS_ARCH']
+ return 1
+- is_linux = buildconfig.substs['OS_ARCH'] in ('Linux', 'SunOS', 'FreeBSD')
++ is_linux = buildconfig.substs['OS_ARCH'] in ('Linux', 'SunOS', 'FreeBSD', 'NetBSD')
+
+ with open(input, 'rb') as f:
+ for line in f:
+@@ -49,4 +49,4 @@ def main(output, input):
+ if line and not is_linux:
+ output.write('_')
+ output.write(line)
+- output.write('\n')
+\ No newline at end of file
++ output.write('\n')
Index: pkgsrc/www/palemoon/patches/patch-platform_toolkit_xre_glxtest.cpp
diff -u /dev/null pkgsrc/www/palemoon/patches/patch-platform_toolkit_xre_glxtest.cpp:1.1
--- /dev/null Fri Jul 26 08:05:23 2024
+++ pkgsrc/www/palemoon/patches/patch-platform_toolkit_xre_glxtest.cpp Fri Jul 26 08:05:23 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-platform_toolkit_xre_glxtest.cpp,v 1.1 2024/07/26 08:05:23 nia Exp $
+
+NetBSD does not have the libGL.so.1 version.
+
+--- platform/toolkit/xre/glxtest.cpp.orig 2024-07-25 22:12:30.934622714 +0000
++++ platform/toolkit/xre/glxtest.cpp
+@@ -161,7 +161,7 @@ void glxtest()
+ fatal_error("The MOZ_AVOID_OPENGL_ALTOGETHER environment variable is defined");
+
+ ///// Open libGL and load needed symbols /////
+-#ifdef __OpenBSD__
++#if defined(__OpenBSD__) || defined(__NetBSD__)
+ #define LIBGL_FILENAME "libGL.so"
+ #else
+ #define LIBGL_FILENAME "libGL.so.1"
Home |
Main Index |
Thread Index |
Old Index