Source-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/www/seamonkey seamonkey: Restore lost sun audio patches.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b717dd2ffd12
branches:  trunk
changeset: 431009:b717dd2ffd12
user:      nia <nia%pkgsrc.org@localhost>
date:      Thu May 07 19:36:52 2020 +0000

description:
seamonkey: Restore lost sun audio patches.

diffstat:

 www/seamonkey/Makefile                                               |    3 +-
 www/seamonkey/distinfo                                               |    9 +-
 www/seamonkey/files/cubeb_sun.c                                      |  282 ++++-----
 www/seamonkey/options.mk                                             |    8 +-
 www/seamonkey/patches/patch-mozilla_media_libcubeb_src_cubeb.c       |   37 +
 www/seamonkey/patches/patch-mozilla_media_libcubeb_src_cubeb__alsa.c |    4 +-
 www/seamonkey/patches/patch-mozilla_media_libcubeb_src_moz.build     |   19 +
 www/seamonkey/patches/patch-mozilla_media_libcubeb_update.sh         |   14 +
 www/seamonkey/patches/patch-mozilla_old-configure.in                 |   74 +--
 9 files changed, 222 insertions(+), 228 deletions(-)

diffs (truncated from 804 to 300 lines):

diff -r 5db86e50bddc -r b717dd2ffd12 www/seamonkey/Makefile
--- a/www/seamonkey/Makefile    Thu May 07 19:22:52 2020 +0000
+++ b/www/seamonkey/Makefile    Thu May 07 19:36:52 2020 +0000
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.208 2020/05/06 14:34:52 ryoon Exp $
+# $NetBSD: Makefile,v 1.209 2020/05/07 19:36:52 nia Exp $
 
 DISTNAME=      seamonkey-${SM_VER}.source
 PKGNAME=       seamonkey-${SM_VER:S/b/beta/}
+PKGREVISION=   1
 SM_VER=                2.53.2
 CATEGORIES=    www
 MASTER_SITES=  ${MASTER_SITE_MOZILLA:=seamonkey/releases/${SM_VER}/source/}
diff -r 5db86e50bddc -r b717dd2ffd12 www/seamonkey/distinfo
--- a/www/seamonkey/distinfo    Thu May 07 19:22:52 2020 +0000
+++ b/www/seamonkey/distinfo    Thu May 07 19:36:52 2020 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.162 2020/05/06 14:34:52 ryoon Exp $
+$NetBSD: distinfo,v 1.163 2020/05/07 19:36:52 nia Exp $
 
 SHA1 (seamonkey-2.53.2.source.tar.xz) = 7c6e3295a751aa36c8325e20ef1367d0fb643120
 RMD160 (seamonkey-2.53.2.source.tar.xz) = 567c8bd64166e5854c712f2c2d6ca0dea182c75b
@@ -20,12 +20,15 @@
 SHA1 (patch-mozilla_ipc_glue_GeckoChildProcessHost.cpp) = 7ab1c1701344adab8d7ee0332476a864fa2446bb
 SHA1 (patch-mozilla_js_src_gc_Memory.cpp) = 0850c9d57794c037ee5ab6b3d52319f4ec34c72c
 SHA1 (patch-mozilla_js_src_threading_posix_Thread.cpp) = a22611b1329d38c1a56988be2f84aba71c431506
-SHA1 (patch-mozilla_media_libcubeb_src_cubeb__alsa.c) = 38da2528c83553a43676d300547db060ec25be25
+SHA1 (patch-mozilla_media_libcubeb_src_cubeb.c) = 85e03895737f47dfb373a46bb2992e36fc78728f
+SHA1 (patch-mozilla_media_libcubeb_src_cubeb__alsa.c) = 5931c3293ec6130776f146a6a962ebe86aba39a4
+SHA1 (patch-mozilla_media_libcubeb_src_moz.build) = ca2c76fc54a62323db0e66386a99a996cd7aaef0
+SHA1 (patch-mozilla_media_libcubeb_update.sh) = a1632da23a4752e6cc805f2af9243d152896cc3f
 SHA1 (patch-mozilla_media_libpng_pngpriv.h) = 731061bf32caa61e586a7a7fe86f1393a6520731
 SHA1 (patch-mozilla_modules_pdfium_update.sh) = a09e806625e97c623697667b4c086d309da40dac
 SHA1 (patch-mozilla_netwerk_srtp_src_crypto_hash_hmac.c) = eb07566cd98d4bbab3fd020815e72b17fbed324a
 SHA1 (patch-mozilla_netwerk_srtp_src_crypto_kernel_crypto__kernel.c) = e3974859577a7437e32e37995149c938be8d9ff3
-SHA1 (patch-mozilla_old-configure.in) = e0b626092fae9fcdd021e08bc6363888e047ca2c
+SHA1 (patch-mozilla_old-configure.in) = 5c711b031a2acee9ab4cf803769179de4fff0ea7
 SHA1 (patch-mozilla_servo_components_style_build__gecko.rs) = 473e823fa0cd819dfee1040d360eda543d5557f0
 SHA1 (patch-mozilla_toolkit_components_terminator_nsTerminator.cpp) = 0d975e4b7e3d2a8550c16a9a87c2f7011917cddd
 SHA1 (patch-mozilla_toolkit_library_moz.build) = 51d4b94077a12b136ddc4bd6093336de98f3219e
