pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/www/seamonkey seamonkey: sun audio support for NetBSD/...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ae4c3ace7090
branches:  trunk
changeset: 335125:ae4c3ace7090
user:      nia <nia%pkgsrc.org@localhost>
date:      Thu Jun 13 10:53:11 2019 +0000

description:
seamonkey: sun audio support for NetBSD/SunOS, use gtk3 by default

cubeb_sun replaces cubeb_oss, adding support for additional channels
on NetBSD, passing tests, and recording support (more useful on firefox
where WebRTC works)

upstream's official builds use gtk3 over gtk2 and doing so enables
support for hidpi displays.

me and several others have been using this for the past ~week, see
https://github.com/kinetiknz/cubeb/pull/510

bump PKGREVISION.

diffstat:

 www/seamonkey/Makefile                                           |    5 +-
 www/seamonkey/distinfo                                           |   10 +-
 www/seamonkey/files/cubeb_sun.c                                  |  777 ++++++++++
 www/seamonkey/options.mk                                         |    4 +-
 www/seamonkey/patches/patch-mozilla_media_libcubeb_src_cubeb.c   |   28 +-
 www/seamonkey/patches/patch-mozilla_media_libcubeb_src_moz.build |   14 +-
 www/seamonkey/patches/patch-mozilla_media_libcubeb_update.sh     |   14 +-
 www/seamonkey/patches/patch-mozilla_old-configure.in             |   16 +-
 8 files changed, 842 insertions(+), 26 deletions(-)

diffs (truncated from 1009 to 300 lines):

diff -r e5cbdb52a246 -r ae4c3ace7090 www/seamonkey/Makefile
--- a/www/seamonkey/Makefile    Thu Jun 13 09:45:37 2019 +0000
+++ b/www/seamonkey/Makefile    Thu Jun 13 10:53:11 2019 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.191 2019/06/01 23:54:51 nia Exp $
+# $NetBSD: Makefile,v 1.192 2019/06/13 10:53:11 nia Exp $
 
 DISTNAME=      seamonkey-${SM_VER}.source
 PKGNAME=       seamonkey-${SM_VER:S/b/beta/}
-PKGREVISION=   9
+PKGREVISION=   10
 SM_VER=                2.49.4
 CATEGORIES=    www
 MASTER_SITES=  ${MASTER_SITE_MOZILLA:=seamonkey/releases/${SM_VER}/source/}
@@ -63,6 +63,7 @@
 
 post-extract:
        mv ${WRKSRC}/mozilla/gfx/ycbcr/yuv_row_arm.s ${WRKSRC}/mozilla/gfx/ycbcr/yuv_row_arm.S
+       ${CP} ${FILESDIR}/cubeb_sun.c ${WRKSRC}/mozilla/media/libcubeb/src
 
 pre-configure:
        cd ${WRKSRC} && mkdir ${OBJDIR}
diff -r e5cbdb52a246 -r ae4c3ace7090 www/seamonkey/distinfo
--- a/www/seamonkey/distinfo    Thu Jun 13 09:45:37 2019 +0000
+++ b/www/seamonkey/distinfo    Thu Jun 13 10:53:11 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.157 2019/06/01 23:54:51 nia Exp $
+$NetBSD: distinfo,v 1.158 2019/06/13 10:53:11 nia Exp $
 
 SHA1 (seamonkey-2.49.4.source.tar.xz) = e9fa6d1c57e9141a299f6ec093683fb105ea6657
 RMD160 (seamonkey-2.49.4.source.tar.xz) = 072caadf376b7726356d6121abff87cc1fb62144
@@ -63,12 +63,12 @@
 SHA1 (patch-mozilla_js_src_old-configure.in) = 5aed3a3e211aaa8e49fe97f406f94c6975648e9d
 SHA1 (patch-mozilla_js_xpconnect_src_XPCConvert.cpp) = d866b89d5d741125430c0e3ac900c7ead401a495
 SHA1 (patch-mozilla_js_xpconnect_src_xpcprivate.h) = 6a836224fa46f2b30d337a7893c668ab0cf807cd
-SHA1 (patch-mozilla_media_libcubeb_src_cubeb.c) = b760a10ef1fdff5360b2644913df34d60f2ffbf6
+SHA1 (patch-mozilla_media_libcubeb_src_cubeb.c) = f936368fc7c54c4a808737068fd2f15cf2450fd0
 SHA1 (patch-mozilla_media_libcubeb_src_cubeb__alsa.c) = 06d21721261b85412085b3336aa8c3712c0d5551
 SHA1 (patch-mozilla_media_libcubeb_src_cubeb__oss.c) = 2c4a7cf4253ad098245edd91c2fa5207fe9b9c53
-SHA1 (patch-mozilla_media_libcubeb_src_moz.build) = 20cd45532c053be8b57177c4161537047e365be3
+SHA1 (patch-mozilla_media_libcubeb_src_moz.build) = 71d1e95ecb888905fe50b9900ed929253b0dd231
 SHA1 (patch-mozilla_media_libcubeb_tests_moz.build) = af24f693c6cf0cd7c6dfb2d7ca4ad17d6a77cc97
-SHA1 (patch-mozilla_media_libcubeb_update.sh) = 2ff28e8691e97787ba881b836065b6e4eecd72af
+SHA1 (patch-mozilla_media_libcubeb_update.sh) = 4bb209f62be383733104ddb58b978e9892629881
 SHA1 (patch-mozilla_media_libsoundtouch_src_cpu__detect__x86.cpp) = 1029bc985d6eadf3f030492a8aa51d008fa27740
 SHA1 (patch-mozilla_media_libsoundtouch_src_soundtouch__perms.h) = f04b476a0652aa125c89954bb962528a25b9e962
 SHA1 (patch-mozilla_media_libtheora_lib_arm_armcpu.c) = 544bbb808bbecb24b519a96358c956dcacdfd5be
