pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/security/tor-browser tor-browser: add sun audio backen...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5e70f6af8c23
branches:  trunk
changeset: 397019:5e70f6af8c23
user:      nia <nia%pkgsrc.org@localhost>
date:      Fri Jun 14 17:22:21 2019 +0000

description:
tor-browser: add sun audio backend. requested by wiz.

diffstat:

 security/tor-browser/Makefile                                   |    5 +-
 security/tor-browser/distinfo                                   |   10 +-
 security/tor-browser/files/cubeb_sun.c                          |  752 ++++++++++
 security/tor-browser/options.mk                                 |    9 +-
 security/tor-browser/patches/patch-aa                           |   15 +-
 security/tor-browser/patches/patch-media_libcubeb_src_cubeb.c   |   42 +-
 security/tor-browser/patches/patch-media_libcubeb_src_moz.build |   15 +-
 security/tor-browser/patches/patch-media_libcubeb_update.sh     |    7 +-
 8 files changed, 829 insertions(+), 26 deletions(-)

diffs (truncated from 1007 to 300 lines):

diff -r ea1836a9a3a6 -r 5e70f6af8c23 security/tor-browser/Makefile
--- a/security/tor-browser/Makefile     Fri Jun 14 16:14:25 2019 +0000
+++ b/security/tor-browser/Makefile     Fri Jun 14 17:22:21 2019 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.45 2019/06/01 20:24:03 wiz Exp $
+# $NetBSD: Makefile,v 1.46 2019/06/14 17:22:21 nia Exp $
 
 DISTNAME=      src-firefox-tor-browser-60.7.0esr-8.5-1-build1
 PKGNAME=       tor-browser-8.5.60.7.0
-PKGREVISION=   2
+PKGREVISION=   3
 CATEGORIES=    www
 MASTER_SITES=  https://dist.torproject.org/torbrowser/8.5/
 EXTRACT_SUFX=  .tar.xz
@@ -74,6 +74,7 @@
 
 post-extract:
        mv ${WRKSRC}/gfx/ycbcr/yuv_row_arm.s ${WRKSRC}/gfx/ycbcr/yuv_row_arm.S
+       ${CP} ${FILESDIR}/cubeb_sun.c ${WRKSRC}/media/libcubeb/src/cubeb_sun.c
 
 pre-configure:
        cd ${WRKSRC} && mkdir ${OBJDIR}
diff -r ea1836a9a3a6 -r 5e70f6af8c23 security/tor-browser/distinfo
--- a/security/tor-browser/distinfo     Fri Jun 14 16:14:25 2019 +0000
+++ b/security/tor-browser/distinfo     Fri Jun 14 17:22:21 2019 +0000
@@ -1,11 +1,11 @@
-$NetBSD: distinfo,v 1.11 2019/06/01 20:24:03 wiz Exp $
+$NetBSD: distinfo,v 1.12 2019/06/14 17:22:21 nia Exp $
 
 SHA1 (src-firefox-tor-browser-60.7.0esr-8.5-1-build1.tar.xz) = 2521274bb159d2ed3a955094d19330cdb13b3041
 RMD160 (src-firefox-tor-browser-60.7.0esr-8.5-1-build1.tar.xz) = 41e5674c7eca8ea14cc57be16ffeed97a2753c1b
 SHA512 (src-firefox-tor-browser-60.7.0esr-8.5-1-build1.tar.xz) = 5b58abffab98cc43de19d6fcc0416e195487ce39226c5dfedc6ddeb6194b2660bbd4bf895f690e277cfdb9205898b3ae8330c1557101a55efe4749ed85e8c23d
 Size (src-firefox-tor-browser-60.7.0esr-8.5-1-build1.tar.xz) = 279370536 bytes
 SHA1 (patch-.mozconfig) = 3377e91db2560d79503e9a9dd69011f5a84b6994
-SHA1 (patch-aa) = 17ea1093941cabc3dac1c653ba9edd92ec9877da
+SHA1 (patch-aa) = a67963a9a53546061acaaa6f219bbd04685157f9
 SHA1 (patch-browser_app_profile_firefox.js) = 9a43095d94f83f315b9a3ce4a7b0a4301e9c40e6
 SHA1 (patch-build_moz.configure_old.configure) = 1df6867eaf73a350fbe8fcd5bd34e1fcab09d707
 SHA1 (patch-build_moz.configure_rust.configure) = 2818454ba4df3cbd85174edc4828206b3bf0a82b
@@ -24,11 +24,11 @@
 SHA1 (patch-js_src_util_NativeStack.cpp) = ac5c7cb9ca553773ebff18a926e2a4d1b473faa5
 SHA1 (patch-js_src_wasm_WasmSignalHandlers.cpp) = 19a396b57b42f4b7b0861f08e4ae2b2d6effc729
 SHA1 (patch-media_libcubeb_gtest_moz.build) = 921a001726cda9e9782df5e59ae02b19d76ef47e
-SHA1 (patch-media_libcubeb_src_cubeb.c) = 1b1b8d57eb710cad13518ded79a0ddee2681881b
+SHA1 (patch-media_libcubeb_src_cubeb.c) = b5bc831d1ea32d185c4e6ec2eb7a13e87f8230bb
 SHA1 (patch-media_libcubeb_src_cubeb__alsa.c) = 3ee36f58bb525767c7d2b9e814ba4ccaa4868717
 SHA1 (patch-media_libcubeb_src_cubeb__oss.c) = 103f751d5a7bc14a81a6ed43e1afc722bc092f7e
-SHA1 (patch-media_libcubeb_src_moz.build) = f243068c8908dcb16434221edef8c65db3bb0c83
-SHA1 (patch-media_libcubeb_update.sh) = 3a322de06bbe9aafba9da349954ef022bd094992
+SHA1 (patch-media_libcubeb_src_moz.build) = 66d63d585f8b576219d07cd92e894b780c1b3f50
+SHA1 (patch-media_libcubeb_update.sh) = 136b3f3b44ef8d819db0e122816d8d669bca1b8c
 SHA1 (patch-media_libpng_pngpriv.h) = c8084332560017cd7c9b519b61d125fa28af0dbc
 SHA1 (patch-media_webrtc_trunk_webrtc_modules_audio__device_linux_audio__device__alsa__linux.cc) = 91e8ce496c1f4dbbd0a463d83cb033afd1de3f49
 SHA1 (patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_device__info__linux.cc) = 0141dd1372c13ea1fce6e2f5ffb65e0cb0f3a13e
diff -r ea1836a9a3a6 -r 5e70f6af8c23 security/tor-browser/files/cubeb_sun.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/security/tor-browser/files/cubeb_sun.c    Fri Jun 14 17:22:21 2019 +0000
@@ -0,0 +1,752 @@
+/*
+ * 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 <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include "cubeb/cubeb.h"
+#include "cubeb-internal.h"
+
+#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;
+  uint64_t blocks_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;
+}
+
+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:
+      /* 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 */



Home | Main Index | Thread Index | Old Index