Changes of Revision 11

pipewire-aptx.changes Changed
x
 
1
@@ -1,4 +1,9 @@
2
 -------------------------------------------------------------------
3
+Mon Jul 11 18:00:28 UTC 2022 - Bjørn Lie <zaitor@opensuse.org>
4
+
5
+- Update to version 0.3.54
6
+
7
+-------------------------------------------------------------------
8
 Thu Jul  7 18:13:40 UTC 2022 - Bjørn Lie <zaitor@opensuse.org>
9
 
10
 - Update to version 0.3.53
11
pipewire-aptx.spec Changed
10
 
1
@@ -7,7 +7,7 @@
2
 %define soversion 0_2
3
 
4
 Name:           pipewire-aptx
5
-Version:        0.3.53
6
+Version:        0.3.54
7
 Release:        0
8
 Summary:        PipeWire Bluetooth aptX codec plugin
9
 License:        MIT
10
pipewire-0.3.53.tar.gz/NEWS -> pipewire-0.3.54.tar.gz/NEWS Changed
66
 
1
@@ -1,3 +1,55 @@
2
+# PipeWire 0.3.54 (2022-07-07)
3
+
4
+This is a quick bugfix release that is API and ABI compatible with previous
5
+0.3.x releases.
6
+
7
+## Highlights
8
+  - Some critical bugs in the new audioconvert were fixed. The old
9
+    adapter had internal buffering that was abused in some places.
10
+  - The bluetooth sources were rewritten using a ringbuffer to make them
11
+    more reliable to jitter and remove old audioconvert behaviour.
12
+  - Many improvements to the audio converter.
13
+  - Native DSD128 and up is now supported by pw-dsdplay.
14
+
15
+
16
+## tools
17
+  - Support DSD128 to DSD512 as well by scaling the amount of samples
18
+    to read per time slice.
19
+
20
+## SPA
21
+  - Format conversion is now generated with macros to remove duplication
22
+    of code.
23
+  - 24bits conversions were rewritten to use the generic conversion
24
+    functions.
25
+  - Temporary buffers in audioconvert are now made large enough in all
26
+    cases.
27
+  - Fix draining in audioconvert. This fixes speaker-test.
28
+  - Fix the channel remapping. (#2502, #2490)
29
+  - Audio conversion constants were tweaked to handle the maximum ranges
30
+    and provide lossless conversion between 24bits and floats.
31
+  - Vector code and C code are aligned and the unit tests are activated
32
+    again. A new lossless conversion test was added.
33
+  - Fix an underrun case where the adapter would not ask for more data.
34
+  - Fix PROP_INFO for audioconvert. (#2488)
35
+  - Use the blackman window again for the resampler, the cosh window has
36
+    some bugs that can cause distortion in some cases. (#2483)
37
+  - Add more unit tests for audioconvert. Add end-to-end conversion tests.
38
+  - Don't leak memory in format converter.
39
+
40
+## pulse-server
41
+  - Card properties are now also added to sinks and sources, just like
42
+    in pulseaudio.
43
+  - Increase the maxlength size to at least 4 times the fragsize to avoid
44
+    xruns.
45
+  - Fix a race when setting default devices.
46
+
47
+## Bluetooth
48
+  - The source was rewritten to use a ringbuffer. This avoids regressions
49
+    caused by audioconvert. 
50
+
51
+Older versions:
52
+
53
+
54
 # PipeWire 0.3.53 (2022-06-30)
55
 
56
 This is a bugfix release that is API and ABI compatible with previous
57
@@ -74,8 +126,6 @@
58
     giving a -19 nice level to all processes, not just the pipewire
59
     daemon.
60
 
61
-Older versions:
62
-
63
 # PipeWire 0.3.52 (2022-06-09)
64
 
65
 This is a bugfix release that is API and ABI compatible with previous
66
pipewire-0.3.53.tar.gz/meson.build -> pipewire-0.3.54.tar.gz/meson.build Changed
8
 
1
@@ -1,5 +1,5 @@
2
 project('pipewire', 'c' ,
3
-  version : '0.3.53',
4
+  version : '0.3.54',
5
   license :  'MIT', 'LGPL-2.1-or-later', 'GPL-2.0-only' ,
6
   meson_version : '>= 0.59.0',
7
   default_options :  'warning_level=3',
8
pipewire-0.3.53.tar.gz/pipewire-alsa/alsa-plugins/pcm_pipewire.c -> pipewire-0.3.54.tar.gz/pipewire-alsa/alsa-plugins/pcm_pipewire.c Changed
17
 
1
@@ -726,6 +726,7 @@
2
 {
3
    snd_pcm_pipewire_t *pw = io->private_data;
4
 
5
+   pw_thread_loop_lock(pw->main_loop);
6
    if (pw->stream) {
7
        snd_pcm_uframes_t min_avail;
8
        snd_pcm_sw_params_get_avail_min( sw_params, &min_avail);
9
@@ -746,6 +747,7 @@
10
    } else {
11
        pw_log_debug("%p: sw_params pre-prepare noop", pw);
12
    }
13
+   pw_thread_loop_unlock(pw->main_loop);
14
 
15
    return 0;
16
 }
17
pipewire-0.3.53.tar.gz/po/hr.po -> pipewire-0.3.54.tar.gz/po/hr.po Changed
201
 
1
@@ -7,8 +7,8 @@
2
 msgstr ""
3
 "Project-Id-Version: pipewire\n"
4
 "Report-Msgid-Bugs-To: \n"
5
-"POT-Creation-Date: 2022-04-03 12:56+0200\n"
6
-"PO-Revision-Date: 2022-04-03 12:57+0200\n"
7
+"POT-Creation-Date: 2022-06-30 12:50+0200\n"
8
+"PO-Revision-Date: 2022-06-30 13:14+0200\n"
9
 "Last-Translator: gogo <trebelnik2@gmail.com>\n"
10
 "Language-Team: Croatian <https://translate.fedoraproject.org/projects/"
11
 "pipewire/pipewire/hr/>\n"
12
@@ -34,8 +34,8 @@
13
 "      --version                         Prikaži inačicu\n"
14
 "  -c, --config                          Učitaj podešavanje (Zadano %s)\n"
15
 
16
-#: src/modules/module-protocol-pulse/modules/module-tunnel-sink.c:190
17
-#: src/modules/module-protocol-pulse/modules/module-tunnel-source.c:190
18
+#: src/modules/module-protocol-pulse/modules/module-tunnel-sink.c:180
19
+#: src/modules/module-protocol-pulse/modules/module-tunnel-source.c:180
20
 #, c-format
21
 msgid "Tunnel to %s/%s"
22
 msgstr "Tunel do %s/%s"
23
@@ -44,41 +44,41 @@
24
 msgid "Dummy Output"
25
 msgstr "Lažni izlaz"
26
 
27
-#: src/modules/module-pulse-tunnel.c:545
28
+#: src/modules/module-pulse-tunnel.c:648
29
 #, c-format
30
 msgid "Tunnel for %s@%s"
31
 msgstr "Tunel za %s@%s"
32
 
33
-#: src/modules/module-zeroconf-discover.c:313
34
+#: src/modules/module-zeroconf-discover.c:332
35
 msgid "Unknown device"
36
 msgstr "Nepoznat uređaj"
37
 
38
-#: src/modules/module-zeroconf-discover.c:325
39
+#: src/modules/module-zeroconf-discover.c:344
40
 #, c-format
41
 msgid "%s on %s@%s"
42
 msgstr "%s na %s@%s"
43
 
44
-#: src/modules/module-zeroconf-discover.c:329
45
+#: src/modules/module-zeroconf-discover.c:348
46
 #, c-format
47
 msgid "%s on %s"
48
 msgstr "%s na %s"
49
 
50
-#: src/tools/pw-cat.c:1087
51
+#: src/tools/pw-cat.c:784
52
 #, c-format
53
 msgid ""
54
-"%s options <file>\n"
55
+"%s options <file>|-\n"
56
 "  -h, --help                            Show this help\n"
57
 "      --version                         Show version\n"
58
 "  -v, --verbose                         Enable verbose operations\n"
59
 "\n"
60
 msgstr ""
61
-"%s mogućnosti <datoteka>\n"
62
+"%s mogućnosti <datoteka>|-\n"
63
 "  -h, --help                            Prikaži ovu pomoć\n"
64
 "      --version                         Prikaži inačicu\n"
65
 "  -v, --verbose                         Omogući opširnije radnje\n"
66
 "\n"
67
 
68
-#: src/tools/pw-cat.c:1094
69
+#: src/tools/pw-cat.c:791
70
 #, c-format
71
 msgid ""
72
 "  -R, --remote                          Remote daemon name\n"
73
@@ -92,7 +92,7 @@
74
 "                                          or direct samples (256)\n"
75
 "                                          the rate is the one of the source "
76
 "file\n"
77
-"      --list-targets                    List available targets for --target\n"
78
+"  -P  --properties                      Set node properties\n"
79
 "\n"
80
 msgstr ""
81
 "  -R, --remote                          Naziv udaljenog pozadinskog "
82
@@ -111,11 +111,10 @@
83
 "                                          ili izravne uzorke (256)\n"
84
 "                                          frekvencija je jednaka izvornoj "
85
 "datoteci\n"
86
-"      --list-targets                    Prikaži dostupna odredišta za --"
87
-"target\n"
88
+"  -P  --properties                      Postavi svojstva čvora\n"
89
 "\n"
90
 
91
-#: src/tools/pw-cat.c:1112
92
+#: src/tools/pw-cat.c:809
93
 #, c-format
94
 msgid ""
95
 "      --rate                            Sample rate (req. for rec) (default "
96
@@ -151,7 +150,7 @@
97
 "15) (zadano je %d)\n"
98
 "\n"
99
 
100
-#: src/tools/pw-cat.c:1129
101
+#: src/tools/pw-cat.c:826
102
 msgid ""
103
 "  -p, --playback                        Playback mode\n"
104
 "  -r, --record                          Recording mode\n"
105
@@ -165,7 +164,7 @@
106
 "  -d, --dsd                             DSD način\n"
107
 "\n"
108
 
109
-#: src/tools/pw-cli.c:3051
110
+#: src/tools/pw-cli.c:3165
111
 #, c-format
112
 msgid ""
113
 "%s options command\n"
114
@@ -188,8 +187,8 @@
115
 msgid "Pro Audio"
116
 msgstr "Pro Audio"
117
 
118
-#: spa/plugins/alsa/acp/acp.c:444 spa/plugins/alsa/acp/alsa-mixer.c:4648
119
-#: spa/plugins/bluez5/bluez5-device.c:1159
120
+#: spa/plugins/alsa/acp/acp.c:446 spa/plugins/alsa/acp/alsa-mixer.c:4648
121
+#: spa/plugins/bluez5/bluez5-device.c:1161
122
 msgid "Off"
123
 msgstr "Isključeno"
124
 
125
@@ -216,7 +215,7 @@
126
 
127
 #: spa/plugins/alsa/acp/alsa-mixer.c:2657
128
 #: spa/plugins/alsa/acp/alsa-mixer.c:2741
129
-#: spa/plugins/bluez5/bluez5-device.c:1328
130
+#: spa/plugins/bluez5/bluez5-device.c:1330
131
 msgid "Microphone"
132
 msgstr "Mikrofon"
133
 
134
@@ -282,7 +281,7 @@
135
 msgstr "Bez pojačanja basa"
136
 
137
 #: spa/plugins/alsa/acp/alsa-mixer.c:2672
138
-#: spa/plugins/bluez5/bluez5-device.c:1333
139
+#: spa/plugins/bluez5/bluez5-device.c:1335
140
 msgid "Speaker"
141
 msgstr "Zvučnik"
142
 
143
@@ -397,7 +396,7 @@
144
 
145
 #: spa/plugins/alsa/acp/alsa-mixer.c:4484
146
 #: spa/plugins/alsa/acp/alsa-mixer.c:4642
147
-#: spa/plugins/bluez5/bluez5-device.c:1318
148
+#: spa/plugins/bluez5/bluez5-device.c:1320
149
 msgid "Headset"
150
 msgstr "Slušalice s mikrofonom"
151
 
152
@@ -521,8 +520,7 @@
153
 msgid "%s Input"
154
 msgstr "%s ulaz"
155
 
156
-#: spa/plugins/alsa/acp/alsa-util.c:1173
157
-#: spa/plugins/alsa/acp/alsa-util.c:1267
158
+#: spa/plugins/alsa/acp/alsa-util.c:1173 spa/plugins/alsa/acp/alsa-util.c:1267
159
 #, c-format
160
 msgid ""
161
 "snd_pcm_avail() returned a value that is exceptionally large: %lu byte (%lu "
162
@@ -619,7 +617,7 @@
163
 "Najvjerojatnije je ovo greška ALSA upravljačkog programa '%s'. Prijavite "
164
 "problem ALSA razvijateljima."
165
 
166
-#: spa/plugins/alsa/acp/channelmap.h:464
167
+#: spa/plugins/alsa/acp/channelmap.h:457
168
 msgid "(invalid)"
169
 msgstr "(neispravno)"
170
 
171
@@ -631,62 +629,62 @@
172
 msgid "Modem"
173
 msgstr "Modem"
174
 
175
-#: spa/plugins/bluez5/bluez5-device.c:1170
176
+#: spa/plugins/bluez5/bluez5-device.c:1172
177
 msgid "Audio Gateway (A2DP Source & HSP/HFP AG)"
178
 msgstr "Zvučni pristupnik (A2DP izvor i HSP/HFP AG)"
179
 
180
-#: spa/plugins/bluez5/bluez5-device.c:1195
181
+#: spa/plugins/bluez5/bluez5-device.c:1197
182
 #, c-format
183
 msgid "High Fidelity Playback (A2DP Sink, codec %s)"
184
 msgstr "Reprodukcija visoke autentičnosti (A2DP slivnik, kôdek %s)"
185
 
186
-#: spa/plugins/bluez5/bluez5-device.c:1198
187
+#: spa/plugins/bluez5/bluez5-device.c:1200
188
 #, c-format
189
 msgid "High Fidelity Duplex (A2DP Source/Sink, codec %s)"
190
 msgstr "Telefonija visoke autentičnosti (A2DP slivnik, kôdek %s)"
191
 
192
-#: spa/plugins/bluez5/bluez5-device.c:1206
193
+#: spa/plugins/bluez5/bluez5-device.c:1208
194
 msgid "High Fidelity Playback (A2DP Sink)"
195
 msgstr "Reprodukcija visoke autentičnosti (A2DP slivnik)"
196
 
197
-#: spa/plugins/bluez5/bluez5-device.c:1208
198
+#: spa/plugins/bluez5/bluez5-device.c:1210
199
 msgid "High Fidelity Duplex (A2DP Source/Sink)"
200
 msgstr "Telefonija visoke autentičnosti (A2DP izvor/slivnik)"
201
pipewire-0.3.53.tar.gz/po/pipewire.pot -> pipewire-0.3.54.tar.gz/po/pipewire.pot Changed
201
 
1
@@ -8,7 +8,7 @@
2
 msgstr ""
3
 "Project-Id-Version: pipewire\n"
4
 "Report-Msgid-Bugs-To: https://gitlab.freedesktop.org/pipewire/pipewire/issues/new\n"
5
-"POT-Creation-Date: 2022-04-03 12:56+0200\n"
6
+"POT-Creation-Date: 2022-06-30 12:50+0200\n"
7
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9
 "Language-Team: LANGUAGE <LL@li.org>\n"
10
@@ -27,8 +27,8 @@
11
 "  -c, --config                          Load config (Default %s)\n"
12
 msgstr ""
13
 
14
-#: src/modules/module-protocol-pulse/modules/module-tunnel-sink.c:190
15
-#: src/modules/module-protocol-pulse/modules/module-tunnel-source.c:190
16
+#: src/modules/module-protocol-pulse/modules/module-tunnel-sink.c:180
17
+#: src/modules/module-protocol-pulse/modules/module-tunnel-source.c:180
18
 #, c-format
19
 msgid "Tunnel to %s/%s"
20
 msgstr ""
21
@@ -37,36 +37,36 @@
22
 msgid "Dummy Output"
23
 msgstr ""
24
 
25
-#: src/modules/module-pulse-tunnel.c:545
26
+#: src/modules/module-pulse-tunnel.c:648
27
 #, c-format
28
 msgid "Tunnel for %s@%s"
29
 msgstr ""
30
 
31
-#: src/modules/module-zeroconf-discover.c:313
32
+#: src/modules/module-zeroconf-discover.c:332
33
 msgid "Unknown device"
34
 msgstr ""
35
 
36
-#: src/modules/module-zeroconf-discover.c:325
37
+#: src/modules/module-zeroconf-discover.c:344
38
 #, c-format
39
 msgid "%s on %s@%s"
40
 msgstr ""
41
 
42
-#: src/modules/module-zeroconf-discover.c:329
43
+#: src/modules/module-zeroconf-discover.c:348
44
 #, c-format
45
 msgid "%s on %s"
46
 msgstr ""
47
 
48
-#: src/tools/pw-cat.c:1087
49
+#: src/tools/pw-cat.c:784
50
 #, c-format
51
 msgid ""
52
-"%s options <file>\n"
53
+"%s options <file>|-\n"
54
 "  -h, --help                            Show this help\n"
55
 "      --version                         Show version\n"
56
 "  -v, --verbose                         Enable verbose operations\n"
57
 "\n"
58
 msgstr ""
59
 
60
-#: src/tools/pw-cat.c:1094
61
+#: src/tools/pw-cat.c:791
62
 #, c-format
63
 msgid ""
64
 "  -R, --remote                          Remote daemon name\n"
65
@@ -80,11 +80,11 @@
66
 "                                          or direct samples (256)\n"
67
 "                                          the rate is the one of the source "
68
 "file\n"
69
-"      --list-targets                    List available targets for --target\n"
70
+"  -P  --properties                      Set node properties\n"
71
 "\n"
72
 msgstr ""
73
 
74
-#: src/tools/pw-cat.c:1112
75
+#: src/tools/pw-cat.c:809
76
 #, c-format
77
 msgid ""
78
 "      --rate                            Sample rate (req. for rec) (default "
79
@@ -104,7 +104,7 @@
80
 "\n"
81
 msgstr ""
82
 
83
-#: src/tools/pw-cat.c:1129
84
+#: src/tools/pw-cat.c:826
85
 msgid ""
86
 "  -p, --playback                        Playback mode\n"
87
 "  -r, --record                          Recording mode\n"
88
@@ -113,7 +113,7 @@
89
 "\n"
90
 msgstr ""
91
 
92
-#: src/tools/pw-cli.c:3051
93
+#: src/tools/pw-cli.c:3165
94
 #, c-format
95
 msgid ""
96
 "%s options command\n"
97
@@ -128,8 +128,8 @@
98
 msgid "Pro Audio"
99
 msgstr ""
100
 
101
-#: spa/plugins/alsa/acp/acp.c:444 spa/plugins/alsa/acp/alsa-mixer.c:4648
102
-#: spa/plugins/bluez5/bluez5-device.c:1159
103
+#: spa/plugins/alsa/acp/acp.c:446 spa/plugins/alsa/acp/alsa-mixer.c:4648
104
+#: spa/plugins/bluez5/bluez5-device.c:1161
105
 msgid "Off"
106
 msgstr ""
107
 
108
@@ -156,7 +156,7 @@
109
 
110
 #: spa/plugins/alsa/acp/alsa-mixer.c:2657
111
 #: spa/plugins/alsa/acp/alsa-mixer.c:2741
112
-#: spa/plugins/bluez5/bluez5-device.c:1328
113
+#: spa/plugins/bluez5/bluez5-device.c:1330
114
 msgid "Microphone"
115
 msgstr ""
116
 
117
@@ -222,7 +222,7 @@
118
 msgstr ""
119
 
120
 #: spa/plugins/alsa/acp/alsa-mixer.c:2672
121
-#: spa/plugins/bluez5/bluez5-device.c:1333
122
+#: spa/plugins/bluez5/bluez5-device.c:1335
123
 msgid "Speaker"
124
 msgstr ""
125
 
126
@@ -337,7 +337,7 @@
127
 
128
 #: spa/plugins/alsa/acp/alsa-mixer.c:4484
129
 #: spa/plugins/alsa/acp/alsa-mixer.c:4642
130
-#: spa/plugins/bluez5/bluez5-device.c:1318
131
+#: spa/plugins/bluez5/bluez5-device.c:1320
132
 msgid "Headset"
133
 msgstr ""
134
 
135
@@ -516,7 +516,7 @@
136
 msgstr0 ""
137
 msgstr1 ""
138
 
139
-#: spa/plugins/alsa/acp/channelmap.h:464
140
+#: spa/plugins/alsa/acp/channelmap.h:457
141
 msgid "(invalid)"
142
 msgstr ""
143
 
144
@@ -528,61 +528,61 @@
145
 msgid "Modem"
146
 msgstr ""
147
 
148
-#: spa/plugins/bluez5/bluez5-device.c:1170
149
+#: spa/plugins/bluez5/bluez5-device.c:1172
150
 msgid "Audio Gateway (A2DP Source & HSP/HFP AG)"
151
 msgstr ""
152
 
153
-#: spa/plugins/bluez5/bluez5-device.c:1195
154
+#: spa/plugins/bluez5/bluez5-device.c:1197
155
 #, c-format
156
 msgid "High Fidelity Playback (A2DP Sink, codec %s)"
157
 msgstr ""
158
 
159
-#: spa/plugins/bluez5/bluez5-device.c:1198
160
+#: spa/plugins/bluez5/bluez5-device.c:1200
161
 #, c-format
162
 msgid "High Fidelity Duplex (A2DP Source/Sink, codec %s)"
163
 msgstr ""
164
 
165
-#: spa/plugins/bluez5/bluez5-device.c:1206
166
+#: spa/plugins/bluez5/bluez5-device.c:1208
167
 msgid "High Fidelity Playback (A2DP Sink)"
168
 msgstr ""
169
 
170
-#: spa/plugins/bluez5/bluez5-device.c:1208
171
+#: spa/plugins/bluez5/bluez5-device.c:1210
172
 msgid "High Fidelity Duplex (A2DP Source/Sink)"
173
 msgstr ""
174
 
175
-#: spa/plugins/bluez5/bluez5-device.c:1236
176
+#: spa/plugins/bluez5/bluez5-device.c:1238
177
 #, c-format
178
 msgid "Headset Head Unit (HSP/HFP, codec %s)"
179
 msgstr ""
180
 
181
-#: spa/plugins/bluez5/bluez5-device.c:1241
182
+#: spa/plugins/bluez5/bluez5-device.c:1243
183
 msgid "Headset Head Unit (HSP/HFP)"
184
 msgstr ""
185
 
186
-#: spa/plugins/bluez5/bluez5-device.c:1323
187
+#: spa/plugins/bluez5/bluez5-device.c:1325
188
 msgid "Handsfree"
189
 msgstr ""
190
 
191
-#: spa/plugins/bluez5/bluez5-device.c:1338
192
+#: spa/plugins/bluez5/bluez5-device.c:1340
193
 msgid "Headphone"
194
 msgstr ""
195
 
196
-#: spa/plugins/bluez5/bluez5-device.c:1343
197
+#: spa/plugins/bluez5/bluez5-device.c:1345
198
 msgid "Portable"
199
 msgstr ""
200
 
201
pipewire-0.3.53.tar.gz/spa/plugins/alsa/alsa-pcm-sink.c -> pipewire-0.3.54.tar.gz/spa/plugins/alsa/alsa-pcm-sink.c Changed
9
 
1
@@ -707,6 +707,7 @@
2
        this->port_info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
3
        this->port_paramsPORT_Latency.user++;
4
        emit_port_info(this, false);
5
+       res = 0;
6
        break;
7
    }
8
    default:
9
pipewire-0.3.53.tar.gz/spa/plugins/alsa/alsa-pcm.c -> pipewire-0.3.54.tar.gz/spa/plugins/alsa/alsa-pcm.c Changed
54
 
1
@@ -752,7 +752,7 @@
2
 }
3
 
4
 static int add_rate(struct state *state, uint32_t scale, bool all, uint32_t index, uint32_t *next,
5
-       snd_pcm_hw_params_t *params, struct spa_pod_builder *b)
6
+       uint32_t min_allowed_rate, snd_pcm_hw_params_t *params, struct spa_pod_builder *b)
7
 {
8
    struct spa_pod_frame f1;
9
    int err, dir;
10
@@ -763,6 +763,9 @@
11
    CHECK(snd_pcm_hw_params_get_rate_min(params, &min, &dir), "get_rate_min");
12
    CHECK(snd_pcm_hw_params_get_rate_max(params, &max, &dir), "get_rate_max");
13
 
14
+   min_allowed_rate /= scale;
15
+   min = SPA_MAX(min_allowed_rate, min);
16
+
17
    if (!state->multi_rate && state->card->format_ref > 0)
18
        rate = state->card->rate;
19
    else
20
@@ -1017,7 +1020,7 @@
21
        choice->body.type = SPA_CHOICE_Enum;
22
    spa_pod_builder_pop(b, &f1);
23
 
24
-   if ((res = add_rate(state, 1, false, index & 0xffff, next, params, b)) != 1)
25
+   if ((res = add_rate(state, 1, false, index & 0xffff, next, 0, params, b)) != 1)
26
        return res;
27
 
28
    if ((res = add_channels(state, false, index & 0xffff, next, params, b)) != 1)
29
@@ -1110,7 +1113,7 @@
30
    }
31
    spa_pod_builder_pop(b, &f1);
32
 
33
-   if ((res = add_rate(state, 1, true, index & 0xffff, next, params, b)) != 1)
34
+   if ((res = add_rate(state, 1, true, index & 0xffff, next, 0, params, b)) != 1)
35
        return res;
36
 
37
    (*next)++;
38
@@ -1165,7 +1168,14 @@
39
    spa_pod_builder_prop(b, SPA_FORMAT_AUDIO_interleave, 0);
40
    spa_pod_builder_int(b, interleave);
41
 
42
-   if ((res = add_rate(state, SPA_ABS(interleave), true, index & 0xffff, next, params, b)) != 1)
43
+   /* Use a lower rate limit of 352800 (= 44100 * 64 / 8). This is because in
44
+    * PipeWire, DSD rates are given in bytes, not bits, so 352800 corresponds
45
+    * to the bit rate of DSD64. (The "64" in DSD64 means "64 times the rate
46
+    * of 44.1 kHz".) Some hardware may report rates lower than that, for example
47
+    * 176400. This would correspond to "DSD32" (which does not exist). Trying
48
+    * to use such a rate with DSD hardware does not work and may cause undefined
49
+    * behavior in said hardware. */
50
+   if ((res = add_rate(state, SPA_ABS(interleave), true, index & 0xffff, next, 44100 * 64 / 8, params, b)) != 1)
51
        return res;
52
 
53
    if ((res = add_channels(state, true, index & 0xffff, next, params, b)) != 1)
54
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/audioadapter.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/audioadapter.c Changed
25
 
1
@@ -1153,8 +1153,21 @@
2
    if (this->target != this->follower) {
3
        this->driver = true;
4
 
5
-       if (this->direction == SPA_DIRECTION_OUTPUT)
6
-           status = spa_node_process(this->convert);
7
+       if (this->direction == SPA_DIRECTION_OUTPUT) {
8
+           int retry = 8;
9
+           while (retry--) {
10
+               status = spa_node_process(this->convert);
11
+               if (status & SPA_STATUS_HAVE_DATA)
12
+                   break;
13
+
14
+               if (status & SPA_STATUS_NEED_DATA) {
15
+                   status = spa_node_process(this->follower);
16
+                   if (!(status & SPA_STATUS_HAVE_DATA))
17
+                       break;
18
+               }
19
+           }
20
+
21
+       }
22
    }
23
 
24
    return spa_node_call_ready(&this->callbacks, status);
25
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/audioconvert.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/audioconvert.c Changed
201
 
1
@@ -166,10 +166,10 @@
2
    unsigned int have_profile:1;
3
    struct spa_latency_info latency;
4
 
5
-   uint32_t src_remapMAX_PORTS;
6
-   uint32_t dst_remapMAX_PORTS;
7
+   uint32_t remapMAX_PORTS;
8
 
9
    struct convert conv;
10
+   unsigned int need_remap:1;
11
    unsigned int is_passthrough:1;
12
    unsigned int control:1;
13
 };