@@ -88,7 +88,7 @@
 SHA1 (patch-mozilla_mozglue_build_arm.cpp) = 592ae5ce1a404227cc2ab6a06418cc813c5743c9
 SHA1 (patch-mozilla_mozglue_build_arm.h) = 94e2b1a1a9ebf20bfa8a542066aa0dad475db320
 SHA1 (patch-mozilla_netwerk_dns_moz.build) = d87c07ebfa01d32ca826932af733b37ce586e9f7
-SHA1 (patch-mozilla_old-configure.in) = 100f03e97fb362defbf4d26b82b64508855debbe
+SHA1 (patch-mozilla_old-configure.in) = e98e393a90c8283259d7c6fe2a2fff03f2747e4d
 SHA1 (patch-mozilla_toolkit_components_osfile_modules_osfile__unix__back.jsm) = db4084f6a7dba2fc5d35cd256c6f149fabbf7bc7
 SHA1 (patch-mozilla_toolkit_components_osfile_modules_osfile__unix__front.jsm) = 1e8d0883d3cc12541020c7df0b1d67f60e7391f5
 SHA1 (patch-mozilla_toolkit_components_protobuf_src_google_protobuf_stubs_atomicops.h) = 0b5cad33bc9a90f4ae2d6346065707b642aba3a9
diff -r e5cbdb52a246 -r ae4c3ace7090 www/seamonkey/files/cubeb_sun.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/www/seamonkey/files/cubeb_sun.c   Thu Jun 13 10:53:11 2019 +0000
@@ -0,0 +1,777 @@
+/*
+ * Copyright © 2019 Nia Alarie
+ *
+ * This program is made available under an ISC-style license.  See the
+ * accompanying file LICENSE for details.
+ */
+#include <sys/audioio.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <poll.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include "cubeb/cubeb.h"
+#include "cubeb-internal.h"
+
+#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
+
+/*
+ * Supported on NetBSD regardless of hardware.
+ */
+
+#ifndef SUN_MAX_CHANNELS
+# ifdef __NetBSD__
+#  define SUN_MAX_CHANNELS (12)
+# else
+#  define SUN_MAX_CHANNELS (2)
+# endif
+#endif
+
+#ifndef SUN_MIN_RATE
+#define SUN_MIN_RATE (1000)
+#endif
+
+#ifndef SUN_MAX_RATE
+#define SUN_MAX_RATE (192000)
+#endif
+
+static struct cubeb_ops const sun_ops;
+
+struct cubeb {
+  struct cubeb_ops const * ops;
+};
+
+struct cubeb_stream {
+  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;
+};
+
+int
+sun_init(cubeb ** context, char const * context_name)
+{
+  cubeb * c;
+
+  (void)context_name;
+  if ((c = calloc(1, sizeof(cubeb))) == NULL) {
+    return CUBEB_ERROR;
+  }
+  c->ops = &sun_ops;
+  *context = c;
+  return CUBEB_OK;
+}
+
+static void
+sun_destroy(cubeb * context)
+{
+  free(context);
+}
+
+static char const *
+sun_get_backend_id(cubeb * context)
+{
+  return "sun";
+}
+
+static int
+sun_get_preferred_sample_rate(cubeb * context, uint32_t * rate)
+{
+  (void)context;
+
+  *rate = SUN_PREFER_RATE;
+  return CUBEB_OK;
+}
+
+static int
+sun_get_max_channel_count(cubeb * context, uint32_t * max_channels)
+{
+  (void)context;
+
+  *max_channels = SUN_MAX_CHANNELS;
+  return CUBEB_OK;
+}
+
+static int
+sun_get_min_latency(cubeb * context, cubeb_stream_params params,
+                    uint32_t * latency_frames)
+{
+  (void)context;
+
+  *latency_frames = SUN_LATENCY_MS * params.rate / 1000;
+  return CUBEB_OK;
+}
+
+static int
+sun_get_hwinfo(const char * device, struct audio_info * format,
+               int * props, struct audio_device * dev)
+{
+  int fd = -1;
+
+  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;
+}
+
+/*
+ * XXX: PR kern/54264
+ */
+static int
+sun_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
+sun_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;
+
+  collection->device = calloc(SUN_DEVICE_COUNT, sizeof(cubeb_device_info));
+  if (collection->device == NULL) {
+    return CUBEB_ERROR;
+  }
+  collection->count = 0;
+
+  for (i = 0; i < SUN_DEVICE_COUNT; ++i) {
+    if (i > 0) {
+      (void)snprintf(dev, sizeof(dev), "/dev/audio%u", i - 1);
+    }
+    if (sun_get_hwinfo(dev, &hwfmt, &hwprops, &hwname) != CUBEB_OK) {
+      continue;
+    }
+#ifdef AUDIO_GETPROPS
+    device.type = 0;
+    if ((hwprops & AUDIO_PROP_CAPTURE) != 0 &&
+        sun_prinfo_verify_sanity(&hwfmt.record)) {
+      /* the device supports recording, probably */
+      device.type |= CUBEB_DEVICE_TYPE_INPUT;
+    }
+    if ((hwprops & AUDIO_PROP_PLAYBACK) != 0 &&
+        sun_prinfo_verify_sanity(&hwfmt.play)) {
+      /* the device supports playback, probably */
+      device.type |= CUBEB_DEVICE_TYPE_OUTPUT;
+    }
+    switch (device.type) {
+    case 0:



Home | Main Index | Thread Index | Old Index