View | Details | Raw Unified | Return to bug 228479
Collapse All | Expand All

(-)Makefile (+1 lines)
Lines 3-8 Link Here
3
3
4
PORTNAME=	palemoon
4
PORTNAME=	palemoon
5
DISTVERSION=	27.9.2
5
DISTVERSION=	27.9.2
6
PORTREVISION=	1
6
DISTVERSIONSUFFIX=_Release
7
DISTVERSIONSUFFIX=_Release
7
CATEGORIES=	www ipv6
8
CATEGORIES=	www ipv6
8
9
(-)files/patch-bug1153151 (-13 lines)
Lines 1-13 Link Here
1
Bug 1153151 - make libcubeb sndio use non-blocking i/o
2
3
--- media/libcubeb/src/cubeb_sndio.c.orig	2017-01-12 17:53:15 UTC
4
+++ media/libcubeb/src/cubeb_sndio.c
5
@@ -187,7 +187,7 @@ sndio_stream_init(cubeb *context,
6
   if (s == NULL)
7
     return CUBEB_ERROR;
8
   s->context = context;
9
-  s->hdl = sio_open(NULL, SIO_PLAY, 0);
10
+  s->hdl = sio_open(NULL, SIO_PLAY, 1);
11
   if (s->hdl == NULL) {
12
     free(s);
13
     DPR("sndio_stream_init(), sio_open() failed\n");
(-)files/patch-bug1153179 (-40 lines)
Lines 1-40 Link Here
1
Bug 1153179 - fix latency reporting in libcubeb sndio
2
3
--- media/libcubeb/src/cubeb_sndio.c.orig	2017-01-12 17:53:15 UTC
4
+++ media/libcubeb/src/cubeb_sndio.c
5
@@ -67,7 +67,7 @@ sndio_onmove(void *arg, int delta)
6
 {
7
   cubeb_stream *s = (cubeb_stream *)arg;
8
 
9
-  s->rdpos += delta;
10
+  s->rdpos += delta * s->bpf;
11
 }
12
 
13
 static void *
14
@@ -135,7 +135,7 @@ sndio_mainloop(void *arg)
15
         state = CUBEB_STATE_ERROR;
16
         break;
17
       }
18
-      s->wrpos = 0;
19
+      s->wrpos += n;
20
       start += n;
21
     }
22
   }
23
@@ -326,7 +336,7 @@ sndio_stream_get_position(cubeb_stream *
24
 {
25
   pthread_mutex_lock(&s->mtx);
26
   DPR("sndio_stream_get_position() %lld\n", s->rdpos);
27
-  *p = s->rdpos;
28
+  *p = s->rdpos / s->bpf;
29
   pthread_mutex_unlock(&s->mtx);
30
   return CUBEB_OK;
31
 }
32
@@ -346,7 +356,7 @@ sndio_stream_get_latency(cubeb_stream * 
33
 {
34
   // http://www.openbsd.org/cgi-bin/man.cgi?query=sio_open
35
   // in the "Measuring the latency and buffers usage" paragraph.
36
-  *latency = stm->wrpos - stm->rdpos;
37
+  *latency = (stm->wrpos - stm->rdpos) / stm->bpf;
38
   return CUBEB_OK;
39
 }
40
 
(-)files/patch-cubeb5ffce9e91b (-41 lines)
Lines 1-41 Link Here
1
From 5ffce9e91b2fde70ba532ea215e3e9e7eed3d41a Mon Sep 17 00:00:00 2001
2
From: Alexandre Ratchov <alex@caoua.org>
3
Date: Thu, 2 Apr 2015 13:09:22 +1300
4
Subject: [PATCH] sndio: improve and clamp float->s16 conversion.
5
6
---
7
 src/cubeb_sndio.c | 14 +++++++++++---
8
 1 file changed, 11 insertions(+), 3 deletions(-)
9
10
diff --git a/src/cubeb_sndio.c b/src/cubeb_sndio.c
11
index 01f96346..e6d531a4 100644
12
--- media/libcubeb/src/cubeb_sndio.c.orig
13
+++ media/libcubeb/src/cubeb_sndio.c
14
@@ -4,6 +4,7 @@
15
  * This program is made available under an ISC-style license.  See the
16
  * accompanying file LICENSE for details.
17
  */
18
+#include <math.h>
19
 #include <poll.h>
20
 #include <pthread.h>
21
 #include <sndio.h>
22
@@ -49,9 +50,16 @@ float_to_s16(void *ptr, long nsamp)
23
 {
24
   int16_t *dst = ptr;
25
   float *src = ptr;
26
-
27
-  while (nsamp-- > 0)
28
-    *(dst++) = *(src++) * 32767;
29
+  int s;
30
+
31
+  while (nsamp-- > 0) {
32
+    s = lrintf(*(src++) * 32768);
33
+    if (s < -32768)
34
+      s = -32768;
35
+    else if (s > 32767)
36
+      s = 32767;
37
+    *(dst++) = s;
38
+  }
39
 }
40
 
41
 static void
(-)files/patch-sndio (+145 lines)
Line 0 Link Here
1
Bug 1153151 - make libcubeb sndio use non-blocking i/o
2
Bug 1153179 - fix latency reporting in libcubeb sndio
3
4
From cubeb:
5
From 5ffce9e91b2fde70ba532ea215e3e9e7eed3d41a Mon Sep 17 00:00:00 2001
6
From: Alexandre Ratchov <alex@caoua.org>
7
Date: Thu, 2 Apr 2015 13:09:22 +1300
8
Subject: [PATCH] sndio: improve and clamp float->s16 conversion.
9
10
https://marc.info/?l=openbsd-ports&m=152641946326955&w=2
11
Apply volume in software as do other backends. This is necessary
12
because sndio volume may be controlled externally and there's no
13
volume getter in libcubeb to notify the caller about volume
14
changes.
15
16
--- media/libcubeb/src/cubeb_sndio.c.orig	2018-05-24 13:59:58 UTC
17
+++ media/libcubeb/src/cubeb_sndio.c
18
@@ -4,6 +4,7 @@
19
  * This program is made available under an ISC-style license.  See the
20
  * accompanying file LICENSE for details.
21
  */
22
+#include <math.h>
23
 #include <poll.h>
24
 #include <pthread.h>
25
 #include <sndio.h>
26
@@ -41,17 +42,39 @@ struct cubeb_stream {
27
   uint64_t wrpos;		  /* number of written frames */
28
   cubeb_data_callback data_cb;    /* cb to preapare data */
29
   cubeb_state_callback state_cb;  /* cb to notify about state changes */
30
+  float volume;			  /* current volume */
31
   void *arg;			  /* user arg to {data,state}_cb */
32
 };
33
 
34
 static void
35
-float_to_s16(void *ptr, long nsamp)
36
+s16_setvol(void *ptr, long nsamp, float volume)
37
 {
38
   int16_t *dst = ptr;
39
+  int32_t mult = volume * 32768;
40
+  int32_t s;
41
+  while (nsamp-- > 0) {
42
+    s = *dst;
43
+    s = (s * mult) >> 15;
44
+    *(dst++) = s;
45
+  }
46
+}
47
+
48
+static void
49
+float_to_s16(void *ptr, long nsamp, float volume)
50
+{
51
+  int16_t *dst = ptr;
52
   float *src = ptr;
53
+  float mult = volume * 32768;
54
+  int s;
55
 
56
-  while (nsamp-- > 0)
57
-    *(dst++) = *(src++) * 32767;
58
+  while (nsamp-- > 0) {
59
+    s = lrintf(*(src++) * mult);
60
+    if (s < -32768)
61
+      s = -32768;
62
+    else if (s > 32767)
63
+      s = 32767;
64
+    *(dst++) = s;
65
+  }
66
 }
67
 
68
 static void
69
@@ -59,7 +82,7 @@ sndio_onmove(void *arg, int delta)
70
 {
71
   cubeb_stream *s = (cubeb_stream *)arg;
72
 
73
-  s->rdpos += delta;
74
+  s->rdpos += delta * s->bpf;
75
 }
76
 
77
 static void *
78
@@ -103,7 +126,9 @@ sndio_mainloop(void *arg)
79
         break;
80
       }
81
       if (s->conv)
82
-        float_to_s16(s->buf, nfr * s->pchan);
83
+        float_to_s16(s->buf, nfr * s->pchan, s->volume);
84
+      else
85
+        s16_setvol(s->buf, nfr * s->pchan, s->volume);
86
       start = 0;
87
       end = nfr * s->bpf;
88
     }