14
@@ -221,9 +221,7 @@
15
    uint32_t empty_size;
16
    float *empty;
17
    float *scratch;
18
-   float *tmp;
19
-   float *tmp2;
20
-
21
+   float *tmp2;
22
    float *tmp_datas2MAX_PORTS;
23
 };
24
 
25
@@ -438,21 +436,21 @@
26
            param = spa_pod_builder_add_object(&b,
27
                SPA_TYPE_OBJECT_PropInfo, id,
28
                SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_volume),
29
-               SPA_PROP_INFO_name, SPA_POD_String("Volume"),
30
+               SPA_PROP_INFO_description, SPA_POD_String("Volume"),
31
                SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Float(p->volume, 0.0, 10.0));
32
            break;
33
        case 1:
34
            param = spa_pod_builder_add_object(&b,
35
                SPA_TYPE_OBJECT_PropInfo, id,
36
                SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_mute),
37
-               SPA_PROP_INFO_name, SPA_POD_String("Mute"),
38
+               SPA_PROP_INFO_description, SPA_POD_String("Mute"),
39
                SPA_PROP_INFO_type, SPA_POD_CHOICE_Bool(p->channel.mute));
40
            break;
41
        case 2:
42
            param = spa_pod_builder_add_object(&b,
43
                SPA_TYPE_OBJECT_PropInfo, id,
44
                SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_channelVolumes),
45
-               SPA_PROP_INFO_name, SPA_POD_String("Channel Volumes"),
46
+               SPA_PROP_INFO_description, SPA_POD_String("Channel Volumes"),
47
                SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Float(p->volume, 0.0, 10.0),
48
                SPA_PROP_INFO_container, SPA_POD_Id(SPA_TYPE_Array));
49
            break;
50
@@ -460,7 +458,7 @@
51
            param = spa_pod_builder_add_object(&b,
52
                SPA_TYPE_OBJECT_PropInfo, id,
53
                SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_channelMap),
54
-               SPA_PROP_INFO_name, SPA_POD_String("Channel Map"),
55
+               SPA_PROP_INFO_description, SPA_POD_String("Channel Map"),
56
                SPA_PROP_INFO_type, SPA_POD_Id(SPA_AUDIO_CHANNEL_UNKNOWN),
57
                SPA_PROP_INFO_container, SPA_POD_Id(SPA_TYPE_Array));
58
            break;
59
@@ -468,14 +466,14 @@
60
            param = spa_pod_builder_add_object(&b,
61
                SPA_TYPE_OBJECT_PropInfo, id,
62
                SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_monitorMute),
63
-               SPA_PROP_INFO_name, SPA_POD_String("Monitor Mute"),
64
+               SPA_PROP_INFO_description, SPA_POD_String("Monitor Mute"),
65
                SPA_PROP_INFO_type, SPA_POD_CHOICE_Bool(p->monitor.mute));
66
            break;
67
        case 5:
68
            param = spa_pod_builder_add_object(&b,
69
                SPA_TYPE_OBJECT_PropInfo, id,
70
                SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_monitorVolumes),
71
-               SPA_PROP_INFO_name, SPA_POD_String("Monitor Volumes"),
72
+               SPA_PROP_INFO_description, SPA_POD_String("Monitor Volumes"),
73
                SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Float(p->volume, 0.0, 10.0),
74
                SPA_PROP_INFO_container, SPA_POD_Id(SPA_TYPE_Array));
75
            break;
76
@@ -483,14 +481,14 @@
77
            param = spa_pod_builder_add_object(&b,
78
                SPA_TYPE_OBJECT_PropInfo, id,
79
                SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_softMute),
80
-               SPA_PROP_INFO_name, SPA_POD_String("Soft Mute"),
81
+               SPA_PROP_INFO_description, SPA_POD_String("Soft Mute"),
82
                SPA_PROP_INFO_type, SPA_POD_CHOICE_Bool(p->soft.mute));
83
            break;
84
        case 7:
85
            param = spa_pod_builder_add_object(&b,
86
                SPA_TYPE_OBJECT_PropInfo, id,
87
                SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_softVolumes),
88
-               SPA_PROP_INFO_name, SPA_POD_String("Soft Volumes"),
89
+               SPA_PROP_INFO_description, SPA_POD_String("Soft Volumes"),
90
                SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Float(p->volume, 0.0, 10.0),
91
                SPA_PROP_INFO_container, SPA_POD_Id(SPA_TYPE_Array));
92
            break;
93
@@ -1104,6 +1102,7 @@
94
    struct dir *in = &this->dirSPA_DIRECTION_INPUT;
95
    struct spa_audio_info src_info, dst_info;
96
    int res;
97
+   bool remap = false;
98
 
99
    src_info = in->format;
100
    dst_info = src_info;
101
@@ -1125,10 +1124,11 @@
102
            if (src_info.info.raw.positioni !=
103
                dst_info.info.raw.positionj)
104
                continue;
105
-           in->src_remapi = j;
106
-           in->dst_remapj = i;
107
-           spa_log_debug(this->log, "%p: channel %d -> %d (%s -> %s)", this,
108
-                   i, j,
109
+           in->remapi = j;
110
+           if (i != j)
111
+               remap = true;
112
+           spa_log_debug(this->log, "%p: channel %d (%d) -> %d (%s -> %s)", this,
113
+                   i, in->remapi, j,
114
                    spa_debug_type_find_short_name(spa_type_audio_channel,
115
                        src_info.info.raw.positioni),
116
                    spa_debug_type_find_short_name(spa_type_audio_channel,
117
@@ -1137,17 +1137,21 @@
118
            break;
119
        }
120
    }
121
+   if (in->conv.free)
122
+       convert_free(&in->conv);
123
+
124
    in->conv.src_fmt = src_info.info.raw.format;
125
    in->conv.dst_fmt = dst_info.info.raw.format;
126
    in->conv.n_channels = dst_info.info.raw.channels;
127
    in->conv.cpu_flags = this->cpu_flags;
128
+   in->need_remap = remap;
129
 
130
    if ((res = convert_init(&in->conv)) < 0)
131
        return res;
132
 
133
-   spa_log_debug(this->log, "%p: got converter features %08x:%08x passthrough:%d %s", this,
134
+   spa_log_debug(this->log, "%p: got converter features %08x:%08x passthrough:%d remap:%d %s", this,
135
            this->cpu_flags, in->conv.cpu_flags, in->conv.is_passthrough,
136
-           in->conv.func_name);
137
+           remap, in->conv.func_name);
138
 
139
    return 0;
140
 }
141
@@ -1266,7 +1270,7 @@
142
        vol = &this->props.channel;
143
 
144
    for (i = 0; i < vol->n_volumes; i++)
145
-       volumesi = vol->volumesdir->src_remapi;
146
+       volumesi = vol->volumesdir->remapi;
147
 
148
    channelmix_set_volume(&this->mix, this->props.volume, vol->mute,
149
            vol->n_volumes, volumes);
150
@@ -1396,6 +1400,7 @@
151
    struct dir *out = &this->dirSPA_DIRECTION_OUTPUT;
152
    struct spa_audio_info src_info, dst_info;
153
    int res;
154
+   bool remap = false;
155
 
156
    dst_info = out->format;
157
    src_info = dst_info;
158
@@ -1417,10 +1422,12 @@
159
            if (src_info.info.raw.positioni !=
160
                dst_info.info.raw.positionj)
161
                continue;
162
-           out->src_remapi = j;
163
-           out->dst_remapj = i;
164
-           spa_log_debug(this->log, "%p: channel %d -> %d (%s -> %s)", this,
165
-                   i, j,
166
+           out->remapi = j;
167
+           if (i != j)
168
+               remap = true;
169
+
170
+           spa_log_debug(this->log, "%p: channel %d (%d) -> %d (%s -> %s)", this,
171
+                   i, out->remapi, j,
172
                    spa_debug_type_find_short_name(spa_type_audio_channel,
173
                        src_info.info.raw.positioni),
174
                    spa_debug_type_find_short_name(spa_type_audio_channel,
175
@@ -1429,20 +1436,23 @@
176
            break;
177
        }
178
    }
179
-   out->conv.quantize = calc_width(&dst_info) * 8;
180
+   if (out->conv.free)
181
+       convert_free(&out->conv);
182
+
183
    out->conv.src_fmt = src_info.info.raw.format;
184
    out->conv.dst_fmt = dst_info.info.raw.format;
185
    out->conv.rate = dst_info.info.raw.rate;
186
    out->conv.n_channels = dst_info.info.raw.channels;
187
    out->conv.cpu_flags = this->cpu_flags;
188
+   out->need_remap = remap;
189
 
190
    if ((res = convert_init(&out->conv)) < 0)
191
        return res;
192
 
193
-   spa_log_debug(this->log, "%p: got converter features %08x:%08x quant:%d:%d:%d passthrough:%d %s", this,
194
+   spa_log_debug(this->log, "%p: got converter features %08x:%08x quant:%d:%d"
195
+           " passthrough:%d remap:%d %s", this,
196
            this->cpu_flags, out->conv.cpu_flags, out->conv.method,
197
-           out->conv.quantize, out->conv.noise,
198
-           out->conv.is_passthrough, out->conv.func_name);
199
+           out->conv.noise, out->conv.is_passthrough, remap, out->conv.func_name);
200
 
201
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/benchmark-fmt-ops.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/benchmark-fmt-ops.c Changed
28
 
1
@@ -271,18 +271,18 @@
2
 
3
 static void test_interleave(void)
4
 {
5
-   run_test("test_interleave_8", "c", false, true, conv_interleave_8_c);
6
-   run_test("test_interleave_16", "c", false, true, conv_interleave_16_c);
7
-   run_test("test_interleave_24", "c", false, true, conv_interleave_24_c);
8
-   run_test("test_interleave_32", "c", false, true, conv_interleave_32_c);
9
+   run_test("test_8d_to_8", "c", false, true, conv_8d_to_8_c);
10
+   run_test("test_16d_to_16", "c", false, true, conv_16d_to_16_c);
11
+   run_test("test_24d_to_24", "c", false, true, conv_24d_to_24_c);
12
+   run_test("test_32d_to_32", "c", false, true, conv_32d_to_32_c);
13
 }
14
 
15
 static void test_deinterleave(void)
16
 {
17
-   run_test("test_deinterleave_8", "c", true, false, conv_deinterleave_8_c);
18
-   run_test("test_deinterleave_16", "c", true, false, conv_deinterleave_16_c);
19
-   run_test("test_deinterleave_24", "c", true, false, conv_deinterleave_24_c);
20
-   run_test("test_deinterleave_32", "c", true, false, conv_deinterleave_32_c);
21
+   run_test("test_8_to_8d", "c", true, false, conv_8_to_8d_c);
22
+   run_test("test_16_to_16d", "c", true, false, conv_16_to_16d_c);
23
+   run_test("test_24_to_24d", "c", true, false, conv_24_to_24d_c);
24
+   run_test("test_32_to_32d", "c", true, false, conv_32_to_32d_c);
25
 }
26
 
27
 static int compare_func(const void *_a, const void *_b)
28
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-avx2.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/fmt-ops-avx2.c Changed
201
 
1
@@ -147,7 +147,7 @@
2
 conv_s24_to_f32d_1s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
3
        uint32_t n_channels, uint32_t n_samples)