diff -r 5db86e50bddc -r b717dd2ffd12 www/seamonkey/files/cubeb_sun.c
--- a/www/seamonkey/files/cubeb_sun.c   Thu May 07 19:22:52 2020 +0000
+++ b/www/seamonkey/files/cubeb_sun.c   Thu May 07 19:36:52 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Nia Alarie
+ * Copyright © 2019-2020 Nia Alarie <nia%NetBSD.org@localhost>
  *
  * This program is made available under an ISC-style license.  See the
  * accompanying file LICENSE for details.
@@ -9,21 +9,14 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <pthread.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <math.h>
+#include <limits.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)
@@ -43,10 +36,6 @@
 #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
@@ -77,26 +66,26 @@
   struct cubeb_ops const * ops;
 };
 
+struct sun_stream {
+  char name[32];
+  int fd;
+  void * buf;
+  struct audio_info info;
+  unsigned frame_size; /* precision in bytes * channels */
+  bool floating;
+};
+
 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;
+  bool running;
   float volume;
-  struct audio_info p_info; /* info for the play fd */
-  struct audio_info r_info; /* info for the record fd */
+  struct sun_stream play;
+  struct sun_stream record;
   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;
 };
@@ -197,7 +186,6 @@
      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)
@@ -292,9 +280,7 @@
   }
   return CUBEB_OK;
 }
-#endif
 
-#ifndef CUBEB_OLD_API
 static int
 sun_device_collection_destroy(cubeb * context,
                               cubeb_device_collection * collection)
@@ -310,7 +296,6 @@
   free(collection->device);
   return CUBEB_OK;
 }
-#endif
 
 static int
 sun_copy_params(int fd, cubeb_stream * stream, cubeb_stream_params * params,
@@ -318,18 +303,19 @@
 {
   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;
+    prinfo->precision = 16;
     break;
   case CUBEB_SAMPLE_S16BE:
     prinfo->encoding = AUDIO_ENCODING_SLINEAR_BE;
+    prinfo->precision = 16;
     break;
   case CUBEB_SAMPLE_FLOAT32NE:
-    stream->floating = 1;
     prinfo->encoding = AUDIO_ENCODING_SLINEAR;
+    prinfo->precision = 32;
     break;
   default:
     LOG("Unsupported format");
@@ -339,10 +325,11 @@
   switch (params->format) {
   case CUBEB_SAMPLE_S16NE:
     prinfo->encoding = AUDIO_ENCODING_LINEAR;
+    prinfo->precision = 16;
     break;
   case CUBEB_SAMPLE_FLOAT32NE:
-    stream->floating = 1;
     prinfo->encoding = AUDIO_ENCODING_LINEAR;
+    prinfo->precision = 32;
     break;
   default:
     LOG("Unsupported format");
@@ -363,7 +350,7 @@
 {
   pthread_mutex_lock(&s->mutex);
   if (s->running) {
-    s->running = 0;
+    s->running = false;
     pthread_mutex_unlock(&s->mutex);
     pthread_join(s->thread, NULL);
   } else {
@@ -377,53 +364,50 @@
 {
   pthread_mutex_destroy(&s->mutex);
   sun_stream_stop(s);
-  if (s->play_fd != -1) {
-    close(s->play_fd);
+  if (s->play.fd != -1) {
+    close(s->play.fd);
   }
-  if (s->record_fd != -1) {
-    close(s->record_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->play.buf);
+  free(s->record.buf);
   free(s);
 }
 
 static void
-sun_float_to_linear(float * in, int16_t * out,
-                    unsigned channels, long frames, float vol)
+sun_float_to_linear32(void * buf, unsigned sample_count, float vol)
 {
-  unsigned i, sample_count = frames * channels;
-  float multiplier = vol * 0x8000;
+  float * in = buf;
+  int32_t * out = buf;
+  int32_t * tail = out + sample_count;
 
-  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;
-    }
+  while (out < tail) {
+    float f = *(in++) * vol;
+    if (f < -1.0)
+      f = -1.0;
+    else if (f > 1.0)
+      f = 1.0;
+    *(out++) = f * (float)INT32_MAX;
   }
 }
 
 static void
-sun_linear_to_float(int16_t * in, float * out,
-                    unsigned channels, long frames)
+sun_linear32_to_float(void * buf, unsigned sample_count) 
 {
-  unsigned i, sample_count = frames * channels;
+  int32_t * in = buf;
+  float * out = buf;
+  float * tail = out + sample_count;
 
-  for (i = 0; i < sample_count; ++i) {
-    out[i] = (1.0 / 0x8000) * in[i];
+  while (out < tail) {
+    *(out++) = (1.0 / 0x80000000) * *(in++);
   }
 }
 
 static void
-sun_linear_set_vol(int16_t * buf, unsigned channels, long frames, float vol)
+sun_linear16_set_vol(int16_t * buf, unsigned sample_count, float vol)
 {
-  unsigned i, sample_count = frames * channels;
+  unsigned i;
   int32_t multiplier = vol * 0x8000;
 
   for (i = 0; i < sample_count; ++i) {
@@ -451,41 +435,36 @@
       break;
     }
     pthread_mutex_unlock(&s->mutex);
-    if (s->floating) {
-      if (s->record_fd != -1) {
-        sun_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);
-        sun_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;



Home | Main Index | Thread Index | Old Index