aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobik <tobik@FreeBSD.org>2018-07-01 03:21:48 +0800
committertobik <tobik@FreeBSD.org>2018-07-01 03:21:48 +0800
commita801a1f63ccb9a63611069ccab3b1f8299440491 (patch)
treed782b8afa774bfe9e2d0e0edcbdd8956e16dda00
parent867881f579ba384a86899cd28bc6e7c7966ae87b (diff)
downloadfreebsd-ports-gnome-a801a1f63ccb9a63611069ccab3b1f8299440491.tar.gz
freebsd-ports-gnome-a801a1f63ccb9a63611069ccab3b1f8299440491.tar.zst
freebsd-ports-gnome-a801a1f63ccb9a63611069ccab3b1f8299440491.zip
www/waterfox: Backport sndio volume handling fix
https://bugzilla.mozilla.org/show_bug.cgi?id=1467882 PR: 229135 Approved by: jbeich (maintainer)
-rw-r--r--www/waterfox/Makefile1
-rw-r--r--www/waterfox/files/patch-bug146788274
2 files changed, 75 insertions, 0 deletions
diff --git a/www/waterfox/Makefile b/www/waterfox/Makefile
index 23aafcd364b7..48bf0c63c45d 100644
--- a/www/waterfox/Makefile
+++ b/www/waterfox/Makefile
@@ -3,6 +3,7 @@
PORTNAME= waterfox
DISTVERSION= 56.2.1-48
DISTVERSIONSUFFIX= -g7f6ff796eeda4
+PORTREVISION= 1
CATEGORIES= www ipv6
MAINTAINER= jbeich@FreeBSD.org
diff --git a/www/waterfox/files/patch-bug1467882 b/www/waterfox/files/patch-bug1467882
new file mode 100644
index 000000000000..3047e0c9c068
--- /dev/null
+++ b/www/waterfox/files/patch-bug1467882
@@ -0,0 +1,74 @@
+--- media/libcubeb/src/cubeb_sndio.c.orig 2018-06-29 17:19:53 UTC
++++ media/libcubeb/src/cubeb_sndio.c
+@@ -49,17 +49,33 @@ struct cubeb_stream {
+ 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 */
++ float volume; /* current volume */
+ };
+
+ static void
+-float_to_s16(void *ptr, long nsamp)
++s16_setvol(void *ptr, long nsamp, float volume)
++{
++ int16_t *dst = ptr;
++ int32_t mult = volume * 32768;
++ int32_t s;
++
++ while (nsamp-- > 0) {
++ s = *dst;
++ s = (s * mult) >> 15;
++ *(dst++) = s;
++ }
++}
++
++static void
++float_to_s16(void *ptr, long nsamp, float volume)
+ {
+ int16_t *dst = ptr;
+ float *src = ptr;
++ float mult = volume * 32768;
+ int s;
+
+ while (nsamp-- > 0) {
+- s = lrintf(*(src++) * 32768);
++ s = lrintf(*(src++) * mult);
+ if (s < -32768)
+ s = -32768;
+ else if (s > 32767)
+@@ -167,8 +183,12 @@ sndio_mainloop(void *arg)
+ if (prime > 0)
+ prime--;
+
+- if ((s->mode & SIO_PLAY) && s->conv)
+- float_to_s16(s->pbuf, nfr * s->pchan);
++ if (s->mode & SIO_PLAY) {
++ if (s->conv)
++ float_to_s16(s->pbuf, nfr * s->pchan, s->volume);
++ else
++ s16_setvol(s->pbuf, nfr * s->pchan, s->volume);
++ }
+
+ if (s->mode & SIO_REC)
+ rstart = 0;
+@@ -362,6 +382,7 @@ sndio_stream_init(cubeb * context,
+ if (s->rbuf == NULL)
+ goto err;
+ }
++ s->volume = 1.;
+ *stream = s;
+ DPR("sndio_stream_init() end, ok\n");
+ (void)context;
+@@ -466,7 +487,11 @@ sndio_stream_set_volume(cubeb_stream *s, float volume)
+ {
+ DPR("sndio_stream_set_volume(%f)\n", volume);
+ pthread_mutex_lock(&s->mtx);
+- sio_setvol(s->hdl, SIO_MAXVOL * volume);
++ if (volume < 0.)
++ volume = 0.;
++ else if (volume > 1.0)
++ volume = 1.;
++ s->volume = volume;
+ pthread_mutex_unlock(&s->mtx);
+ return CUBEB_OK;
+ }