4
 {
5
-   const uint8_t *s = src;
6
+   const int24_t *s = src;
7
    float *d0 = dst0;
8
    uint32_t n, unrolled;
9
    __m128i in;
10
@@ -164,21 +164,21 @@
11
    for(n = 0; n < unrolled; n += 4) {
12
        in = _mm_setr_epi32(
13
            *((uint32_t*)&s0 * n_channels),
14
-           *((uint32_t*)&s3 * n_channels),
15
-           *((uint32_t*)&s6 * n_channels),
16
-           *((uint32_t*)&s9 * n_channels));
17
+           *((uint32_t*)&s1 * n_channels),
18
+           *((uint32_t*)&s2 * n_channels),
19
+           *((uint32_t*)&s3 * n_channels));
20
        in = _mm_slli_epi32(in, 8);
21
        in = _mm_srai_epi32(in, 8);
22
        out = _mm_cvtepi32_ps(in);
23
        out = _mm_mul_ps(out, factor);
24
        _mm_store_ps(&d0n, out);
25
-       s += 12 * n_channels;
26
+       s += 4 * n_channels;
27
    }
28
    for(; n < n_samples; n++) {
29
-       out = _mm_cvtsi32_ss(factor, read_s24(s));
30
+       out = _mm_cvtsi32_ss(factor, s24_to_s32(*s));
31
        out = _mm_mul_ss(out, factor);
32
        _mm_store_ss(&d0n, out);
33
-       s += 3 * n_channels;
34
+       s += n_channels;
35
    }
36
 }
37
 
38
@@ -186,7 +186,7 @@
39
 conv_s24_to_f32d_2s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
40
        uint32_t n_channels, uint32_t n_samples)
41
 {
42
-   const uint8_t *s = src;
43
+   const int24_t *s = src;
44
    float *d0 = dst0, *d1 = dst1;
45
    uint32_t n, unrolled;
46
    __m128i in2;
47
@@ -205,14 +205,14 @@
48
    for(n = 0; n < unrolled; n += 4) {
49
        in0 = _mm_setr_epi32(
50
            *((uint32_t*)&s0 + 0*n_channels),
51
-           *((uint32_t*)&s0 + 3*n_channels),
52
-           *((uint32_t*)&s0 + 6*n_channels),
53
-           *((uint32_t*)&s0 + 9*n_channels));
54
+           *((uint32_t*)&s0 + 1*n_channels),
55
+           *((uint32_t*)&s0 + 2*n_channels),
56
+           *((uint32_t*)&s0 + 3*n_channels));
57
        in1 = _mm_setr_epi32(
58
-           *((uint32_t*)&s3 + 0*n_channels),
59
-           *((uint32_t*)&s3 + 3*n_channels),
60
-           *((uint32_t*)&s3 + 6*n_channels),
61
-           *((uint32_t*)&s3 + 9*n_channels));
62
+           *((uint32_t*)&s1 + 0*n_channels),
63
+           *((uint32_t*)&s1 + 1*n_channels),
64
+           *((uint32_t*)&s1 + 2*n_channels),
65
+           *((uint32_t*)&s1 + 3*n_channels));
66
 
67
        in0 = _mm_slli_epi32(in0, 8);
68
        in1 = _mm_slli_epi32(in1, 8);
69
@@ -229,23 +229,23 @@
70
        _mm_store_ps(&d0n, out0);
71
        _mm_store_ps(&d1n, out1);
72
 
73
-       s += 12 * n_channels;
74
+       s += 4 * n_channels;
75
    }
76
    for(; n < n_samples; n++) {
77
-       out0 = _mm_cvtsi32_ss(factor, read_s24(s));
78
-       out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
79
+       out0 = _mm_cvtsi32_ss(factor, s24_to_s32(*s));
80
+       out1 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+1)));
81
        out0 = _mm_mul_ss(out0, factor);
82
        out1 = _mm_mul_ss(out1, factor);
83
        _mm_store_ss(&d0n, out0);
84
        _mm_store_ss(&d1n, out1);
85
-       s += 3 * n_channels;
86
+       s += n_channels;
87
    }
88
 }
89
 static void
90
 conv_s24_to_f32d_4s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
91
        uint32_t n_channels, uint32_t n_samples)
92
 {
93
-   const uint8_t *s = src;
94
+   const int24_t *s = src;
95
    float *d0 = dst0, *d1 = dst1, *d2 = dst2, *d3 = dst3;
96
    uint32_t n, unrolled;
97
    __m128i in4;
98
@@ -266,24 +266,24 @@
99
    for(n = 0; n < unrolled; n += 4) {
100
        in0 = _mm_setr_epi32(
101
            *((uint32_t*)&s0 + 0*n_channels),
102
-           *((uint32_t*)&s0 + 3*n_channels),
103
-           *((uint32_t*)&s0 + 6*n_channels),
104
-           *((uint32_t*)&s0 + 9*n_channels));
105
+           *((uint32_t*)&s0 + 1*n_channels),
106
+           *((uint32_t*)&s0 + 2*n_channels),
107
+           *((uint32_t*)&s0 + 3*n_channels));
108
        in1 = _mm_setr_epi32(
109
-           *((uint32_t*)&s3 + 0*n_channels),
110
-           *((uint32_t*)&s3 + 3*n_channels),
111
-           *((uint32_t*)&s3 + 6*n_channels),
112
-           *((uint32_t*)&s3 + 9*n_channels));
113
+           *((uint32_t*)&s1 + 0*n_channels),
114
+           *((uint32_t*)&s1 + 1*n_channels),
115
+           *((uint32_t*)&s1 + 2*n_channels),
116
+           *((uint32_t*)&s1 + 3*n_channels));
117
        in2 = _mm_setr_epi32(
118
-           *((uint32_t*)&s6 + 0*n_channels),
119
-           *((uint32_t*)&s6 + 3*n_channels),
120
-           *((uint32_t*)&s6 + 6*n_channels),
121
-           *((uint32_t*)&s6 + 9*n_channels));
122
+           *((uint32_t*)&s2 + 0*n_channels),
123
+           *((uint32_t*)&s2 + 1*n_channels),
124
+           *((uint32_t*)&s2 + 2*n_channels),
125
+           *((uint32_t*)&s2 + 3*n_channels));
126
        in3 = _mm_setr_epi32(
127
-           *((uint32_t*)&s9 + 0*n_channels),
128
-           *((uint32_t*)&s9 + 3*n_channels),
129
-           *((uint32_t*)&s9 + 6*n_channels),
130
-           *((uint32_t*)&s9 + 9*n_channels));
131
+           *((uint32_t*)&s3 + 0*n_channels),
132
+           *((uint32_t*)&s3 + 1*n_channels),
133
+           *((uint32_t*)&s3 + 2*n_channels),
134
+           *((uint32_t*)&s3 + 3*n_channels));
135
 
136
        in0 = _mm_slli_epi32(in0, 8);
137
        in1 = _mm_slli_epi32(in1, 8);
138
@@ -310,13 +310,13 @@
139
        _mm_store_ps(&d2n, out2);
140
        _mm_store_ps(&d3n, out3);
141
 
142
-       s += 12 * n_channels;
143
+       s += 4 * n_channels;
144
    }
145
    for(; n < n_samples; n++) {
146
-       out0 = _mm_cvtsi32_ss(factor, read_s24(s));
147
-       out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
148
-       out2 = _mm_cvtsi32_ss(factor, read_s24(s+6));
149
-       out3 = _mm_cvtsi32_ss(factor, read_s24(s+9));
150
+       out0 = _mm_cvtsi32_ss(factor, s24_to_s32(*s));
151
+       out1 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+1)));
152
+       out2 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+2)));
153
+       out3 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+3)));
154
        out0 = _mm_mul_ss(out0, factor);
155
        out1 = _mm_mul_ss(out1, factor);
156
        out2 = _mm_mul_ss(out2, factor);
157
@@ -325,7 +325,7 @@
158
        _mm_store_ss(&d1n, out1);
159
        _mm_store_ss(&d2n, out2);
160
        _mm_store_ss(&d3n, out3);
161
-       s += 3 * n_channels;
162
+       s += n_channels;
163
    }
164
 }
165
 
166
@@ -353,7 +353,7 @@
167
    float *d0 = dst0, *d1 = dst1, *d2 = dst2, *d3 = dst3;
168
    uint32_t n, unrolled;
169
    __m256i in4, t4;
170
-   __m256 out4, factor = _mm256_set1_ps(1.0f / S24_SCALE);
171
+   __m256 out4, factor = _mm256_set1_ps(1.0f / S32_SCALE);
172
    __m256i mask1 = _mm256_setr_epi64x(0*n_channels, 0*n_channels+2, 4*n_channels, 4*n_channels+2);
173
    __m256i mask2 = _mm256_setr_epi64x(1*n_channels, 1*n_channels+2, 5*n_channels, 5*n_channels+2);
174
    __m256i mask3 = _mm256_setr_epi64x(2*n_channels, 2*n_channels+2, 6*n_channels, 6*n_channels+2);
175
@@ -373,11 +373,6 @@
176
        in2 = _mm256_i64gather_epi64((long long int *)&s0*n_channels, mask3, 4);
177
        in3 = _mm256_i64gather_epi64((long long int *)&s0*n_channels, mask4, 4);
178
 
179
-       in0 = _mm256_srai_epi32(in0, 8); /* a0 b0 c0 d0 a4 b4 c4 d4 */
180
-       in1 = _mm256_srai_epi32(in1, 8); /* a1 b1 c1 d1 a5 b5 c5 d5 */
181
-       in2 = _mm256_srai_epi32(in2, 8); /* a2 b2 c2 d2 a6 b6 c6 d6 */
182
-       in3 = _mm256_srai_epi32(in3, 8); /* a3 b3 c3 d3 a7 b7 c7 d7 */
183
-
184
        t0 = _mm256_unpacklo_epi32(in0, in1);   /* a0 a1 b0 b1 a4 a5 b4 b5 */
185
        t1 = _mm256_unpackhi_epi32(in0, in1);   /* c0 c1 d0 d1 c4 c5 d4 d5 */
186
        t2 = _mm256_unpacklo_epi32(in2, in3);   /* a2 a3 b2 b3 a6 a7 b6 b7 */
187
@@ -405,11 +400,11 @@
188
        s += 8*n_channels;
189
    }
190
    for(; n < n_samples; n++) {
191
-       __m128 out4, factor = _mm_set1_ps(1.0f / S24_SCALE);
192
-       out0 = _mm_cvtsi32_ss(factor, s0>>8);
193
-       out1 = _mm_cvtsi32_ss(factor, s1>>8);
194
-       out2 = _mm_cvtsi32_ss(factor, s2>>8);
195
-       out3 = _mm_cvtsi32_ss(factor, s3>>8);
196
+       __m128 out4, factor = _mm_set1_ps(1.0f / S32_SCALE);
197
+       out0 = _mm_cvtsi32_ss(factor, s0);
198
+       out1 = _mm_cvtsi32_ss(factor, s1);
199
+       out2 = _mm_cvtsi32_ss(factor, s2);
200
+       out3 = _mm_cvtsi32_ss(factor, s3);
201
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-c.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/fmt-ops-c.c Changed
201
 
1
@@ -33,708 +33,196 @@
2
 #include "fmt-ops.h"
3
 #include "law.h"
4
 
5
-void
6
-conv_copy8d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
7
-       uint32_t n_samples)
8
-{
9
-   uint32_t i, n_channels = conv->n_channels;
10
-   for (i = 0; i < n_channels; i++)
11
-       spa_memcpy(dsti, srci, n_samples);
12
-}
13
-
14
-void
15
-conv_copy8_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
16
-       uint32_t n_samples)
17
-{
18
-   spa_memcpy(dst0, src0, n_samples * conv->n_channels);
19
-}
20
-
21
-
22
-void
23
-conv_copy16d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
24
-       uint32_t n_samples)
25
-{
26
-   uint32_t i, n_channels = conv->n_channels;
27
-   for (i = 0; i < n_channels; i++)
28
-       spa_memcpy(dsti, srci, n_samples * sizeof(int16_t));
29
-}
30
-
31
-void
32
-conv_copy16_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
33
-       uint32_t n_samples)
34
-{
35
-   spa_memcpy(dst0, src0, n_samples * sizeof(int16_t) * conv->n_channels);
36
-}
37
-
38
-void
39
-conv_copy24d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
40
-       uint32_t n_samples)
41
-{
42
-   uint32_t i, n_channels = conv->n_channels;
43
-   for (i = 0; i < n_channels; i++)
44
-       spa_memcpy(dsti, srci, n_samples * 3);
45
-}
46
-
47
-void
48
-conv_copy24_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
49
-       uint32_t n_samples)
50
-{
51
-   spa_memcpy(dst0, src0, n_samples * 3 * conv->n_channels);
52
-}
53
-
54
-void
55
-conv_copy32d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
56
-       uint32_t n_samples)
57
-{
58
-   uint32_t i, n_channels = conv->n_channels;
59
-   for (i = 0; i < n_channels; i++)
60
-       spa_memcpy(dsti, srci, n_samples * sizeof(int32_t));
61
-}
62
-
63
-void
64
-conv_copy32_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
65
-       uint32_t n_samples)
66
-{
67
-   spa_memcpy(dst0, src0, n_samples * sizeof(int32_t) * conv->n_channels);
68
-}
69
-
70
-void
71
-conv_copy64d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
72
-       uint32_t n_samples)
73
-{
74
-   uint32_t i, n_channels = conv->n_channels;
75
-   for (i = 0; i < n_channels; i++)
76
-       spa_memcpy(dsti, srci, n_samples * sizeof(int64_t));
77
-}
78
-
79
-void
80
-conv_copy64_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
81
-       uint32_t n_samples)
82
-{
83
-   spa_memcpy(dst0, src0, n_samples * sizeof(int64_t) * conv->n_channels);
84
-}
85
-
86
-void
87
-conv_u8d_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
88
-       uint32_t n_samples)
89
-{
90
-   uint32_t i, j, n_channels = conv->n_channels;
91
-
92
-   for (i = 0; i < n_channels; i++) {
93
-       const uint8_t *s = srci;
94
-       float *d = dsti;
95
-
96
-       for (j = 0; j < n_samples; j++)
97
-           dj = U8_TO_F32(sj);
98
-   }
99
-}
100
-
101
-void
102
-conv_u8_to_f32_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
103
-       uint32_t n_samples)
104
-{
105
-   uint32_t i, n_channels = conv->n_channels;
106
-   const uint8_t *s = src0;
107
-   float *d = dst0;
108
-
109
-   n_samples *= n_channels;
110
-
111
-   for (i = 0; i < n_samples; i++)
112
-       di = U8_TO_F32(si);
113
-}
114
-
115
-void
116
-conv_u8_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
117
-       uint32_t n_samples)
118
-{
119
-   const uint8_t *s = src0;
120
-   float **d = (float **) dst;
121
-   uint32_t i, j, n_channels = conv->n_channels;
122
-
123
-   for (j = 0; j < n_samples; j++) {
124
-       for (i = 0; i < n_channels; i++)
125
-           dij = U8_TO_F32(*s++);
126
-   }
127
-}
128
-
129
-void
130
-conv_u8d_to_f32_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
131
-       uint32_t n_samples)
132
-{
133
-   const uint8_t **s = (const uint8_t **) src;
134
-   float *d = dst0;
135
-   uint32_t i, j, n_channels = conv->n_channels;
136
-
137
-   for (j = 0; j < n_samples; j++) {
138
-       for (i = 0; i < n_channels; i++)
139
-           *d++ = U8_TO_F32(sij);
140
-   }
141
-}
142
-
143
-void
144
-conv_s8d_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
145
-       uint32_t n_samples)
146
-{
147
-   uint32_t i, j, n_channels = conv->n_channels;
148
-
149
-   for (i = 0; i < n_channels; i++) {
150
-       const int8_t *s = srci;
151
-       float *d = dsti;
152
-       for (j = 0; j < n_samples; j++)
153
-           dj = S8_TO_F32(sj);
154
-   }
155
-}
156
-
157
-void
158
-conv_s8_to_f32_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
159
-       uint32_t n_samples)
160
-{
161
-   uint32_t i, n_channels = conv->n_channels;
162
-   const int8_t *s = src0;
163
-   float *d = dst0;
164
-
165
-   n_samples *= n_channels;
166
-
167
-   for (i = 0; i < n_samples; i++)
168
-       di = S8_TO_F32(si);
169
-}
170
-
171
-void
172
-conv_s8_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
173
-       uint32_t n_samples)
174
-{
175
-   const int8_t *s = src0;
176
-   float **d = (float **) dst;
177
-   uint32_t i, j, n_channels = conv->n_channels;
178
-
179
-   for (j = 0; j < n_samples; j++) {
180
-       for (i = 0; i < n_channels; i++)
181
-           dij = S8_TO_F32(*s++);
182
-   }
183
-}
184
-
185
-void
186
-conv_s8d_to_f32_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
187
-       uint32_t n_samples)
188
-{
189
-   const int8_t **s = (const int8_t **) src;
190
-   float *d = dst0;
191
-   uint32_t i, j, n_channels = conv->n_channels;
192
-
193
-   for (j = 0; j < n_samples; j++) {
194
-       for (i = 0; i < n_channels; i++)
195
-           *d++ = S8_TO_F32(sij);
196
-   }
197
-}
198
-
199
-void
200
-conv_alaw_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
201
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-sse2.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/fmt-ops-sse2.c Changed
201
 
1
@@ -132,7 +132,7 @@
2
 conv_s24_to_f32d_1s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
3
        uint32_t n_channels, uint32_t n_samples)
