View | Details | Raw Unified | Return to bug 194727 | Differences between
and this patch

Collapse All | Expand All

(-)files/patch-src_modules_oss_module-oss.c (-2 / +142 lines)
Lines 1-6 Link Here
1
--- src/modules/oss/module-oss.c.orig	2018-05-07 14:30:52 UTC
1
--- src/modules/oss/module-oss.c.orig	2019-09-13 13:10:23 UTC
2
+++ src/modules/oss/module-oss.c
2
+++ src/modules/oss/module-oss.c
3
@@ -1235,10 +1235,14 @@ int pa__init(pa_module*m) {
3
@@ -126,6 +126,8 @@ struct userdata {
4
 
5
     int nfrags, frag_size, orig_frag_size;
6
 
7
+    bool shutdown;
8
+
9
     bool use_mmap;
10
     unsigned out_mmap_current, in_mmap_current;
11
     void *in_mmap, *out_mmap;
12
@@ -843,14 +845,10 @@ static void sink_set_volume(pa_sink *s) {
13
     pa_assert(u->mixer_devmask & (SOUND_MASK_VOLUME|SOUND_MASK_PCM));
14
 
15
     if (u->mixer_devmask & SOUND_MASK_VOLUME)
16
-        if (pa_oss_set_volume(u->mixer_fd, SOUND_MIXER_WRITE_VOLUME, &s->sample_spec, &s->real_volume) >= 0)
17
-            return;
18
+        (void) pa_oss_set_volume(u->mixer_fd, SOUND_MIXER_WRITE_VOLUME, &s->sample_spec, &s->real_volume);
19
 
20
     if (u->mixer_devmask & SOUND_MASK_PCM)
21
-        if (pa_oss_get_volume(u->mixer_fd, SOUND_MIXER_WRITE_PCM, &s->sample_spec, &s->real_volume) >= 0)
22
-            return;
23
-
24
-    pa_log_info("Device doesn't support writing mixer settings: %s", pa_cstrerror(errno));
25
+        (void) pa_oss_set_volume(u->mixer_fd, SOUND_MIXER_WRITE_PCM, &s->sample_spec, &s->real_volume);
26
 }
27
 
28
 static void source_get_volume(pa_source *s) {
29
@@ -858,7 +856,7 @@ static void source_get_volume(pa_source *s) {
30
 
31
     pa_assert_se(u = s->userdata);
32
 
33
-    pa_assert(u->mixer_devmask & (SOUND_MASK_IGAIN|SOUND_MASK_RECLEV));
34
+    pa_assert(u->mixer_devmask & (SOUND_MASK_MIC|SOUND_MASK_IGAIN|SOUND_MASK_RECLEV));
35
 
36
     if (u->mixer_devmask & SOUND_MASK_IGAIN)
37
         if (pa_oss_get_volume(u->mixer_fd, SOUND_MIXER_READ_IGAIN, &s->sample_spec, &s->real_volume) >= 0)
38
@@ -868,6 +866,10 @@ static void source_get_volume(pa_source *s) {
39
         if (pa_oss_get_volume(u->mixer_fd, SOUND_MIXER_READ_RECLEV, &s->sample_spec, &s->real_volume) >= 0)
40
             return;
41
 
42
+    if (u->mixer_devmask & SOUND_MASK_MIC)
43
+        if (pa_oss_get_volume(u->mixer_fd, SOUND_MIXER_READ_MIC, &s->sample_spec, &s->real_volume) >= 0)
44
+            return;
45
+    
46
     pa_log_info("Device doesn't support reading mixer settings: %s", pa_cstrerror(errno));
47
 }
48
 
49
@@ -876,17 +878,16 @@ static void source_set_volume(pa_source *s) {
50
 
51
     pa_assert_se(u = s->userdata);
52
 
53
-    pa_assert(u->mixer_devmask & (SOUND_MASK_IGAIN|SOUND_MASK_RECLEV));
54
+    pa_assert(u->mixer_devmask & (SOUND_MASK_MIC|SOUND_MASK_IGAIN|SOUND_MASK_RECLEV));
55
 
56
     if (u->mixer_devmask & SOUND_MASK_IGAIN)
57
-        if (pa_oss_set_volume(u->mixer_fd, SOUND_MIXER_WRITE_IGAIN, &s->sample_spec, &s->real_volume) >= 0)
58
-            return;
59
+        (void) pa_oss_set_volume(u->mixer_fd, SOUND_MIXER_WRITE_IGAIN, &s->sample_spec, &s->real_volume);
60
 
61
     if (u->mixer_devmask & SOUND_MASK_RECLEV)
62
-        if (pa_oss_get_volume(u->mixer_fd, SOUND_MIXER_WRITE_RECLEV, &s->sample_spec, &s->real_volume) >= 0)
63
-            return;
64
+        (void) pa_oss_set_volume(u->mixer_fd, SOUND_MIXER_WRITE_RECLEV, &s->sample_spec, &s->real_volume);
65
 
66
-    pa_log_info("Device doesn't support writing mixer settings: %s", pa_cstrerror(errno));
67
+    if (u->mixer_devmask & SOUND_MASK_MIC)
68
+        (void) pa_oss_set_volume(u->mixer_fd, SOUND_MIXER_WRITE_MIC, &s->sample_spec, &s->real_volume);
69
 }
70
 
71
 static void thread_func(void *userdata) {
72
@@ -1133,15 +1134,22 @@ static void thread_func(void *userdata) {
73
             pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
74
             pollfd->events = (short)
75
                 (((u->source && PA_SOURCE_IS_OPENED(u->source->thread_info.state)) ? POLLIN : 0) |
76
-                 ((u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state)) ? POLLOUT : 0));
77
+                 ((u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state)) ? POLLOUT : 0) |
78
+                 POLLHUP);
79
         }
80
 
81
+        /* set a watchdog timeout of one second */
82
+        pa_rtpoll_set_timer_relative(u->rtpoll, 1000000);
83
+
84
         /* Hmm, nothing to do. Let's sleep */
85
-        if ((ret = pa_rtpoll_run(u->rtpoll)) < 0)
86
+        if ((ret = pa_rtpoll_run(u->rtpoll)) < 0) {
87
             goto fail;
88
+        }
89
 
90
-        if (ret == 0)
91
-            goto finish;
92
+        /* check for shutdown */
93
+        if (u->shutdown) {
94
+            goto fail;
95
+        }
96
 
97
         if (u->rtpoll_item) {
98
             struct pollfd *pollfd;
99
@@ -1156,6 +1164,16 @@ static void thread_func(void *userdata) {
100
             revents = pollfd->revents;
101
         } else
102
             revents = 0;
103
+
104
+        /* check for mixer shutdown, if any */
105
+        if ((revents & (POLLOUT | POLLIN)) == 0) {
106
+            int mixer_fd = u->mixer_fd;
107
+            int devmask;
108
+            if (mixer_fd > -1 && ioctl(mixer_fd, SOUND_MIXER_READ_DEVMASK, &devmask) < 0) {
109
+                pa_log("Mixer shutdown.");
110
+                goto fail;
111
+            }
112
+        }
113
     }
114
 
115
 fail:
116
@@ -1163,9 +1181,6 @@ fail:
117
      * processing messages until we received PA_MESSAGE_SHUTDOWN */
118
     pa_asyncmsgq_post(u->thread_mq.outq, PA_MSGOBJECT(u->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL);
119
     pa_asyncmsgq_wait_for(u->thread_mq.inq, PA_MESSAGE_SHUTDOWN);
120
-
121
-finish:
122
-    pa_log_debug("Thread shutting down");
123
 }
124
 
125
 int pa__init(pa_module*m) {
126
@@ -1235,10 +1250,14 @@ int pa__init(pa_module*m) {
4
         use_mmap = false;
127
         use_mmap = false;
5
     }
128
     }
6
 
129
 
Lines 15-17 Link Here
15
 
138
 
16
     if (pa_oss_get_hw_description(dev, hwdesc, sizeof(hwdesc)) >= 0)
139
     if (pa_oss_get_hw_description(dev, hwdesc, sizeof(hwdesc)) >= 0)
17
         pa_log_info("Hardware name is '%s'.", hwdesc);
140
         pa_log_info("Hardware name is '%s'.", hwdesc);
141
@@ -1452,7 +1471,7 @@ int pa__init(pa_module*m) {
142
                 do_close = false;
143
             }
144
 
145
-            if (u->source && (u->mixer_devmask & (SOUND_MASK_RECLEV|SOUND_MASK_IGAIN))) {
146
+            if (u->source && (u->mixer_devmask & (SOUND_MASK_MIC|SOUND_MASK_RECLEV|SOUND_MASK_IGAIN))) {
147
                 pa_log_debug("Found hardware mixer track for recording.");
148
                 pa_source_set_get_volume_callback(u->source, source_get_volume);
149
                 pa_source_set_set_volume_callback(u->source, source_set_volume);
150
@@ -1537,6 +1556,7 @@ void pa__done(pa_module*m) {
151
         pa_source_unlink(u->source);
152
 
153
     if (u->thread) {
154
+        u->shutdown = true;
155
         pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
156
         pa_thread_free(u->thread);
157
     }
(-)files/patch-src_modules_oss_oss-util.c (-3 / +103 lines)
Lines 1-9 Link Here
1
Support 24bit audio see Comment 6 of 
1
Support 24bit audio see Comment 6 of 
2
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198567
2
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198567
3
3
4
--- src/modules/oss/oss-util.c.orig	2015-09-10 04:51:41 UTC
4
--- src/modules/oss/oss-util.c.orig	2018-07-13 19:06:14 UTC
5
+++ src/modules/oss/oss-util.c
5
+++ src/modules/oss/oss-util.c
6
@@ -39,6 +39,22 @@
6
@@ -39,7 +39,27 @@
7
 
7
 
8
 #include "oss-util.h"
8
 #include "oss-util.h"
9
 
9
 
Lines 22-32 Link Here
22
+#ifndef DSP_CAP_BIND
22
+#ifndef DSP_CAP_BIND
23
+#define DSP_CAP_BIND  0x00008000
23
+#define DSP_CAP_BIND  0x00008000
24
+#endif
24
+#endif
25
+#ifndef ENOLINK
26
+#define	ENOLINK EINVAL
27
+#endif
25
+
28
+
26
 int pa_oss_open(const char *device, int *mode, int* pcaps) {
29
 int pa_oss_open(const char *device, int *mode, int* pcaps) {
30
+    static const int nonblock_io = 1;
27
     int fd = -1;
31
     int fd = -1;
28
     int caps;
32
     int caps;
29
@@ -164,8 +180,8 @@ int pa_oss_auto_format(int fd, pa_sample
33
     char *t;
34
@@ -89,6 +109,10 @@ int pa_oss_open(const char *device, int *mode, int* pc
35
     }
36
 
37
 success:
38
+    if (ioctl(fd, FIONBIO, &nonblock_io) < 0) {
39
+        pa_log("FIONBIO: %s", pa_cstrerror(errno));
40
+        goto fail;
41
+    }
42
 
43
     t = pa_sprintf_malloc(
44
             "%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
45
@@ -164,8 +188,8 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
30
         [PA_SAMPLE_FLOAT32BE] = AFMT_QUERY, /* not supported */
46
         [PA_SAMPLE_FLOAT32BE] = AFMT_QUERY, /* not supported */
31
         [PA_SAMPLE_S32LE] = AFMT_QUERY, /* not supported */
47
         [PA_SAMPLE_S32LE] = AFMT_QUERY, /* not supported */
32
         [PA_SAMPLE_S32BE] = AFMT_QUERY, /* not supported */
48
         [PA_SAMPLE_S32BE] = AFMT_QUERY, /* not supported */
Lines 37-39 Link Here
37
         [PA_SAMPLE_S24_32LE] = AFMT_QUERY, /* not supported */
53
         [PA_SAMPLE_S24_32LE] = AFMT_QUERY, /* not supported */
38
         [PA_SAMPLE_S24_32BE] = AFMT_QUERY, /* not supported */
54
         [PA_SAMPLE_S24_32BE] = AFMT_QUERY, /* not supported */
39
     };
55
     };
56
@@ -290,41 +314,35 @@ int pa_oss_set_volume(int fd, unsigned long mixer, con
57
 }
58
 
59
 static int get_device_number(const char *dev) {
60
-    const char *p, *e;
61
+    const char *p;
62
+    const char *e;
63
     char *rp = NULL;
64
-    int r;
65
+    int r = -1;
66
 
67
     if (!(p = rp = pa_readlink(dev))) {
68
-#ifdef ENOLINK
69
-        if (errno != EINVAL && errno != ENOLINK) {
70
-#else
71
-        if (errno != EINVAL) {
72
-#endif
73
-            r = -1;
74
-            goto finish;
75
-        }
76
-
77
+        if (errno != EINVAL && errno != ENOLINK)
78
+            return -2;
79
         p = dev;
80
     }
81
 
82
-    if ((e = strrchr(p, '/')))
83
-        p = e+1;
84
+    /* find the last forward slash */
85
+    while ((e = strrchr(p, '/')))
86
+        p = e + 1;
87
 
88
-    if (p == 0) {
89
-        r = 0;
90
-        goto finish;
91
+    /* collect unit number at end, if any */
92
+    while (*p) {
93
+        if (*p >= '0' && *p <= '9') {
94
+            if (r < 0)
95
+                r = 0;
96
+            else
97
+                r *= 10;
98
+            r += *p - '0';
99
+        } else {
100
+            r = -1;
101
+        }
102
+        p++;
103
     }
104
 
105
-    p = strchr(p, 0) -1;
106
-
107
-    if (*p >= '0' && *p <= '9') {
108
-        r = *p - '0';
109
-        goto finish;
110
-    }
111
-
112
-    r = -1;
113
-
114
-finish:
115
     pa_xfree(rp);
116
     return r;
117
 }
118
@@ -334,7 +352,7 @@ int pa_oss_get_hw_description(const char *dev, char *n
119
     int n, r = -1;
120
     int b = 0;
121
 
122
-    if ((n = get_device_number(dev)) < 0)
123
+    if ((n = get_device_number(dev)) == -2)
124
         return -1;
125
 
126
     if (!(f = pa_fopen_cloexec("/dev/sndstat", "r")) &&
127
@@ -400,10 +418,10 @@ int pa_oss_open_mixer_for_device(const char *device) {
128
     char *fn;
129
     int fd;
130
 
131
-    if ((n = get_device_number(device)) < 0)
132
+    if ((n = get_device_number(device)) == -2)
133
         return -1;
134
 
135
-    if (n == 0)
136
+    if (n == -1)
137
         if ((fd = open_mixer("/dev/mixer")) >= 0)
138
             return fd;
139
 

Return to bug 194727