89
@@ -127,7 +152,7 @@ sndio_mainloop(void *arg)
90
         state = CUBEB_STATE_ERROR;
91
         break;
92
       }
93
-      s->wrpos = 0;
94
+      s->wrpos += n;
95
       start += n;
96
     }
97
   }
98
@@ -179,7 +204,7 @@ sndio_stream_init(cubeb *context,
99
   if (s == NULL)
100
     return CUBEB_ERROR;
101
   s->context = context;
102
-  s->hdl = sio_open(NULL, SIO_PLAY, 0);
103
+  s->hdl = sio_open(NULL, SIO_PLAY, 1);
104
   if (s->hdl == NULL) {
105
     free(s);
106
     DPR("sndio_stream_init(), sio_open() failed\n");
107
@@ -242,6 +267,7 @@ sndio_stream_init(cubeb *context,
108
     free(s);
109
     return CUBEB_ERROR;
110
   }
111
+  s->volume = 1.;
112
   *stream = s;
113
   DPR("sndio_stream_init() end, ok\n");
114
   (void)context;
115
@@ -318,7 +344,7 @@ sndio_stream_get_position(cubeb_stream *s, uint64_t *p
116
 {
117
   pthread_mutex_lock(&s->mtx);
118
   DPR("sndio_stream_get_position() %lld\n", s->rdpos);
119
-  *p = s->rdpos;
120
+  *p = s->rdpos / s->bpf;
121
   pthread_mutex_unlock(&s->mtx);
122
   return CUBEB_OK;
123
 }
124
@@ -328,7 +354,11 @@ sndio_stream_set_volume(cubeb_stream *s, float volume)
125
 {
126
   DPR("sndio_stream_set_volume(%f)\n", volume);
127
   pthread_mutex_lock(&s->mtx);
128
-  sio_setvol(s->hdl, SIO_MAXVOL * volume);
129
+  if (volume < 0.)
130
+    volume = 0.;
131
+  else if (volume > 1.0)
132
+    volume = 1.;
133
+  s->volume = volume;
134
   pthread_mutex_unlock(&s->mtx);
135
   return CUBEB_OK;
136
 }
137
@@ -338,7 +368,7 @@ sndio_stream_get_latency(cubeb_stream * stm, uint32_t 
138
 {
139
   // http://www.openbsd.org/cgi-bin/man.cgi?query=sio_open
140
   // in the "Measuring the latency and buffers usage" paragraph.
141
-  *latency = stm->wrpos - stm->rdpos;
142
+  *latency = (stm->wrpos - stm->rdpos) / stm->bpf;
143
   return CUBEB_OK;
144
 }
145
 

Return to bug 228479