4
 {
5
-   const uint8_t *s = src;
6
+   const int24_t *s = src;
7
    float *d0 = dst0;
8
    uint32_t n, unrolled;
9
    __m128i in;
10
@@ -149,21 +149,21 @@
11
    for(n = 0; n < unrolled; n += 4) {
12
        in = _mm_setr_epi32(
13
            *((uint32_t*)&s0 * n_channels),
14
-           *((uint32_t*)&s3 * n_channels),
15
-           *((uint32_t*)&s6 * n_channels),
16
-           *((uint32_t*)&s9 * n_channels));
17
+           *((uint32_t*)&s1 * n_channels),
18
+           *((uint32_t*)&s2 * n_channels),
19
+           *((uint32_t*)&s3 * n_channels));
20
        in = _mm_slli_epi32(in, 8);
21
        in = _mm_srai_epi32(in, 8);
22
        out = _mm_cvtepi32_ps(in);
23
        out = _mm_mul_ps(out, factor);
24
        _mm_store_ps(&d0n, out);
25
-       s += 12 * n_channels;
26
+       s += 4 * n_channels;
27
    }
28
    for(; n < n_samples; n++) {
29
-       out = _mm_cvtsi32_ss(factor, read_s24(s));
30
+       out = _mm_cvtsi32_ss(factor, s24_to_s32(*s));
31
        out = _mm_mul_ss(out, factor);
32
        _mm_store_ss(&d0n, out);
33
-       s += 3 * n_channels;
34
+       s += n_channels;
35
    }
36
 }
37
 
38
@@ -171,7 +171,7 @@
39
 conv_s24_to_f32d_2s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
40
        uint32_t n_channels, uint32_t n_samples)
41
 {
42
-   const uint8_t *s = src;
43
+   const int24_t *s = src;
44
    float *d0 = dst0, *d1 = dst1;
45
    uint32_t n, unrolled;
46
    __m128i in2;
47
@@ -190,14 +190,14 @@
48
    for(n = 0; n < unrolled; n += 4) {
49
        in0 = _mm_setr_epi32(
50
            *((uint32_t*)&s0 + 0*n_channels),
51
-           *((uint32_t*)&s0 + 3*n_channels),
52
-           *((uint32_t*)&s0 + 6*n_channels),
53
-           *((uint32_t*)&s0 + 9*n_channels));
54
+           *((uint32_t*)&s0 + 1*n_channels),
55
+           *((uint32_t*)&s0 + 2*n_channels),
56
+           *((uint32_t*)&s0 + 3*n_channels));
57
        in1 = _mm_setr_epi32(
58
-           *((uint32_t*)&s3 + 0*n_channels),
59
-           *((uint32_t*)&s3 + 3*n_channels),
60
-           *((uint32_t*)&s3 + 6*n_channels),
61
-           *((uint32_t*)&s3 + 9*n_channels));
62
+           *((uint32_t*)&s1 + 0*n_channels),
63
+           *((uint32_t*)&s1 + 1*n_channels),
64
+           *((uint32_t*)&s1 + 2*n_channels),
65
+           *((uint32_t*)&s1 + 3*n_channels));
66
 
67
        in0 = _mm_slli_epi32(in0, 8);
68
        in1 = _mm_slli_epi32(in1, 8);
69
@@ -214,23 +214,23 @@
70
        _mm_store_ps(&d0n, out0);
71
        _mm_store_ps(&d1n, out1);
72
 
73
-       s += 12 * n_channels;
74
+       s += 4 * n_channels;
75
    }
76
    for(; n < n_samples; n++) {
77
-       out0 = _mm_cvtsi32_ss(factor, read_s24(s));
78
-       out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
79
+       out0 = _mm_cvtsi32_ss(factor, s24_to_s32(*s));
80
+       out1 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+1)));
81
        out0 = _mm_mul_ss(out0, factor);
82
        out1 = _mm_mul_ss(out1, factor);
83
        _mm_store_ss(&d0n, out0);
84
        _mm_store_ss(&d1n, out1);
85
-       s += 3 * n_channels;
86
+       s += n_channels;
87
    }
88
 }
89
 static void
90
 conv_s24_to_f32d_4s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
91
        uint32_t n_channels, uint32_t n_samples)
92
 {
93
-   const uint8_t *s = src;
94
+   const int24_t *s = src;
95
    float *d0 = dst0, *d1 = dst1, *d2 = dst2, *d3 = dst3;
96
    uint32_t n, unrolled;
97
    __m128i in4;
98
@@ -251,24 +251,24 @@
99
    for(n = 0; n < unrolled; n += 4) {
100
        in0 = _mm_setr_epi32(
101
            *((uint32_t*)&s0 + 0*n_channels),
102
-           *((uint32_t*)&s0 + 3*n_channels),
103
-           *((uint32_t*)&s0 + 6*n_channels),
104
-           *((uint32_t*)&s0 + 9*n_channels));
105
+           *((uint32_t*)&s0 + 1*n_channels),
106
+           *((uint32_t*)&s0 + 2*n_channels),
107
+           *((uint32_t*)&s0 + 3*n_channels));
108
        in1 = _mm_setr_epi32(
109
-           *((uint32_t*)&s3 + 0*n_channels),
110
-           *((uint32_t*)&s3 + 3*n_channels),
111
-           *((uint32_t*)&s3 + 6*n_channels),
112
-           *((uint32_t*)&s3 + 9*n_channels));
113
+           *((uint32_t*)&s1 + 0*n_channels),
114
+           *((uint32_t*)&s1 + 1*n_channels),
115
+           *((uint32_t*)&s1 + 2*n_channels),
116
+           *((uint32_t*)&s1 + 3*n_channels));
117
        in2 = _mm_setr_epi32(
118
-           *((uint32_t*)&s6 + 0*n_channels),
119
-           *((uint32_t*)&s6 + 3*n_channels),
120
-           *((uint32_t*)&s6 + 6*n_channels),
121
-           *((uint32_t*)&s6 + 9*n_channels));
122
+           *((uint32_t*)&s2 + 0*n_channels),
123
+           *((uint32_t*)&s2 + 1*n_channels),
124
+           *((uint32_t*)&s2 + 2*n_channels),
125
+           *((uint32_t*)&s2 + 3*n_channels));
126
        in3 = _mm_setr_epi32(
127
-           *((uint32_t*)&s9 + 0*n_channels),
128
-           *((uint32_t*)&s9 + 3*n_channels),
129
-           *((uint32_t*)&s9 + 6*n_channels),
130
-           *((uint32_t*)&s9 + 9*n_channels));
131
+           *((uint32_t*)&s3 + 0*n_channels),
132
+           *((uint32_t*)&s3 + 1*n_channels),
133
+           *((uint32_t*)&s3 + 2*n_channels),
134
+           *((uint32_t*)&s3 + 3*n_channels));
135
 
136
        in0 = _mm_slli_epi32(in0, 8);
137
        in1 = _mm_slli_epi32(in1, 8);
138
@@ -295,13 +295,13 @@
139
        _mm_store_ps(&d2n, out2);
140
        _mm_store_ps(&d3n, out3);
141
 
142
-       s += 12 * n_channels;
143
+       s += 4 * n_channels;
144
    }
145
    for(; n < n_samples; n++) {
146
-       out0 = _mm_cvtsi32_ss(factor, read_s24(s));
147
-       out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
148
-       out2 = _mm_cvtsi32_ss(factor, read_s24(s+6));
149
-       out3 = _mm_cvtsi32_ss(factor, read_s24(s+9));
150
+       out0 = _mm_cvtsi32_ss(factor, s24_to_s32(*s));
151
+       out1 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+1)));
152
+       out2 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+2)));
153
+       out3 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+3)));
154
        out0 = _mm_mul_ss(out0, factor);
155
        out1 = _mm_mul_ss(out1, factor);
156
        out2 = _mm_mul_ss(out2, factor);
157
@@ -310,7 +310,7 @@
158
        _mm_store_ss(&d1n, out1);
159
        _mm_store_ss(&d2n, out2);
160
        _mm_store_ss(&d3n, out3);
161
-       s += 3 * n_channels;
162
+       s += n_channels;
163
    }
164
 }
165
 
166
@@ -338,7 +338,7 @@
167
    float *d0 = dst0;
168
    uint32_t n, unrolled;
169
    __m128i in;
170
-   __m128 out, factor = _mm_set1_ps(1.0f / S24_SCALE);
171
+   __m128 out, factor = _mm_set1_ps(1.0f / S32_SCALE);
172
 
173
    if (SPA_IS_ALIGNED(d0, 16))
174
        unrolled = n_samples & ~3;
175
@@ -350,14 +350,13 @@
176
                    s1*n_channels,
177
                    s2*n_channels,
178
                    s3*n_channels);
179
-       in = _mm_srai_epi32(in, 8);
180
        out = _mm_cvtepi32_ps(in);
181
        out = _mm_mul_ps(out, factor);
182
        _mm_store_ps(&d0n, out);
183
        s += 4*n_channels;
184
    }
185
    for(; n < n_samples; n++) {
186
-       out = _mm_cvtsi32_ss(factor, s0>>8);
187
+       out = _mm_cvtsi32_ss(factor, s0);
188
        out = _mm_mul_ss(out, factor);
189
        _mm_store_ss(&d0n, out);
190
        s += n_channels;
191
@@ -395,7 +394,7 @@
192
    for(n = 0; n < unrolled; n += 4) {
193
        in0 = _mm_mul_ps(_mm_load_ps(&s0n), scale);
194
        in0 = _mm_min_ps(in0, int_max);
195
-       out0 = _mm_cvtps_epi32(in0);
196
+       out0 = _mm_cvttps_epi32(in0);
197
        out1 = _mm_shuffle_epi32(out0, _MM_SHUFFLE(0, 3, 2, 1));
198
        out2 = _mm_shuffle_epi32(out0, _MM_SHUFFLE(1, 0, 3, 2));
199
        out3 = _mm_shuffle_epi32(out0, _MM_SHUFFLE(2, 1, 0, 3));
200
@@ -440,8 +439,8 @@
201
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-sse41.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/fmt-ops-sse41.c Changed
38
 
1
@@ -30,7 +30,7 @@
2
 conv_s24_to_f32d_1s_sse41(void *data, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
3
        uint32_t n_channels, uint32_t n_samples)
4
 {
5
-   const uint8_t *s = src;
6
+   const int24_t *s = src;
7
    float *d0 = dst0;
8
    uint32_t n, unrolled;
9
    __m128i in = _mm_setzero_si128();
10
@@ -43,21 +43,21 @@
11
 
12
    for(n = 0; n < unrolled; n += 4) {
13
        in = _mm_insert_epi32(in, *((uint32_t*)&s0 * n_channels), 0);
14
-       in = _mm_insert_epi32(in, *((uint32_t*)&s3 * n_channels), 1);
15
-       in = _mm_insert_epi32(in, *((uint32_t*)&s6 * n_channels), 2);
16
-       in = _mm_insert_epi32(in, *((uint32_t*)&s9 * n_channels), 3);
17
+       in = _mm_insert_epi32(in, *((uint32_t*)&s1 * n_channels), 1);
18
+       in = _mm_insert_epi32(in, *((uint32_t*)&s2 * n_channels), 2);
19
+       in = _mm_insert_epi32(in, *((uint32_t*)&s3 * n_channels), 3);
20
        in = _mm_slli_epi32(in, 8);
21
        in = _mm_srai_epi32(in, 8);
22
        out = _mm_cvtepi32_ps(in);
23
        out = _mm_mul_ps(out, factor);
24
        _mm_store_ps(&d0n, out);
25
-       s += 12 * n_channels;
26
+       s += 4 * n_channels;
27
    }
28
    for(; n < n_samples; n++) {
29
-       out = _mm_cvtsi32_ss(factor, read_s24(s));
30
+       out = _mm_cvtsi32_ss(factor, s24_to_s32(*s));
31
        out = _mm_mul_ss(out, factor);
32
        _mm_store_ss(&d0n, out);
33
-       s += 3 * n_channels;
34
+       s += n_channels;
35
    }
36
 }
37
 
38
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-ssse3.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/fmt-ops-ssse3.c Changed
51
 
1
@@ -30,7 +30,7 @@
2
 conv_s24_to_f32d_4s_ssse3(void *data, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
3
        uint32_t n_channels, uint32_t n_samples)
4
 {
5
-   const uint8_t *s = src;
6
+   const int24_t *s = src;
7
    float *d0 = dst0, *d1 = dst1, *d2 = dst2, *d3 = dst3;
8
    uint32_t n, unrolled;
9
    __m128i in4;
10
@@ -48,9 +48,9 @@
11
 
12
    for(n = 0; n < unrolled; n += 4) {
13
                 in0 = _mm_loadu_si128((__m128i*)(s + 0*n_channels));
14
-                in1 = _mm_loadu_si128((__m128i*)(s + 3*n_channels));
15
-                in2 = _mm_loadu_si128((__m128i*)(s + 6*n_channels));
16
-                in3 = _mm_loadu_si128((__m128i*)(s + 9*n_channels));
17
+                in1 = _mm_loadu_si128((__m128i*)(s + 1*n_channels));
18
+                in2 = _mm_loadu_si128((__m128i*)(s + 2*n_channels));
19
+                in3 = _mm_loadu_si128((__m128i*)(s + 3*n_channels));
20
        in0 = _mm_shuffle_epi8(in0, mask);
21
        in1 = _mm_shuffle_epi8(in1, mask);
22
        in2 = _mm_shuffle_epi8(in2, mask);
23
@@ -74,13 +74,13 @@
24
        _mm_store_ps(&d1n, out1);
25
        _mm_store_ps(&d2n, out2);
26
        _mm_store_ps(&d3n, out3);
27
-       s += 12 * n_channels;
28
+       s += 4 * n_channels;
29
    }
30
    for(; n < n_samples; n++) {
31
-       out0 = _mm_cvtsi32_ss(factor, read_s24(s));
32
-       out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
33
-       out2 = _mm_cvtsi32_ss(factor, read_s24(s+6));
34
-       out3 = _mm_cvtsi32_ss(factor, read_s24(s+9));
35
+       out0 = _mm_cvtsi32_ss(factor, s24_to_s32(*s));
36
+       out1 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+1)));
37
+       out2 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+2)));
38
+       out3 = _mm_cvtsi32_ss(factor, s24_to_s32(*(s+3)));
39
        out0 = _mm_mul_ss(out0, factor);
40
        out1 = _mm_mul_ss(out1, factor);
41
        out2 = _mm_mul_ss(out2, factor);
42
@@ -89,7 +89,7 @@
43
        _mm_store_ss(&d1n, out1);
44
        _mm_store_ss(&d2n, out2);
45
        _mm_store_ss(&d3n, out3);
46
-       s += 3 * n_channels;
47
+       s += n_channels;
48
    }
49
 }
50
 
51
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/fmt-ops.c Changed
110
 
1
@@ -96,22 +96,22 @@
2
    MAKE(F32, F32, 0, conv_copy32_c),
3
    MAKE(F32P, F32P, 0, conv_copy32d_c),
4
 #if defined (HAVE_SSE2)
5
-   MAKE(F32, F32P, 0, conv_deinterleave_32_sse2, SPA_CPU_FLAG_SSE2),
6
+   MAKE(F32, F32P, 0, conv_32_to_32d_sse2, SPA_CPU_FLAG_SSE2),
7
 #endif
8
-   MAKE(F32, F32P, 0, conv_deinterleave_32_c),
9
+   MAKE(F32, F32P, 0, conv_32_to_32d_c),
10
 #if defined (HAVE_SSE2)
11
-   MAKE(F32P, F32, 0, conv_interleave_32_sse2, SPA_CPU_FLAG_SSE2),
12
+   MAKE(F32P, F32, 0, conv_32d_to_32_sse2, SPA_CPU_FLAG_SSE2),
13
 #endif
14
-   MAKE(F32P, F32, 0, conv_interleave_32_c),
15
+   MAKE(F32P, F32, 0, conv_32d_to_32_c),
16
 
17
 #if defined (HAVE_SSE2)
18
-   MAKE(F32_OE, F32P, 0, conv_deinterleave_32s_sse2, SPA_CPU_FLAG_SSE2),
19
+   MAKE(F32_OE, F32P, 0, conv_32s_to_32sd_sse2, SPA_CPU_FLAG_SSE2),
20
 #endif
21
-   MAKE(F32_OE, F32P, 0, conv_deinterleave_32s_c),
22
+   MAKE(F32_OE, F32P, 0, conv_32s_to_32sd_c),
23
 #if defined (HAVE_SSE2)
24
-   MAKE(F32P, F32_OE, 0, conv_interleave_32s_sse2, SPA_CPU_FLAG_SSE2),
25
+   MAKE(F32P, F32_OE, 0, conv_32sd_to_32s_sse2, SPA_CPU_FLAG_SSE2),
26
 #endif
27
-   MAKE(F32P, F32_OE, 0, conv_interleave_32s_c),
28
+   MAKE(F32P, F32_OE, 0, conv_32sd_to_32s_c),
29
 
30
    MAKE(U32, F32, 0, conv_u32_to_f32_c),
31
    MAKE(U32, F32P, 0, conv_u32_to_f32d_c),
32
@@ -287,14 +287,14 @@
33
    /* u8 */
34
    MAKE(U8, U8, 0, conv_copy8_c),
35
    MAKE(U8P, U8P, 0, conv_copy8d_c),
36
-   MAKE(U8, U8P, 0, conv_deinterleave_8_c),
37
-   MAKE(U8P, U8, 0, conv_interleave_8_c),
38
+   MAKE(U8, U8P, 0, conv_8_to_8d_c),
39
+   MAKE(U8P, U8, 0, conv_8d_to_8_c),
40
 
41
    /* s8 */
42
    MAKE(S8, S8, 0, conv_copy8_c),
43
    MAKE(S8P, S8P, 0, conv_copy8d_c),
44
-   MAKE(S8, S8P, 0, conv_deinterleave_8_c),
45
-   MAKE(S8P, S8, 0, conv_interleave_8_c),
46
+   MAKE(S8, S8P, 0, conv_8_to_8d_c),
47
+   MAKE(S8P, S8, 0, conv_8d_to_8_c),
48
 
49
    /* alaw */
50
    MAKE(ALAW, ALAW, 0, conv_copy8_c),
51
@@ -304,44 +304,44 @@
52
    /* s16 */
53
    MAKE(S16, S16, 0, conv_copy16_c),
54
    MAKE(S16P, S16P, 0, conv_copy16d_c),
55
-   MAKE(S16, S16P, 0, conv_deinterleave_16_c),
56
-   MAKE(S16P, S16, 0, conv_interleave_16_c),
57
+   MAKE(S16, S16P, 0, conv_16_to_16d_c),
58
+   MAKE(S16P, S16, 0, conv_16d_to_16_c),
59
 
60
    /* s32 */
61
    MAKE(S32, S32, 0, conv_copy32_c),
62
    MAKE(S32P, S32P, 0, conv_copy32d_c),
63
 #if defined (HAVE_SSE2)
64
-   MAKE(S32, S32P, 0, conv_deinterleave_32_sse2, SPA_CPU_FLAG_SSE2),
65
+   MAKE(S32, S32P, 0, conv_32_to_32d_sse2, SPA_CPU_FLAG_SSE2),
66
 #endif
67
-   MAKE(S32, S32P, 0, conv_deinterleave_32_c),
68
+   MAKE(S32, S32P, 0, conv_32_to_32d_c),
69
 #if defined (HAVE_SSE2)
70
-   MAKE(S32P, S32, 0, conv_interleave_32_sse2, SPA_CPU_FLAG_SSE2),
71
+   MAKE(S32P, S32, 0, conv_32d_to_32_sse2, SPA_CPU_FLAG_SSE2),
72
 #endif
73
-   MAKE(S32P, S32, 0, conv_interleave_32_c),
74
+   MAKE(S32P, S32, 0, conv_32d_to_32_c),
75
 
76
    /* s24 */
77
    MAKE(S24, S24, 0, conv_copy24_c),
78
    MAKE(S24P, S24P, 0, conv_copy24d_c),
79
-   MAKE(S24, S24P, 0, conv_deinterleave_24_c),
80
-   MAKE(S24P, S24, 0, conv_interleave_24_c),
81
+   MAKE(S24, S24P, 0, conv_24_to_24d_c),
82
+   MAKE(S24P, S24, 0, conv_24d_to_24_c),
83
 
84
    /* s24_32 */
85
    MAKE(S24_32, S24_32, 0, conv_copy32_c),
86
    MAKE(S24_32P, S24_32P, 0, conv_copy32d_c),
87
 #if defined (HAVE_SSE2)
88
-   MAKE(S24_32, S24_32P, 0, conv_deinterleave_32_sse2, SPA_CPU_FLAG_SSE2),
89
+   MAKE(S24_32, S24_32P, 0, conv_32_to_32d_sse2, SPA_CPU_FLAG_SSE2),
90
 #endif
91
-   MAKE(S24_32, S24_32P, 0, conv_deinterleave_32_c),
92
+   MAKE(S24_32, S24_32P, 0, conv_32_to_32d_c),
93
 #if defined (HAVE_SSE2)
94
-   MAKE(S24_32P, S24_32, 0, conv_interleave_32_sse2, SPA_CPU_FLAG_SSE2),
95
+   MAKE(S24_32P, S24_32, 0, conv_32d_to_32_sse2, SPA_CPU_FLAG_SSE2),
96
 #endif
97
-   MAKE(S24_32P, S24_32, 0, conv_interleave_32_c),
98
+   MAKE(S24_32P, S24_32, 0, conv_32d_to_32_c),
99
 
100
    /* F64 */
101
    MAKE(F64, F64, 0, conv_copy64_c),
102
    MAKE(F64P, F64P, 0, conv_copy64d_c),
103
-   MAKE(F64, F64P, 0, conv_deinterleave_64_c),
104
-   MAKE(F64P, F64, 0, conv_interleave_64_c),
105
+   MAKE(F64, F64P, 0, conv_64_to_64d_c),
106
+   MAKE(F64P, F64, 0, conv_64d_to_64_c),
107
 };
108
 #undef MAKE
109
 
110
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops.h -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/fmt-ops.h Changed
201
 
1
@@ -39,35 +39,33 @@
2
 
3
 #define U8_MIN         0u
4
 #define U8_MAX         255u
5
-#define U8_SCALE       127.5f
6
+#define U8_SCALE       128.f
7
 #define U8_OFFS            128.f
8
-#define U8_TO_F32(v)       ((((uint8_t)(v)) * (1.0f / U8_OFFS)) - 1.0f)
9
+#define U8_TO_F32(v)       ((((uint8_t)(v)) * (1.0f / U8_SCALE)) - 1.0f)
10
 #define F32_TO_U8(v)       (uint8_t)SPA_CLAMP((v) * U8_SCALE + U8_OFFS, U8_MIN, U8_MAX)
11
 #define F32_TO_U8_D(v,d)   (uint8_t)SPA_CLAMP((v) * U8_SCALE + U8_OFFS + (d), U8_MIN, U8_MAX)
12
 
13
-#define S8_MIN         -127
14
+#define S8_MIN         -128
15
 #define S8_MAX         127
16
-#define S8_MAX_F       127.0f
17
-#define S8_SCALE       127.0f
18
+#define S8_SCALE       128.0f
19
 #define S8_TO_F32(v)       (((int8_t)(v)) * (1.0f / S8_SCALE))
20
 #define F32_TO_S8(v)       (int8_t)SPA_CLAMP((v) * S8_SCALE, S8_MIN, S8_MAX)
21
 #define F32_TO_S8_D(v,d)   (int8_t)SPA_CLAMP((v) * S8_SCALE + (d), S8_MIN, S8_MAX)
22
 
23
 #define U16_MIN            0u
24
 #define U16_MAX            65535u
25
-#define U16_SCALE      32767.5f
26
+#define U16_SCALE      32768.f
27
 #define U16_OFFS       32768.f
28
-#define U16_TO_F32(v)      ((((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0)
29
-#define U16S_TO_F32(v)     (((uint16_t)bswap_16((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0)
30
+#define U16_TO_F32(v)      ((((uint16_t)(v)) * (1.0f / U16_SCALE)) - 1.0f)
31
+#define U16S_TO_F32(v)     (((uint16_t)bswap_16((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0f)
32
 #define F32_TO_U16(v)      (uint16_t)SPA_CLAMP((v) * U16_SCALE + U16_OFFS, U16_MIN, U16_MAX)
33
 #define F32_TO_U16_D(v,d)  (uint16_t)SPA_CLAMP((v) * U16_SCALE + U16_OFFS + (d), U16_MIN, U16_MAX)
34
 #define F32_TO_U16S(v)     bswap_16(F32_TO_U16(v))
35
 #define F32_TO_U16S_D(v,d) bswap_16(F32_TO_U16_D(v,d))
36
 
37
-#define S16_MIN            -32767
38
+#define S16_MIN            -32768
39
 #define S16_MAX            32767
40
-#define S16_MAX_F      32767.0f
41
-#define S16_SCALE      32767.0f
42
+#define S16_SCALE      32768.0f
43
 #define S16_TO_F32(v)      (((int16_t)(v)) * (1.0f / S16_SCALE))
44
 #define S16S_TO_F32(v)     (((int16_t)bswap_16(v)) * (1.0f / S16_SCALE))
45
 #define F32_TO_S16(v)      (int16_t)SPA_CLAMP((v) * S16_SCALE, S16_MIN, S16_MAX)
46
@@ -77,31 +75,31 @@
47
 
48
 #define U24_MIN            0u
49
 #define U24_MAX            16777215u
50
-#define U24_SCALE      8388607.5f
51
+#define U24_SCALE      8388608.f
52
 #define U24_OFFS       8388608.f
53
-#define U24_TO_F32(v)      ((((uint32_t)(v)) * (1.0f / U24_OFFS)) - 1.0)
54
-#define F32_TO_U24(v)      (uint32_t)SPA_CLAMP((v) * U24_SCALE + U24_OFFS, U24_MIN, U24_MAX)
55
-#define F32_TO_U24_D(v,d)  (uint32_t)SPA_CLAMP((v) * U24_SCALE + U24_OFFS + (d), U24_MIN, U24_MAX)
56
+#define U24_TO_F32(v)      ((u24_to_u32(v) * (1.0f / U24_SCALE)) - 1.0f)
57
+#define F32_TO_U24(v)      u32_to_u24(SPA_CLAMP((v) * U24_SCALE + U24_OFFS, U24_MIN, U24_MAX))
58
+#define F32_TO_U24_D(v,d)  u32_to_u24(SPA_CLAMP((v) * U24_SCALE + U24_OFFS + (d), U24_MIN, U24_MAX))
59
 
60
-#define S24_MIN            -8388607
61
+#define S24_MIN            -8388608
62
 #define S24_MAX            8388607
63
-#define S24_MAX_F      8388607.0f
64
-#define S24_SCALE      8388607.0f
65
-#define S24_TO_F32(v)      (((int32_t)(v)) * (1.0f / S24_SCALE))
66
-#define F32_TO_S24(v)      (int32_t)SPA_CLAMP((v) * S24_SCALE, S24_MIN, S24_MAX)
67
-#define F32_TO_S24_D(v,d)  (int32_t)SPA_CLAMP((v) * S24_SCALE + (d), S24_MIN, S24_MAX)
68
+#define S24_SCALE      8388608.0f
69
+#define S24_TO_F32(v)      (s24_to_s32(v) * (1.0f / S24_SCALE))
70
+#define S24S_TO_F32(v)     (s24_to_s32(bswap_s24(v)) * (1.0f / S24_SCALE))
71
+#define F32_TO_S24(v)      s32_to_s24(SPA_CLAMP((v) * S24_SCALE, S24_MIN, S24_MAX))
72
+#define F32_TO_S24S(v)     bswap_s24(F32_TO_S24(v))
73
+#define F32_TO_S24_D(v,d)  s32_to_s24(SPA_CLAMP((v) * S24_SCALE + (d), S24_MIN, S24_MAX))
74
 
75
 #define U32_MIN            0u
76
-#define U32_MAX            4294967040u
77
-#define U32_SCALE      2147483520.f
78
-#define U32_OFFS       2147483520.f
79
-#define U32_TO_F32(v)      ((((uint32_t)(v)) * (1.0f / U32_OFFS)) - 1.0)
80
+#define U32_MAX            4294967295
81
+#define U32_SCALE      2147483648.f
82
+#define U32_OFFS       2147483648.f
83
+#define U32_TO_F32(v)      ((((uint32_t)(v)) * (1.0f / U32_SCALE)) - 1.0f)
84
 #define F32_TO_U32(v)      (uint32_t)SPA_CLAMP((v) * U32_SCALE + U32_OFFS, U32_MIN, U32_MAX)
85
 #define F32_TO_U32_D(v,d)  (uint32_t)SPA_CLAMP((v) * U32_SCALE + U32_OFFS + (d), U32_MIN, U32_MAX)
86
 
87
-#define S32_MIN            -2147483520
88
+#define S32_MIN            -2147483648
89
 #define S32_MAX            2147483520
90
-#define S32_MAX_F      2147483520.f
91
 #define S32_SCALE      2147483648.f
92
 #define S32_TO_F32(v)      (((int32_t)(v)) * (1.0f / S32_SCALE))
93
 #define S32S_TO_F32(v)     (((int32_t)bswap_32(v)) * (1.0f / S32_SCALE))
94
@@ -112,88 +110,75 @@
95
 
96
 #define U24_32_TO_F32(v)   U32_TO_F32((v)<<8)
97
 #define U24_32S_TO_F32(v)  U32_TO_F32(((int32_t)bswap_32(v))<<8)
98
-#define F32_TO_U24_32(v)   F32_TO_U24(v)
99
-#define F32_TO_U24_32S(v)  bswap_32(F32_TO_U24(v))
100
-#define F32_TO_U24_32_D(v,d)   F32_TO_U24_D(v,d)
101
-#define F32_TO_U24_32S_D(v,d)  bswap_32(F32_TO_U24_D(v,d))
102
+#define F32_TO_U24_32(v)   (uint32_t)SPA_CLAMP((v) * U24_SCALE + U24_OFFS, U24_MIN, U24_MAX)
103
+#define F32_TO_U24_32S(v)  bswap_32(F32_TO_U24_32(v))
104
+#define F32_TO_U24_32_D(v,d)   (uint32_t)SPA_CLAMP((v) * U24_SCALE + U24_OFFS + (d), U24_MIN, U24_MAX)
105
+#define F32_TO_U24_32S_D(v,d)  bswap_32(F32_TO_U24_32_D(v,d))
106
 
107
 #define S24_32_TO_F32(v)   S32_TO_F32((v)<<8)
108
 #define S24_32S_TO_F32(v)  S32_TO_F32(((int32_t)bswap_32(v))<<8)
109
-#define F32_TO_S24_32(v)   F32_TO_S24(v)
110
-#define F32_TO_S24_32S(v)  bswap_32(F32_TO_S24(v))
111
-#define F32_TO_S24_32_D(v,d)   F32_TO_S24_D(v,d)
112
-#define F32_TO_S24_32S_D(v,d)  bswap_32(F32_TO_S24_D(v,d))
113
+#define F32_TO_S24_32(v)   (int32_t)SPA_CLAMP((v) * S24_SCALE, S24_MIN, S24_MAX)
114
+#define F32_TO_S24_32S(v)  bswap_32(F32_TO_S24_32(v))
115
+#define F32_TO_S24_32_D(v,d)   (int32_t)SPA_CLAMP((v) * S24_SCALE + (d), S24_MIN, S24_MAX)
116
+#define F32_TO_S24_32S_D(v,d)  bswap_32(F32_TO_S24_32_D(v,d))
117
 
118
-static inline uint32_t read_u24(const void *src)
119
-{
120
-   const uint8_t *s = src;
121
+typedef struct {
122
 #if __BYTE_ORDER == __LITTLE_ENDIAN
123
-   return (((uint32_t)s2 << 16) | ((uint32_t)(uint8_t)s1 << 8) | (uint32_t)(uint8_t)s0);
124
+   uint8_t v3;
125
+   uint8_t v2;
126
+   uint8_t v1;
127
 #else
128
-   return (((uint32_t)s0 << 16) | ((uint32_t)(uint8_t)s1 << 8) | (uint32_t)(uint8_t)s2);
129
+   uint8_t v1;
130
+   uint8_t v2;
131
+   uint8_t v3;
132
 #endif
133
-}
134
+} __attribute__ ((packed)) uint24_t;
135
 
136
-static inline int32_t read_s24(const void *src)
137
-{
138
-   const int8_t *s = src;
139
+typedef struct {
140
 #if __BYTE_ORDER == __LITTLE_ENDIAN
141
-   return (((int32_t)s2 << 16) | ((uint32_t)(uint8_t)s1 << 8) | (uint32_t)(uint8_t)s0);
142
+   uint8_t v3;
143
+   uint8_t v2;
144
+   int8_t v1;
145
 #else
146
-   return (((int32_t)s0 << 16) | ((uint32_t)(uint8_t)s1 << 8) | (uint32_t)(uint8_t)s2);
147
+   int8_t v1;
148
+   uint8_t v2;
149
+   uint8_t v3;
150
 #endif
151
+} __attribute__ ((packed)) int24_t;
152
+
153
+static inline uint32_t u24_to_u32(uint24_t src)
154
+{
155
+   return ((uint32_t)src.v1 << 16) | ((uint32_t)src.v2 << 8) | (uint32_t)src.v3;
156
 }
157
 
158
-static inline int32_t read_s24s(const void *src)
159
+#define U32_TO_U24(s) (uint24_t) { .v1 = (uint8_t)(((uint32_t)s) >> 16), \
160
+   .v2 = (uint8_t)(((uint32_t)s) >> 8), .v3 = (uint8_t)((uint32_t)s) }
161
+
162
+static inline uint24_t u32_to_u24(uint32_t src)
163
 {
164
-   const int8_t *s = src;
165
-#if __BYTE_ORDER == __LITTLE_ENDIAN
166
-   return (((int32_t)s0 << 16) | ((uint32_t)(uint8_t)s1 << 8) | (uint32_t)(uint8_t)s2);
167
-#else
168
-   return (((int32_t)s2 << 16) | ((uint32_t)(uint8_t)s1 << 8) | (uint32_t)(uint8_t)s0);
169
-#endif
170
+   return U32_TO_U24(src);
171
 }
172
 
173
-static inline void write_u24(void *dst, uint32_t val)
174
+static inline int32_t s24_to_s32(int24_t src)
175
 {
176
-   uint8_t *d = dst;
177
-#if __BYTE_ORDER == __LITTLE_ENDIAN
178
-   d0 = (uint8_t) (val);
179
-   d1 = (uint8_t) (val >> 8);
180
-   d2 = (uint8_t) (val >> 16);
181
-#else
182
-   d0 = (uint8_t) (val >> 16);
183
-   d1 = (uint8_t) (val >> 8);
184
-   d2 = (uint8_t) (val);
185
-#endif
186
+   return ((int32_t)src.v1 << 16) | ((uint32_t)src.v2 << 8) | (uint32_t)src.v3;
187
 }
188
 
189
-static inline void write_s24(void *dst, int32_t val)
190
+#define S32_TO_S24(s) (int24_t) { .v1 = (int8_t)(((int32_t)s) >> 16), \
191
+   .v2 = (uint8_t)(((uint32_t)s) >> 8), .v3 = (uint8_t)((uint32_t)s) }
192
+
193
+static inline int24_t s32_to_s24(int32_t src)
194
 {
195
-   uint8_t *d = dst;
196
-#if __BYTE_ORDER == __LITTLE_ENDIAN
197
-   d0 = (uint8_t) (val);
198
-   d1 = (uint8_t) (val >> 8);
199
-   d2 = (uint8_t) (val >> 16);
200
-#else
201
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/resample-native.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/resample-native.c Changed
44
 
1
@@ -58,23 +58,24 @@
2
    return sin(x) / x;
3
 }
4
 
5
-#if 0
6
 static inline double window_blackman(double x, double n_taps)
7
 {
8
-   double alpha = 0.232;
9
+   double alpha = 0.232, r;
10
    x =  2.0 * M_PI * x / n_taps;
11
-   return (1.0 - alpha) / 2.0 + (1.0 / 2.0) * cos(x) +
12
-       (alpha / 2.0) * cos(2 * x);
13
+   r = (1.0 - alpha) / 2.0 + (1.0 / 2.0) * cos(x) +
14
+       (alpha / 2.0) * cos(2.0 * x);
15
+   return r;
16
 }
17
-#else
18
 static inline double window_cosh(double x, double n_taps)
19
 {
20
-   double R = 95.0;
21
+   double R = 190.0, r;
22
    double A = -325.1E-6 * (R * R) + 0.1677 * R - 3.149;
23
-   x =  2.0 * M_PI * x / n_taps;
24
-   return cosh(A * sqrt(1 - pow(x / M_PI, 2))) / cosh(A);
25
+   x =  2.0 * x / n_taps;
26
+   r = cosh(A * sqrt(1 - pow(x, 2))) / cosh(A);
27
+   return r;
28
 }
29
-#endif
30
+
31
+#define window window_blackman
32
 
33
 static int build_filter(float *taps, uint32_t stride, uint32_t n_taps, uint32_t n_phases, double cutoff)
34
 {
35
@@ -86,7 +87,7 @@
36
            /* exploit symmetry in filter taps */
37
            taps(n_phases - i) * stride + n_taps12 + j =
38
                tapsi * stride + (n_taps12 - j - 1) =
39
-                   cutoff * sinc(t * cutoff) * window_cosh(t, n_taps);
40
+                   cutoff * sinc(t * cutoff) * window(t, n_taps);
41
        }
42
    }
43
    return 0;
44
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/test-audioconvert.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/test-audioconvert.c Changed
201
 
1
@@ -36,6 +36,7 @@
2
 #include <spa/param/audio/format.h>
3
 #include <spa/param/audio/format-utils.h>
4
 #include <spa/node/node.h>
5
+#include <spa/node/io.h>
6
 #include <spa/debug/mem.h>
7
 #include <spa/support/log-impl.h>
8
 
9
@@ -71,6 +72,7 @@
10
    size_t size;
11
    int res;
12
    struct spa_support support1;
13
+   struct spa_dict_item items2;
14
    const struct spa_handle_factory *factory;
15
    void *iface;
16
 
17
@@ -86,9 +88,11 @@
18
    ctx->convert_handle = calloc(1, size);
19
    spa_assert_se(ctx->convert_handle != NULL);
20
 
21
+   items0 = SPA_DICT_ITEM_INIT("clock.quantum-limit", "8192");
22
+
23
    res = spa_handle_factory_init(factory,
24
            ctx->convert_handle,
25
-           NULL,
26
+           &SPA_DICT_INIT(items, 1),
27
            support, 1);
28
    spa_assert_se(res >= 0);
29
 
30
@@ -510,6 +514,351 @@
31
    return 0;
32
 }
33
 
34
+static int setup_direction(struct context *ctx, enum spa_direction direction, uint32_t mode,
35
+       struct spa_audio_info_raw *info)
36
+{
37
+   struct spa_pod_builder b = { 0 };
38
+   uint8_t buffer1024;
39
+   struct spa_pod *param, *format;
40
+   int res;
41
+   uint32_t i;
42
+
43
+   spa_pod_builder_init(&b, buffer, sizeof(buffer));
44
+   format = spa_format_audio_raw_build(&b, SPA_PARAM_Format, info);
45
+
46
+   switch (mode) {
47
+   case SPA_PARAM_PORT_CONFIG_MODE_dsp:
48
+       param = spa_pod_builder_add_object(&b,
49
+           SPA_TYPE_OBJECT_ParamPortConfig, SPA_PARAM_PortConfig,
50
+           SPA_PARAM_PORT_CONFIG_direction,    SPA_POD_Id(direction),
51
+           SPA_PARAM_PORT_CONFIG_mode,     SPA_POD_Id(mode),
52
+           SPA_PARAM_PORT_CONFIG_format,       SPA_POD_Pod(format));
53
+       break;
54
+
55
+   case SPA_PARAM_PORT_CONFIG_MODE_convert:
56
+       param = spa_pod_builder_add_object(&b,
57
+           SPA_TYPE_OBJECT_ParamPortConfig, SPA_PARAM_PortConfig,
58
+           SPA_PARAM_PORT_CONFIG_direction,    SPA_POD_Id(direction),
59
+           SPA_PARAM_PORT_CONFIG_mode,     SPA_POD_Id(mode));
60
+       break;
61
+   default:
62
+       return -EINVAL;
63
+   }
64
+   res = spa_node_set_param(ctx->convert_node, SPA_PARAM_PortConfig, 0, param);
65
+   spa_assert_se(res == 0);
66
+
67
+   switch (mode) {
68
+   case SPA_PARAM_PORT_CONFIG_MODE_convert:
69
+       res = spa_node_port_set_param(ctx->convert_node, direction, 0,
70
+           SPA_PARAM_Format, 0, format);
71
+       spa_assert_se(res == 0);
72
+       break;
73
+   case SPA_PARAM_PORT_CONFIG_MODE_dsp:
74
+       spa_pod_builder_init(&b, buffer, sizeof(buffer));
75
+       format = spa_format_audio_dsp_build(&b, SPA_PARAM_Format,
76
+                   &SPA_AUDIO_INFO_DSP_INIT(
77
+               .format = SPA_AUDIO_FORMAT_F32P));
78
+       for (i = 0; i < info->channels; i++) {
79
+           res = spa_node_port_set_param(ctx->convert_node, direction, i,
80
+               SPA_PARAM_Format, 0, format);
81
+           spa_assert_se(res == 0);
82
+       }
83
+       break;
84
+   default:
85
+       return -EINVAL;
86
+   }
87
+   return 0;
88
+}
89
+
90
+struct buffer {
91
+   struct spa_buffer buffer;
92
+        struct spa_data datasMAX_PORTS;
93
+        struct spa_chunk chunksMAX_PORTS;
94
+};
95
+
96
+struct data {
97
+   uint32_t mode;
98
+   struct spa_audio_info_raw info;
99
+   uint32_t ports;
100
+   uint32_t planes;
101
+   const void *dataMAX_PORTS;
102
+   uint32_t size;
103
+};
104
+
105
+static int run_convert(struct context *ctx, struct data *in_data,
106
+       struct data *out_data)
107
+{
108
+   struct spa_command cmd;
109
+   int res;
110
+   uint32_t i, j, k;
111
+   struct buffer in_buffersin_data->ports;
112
+   struct buffer out_buffersout_data->ports;
113
+   struct spa_io_buffers in_ioin_data->ports;
114
+   struct spa_io_buffers out_ioout_data->ports;
115
+
116
+   setup_direction(ctx, SPA_DIRECTION_INPUT, in_data->mode, &in_data->info);
117
+   setup_direction(ctx, SPA_DIRECTION_OUTPUT, out_data->mode, &out_data->info);
118
+
119
+   cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start);
120
+   res = spa_node_send_command(ctx->convert_node, &cmd);
121
+   spa_assert_se(res == 0);
122
+
123
+   for (i = 0, k = 0; i < in_data->ports; i++) {
124
+       struct buffer *b = &in_buffersi;
125
+       struct spa_buffer *buffers1;
126
+       spa_zero(*b);
127
+       b->buffer.datas = b->datas;
128
+                b->buffer.n_datas = in_data->planes;
129
+
130
+       for (j = 0; j < in_data->planes; j++, k++) {
131
+           b->datasj.type = SPA_DATA_MemPtr;
132
+           b->datasj.flags = 0;
133
+           b->datasj.fd = -1;
134
+           b->datasj.mapoffset = 0;
135
+           b->datasj.maxsize = in_data->size;
136
+           b->datasj.data = (void *)in_data->datak;
137
+           b->datasj.chunk = &b->chunksj;
138
+           b->datasj.chunk->offset = 0;
139
+           b->datasj.chunk->size = in_data->size;
140
+           b->datasj.chunk->stride = 0;
141
+       }
142
+       buffers0 = &b->buffer;
143
+       res = spa_node_port_use_buffers(ctx->convert_node, SPA_DIRECTION_INPUT, i,
144
+               0, buffers, 1);
145
+       spa_assert_se(res == 0);
146
+
147
+       in_ioi.status = SPA_STATUS_HAVE_DATA;
148
+       in_ioi.buffer_id = 0;
149
+
150
+       res = spa_node_port_set_io(ctx->convert_node, SPA_DIRECTION_INPUT, i,
151
+               SPA_IO_Buffers, &in_ioi, sizeof(in_ioi));
152
+       spa_assert_se(res == 0);
153
+   }
154
+   for (i = 0; i < out_data->ports; i++) {
155
+       struct buffer *b = &out_buffersi;
156
+       struct spa_buffer *buffers1;
157
+       spa_zero(*b);
158
+       b->buffer.datas = b->datas;
159
+                b->buffer.n_datas = out_data->planes;
160
+
161
+       for (j = 0; j < out_data->planes; j++) {
162
+           b->datasj.type = SPA_DATA_MemPtr;
163
+           b->datasj.flags = 0;
164
+           b->datasj.fd = -1;
165
+           b->datasj.mapoffset = 0;
166
+           b->datasj.maxsize = out_data->size;
167
+           b->datasj.data = calloc(1, out_data->size);
168
+           b->datasj.chunk = &b->chunksj;
169
+           b->datasj.chunk->offset = 0;
170
+           b->datasj.chunk->size = 0;
171
+           b->datasj.chunk->stride = 0;
172
+       }
173
+       buffers0 = &b->buffer;
174
+       res = spa_node_port_use_buffers(ctx->convert_node,
175
+               SPA_DIRECTION_OUTPUT, i, 0, buffers, 1);
176
+       spa_assert_se(res == 0);
177
+
178
+       out_ioi.status = SPA_STATUS_NEED_DATA;
179
+       out_ioi.buffer_id = -1;
180
+
181
+       res = spa_node_port_set_io(ctx->convert_node, SPA_DIRECTION_OUTPUT, i,
182
+               SPA_IO_Buffers, &out_ioi, sizeof(out_ioi));
183
+       spa_assert_se(res == 0);
184
+   }
185
+
186
+   res = spa_node_process(ctx->convert_node);
187
+   spa_assert_se(res == (SPA_STATUS_NEED_DATA | SPA_STATUS_HAVE_DATA));
188
+
189
+   for (i = 0, k = 0; i < out_data->ports; i++) {
190
+       struct buffer *b = &out_buffersi;
191
+
192
+       spa_assert_se(out_ioi.status == SPA_STATUS_HAVE_DATA);
193
+       spa_assert_se(out_ioi.buffer_id == 0);
194
+
195
+       for (j = 0; j < out_data->planes; j++, k++) {
196
+           spa_assert_se(b->datasj.chunk->offset == 0);
197
+           spa_assert_se(b->datasj.chunk->size == out_data->size);
198
+
199
+           res = memcmp(b->datasj.data, out_data->datak, out_data->size);
200
+           if (res != 0) {
201
pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/test-fmt-ops.c -> pipewire-0.3.54.tar.gz/spa/plugins/audioconvert/test-fmt-ops.c Changed
201
 
1
@@ -50,7 +50,7 @@
2
 {
3
    int res = memcmp(m1, m2, size);
4
    if (res != 0) {
5
-       fprintf(stderr, "%d %d:\n", i, j);
6
+       fprintf(stderr, "%d %d %zd:\n", i, j, size);
7
        spa_debug_mem(0, m1, size);
8
        spa_debug_mem(0, m2, size);
9
    }
10
@@ -81,19 +81,19 @@
11
        tp0 = temp_in;
12
        switch(in_size) {
13
        case 1:
14
-           conv_interleave_8_c(&conv, tp, ip, N_SAMPLES);
15
+           conv_8d_to_8_c(&conv, tp, ip, N_SAMPLES);
16
            break;
17
        case 2:
18
-           conv_interleave_16_c(&conv, tp, ip, N_SAMPLES);
19
+           conv_16d_to_16_c(&conv, tp, ip, N_SAMPLES);
20
            break;
21
        case 3:
22
-           conv_interleave_24_c(&conv, tp, ip, N_SAMPLES);
23
+           conv_24d_to_24_c(&conv, tp, ip, N_SAMPLES);
24
            break;
25
        case 4:
26
-           conv_interleave_32_c(&conv, tp, ip, N_SAMPLES);
27
+           conv_32d_to_32_c(&conv, tp, ip, N_SAMPLES);
28
            break;
29
        case 8:
30
-           conv_interleave_64_c(&conv, tp, ip, N_SAMPLES);
31
+           conv_64d_to_64_c(&conv, tp, ip, N_SAMPLES);
32
            break;
33
        default:
34
            fprintf(stderr, "unknown size %zd\n", in_size);
35
@@ -125,10 +125,40 @@
36
    }
37
 }
38
 
39
+static void test_f32_s8(void)
40
+{
41
+   static const float in = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
42
+   static const int8_t out = { 0, 127, -128, 64, 192, 127, -128 };
43
+
44
+   run_test("test_f32_s8", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
45
+           true, true, conv_f32_to_s8_c);
46
+   run_test("test_f32d_s8", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
47
+           false, true, conv_f32d_to_s8_c);
48
+   run_test("test_f32_s8d", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
49
+           true, false, conv_f32_to_s8d_c);
50
+   run_test("test_f32d_s8d", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
51
+           false, false, conv_f32d_to_s8d_c);
52
+}
53
+
54
+static void test_s8_f32(void)
55
+{
56
+   static const int8_t in = { 0, 127, -128, 64, 192, };
57
+   static const float out = { 0.0f, 0.9921875f, -1.0f, 0.5f, -0.5f, };
58
+
59
+   run_test("test_s8_f32", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
60
+           true, true, conv_s8_to_f32_c);
61
+   run_test("test_s8d_f32", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
62
+           false, true, conv_s8d_to_f32_c);
63
+   run_test("test_s8_f32d", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
64
+           true, false, conv_s8_to_f32d_c);
65
+   run_test("test_s8d_f32d", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
66
+           false, false, conv_s8d_to_f32d_c);
67
+}
68
+
69
 static void test_f32_u8(void)
70
 {
71
    static const float in = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
72
-   static const uint8_t out = { 128, 255, 0, 191, 64, 255, 0, };
73
+   static const uint8_t out = { 128, 255, 0, 192, 64, 255, 0, };
74
 
75
    run_test("test_f32_u8", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
76
            true, true, conv_f32_to_u8_c);
77
@@ -158,7 +188,7 @@
78
 static void test_f32_u16(void)
79
 {
80
    static const float in = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
81
-   static const uint16_t out = { 32767, 65535, 0, 49150, 16383, 65535, 0 };
82
+   static const uint16_t out = { 32768, 65535, 0, 49152, 16384, 65535, 0 };
83
 
84
    run_test("test_f32_u16", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
85
            true, true, conv_f32_to_u16_c);
86
@@ -168,8 +198,8 @@
87
 
88
 static void test_u16_f32(void)
89
 {
90
-   static const uint16_t in = { 32767, 65535, 0, 49150, 16383, };
91
-   static const float out = { 0.0f, 1.0f, -1.0f, 0.4999847412f, -0.4999847412f };
92
+   static const uint16_t in = { 32768, 65535, 0, 49152, 16384, };
93
+   static const float out = { 0.0f, 0.999969482422f, -1.0f, 0.5f, -0.5f };
94
 
95
    run_test("test_u16_f32d", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
96
            true, false, conv_u16_to_f32d_c);
97
@@ -180,7 +210,7 @@
98
 static void test_f32_s16(void)
99
 {
100
    static const float in = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
101
-   static const int16_t out = { 0, 32767, -32767, 16383, -16383, 32767, -32767 };
102
+   static const int16_t out = { 0, 32767, -32768, 16384, -16384, 32767, -32768 };
103
 
104
    run_test("test_f32_s16", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
105
            true, true, conv_f32_to_s16_c);
106
@@ -192,16 +222,26 @@
107
            false, false, conv_f32d_to_s16d_c);
108
 #if defined(HAVE_SSE2)
109
    if (cpu_flags & SPA_CPU_FLAG_SSE2) {
110
+       run_test("test_f32_s16_sse2", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
111
+           true, true, conv_f32_to_s16_sse2);
112
        run_test("test_f32d_s16_sse2", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
113
            false, true, conv_f32d_to_s16_sse2);
114
+       run_test("test_f32d_s16d_sse2", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
115
+           false, false, conv_f32d_to_s16d_sse2);
116
+   }
117
+#endif
118
+#if defined(HAVE_AVX2)
119
+   if (cpu_flags & SPA_CPU_FLAG_AVX2) {
120
+       run_test("test_f32d_s16_avx2", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
121
+           false, true, conv_f32d_to_s16_avx2);
122
    }
123
 #endif
124
 }
125
 
126
 static void test_s16_f32(void)
127
 {
128
-   static const int16_t in = { 0, 32767, -32767, 16383, -16383, };
129
-   static const float out = { 0.0f, 1.0f, -1.0f, 0.4999847412f, -0.4999847412f };
130
+   static const int16_t in = { 0, 32767, -32768, 16384, -16384, };
131
+   static const float out = { 0.0f, 0.999969482422f, -1.0f, 0.5f, -0.5f };
132
 
133
    run_test("test_s16_f32d", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
134
            true, false, conv_s16_to_f32d_c);
135
@@ -217,13 +257,19 @@
136
            true, false, conv_s16_to_f32d_sse2);
137
    }
138
 #endif
139
+#if defined(HAVE_AVX2)
140
+   if (cpu_flags & SPA_CPU_FLAG_AVX2) {
141
+       run_test("test_s16_f32d_avx2", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
142
+           true, false, conv_s16_to_f32d_avx2);
143
+   }
144
+#endif
145
 }
146
 
147
 static void test_f32_u32(void)
148
 {
149
    static const float in = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
150
-   static const uint32_t out = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100,
151
-                   0x7fffff00, 0x80000100 };
152
+   static const uint32_t out = { 0x80000000, 0xffffffff, 0x0, 0xc0000000, 0x40000000,
153
+                   0xffffffff, 0x0 };
154
 
155
    run_test("test_f32_u32", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
156
            true, true, conv_f32_to_u32_c);
157
@@ -233,8 +279,8 @@
158
 
159
 static void test_u32_f32(void)
160
 {
161
-   static const uint32_t in = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100 };
162
-   static const float out = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, };
163
+   static const uint32_t in = { 0x80000000, 0xffffffff, 0x0, 0xc0000000, 0x40000000 };
164
+   static const float out = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, };
165
 
166
    run_test("test_u32_f32d", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
167
            true, false, conv_u32_to_f32d_c);
168
@@ -245,8 +291,8 @@
169
 static void test_f32_s32(void)
170
 {
171
    static const float in = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
172
-   static const int32_t out = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100,
173
-                   0x7fffff00, 0x80000100 };
174
+   static const int32_t out = { 0, 0x7fffff80, 0x80000000, 0x40000000, 0xc0000000,
175
+                   0x7fffff80, 0x80000000 };
176
 
177
    run_test("test_f32_s32", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
178
            true, true, conv_f32_to_s32_c);
179
@@ -262,12 +308,18 @@
180
            false, true, conv_f32d_to_s32_sse2);
181
    }
182
 #endif
183
+#if defined(HAVE_AVX2)
184
+   if (cpu_flags & SPA_CPU_FLAG_AVX2) {
185
+       run_test("test_f32d_s32_avx2", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
186
+           false, true, conv_f32d_to_s32_avx2);
187
+   }
188
+#endif
189
 }
190
 
191
 static void test_s32_f32(void)
192
 {
193
-   static const int32_t in = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100 };
194
-   static const float out = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, };
195
+   static const int32_t in = { 0, 0x7fffff80, 0x80000000, 0x40000000, 0xc0000000 };
196
+   static const float out = { 0.0f, 0.999999940395f, -1.0f, 0.5, -0.5, };
197
 
198
    run_test("test_s32_f32d", in, sizeof(in0), out, sizeof(out0), SPA_N_ELEMENTS(out),
199
            true, false, conv_s32_to_f32d_c);
200
@@ -283,18 +335,20 @@
201
pipewire-0.3.53.tar.gz/spa/plugins/bluez5/a2dp-codec-aac.c -> pipewire-0.3.54.tar.gz/spa/plugins/bluez5/a2dp-codec-aac.c Changed
10
 
1
@@ -415,7 +415,7 @@
2
    return this;
3
 
4
 error:
5
-   if (this->aacenc)
6
+   if (this && this->aacenc)
7
        aacEncClose(&this->aacenc);
8
    free(this);
9
    errno = -res;
10
pipewire-0.3.53.tar.gz/spa/plugins/bluez5/a2dp-sink.c -> pipewire-0.3.54.tar.gz/spa/plugins/bluez5/a2dp-sink.c Changed
19
 
1
@@ -743,7 +743,7 @@
2
         * => timeout = (quantum - max_excess)/quantum * packet_time
3
         */
4
        uint64_t max_excess = 2*256;
5
-       uint64_t packet_samples = this->frame_count * this->block_size / port->frame_size;
6
+       uint64_t packet_samples = (uint64_t)this->frame_count * this->block_size / port->frame_size;
7
        uint64_t packet_time = packet_samples * SPA_NSEC_PER_SEC / port->current_format.info.raw.rate;
8
        uint64_t quantum = SPA_LIKELY(this->clock) ? this->clock->duration : 0;
9
        uint64_t timeout = (quantum > max_excess) ?
10
@@ -843,7 +843,7 @@
11
    prev_time = this->current_time;
12
    now_time = this->current_time = this->next_time;
13
 
14
-   spa_log_debug(this->log, "%p: timeout %"PRIu64" %"PRIu64"", this,
15
+   spa_log_debug(this->log, "%p: timer %"PRIu64" %"PRIu64"", this,
16
            now_time, now_time - prev_time);
17
 
18
    if (SPA_LIKELY(this->position)) {
19
pipewire-0.3.53.tar.gz/spa/plugins/bluez5/a2dp-source.c -> pipewire-0.3.54.tar.gz/spa/plugins/bluez5/a2dp-source.c Changed
201
 
1
@@ -60,18 +60,16 @@
2
 #undef SPA_LOG_TOPIC_DEFAULT
3
 #define SPA_LOG_TOPIC_DEFAULT &log_topic
4
 
5
+#include "decode-buffer.h"
6
+
7
 #define DEFAULT_CLOCK_NAME "clock.system.monotonic"
8
 
9
 struct props {
10
-   uint32_t min_latency;
11
-   uint32_t max_latency;
12
    char clock_name64;
13
 };
14
 
15
 #define FILL_FRAMES 2
16
 #define MAX_BUFFERS 32
17
-#define MIN_LATENCY    512
18
-#define MAX_LATENCY    1024
19
 
20
 struct buffer {
21
    uint32_t id;
22
@@ -89,6 +87,7 @@
23
    uint64_t info_all;
24
    struct spa_port_info info;
25
    struct spa_io_buffers *io;
26
+   struct spa_io_rate_match *rate_match;
27
    struct spa_latency_info latency;
28
 #define IDX_EnumFormat 0
29
 #define IDX_Meta   1
30
@@ -105,8 +104,7 @@
31
    struct spa_list free;
32
    struct spa_list ready;
33
 
34
-   struct buffer *current_buffer;
35
-   uint32_t ready_offset;
36
+   struct spa_bt_decode_buffer buffer;
37
 };
38
 
39
 struct impl {
40
@@ -120,6 +118,8 @@
41
    struct spa_hook_list hooks;
42
    struct spa_callbacks callbacks;
43
 
44
+   uint32_t quantum_limit;
45
+
46
    uint64_t info_all;
47
    struct spa_node_info info;
48
 #define IDX_PropInfo   0
49
@@ -137,6 +137,8 @@
50
    unsigned int started:1;
51
    unsigned int transport_acquired:1;
52
    unsigned int following:1;
53
+   unsigned int matching:1;
54
+   unsigned int resampling:1;
55
 
56
    unsigned int is_input:1;
57
    unsigned int is_duplex:1;
58
@@ -144,9 +146,15 @@
59
    int fd;
60
    struct spa_source source;
61
 
62
+   struct spa_source timer_source;
63
+   int timerfd;
64
+
65
    struct spa_io_clock *clock;
66
         struct spa_io_position *position;
67
 
68
+   uint64_t current_time;
69
+   uint64_t next_time;
70
+
71
    const struct a2dp_codec *codec;
72
    bool codec_props_changed;
73
    void *codec_props;
74
@@ -154,10 +162,8 @@
75
    struct spa_audio_info codec_format;
76
 
77
    uint8_t buffer_read4096;
78
-   uint8_t buffer_decoded65536;
79
    struct timespec now;
80
    uint64_t sample_count;
81
-   uint64_t skip_count;
82
 
83
    int duplex_timerfd;
84
    uint64_t duplex_timeout;
85
@@ -165,13 +171,8 @@
86
 
87
 #define CHECK_PORT(this,d,p)    ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
88
 
89
-static const uint32_t default_min_latency = MIN_LATENCY;
90
-static const uint32_t default_max_latency = MAX_LATENCY;
91
-
92
 static void reset_props(struct props *props)
93
 {
94
-   props->min_latency = default_min_latency;
95
-   props->max_latency = default_max_latency;
96
    strncpy(props->clock_name, DEFAULT_CLOCK_NAME, sizeof(props->clock_name));
97
 }
98
 
99
@@ -200,43 +201,19 @@
100
    switch (id) {
101
    case SPA_PARAM_PropInfo:
102
    {
103
-       struct props *p = &this->props;
104
-
105
        switch (result.index) {
106
-       case 0:
107
-           param = spa_pod_builder_add_object(&b,
108
-               SPA_TYPE_OBJECT_PropInfo, id,
109
-               SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_minLatency),
110
-               SPA_PROP_INFO_description, SPA_POD_String("The minimum latency"),
111
-               SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Int(p->min_latency, 1, INT32_MAX));
112
-           break;
113
-       case 1:
114
-           param = spa_pod_builder_add_object(&b,
115
-               SPA_TYPE_OBJECT_PropInfo, id,
116
-               SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_maxLatency),
117
-               SPA_PROP_INFO_description, SPA_POD_String("The maximum latency"),
118
-               SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Int(p->max_latency, 1, INT32_MAX));
119
-           break;
120
        default:
121
            enum_codec = true;
122
-           index_offset = 2;
123
+           index_offset = 0;
124
        }
125
        break;
126
    }
127
    case SPA_PARAM_Props:
128
    {
129
-       struct props *p = &this->props;
130
-
131
        switch (result.index) {
132
-       case 0:
133
-           param = spa_pod_builder_add_object(&b,
134
-               SPA_TYPE_OBJECT_Props, id,
135
-               SPA_PROP_minLatency, SPA_POD_Int(p->min_latency),
136
-               SPA_PROP_maxLatency, SPA_POD_Int(p->max_latency));
137
-           break;
138
        default:
139
            enum_codec = true;
140
-           index_offset = 1;
141
+           index_offset = 0;
142
        }
143
        break;
144
    }
145
@@ -267,13 +244,38 @@
146
    return 0;
147
 }
148
 
149
-static int do_reassing_follower(struct spa_loop *loop,
150
+static int set_timeout(struct impl *this, uint64_t time)
151
+{
152
+   struct itimerspec ts;
153
+   ts.it_value.tv_sec = time / SPA_NSEC_PER_SEC;
154
+   ts.it_value.tv_nsec = time % SPA_NSEC_PER_SEC;
155
+   ts.it_interval.tv_sec = 0;
156
+   ts.it_interval.tv_nsec = 0;
157
+   return spa_system_timerfd_settime(this->data_system,
158
+           this->timerfd, SPA_FD_TIMER_ABSTIME, &ts, NULL);
159
+}
160
+
161
+static int set_timers(struct impl *this)
162
+{
163
+   struct timespec now;
164
+
165
+   spa_system_clock_gettime(this->data_system, CLOCK_MONOTONIC, &now);
166
+   this->next_time = SPA_TIMESPEC_TO_NSEC(&now);
167
+
168
+   return set_timeout(this, this->following ? 0 : this->next_time);
169
+}
170
+
171
+static int do_reassign_follower(struct spa_loop *loop,
172
            bool async,
173
            uint32_t seq,
174
            const void *data,
175
            size_t size,
176
            void *user_data)
177
 {
178
+   struct impl *this = user_data;
179
+   struct port *port = &this->port;
180
+
181
+   spa_bt_decode_buffer_recover(&port->buffer);
182
    return 0;
183
 }
184
 
185
@@ -309,7 +311,7 @@
186
    if (this->started && following != this->following) {
187
        spa_log_debug(this->log, "%p: reassign follower %d->%d", this, this->following, following);
188
        this->following = following;
189
-       spa_loop_invoke(this->data_loop, do_reassing_follower, 0, NULL, 0, true, this);
190
+       spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this);
191
    }
192
    return 0;
193
 }
194
@@ -324,10 +326,7 @@
195
    if (param == NULL) {
196
        reset_props(&new_props);
197
    } else {
198
-       spa_pod_parse_object(param,
199
-               SPA_TYPE_OBJECT_Props, NULL,
200
-               SPA_PROP_minLatency, SPA_POD_OPT_Int(&new_props.min_latency),
201
pipewire-0.3.53.tar.gz/spa/plugins/bluez5/bluez5-dbus.c -> pipewire-0.3.54.tar.gz/spa/plugins/bluez5/bluez5-dbus.c Changed
39
 
1
@@ -3293,18 +3293,20 @@
2
 
3
    ret = a2dp_codec_to_endpoint(codec, endpoint, &object_path);
4
    if (ret < 0)
5
-       return ret;
6
+       goto error;
7
 
8
-   caps_size = codec->fill_caps(codec, 0, caps);
9
-   if (caps_size < 0)
10
-       return caps_size;
11
+   ret = caps_size = codec->fill_caps(codec, 0, caps);
12
+   if (ret < 0)
13
+       goto error;
14
 
15
    m = dbus_message_new_method_call(BLUEZ_SERVICE,
16
                                     path,
17
                                     BLUEZ_MEDIA_INTERFACE,
18
                                     "RegisterEndpoint");
19
-   if (m == NULL)
20
-       return -EIO;
21
+   if (m == NULL) {
22
+       ret = -EIO;
23
+       goto error;
24
+   }
25
 
26
    dbus_message_iter_init_append(m, &object_it);
27
    dbus_message_iter_append_basic(&object_it, DBUS_TYPE_OBJECT_PATH, &object_path);
28
@@ -3327,6 +3329,10 @@
29
    free(object_path);
30
 
31
    return 0;
32
+
33
+error:
34
+   free(object_path);
35
+   return ret;
36
 }
37
 
38
 static int register_a2dp_endpoint(struct spa_bt_monitor *monitor,
39
pipewire-0.3.54.tar.gz/spa/plugins/bluez5/decode-buffer.h Added
201
 
1
@@ -0,0 +1,381 @@
2
+/* Spa Bluez5 decode buffer
3
+ *
4
+ * Copyright © 2022 Pauli Virtanen
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a
7
+ * copy of this software and associated documentation files (the "Software"),
8
+ * to deal in the Software without restriction, including without limitation
9
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
+ * and/or sell copies of the Software, and to permit persons to whom the
11
+ * Software is furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice (including the next
14
+ * paragraph) shall be included in all copies or substantial portions of the
15
+ * Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
+ * DEALINGS IN THE SOFTWARE.
24
+ */
25
+
26
+/**
27
+ * \file decode-buffer.h   Buffering for Bluetooth sources
28
+ *
29
+ * A linear buffer, which is compacted when it gets half full.
30
+ *
31
+ * Also contains buffering logic, which calculates a rate correction
32
+ * factor to maintain the buffer level at the target value.
33
+ *
34
+ * Consider typical packet intervals with nominal frame duration
35
+ * of 10ms:
36
+ *
37
+ *     ... 5ms | 5ms | 20ms | 5ms | 5ms | 20ms ...
38
+ *
39
+ *     ... 3ms | 3ms | 4ms | 30ms | 3ms | 3ms | 4ms | 30ms ...
40
+ *
41
+ * plus random jitter; 10ms nominal may occasionally have 20+ms interval.
42
+ * The regular timer cycle cannot be aligned with this, so process()
43
+ * may occur at any time.
44
+ *
45
+ * The buffer level is the difference between the number of samples in
46
+ * buffer immediately after receiving a packet, and the samples consumed
47
+ * before receiving the next packet.
48
+ *
49
+ * The buffer level indicates how much any packet can be delayed without
50
+ * underrun. If it is positive, there are no underruns.
51
+ *
52
+ * The rate correction aims to maintain the average level at a safety margin.
53
+ */
54
+
55
+#ifndef SPA_BLUEZ5_DECODE_BUFFER_H
56
+#define SPA_BLUEZ5_DECODE_BUFFER_H
57
+
58
+#include <stdlib.h>
59
+#include <spa/utils/defs.h>
60
+#include <spa/utils/dll.h>
61
+#include <spa/support/log.h>
62
+
63
+#define BUFFERING_LONG_MSEC        60000
64
+#define BUFFERING_SHORT_MSEC       1000
65
+#define BUFFERING_DLL_BW       0.03
66
+#define BUFFERING_RATE_DIFF_MAX        0.005
67
+
68
+/**
69
+ * Safety margin.
70
+ *
71
+ * The spike is the long-window maximum difference
72
+ * between minimum and average buffer level.
73
+ */
74
+#define BUFFERING_TARGET(spike,packet_size)                \
75
+   SPA_CLAMP((spike)*3/2, (packet_size), 6*(packet_size))
76
+
77
+/** Windowed min/max */
78
+struct spa_bt_ptp
79
+{
80
+   union {
81
+       int32_t min;
82
+       int32_t mins4;
83
+   };
84
+   union {
85
+       int32_t max;
86
+       int32_t maxs4;
87
+   };
88
+   uint32_t pos;
89
+   uint32_t period;
90
+};
91
+
92
+struct spa_bt_decode_buffer
93
+{
94
+   struct spa_log *log;
95
+
96
+   uint32_t frame_size;
97
+   uint32_t rate;
98
+
99
+   uint8_t *buffer_decoded;
100
+   uint32_t buffer_size;
101
+   uint32_t buffer_reserve;
102
+   uint32_t write_index;
103
+   uint32_t read_index;
104
+
105
+   struct spa_bt_ptp spike;    /**< spikes (long window) */
106
+   struct spa_bt_ptp packet_size;  /**< packet size (short window) */
107
+
108
+   int32_t target;
109
+   int32_t level;
110
+   double level_avg;
111
+
112
+   struct spa_dll dll;
113
+   double corr;
114
+
115
+   uint32_t prev_consumed;
116
+   uint32_t prev_avail;
117
+   uint32_t prev_duration;
118
+   uint32_t underrun;
119
+   uint32_t pos;
120
+
121
+   uint8_t received:1;
122
+   uint8_t buffering:1;
123
+};
124
+
125
+static void spa_bt_ptp_init(struct spa_bt_ptp *p, int32_t period)
126
+{
127
+   size_t i;
128
+
129
+   spa_zero(*p);
130
+   for (i = 0; i < SPA_N_ELEMENTS(p->mins); ++i) {
131
+       p->minsi = INT32_MAX;
132
+       p->maxsi = INT32_MIN;
133
+   }
134
+   p->period = period;
135
+}
136
+
137
+static void spa_bt_ptp_update(struct spa_bt_ptp *p, int32_t value, uint32_t duration)
138
+{
139
+   const size_t n = SPA_N_ELEMENTS(p->mins);
140
+   size_t i;
141
+
142
+   for (i = 0; i < n; ++i) {
143
+       p->minsi = SPA_MIN(p->minsi, value);
144
+       p->maxsi = SPA_MAX(p->maxsi, value);
145
+   }
146
+
147
+   p->pos += duration;
148
+   if (p->pos >= p->period / (n - 1)) {
149
+       p->pos = 0;
150
+       for (i = 1; i < SPA_N_ELEMENTS(p->mins); ++i) {
151
+           p->minsi-1 = p->minsi;
152
+           p->maxsi-1 = p->maxsi;
153
+       }
154
+       p->minsn-1 = INT32_MAX;
155
+       p->maxsn-1 = INT32_MIN;
156
+   }
157
+}
158
+
159
+static int spa_bt_decode_buffer_init(struct spa_bt_decode_buffer *this, struct spa_log *log,
160
+       uint32_t frame_size, uint32_t rate, uint32_t quantum_limit, uint32_t reserve)
161
+{
162
+   spa_zero(*this);
163
+   this->frame_size = frame_size;
164
+   this->rate = rate;
165
+   this->log = log;
166
+   this->buffer_reserve = this->frame_size * reserve;
167
+   this->buffer_size = this->frame_size * quantum_limit * 2;
168
+   this->buffer_size += this->buffer_reserve;
169
+   this->corr = 1.0;
170
+   this->buffering = true;
171
+
172
+   spa_dll_init(&this->dll);
173
+
174
+   spa_bt_ptp_init(&this->spike, (uint64_t)this->rate * BUFFERING_LONG_MSEC / 1000);
175
+   spa_bt_ptp_init(&this->packet_size, (uint64_t)this->rate * BUFFERING_SHORT_MSEC / 1000);
176
+
177
+   if ((this->buffer_decoded = malloc(this->buffer_size)) == NULL) {
178
+       this->buffer_size = 0;
179
+       return -ENOMEM;
180
+   }
181
+   return 0;
182
+}
183
+
184
+static void spa_bt_decode_buffer_clear(struct spa_bt_decode_buffer *this)
185
+{
186
+   free(this->buffer_decoded);
187
+   spa_zero(*this);
188
+}
189
+
190
+static void spa_bt_decode_buffer_compact(struct spa_bt_decode_buffer *this)
191
+{
192
+   uint32_t avail;
193
+
194
+   spa_assert(this->read_index <= this->write_index);
195
+
196
+   if (this->read_index == this->write_index) {
197
+       this->read_index = 0;
198
+       this->write_index = 0;
199
+       goto done;
200
+   }
201
pipewire-0.3.53.tar.gz/spa/plugins/bluez5/sco-io.c -> pipewire-0.3.54.tar.gz/spa/plugins/bluez5/sco-io.c Changed
45
 
1
@@ -55,16 +55,12 @@
2
  * since kernel might not report it as the socket MTU, see
3
  * https://lore.kernel.org/linux-bluetooth/20201210003528.3pmaxvubiwegxmhl@pali/T/
4
  *
5
- * Since 24 is the packet size for the smallest setting (ALT1), we'll stop
6
- * reading when rx packet of at least this size is seen, and use its size as the
7
- * heuristic maximum write MTU. Of course, if we have a source connected, we'll
8
- * continue reading without stopping.
9
+ * We continue reading also when there's no source connected, to keep socket
10
+ * flushed.
11
  *
12
  * XXX: when the kernel/backends start giving the right values, the heuristic
13
  * XXX: can be removed
14
  */
15
-#define HEURISTIC_MIN_MTU 24
16
-
17
 #define MAX_MTU 1024
18
 
19
 
20
@@ -94,12 +90,6 @@
21
    int enabled;
22
    int changed = 0;
23
 
24
-   enabled = io->source_cb != NULL || io->read_size < HEURISTIC_MIN_MTU;
25
-   if (SPA_FLAG_IS_SET(io->source.mask, SPA_IO_IN) != enabled) {
26
-       SPA_FLAG_UPDATE(io->source.mask, SPA_IO_IN, enabled);
27
-       changed = 1;
28
-   }
29
-
30
    enabled = io->sink_cb != NULL;
31
    if (SPA_FLAG_IS_SET(io->source.mask, SPA_IO_OUT) != enabled) {
32
        SPA_FLAG_UPDATE(io->source.mask, SPA_IO_OUT, enabled);
33
@@ -118,11 +108,6 @@
34
    if (SPA_FLAG_IS_SET(source->rmask, SPA_IO_IN)) {
35
        int res;
36
 
37
-       /*
38
-        * Note that we will read from the socket for a few times even
39
-        * when there is no source callback, to autodetect packet size.
40
-        */
41
-
42
    read_again:
43
        res = read(io->fd, io->read_buffer, SPA_MIN(io->read_mtu, MAX_MTU));
44
        if (res <= 0) {
45
pipewire-0.3.53.tar.gz/spa/plugins/bluez5/sco-source.c -> pipewire-0.3.54.tar.gz/spa/plugins/bluez5/sco-source.c Changed
201
 
1
@@ -58,11 +58,11 @@
2
 #undef SPA_LOG_TOPIC_DEFAULT
3
 #define SPA_LOG_TOPIC_DEFAULT &log_topic
4
 
5
+#include "decode-buffer.h"
6
+
7
 #define DEFAULT_CLOCK_NAME "clock.system.monotonic"
8
 
9
 struct props {
10
-   uint32_t min_latency;
11
-   uint32_t max_latency;
12
    char clock_name64;
13
 };
14
 
15
@@ -101,8 +101,7 @@
16
    struct spa_list free;
17
    struct spa_list ready;
18
 
19
-   struct buffer *current_buffer;
20
-   uint32_t ready_offset;
21
+   struct spa_bt_decode_buffer buffer;
22
 };
23
 
24
 struct impl {
25
@@ -116,6 +115,8 @@
26
    struct spa_hook_list hooks;
27
    struct spa_callbacks callbacks;
28
 
29
+   uint32_t quantum_limit;
30
+
31
    uint64_t info_all;
32
    struct spa_node_info info;
33
 #define IDX_PropInfo   0
34
@@ -132,10 +133,18 @@
35
 
36
    unsigned int started:1;
37
    unsigned int following:1;
38
+   unsigned int matching:1;
39
+   unsigned int resampling:1;
40
+
41
+   struct spa_source timer_source;
42
+   int timerfd;
43
 
44
    struct spa_io_clock *clock;
45
    struct spa_io_position *position;
46
 
47
+   uint64_t current_time;
48
+   uint64_t next_time;
49
+
50
    /* mSBC */
51
    sbc_t msbc;
52
    bool msbc_seq_initialized;
53
@@ -150,13 +159,8 @@
54
 
55
 #define CHECK_PORT(this,d,p)   ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
56
 
57
-static const uint32_t default_min_latency = 128;
58
-static const uint32_t default_max_latency = 512;
59
-
60
 static void reset_props(struct props *props)
61
 {
62
-   props->min_latency = default_min_latency;
63
-   props->max_latency = default_max_latency;
64
    strncpy(props->clock_name, DEFAULT_CLOCK_NAME, sizeof(props->clock_name));
65
 }
66
 
67
@@ -184,23 +188,7 @@
68
    switch (id) {
69
    case SPA_PARAM_PropInfo:
70
    {
71
-       struct props *p = &this->props;
72
-
73
        switch (result.index) {
74
-       case 0:
75
-           param = spa_pod_builder_add_object(&b,
76
-               SPA_TYPE_OBJECT_PropInfo, id,
77
-               SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_minLatency),
78
-               SPA_PROP_INFO_description, SPA_POD_String("The minimum latency"),
79
-               SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Int(p->min_latency, 1, INT32_MAX));
80
-           break;
81
-       case 1:
82
-           param = spa_pod_builder_add_object(&b,
83
-               SPA_TYPE_OBJECT_PropInfo, id,
84
-               SPA_PROP_INFO_id,   SPA_POD_Id(SPA_PROP_maxLatency),
85
-               SPA_PROP_INFO_description, SPA_POD_String("The maximum latency"),
86
-               SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Int(p->max_latency, 1, INT32_MAX));
87
-           break;
88
        default:
89
            return 0;
90
        }
91
@@ -208,15 +196,7 @@
92
    }
93
    case SPA_PARAM_Props:
94
    {
95
-       struct props *p = &this->props;
96
-
97
        switch (result.index) {
98
-       case 0:
99
-           param = spa_pod_builder_add_object(&b,
100
-               SPA_TYPE_OBJECT_Props, id,
101
-               SPA_PROP_minLatency, SPA_POD_Int(p->min_latency),
102
-               SPA_PROP_maxLatency, SPA_POD_Int(p->max_latency));
103
-           break;
104
        default:
105
            return 0;
106
        }
107
@@ -237,6 +217,41 @@
108
    return 0;
109
 }
110
 
111
+static int set_timeout(struct impl *this, uint64_t time)
112
+{
113
+       struct itimerspec ts;
114
+       ts.it_value.tv_sec = time / SPA_NSEC_PER_SEC;
115
+       ts.it_value.tv_nsec = time % SPA_NSEC_PER_SEC;
116
+       ts.it_interval.tv_sec = 0;
117
+       ts.it_interval.tv_nsec = 0;
118
+       return spa_system_timerfd_settime(this->data_system,
119
+              this->timerfd, SPA_FD_TIMER_ABSTIME, &ts, NULL);
120
+}
121
+
122
+static int set_timers(struct impl *this)
123
+{
124
+       struct timespec now;
125
+
126
+       spa_system_clock_gettime(this->data_system, CLOCK_MONOTONIC, &now);
127
+       this->next_time = SPA_TIMESPEC_TO_NSEC(&now);
128
+
129
+       return set_timeout(this, this->following ? 0 : this->next_time);
130
+}
131
+
132
+static int do_reassign_follower(struct spa_loop *loop,
133
+           bool async,
134
+           uint32_t seq,
135
+           const void *data,
136
+           size_t size,
137
+           void *user_data)
138
+{
139
+   struct impl *this = user_data;
140
+   struct port *port = &this->port;
141
+
142
+   spa_bt_decode_buffer_recover(&port->buffer);
143
+   return 0;
144
+}
145
+
146
 static inline bool is_following(struct impl *this)
147
 {
148
    return this->position && this->clock && this->position->clock.id != this->clock->id;
149
@@ -269,6 +284,7 @@
150
    if (this->started && following != this->following) {
151
        spa_log_debug(this->log, "%p: reassign follower %d->%d", this, this->following, following);
152
        this->following = following;
153
+       spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this);
154
    }
155
 
156
    return 0;
157
@@ -284,10 +300,7 @@
158
    if (param == NULL) {
159
        reset_props(&new_props);
160
    } else {
161
-       spa_pod_parse_object(param,
162
-               SPA_TYPE_OBJECT_Props, NULL,
163
-               SPA_PROP_minLatency, SPA_POD_OPT_Int(&new_props.min_latency),
164
-               SPA_PROP_maxLatency, SPA_POD_OPT_Int(&new_props.max_latency));
165
+       /* noop */
166
    }
167
 
168
    changed = (memcmp(&new_props, &this->props, sizeof(struct props)) != 0);
169
@@ -326,8 +339,6 @@
170
    spa_list_init(&port->free);
171
    spa_list_init(&port->ready);
172
 
173
-   port->current_buffer = NULL;
174
-
175
    for (i = 0; i < port->n_buffers; i++) {
176
        struct buffer *b = &port->buffersi;
177
        spa_list_append(&port->free, &b->link);
178
@@ -422,116 +433,107 @@
179
    return true;
180
 }
181
 
182
-static void preprocess_and_decode_msbc_data(void *userdata, uint8_t *read_data, int size_read)
183
+static uint32_t preprocess_and_decode_msbc_data(void *userdata, uint8_t *read_data, int size_read)
184
 {
185
    struct impl *this = userdata;
186
    struct port *port = &this->port;
187
-   struct spa_data *datas = port->current_buffer->buf->datas;
188
+   uint32_t decoded = 0;
189
+   int i;
190
 
191
    spa_log_trace(this->log, "handling mSBC data");
192
 
193
-   /* check if the packet contains only zeros - if so ignore the packet.
194
-      This is necessary, because some kernels insert bogus "all-zero" packets
195
-      into the datastream.
196
-      See https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/549 */
197
-   if (is_zero_packet(read_data, size_read)) {
198
-       return;
199
-   }
200
+   /*
201
pipewire-0.3.53.tar.gz/spa/plugins/support/null-audio-sink.c -> pipewire-0.3.54.tar.gz/spa/plugins/support/null-audio-sink.c Changed
46
 
1
@@ -42,6 +42,7 @@
2
 #include <spa/node/keys.h>
3
 #include <spa/param/audio/format-utils.h>
4
 #include <spa/debug/types.h>
5
+#include <spa/debug/mem.h>
6
 #include <spa/param/audio/type-info.h>
7
 #include <spa/param/param.h>
8
 #include <spa/pod/filter.h>
9
@@ -57,6 +58,7 @@
10
    uint32_t n_pos;
11
    uint32_t posSPA_AUDIO_MAX_CHANNELS;
12
    char clock_name64;
13
+   unsigned int debug:1;
14
 };
15
 
16
 static void reset_props(struct props *props)
17
@@ -65,6 +67,7 @@
18
    props->rate = 0;
19
    props->n_pos = 0;
20
    strncpy(props->clock_name, DEFAULT_CLOCK_NAME, sizeof(props->clock_name));
21
+   props->debug = false;
22
 }
23
 
24
 #define DEFAULT_CHANNELS   2
25
@@ -744,6 +747,20 @@
26
        io->status = -EINVAL;
27
        return io->status;
28
    }
29
+   if (this->props.debug) {
30
+       struct buffer *b;
31
+       uint32_t i;
32
+
33
+       b = &port->buffersio->buffer_id;
34
+       for (i = 0; i < b->outbuf->n_datas; i++) {
35
+           uint32_t offs, size;
36
+           struct spa_data *d = b->outbuf->datas;
37
+
38
+           offs = SPA_MIN(d->chunk->offset, d->maxsize);
39
+           size = SPA_MIN(d->maxsize - offs, d->chunk->size);
40
+           spa_debug_mem(i, SPA_PTROFF(di.data, offs, void), SPA_MIN(16u, size));;
41
+       }
42
+   }
43
    io->status = SPA_STATUS_OK;
44
    return SPA_STATUS_HAVE_DATA;
45
 }
46
pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/client.c -> pipewire-0.3.54.tar.gz/src/modules/module-protocol-pulse/client.c Changed
11
 
1
@@ -177,6 +177,9 @@
2
    free(client->default_sink);
3
    free(client->default_source);
4
 
5
+   free(client->temporary_default_sink);
6
+   free(client->temporary_default_source);
7
+
8
    pw_properties_free(client->props);
9
    pw_properties_free(client->routes);
10
 
11
pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/client.h -> pipewire-0.3.54.tar.gz/src/modules/module-protocol-pulse/client.h Changed
10
 
1
@@ -75,6 +75,8 @@
2
    struct pw_manager_object *metadata_default;
3
    char *default_sink;
4
    char *default_source;
5
+   char *temporary_default_sink;       /**< pending value, for MOVE_* commands */
6
+   char *temporary_default_source;     /**< pending value, for MOVE_* commands */
7
    struct pw_manager_object *metadata_routes;
8
    struct pw_properties *routes;
9
 
10
pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/pulse-server.c -> pipewire-0.3.54.tar.gz/src/modules/module-protocol-pulse/pulse-server.c Changed
180
 
1
@@ -678,8 +678,8 @@
2
        latency = attr->fragsize;
3
    }
4
    /* make sure can queue at least to fragsize without overruns */
5
-   if (attr->maxlength < attr->fragsize * 2)
6
-       attr->maxlength = attr->fragsize * 2;
7
+   if (attr->maxlength < attr->fragsize * 4)
8
+       attr->maxlength = attr->fragsize * 4;
9
 
10
    pw_log_info("%s maxlength:%u fragsize:%u minfrag:%u latency:%u",
11
            s->client->name, attr->maxlength, attr->fragsize, minfrag,
12
@@ -961,6 +961,8 @@
13
                free(client->default_sink);
14
                client->default_sink = value ? strdup(value) : NULL;
15
            }
16
+           free(client->temporary_default_sink);
17
+           client->temporary_default_sink = NULL;
18
        }
19
        if (key == NULL || spa_streq(key, "default.audio.source")) {
20
            if (value != NULL) {
21
@@ -974,6 +976,8 @@
22
                free(client->default_source);
23
                client->default_source = value ? strdup(value) : NULL;
24
            }
25
+           free(client->temporary_default_source);
26
+           client->temporary_default_source = NULL;
27
        }
28
        if (changed)
29
            send_default_change_subscribe_event(client, true, true);
30
@@ -1801,7 +1805,7 @@
31
    struct channel_map map;
32
    uint32_t source_index;
33
    const char *source_name;
34
-   struct buffer_attr attr;
35
+   struct buffer_attr attr = { 0 };
36
    bool corked = false,
37
        no_remap = false,
38
        no_remix = false,
39
@@ -3685,6 +3689,27 @@
40
    return 0;
41
 }
42
 
43
+static int fill_sink_info_proplist(struct message *m, const struct spa_dict *sink_props,
44
+       const struct pw_manager_object *card)
45
+{
46
+   struct pw_device_info *card_info = card ? card->info : NULL;
47
+   struct pw_properties *props = NULL;
48
+
49
+   if (card_info && card_info->props) {
50
+       props = pw_properties_new_dict(sink_props);
51
+       if (props == NULL)
52
+           return -ENOMEM;
53
+
54
+       pw_properties_add(props, card_info->props);
55
+       sink_props = &props->dict;
56
+   }
57
+   message_put(m, TAG_PROPLIST, sink_props, TAG_INVALID);
58
+
59
+   pw_properties_free(props);
60
+
61
+   return 0;
62
+}
63
+
64
 static int fill_sink_info(struct client *client, struct message *m,
65
        struct pw_manager_object *o)
66
 {
67
@@ -3777,8 +3802,10 @@
68
        TAG_INVALID);
69
 
70
    if (client->version >= 13) {
71
+       int res;
72
+       if ((res = fill_sink_info_proplist(m, info->props, card)) < 0)
73
+           return res;
74
        message_put(m,
75
-           TAG_PROPLIST, info->props,
76
            TAG_USEC, 0LL,          /* requested latency */
77
            TAG_INVALID);
78
    }
79
@@ -3867,22 +3894,27 @@
80
    return 0;
81
 }
82
 
83
-static int fill_source_info_proplist(struct message *m, struct pw_manager_object *o,
84
-       struct pw_node_info *info)
85
+static int fill_source_info_proplist(struct message *m, const struct spa_dict *source_props,
86
+       const struct pw_manager_object *card, const bool is_monitor)
87
 {
88
+   struct pw_device_info *card_info = card ? card->info : NULL;
89
    struct pw_properties *props = NULL;
90
-   struct spa_dict *props_dict = info->props;
91
 
92
-   if (pw_manager_object_is_monitor(o)) {
93
-       props = pw_properties_new_dict(info->props);
94
+   if ((card_info && card_info->props) || is_monitor) {
95
+       props = pw_properties_new_dict(source_props);
96
        if (props == NULL)
97
            return -ENOMEM;
98
 
99
-       pw_properties_set(props, PW_KEY_DEVICE_CLASS, "monitor");
100
-       props_dict = &props->dict;
101
+       if (card_info && card_info->props)
102
+           pw_properties_add(props, card_info->props);
103
+
104
+       if (is_monitor)
105
+           pw_properties_set(props, PW_KEY_DEVICE_CLASS, "monitor");
106
+
107
+       source_props = &props->dict;
108
    }
109
+   message_put(m, TAG_PROPLIST, source_props, TAG_INVALID);
110
 
111
-   message_put(m, TAG_PROPLIST, props_dict, TAG_INVALID);
112
    pw_properties_free(props);
113
 
114
    return 0;
115
@@ -3984,7 +4016,7 @@
116
 
117
    if (client->version >= 13) {
118
        int res;
119
-       if ((res = fill_source_info_proplist(m, o, info)) < 0)
120
+       if ((res = fill_source_info_proplist(m, info->props, card, is_monitor)) < 0)
121
            return res;
122
        message_put(m,
123
            TAG_USEC, 0LL,          /* requested latency */
124
@@ -4723,6 +4755,20 @@
125
    if (res < 0)
126
        return res;
127
 
128
+   /*
129
+    * The metadata is not necessarily updated within one server sync.
130
+    * Correct functioning of MOVE_* commands requires knowing the current
131
+    * default target, so we need to stash temporary values here in case
132
+    * the client emits them before metadata gets updated.
133
+    */
134
+   if (sink) {
135
+       free(client->temporary_default_sink);
136
+       client->temporary_default_sink = name ? strdup(name) : NULL;
137
+   } else {
138
+       free(client->temporary_default_source);
139
+       client->temporary_default_source = name ? strdup(name) : NULL;
140
+   }
141
+
142
    return operation_new(client, tag);
143
 }
144
 
145
@@ -4764,6 +4810,7 @@
146
    int target_id;
147
    int64_t target_serial;
148
    const char *name_device;
149
+   const char *name;
150
    struct pw_node_info *info;
151
    struct selector sel;
152
    int res;
153
@@ -4800,7 +4847,13 @@
154
    if ((dev = find_device(client, index_device, name_device, sink, NULL)) == NULL)
155
        return -ENOENT;
156
 
157
-   dev_default = find_device(client, SPA_ID_INVALID, NULL, sink, NULL);
158
+   /*
159
+    * The client metadata is not necessarily yet updated after SET_DEFAULT command,
160
+    * so use the temporary values if they are still set.
161
+    */
162
+   name = sink ? client->temporary_default_sink : client->temporary_default_source;
163
+   dev_default = find_device(client, SPA_ID_INVALID, name, sink, NULL);
164
+
165
    if (dev == dev_default) {
166
        /*
167
         * When moving streams to a node that is equal to the default,
168
@@ -4826,6 +4879,11 @@
169
            SPA_TYPE_INFO_BASE"Id", "%"PRIi64, target_serial)) < 0)
170
        return res;
171
 
172
+   name = spa_dict_lookup(info->props, PW_KEY_NODE_NAME);
173
+   pw_log_debug("%s %s done tag:%u index:%u name:%s target:%d target-serial:%"PRIi64, client->name,
174
+           commandscommand.name, tag, index, name ? name : "<null>",
175
+           target_id, target_serial);
176
+
177
    /* We will temporarily claim the stream was already moved */
178
    set_temporary_move_target(client, o, dev->index);
179
    send_object_event(client, o, SUBSCRIPTION_EVENT_CHANGE);
180
pipewire-0.3.53.tar.gz/src/tools/dsffile.c -> pipewire-0.3.54.tar.gz/src/tools/dsffile.c Changed
18
 
1
@@ -216,13 +216,15 @@
2
    uint8_t *d = data;
3
    int step = SPA_ABS(layout->interleave);
4
    bool rev = layout->lsb != f->info.lsb;
5
-   size_t total, block, offset, pos;
6
+   size_t total, block, offset, pos, scale;
7
 
8
    block = f->offset / f->info.blocksize;
9
    offset = block * f->info.blocksize * f->info.channels;
10
    pos = f->offset % f->info.blocksize;
11
+   scale = SPA_CLAMP(f->info.rate / (44100u * 64u), 1u, 4u);
12
 
13
    samples *= step;
14
+   samples *= scale;
15
 
16
    for (total = 0; total < samples && offset + pos < f->info.length; total++) {
17
        const uint8_t *s = f->p + offset + pos;
18