We truncated the diff of some files because they were too big.
If you want to see the full diff for every file, click here.
Changes of Revision 10
pipewire-aptx.changes
Changed
x
1
2
-------------------------------------------------------------------
3
+Thu Jul 7 18:13:40 UTC 2022 - Bjørn Lie <zaitor@opensuse.org>
4
+
5
+- Update to version 0.3.53
6
+
7
+-------------------------------------------------------------------
8
Tue Jun 21 11:57:28 UTC 2022 - Bjørn Lie <zaitor@opensuse.org>
9
10
- Update to version 0.3.52
11
pipewire-aptx.spec
Changed
10
1
2
%define soversion 0_2
3
4
Name: pipewire-aptx
5
-Version: 0.3.52
6
+Version: 0.3.53
7
Release: 0
8
Summary: PipeWire Bluetooth aptX codec plugin
9
License: MIT
10
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/channelmix.c
Deleted
201
1
2
-/* Spa
3
- *
4
- * Copyright © 2018 Wim Taymans
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
-#include <errno.h>
27
-#include <string.h>
28
-#include <stdio.h>
29
-
30
-#include <spa/support/plugin.h>
31
-#include <spa/support/log.h>
32
-#include <spa/support/cpu.h>
33
-#include <spa/utils/list.h>
34
-#include <spa/utils/names.h>
35
-#include <spa/utils/json.h>
36
-#include <spa/utils/string.h>
37
-#include <spa/node/keys.h>
38
-#include <spa/node/node.h>
39
-#include <spa/node/io.h>
40
-#include <spa/node/utils.h>
41
-#include <spa/param/audio/format-utils.h>
42
-#include <spa/param/param.h>
43
-#include <spa/pod/filter.h>
44
-#include <spa/debug/types.h>
45
-
46
-#include "channelmix-ops.h"
47
-
48
-
49
-#define DEFAULT_RATE 48000
50
-#define DEFAULT_CHANNELS 2
51
-
52
-#define MAX_BUFFERS 32
53
-#define MAX_DATAS SPA_AUDIO_MAX_CHANNELS
54
-#define MAX_ALIGN CHANNELMIX_OPS_MAX_ALIGN
55
-
56
-#define DEFAULT_CONTROL_BUFFER_SIZE 32768
57
-
58
-struct impl;
59
-
60
-#define DEFAULT_MUTE false
61
-#define DEFAULT_VOLUME 1.0f
62
-
63
-struct volumes {
64
- bool mute;
65
- uint32_t n_volumes;
66
- float volumesSPA_AUDIO_MAX_CHANNELS;
67
-};
68
-
69
-static void init_volumes(struct volumes *vol)
70
-{
71
- uint32_t i;
72
- vol->mute = DEFAULT_MUTE;
73
- vol->n_volumes = 0;
74
- for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
75
- vol->volumesi = DEFAULT_VOLUME;
76
-}
77
-
78
-struct props {
79
- float volume;
80
- uint32_t n_channels;
81
- uint32_t channel_mapSPA_AUDIO_MAX_CHANNELS;
82
- struct volumes channel;
83
- struct volumes soft;
84
- struct volumes monitor;
85
- unsigned int have_soft_volume:1;
86
- unsigned int disabled:1;
87
-};
88
-
89
-static void props_reset(struct props *props)
90
-{
91
- uint32_t i;
92
- props->volume = DEFAULT_VOLUME;
93
- props->n_channels = 0;
94
- for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
95
- props->channel_mapi = SPA_AUDIO_CHANNEL_UNKNOWN;
96
- init_volumes(&props->channel);
97
- init_volumes(&props->soft);
98
- init_volumes(&props->monitor);
99
-}
100
-
101
-struct buffer {
102
- uint32_t id;
103
-#define BUFFER_FLAG_OUT (1 << 0)
104
- uint32_t flags;
105
- struct spa_list link;
106
- struct spa_buffer *outbuf;
107
- struct spa_meta_header *h;
108
- void *datasMAX_DATAS;
109
-};
110
-
111
-struct port {
112
- uint32_t direction;
113
- uint32_t id;
114
-
115
- uint64_t info_all;
116
- struct spa_port_info info;
117
-#define IDX_EnumFormat 0
118
-#define IDX_Meta 1
119
-#define IDX_IO 2
120
-#define IDX_Format 3
121
-#define IDX_Buffers 4
122
- struct spa_param_info params5;
123
-
124
- struct spa_io_buffers *io;
125
-
126
- bool have_format;
127
- struct spa_audio_info format;
128
- uint32_t stride;
129
- uint32_t blocks;
130
- uint32_t size;
131
-
132
- struct buffer buffersMAX_BUFFERS;
133
- uint32_t n_buffers;
134
-
135
- struct spa_list queue;
136
-
137
- struct spa_pod_sequence *ctrl;
138
- uint32_t ctrl_offset;
139
-};
140
-
141
-struct impl {
142
- struct spa_handle handle;
143
- struct spa_node node;
144
-
145
- struct spa_log *log;
146
- struct spa_cpu *cpu;
147
- uint32_t quantum_limit;
148
-
149
- enum spa_direction direction;
150
- struct spa_io_position *io_position;
151
-
152
- struct spa_hook_list hooks;
153
-
154
- uint64_t info_all;
155
- struct spa_node_info info;
156
- struct props props;
157
-#define IDX_PropInfo 0
158
-#define IDX_Props 1
159
- struct spa_param_info params2;
160
-
161
-
162
- struct port control_port;
163
- struct port in_port;
164
- struct port out_port;
165
-
166
- struct channelmix mix;
167
- unsigned int started:1;
168
- unsigned int is_passthrough:1;
169
- uint32_t cpu_flags;
170
- uint32_t max_align;
171
-};
172
-
173
-#define IS_CONTROL_PORT(this,d,id) (id == 1 && d == SPA_DIRECTION_INPUT)
174
-#define IS_DATA_PORT(this,d,id) (id == 0)
175
-
176
-#define CHECK_PORT(this,d,id) (IS_CONTROL_PORT(this,d,id) || IS_DATA_PORT(this,d,id))
177
-#define GET_CONTROL_PORT(this,id) (&this->control_port)
178
-#define GET_IN_PORT(this,id) (&this->in_port)
179
-#define GET_OUT_PORT(this,id) (&this->out_port)
180
-#define GET_PORT(this,d,id) (IS_CONTROL_PORT(this,d,id) ? GET_CONTROL_PORT(this,id) : (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,id) : GET_OUT_PORT(this,id)))
181
-
182
-#define _MASK(ch) (1ULL << SPA_AUDIO_CHANNEL_ ## ch)
183
-#define STEREO (_MASK(FL)|_MASK(FR))
184
-
185
-static void emit_info(struct impl *this, bool full)
186
-{
187
- uint64_t old = full ? this->info.change_mask : 0;
188
- if (full)
189
- this->info.change_mask = this->info_all;
190
- if (this->info.change_mask) {
191
- spa_node_emit_info(&this->hooks, &this->info);
192
- this->info.change_mask = old;
193
- }
194
-}
195
-
196
-static void emit_props_changed(struct impl *this)
197
-{
198
- this->info.change_mask |= SPA_NODE_CHANGE_MASK_PARAMS;
199
- this->paramsIDX_Props.flags ^= SPA_PARAM_INFO_SERIAL;
200
- emit_info(this, false);
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/fmtconvert.c
Deleted
201
1
2
-/* Spa
3
- *
4
- * Copyright © 2018 Wim Taymans
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
-#include <errno.h>
27
-#include <string.h>
28
-#include <stdio.h>
29
-#include <limits.h>
30
-
31
-#include <spa/support/plugin.h>
32
-#include <spa/support/log.h>
33
-#include <spa/support/cpu.h>
34
-#include <spa/utils/list.h>
35
-#include <spa/utils/names.h>
36
-#include <spa/utils/string.h>
37
-#include <spa/node/node.h>
38
-#include <spa/node/io.h>
39
-#include <spa/node/utils.h>
40
-#include <spa/param/audio/format-utils.h>
41
-#include <spa/param/latency-utils.h>
42
-#include <spa/param/param.h>
43
-#include <spa/pod/filter.h>
44
-#include <spa/debug/types.h>
45
-#include <spa/debug/format.h>
46
-
47
-#include "fmt-ops.h"
48
-
49
-#undef SPA_LOG_TOPIC_DEFAULT
50
-#define SPA_LOG_TOPIC_DEFAULT log_topic
51
-static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.fmtconvert");
52
-
53
-#define DEFAULT_RATE 48000
54
-#define DEFAULT_CHANNELS 2
55
-
56
-#define MAX_BUFFERS 32
57
-#define MAX_ALIGN FMT_OPS_MAX_ALIGN
58
-#define MAX_DATAS SPA_AUDIO_MAX_CHANNELS
59
-
60
-#define PROP_DEFAULT_TRUNCATE false
61
-#define PROP_DEFAULT_DITHER 0
62
-
63
-struct impl;
64
-
65
-struct props {
66
- bool truncate;
67
- uint32_t dither;
68
-};
69
-
70
-static void props_reset(struct props *props)
71
-{
72
- props->truncate = PROP_DEFAULT_TRUNCATE;
73
- props->dither = PROP_DEFAULT_DITHER;
74
-}
75
-
76
-struct buffer {
77
- uint32_t id;
78
-#define BUFFER_FLAG_OUT (1 << 0)
79
- uint32_t flags;
80
- struct spa_list link;
81
- struct spa_buffer *outbuf;
82
- struct spa_meta_header *h;
83
- void *datasMAX_DATAS;
84
-};
85
-
86
-struct port {
87
- uint32_t direction;
88
- uint32_t id;
89
-
90
- struct spa_io_buffers *io;
91
-
92
- uint64_t info_all;
93
- struct spa_port_info info;
94
-#define PORT_EnumFormat 0
95
-#define PORT_Meta 1
96
-#define PORT_IO 2
97
-#define PORT_Format 3
98
-#define PORT_Buffers 4
99
-#define PORT_Latency 5
100
-#define N_PORT_PARAMS 6
101
- struct spa_param_info paramsN_PORT_PARAMS;
102
-
103
- struct spa_audio_info format;
104
- uint32_t stride;
105
- uint32_t blocks;
106
- uint32_t size;
107
- unsigned int have_format:1;
108
-
109
- struct buffer buffersMAX_BUFFERS;
110
- uint32_t n_buffers;
111
-
112
- struct spa_list queue;
113
-};
114
-
115
-struct impl {
116
- struct spa_handle handle;
117
- struct spa_node node;
118
-
119
- struct spa_log *log;
120
- struct spa_cpu *cpu;
121
- uint32_t cpu_flags;
122
- uint32_t max_align;
123
- uint32_t quantum_limit;
124
-
125
- struct spa_io_position *io_position;
126
-
127
- uint64_t info_all;
128
- struct spa_node_info info;
129
- struct props props;
130
-#define N_NODE_PARAMS 0
131
- struct spa_param_info params1;
132
-
133
- struct spa_hook_list hooks;
134
-
135
- struct port ports21;
136
-
137
- uint32_t src_remapSPA_AUDIO_MAX_CHANNELS;
138
- uint32_t dst_remapSPA_AUDIO_MAX_CHANNELS;
139
-
140
- struct spa_latency_info latency2;
141
-
142
- struct convert conv;
143
- unsigned int started:1;
144
- unsigned int is_passthrough:1;
145
-};
146
-
147
-#define CHECK_PORT(this,d,id) (id == 0)
148
-#define GET_PORT(this,d,id) (&this->portsdid)
149
-#define GET_IN_PORT(this,id) GET_PORT(this,SPA_DIRECTION_INPUT,id)
150
-#define GET_OUT_PORT(this,id) GET_PORT(this,SPA_DIRECTION_OUTPUT,id)
151
-
152
-static int can_convert(const struct spa_audio_info *info1, const struct spa_audio_info *info2)
153
-{
154
- if (info1->info.raw.channels != info2->info.raw.channels ||
155
- info1->info.raw.rate != info2->info.raw.rate) {
156
- return 0;
157
- }
158
- return 1;
159
-}
160
-
161
-static int setup_convert(struct impl *this)
162
-{
163
- uint32_t src_fmt, dst_fmt;
164
- struct spa_audio_info informat, outformat;
165
- struct port *inport, *outport;
166
- uint32_t i, j;
167
- int res;
168
-
169
- inport = GET_IN_PORT(this, 0);
170
- outport = GET_OUT_PORT(this, 0);
171
-
172
- if (!inport->have_format || !outport->have_format)
173
- return -EIO;
174
-
175
- informat = inport->format;
176
- outformat = outport->format;
177
-
178
- src_fmt = informat.info.raw.format;
179
- dst_fmt = outformat.info.raw.format;
180
-
181
- spa_log_info(this->log, "%p: %s/%d@%d->%s/%d@%d", this,
182
- spa_debug_type_find_name(spa_type_audio_format, src_fmt),
183
- informat.info.raw.channels,
184
- informat.info.raw.rate,
185
- spa_debug_type_find_name(spa_type_audio_format, dst_fmt),
186
- outformat.info.raw.channels,
187
- outformat.info.raw.rate);
188
-
189
- if (!can_convert(&informat, &outformat))
190
- return -EINVAL;
191
-
192
- for (i = 0; i < informat.info.raw.channels; i++) {
193
- for (j = 0; j < outformat.info.raw.channels; j++) {
194
- if (informat.info.raw.positioni !=
195
- outformat.info.raw.positionj)
196
- continue;
197
- if (inport->blocks > 1) {
198
- this->src_remapj = i;
199
- if (outport->blocks > 1)
200
- this->dst_remapj = j;
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/merger.c
Deleted
201
1
2
-/* Spa
3
- *
4
- * Copyright © 2018 Wim Taymans
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
-#include <errno.h>
27
-#include <string.h>
28
-#include <stdio.h>
29
-#include <limits.h>
30
-
31
-#include <spa/support/plugin.h>
32
-#include <spa/support/cpu.h>
33
-#include <spa/support/log.h>
34
-#include <spa/utils/result.h>
35
-#include <spa/utils/list.h>
36
-#include <spa/utils/names.h>
37
-#include <spa/utils/string.h>
38
-#include <spa/node/node.h>
39
-#include <spa/node/io.h>
40
-#include <spa/node/utils.h>
41
-#include <spa/node/keys.h>
42
-#include <spa/param/audio/format-utils.h>
43
-#include <spa/param/param.h>
44
-#include <spa/param/latency-utils.h>
45
-#include <spa/pod/filter.h>
46
-#include <spa/debug/types.h>
47
-#include <spa/debug/pod.h>
48
-
49
-#include "volume-ops.h"
50
-#include "fmt-ops.h"
51
-
52
-#undef SPA_LOG_TOPIC_DEFAULT
53
-#define SPA_LOG_TOPIC_DEFAULT log_topic
54
-static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.merger");
55
-
56
-#define DEFAULT_RATE 48000
57
-#define DEFAULT_CHANNELS 2
58
-
59
-#define MAX_ALIGN FMT_OPS_MAX_ALIGN
60
-#define MAX_BUFFERS 32
61
-#define MAX_DATAS SPA_AUDIO_MAX_CHANNELS
62
-#define MAX_PORTS SPA_AUDIO_MAX_CHANNELS
63
-
64
-#define DEFAULT_MUTE false
65
-#define DEFAULT_VOLUME VOLUME_NORM
66
-
67
-struct volumes {
68
- bool mute;
69
- uint32_t n_volumes;
70
- float volumesSPA_AUDIO_MAX_CHANNELS;
71
-};
72
-
73
-static void init_volumes(struct volumes *vol)
74
-{
75
- uint32_t i;
76
- vol->mute = DEFAULT_MUTE;
77
- vol->n_volumes = 0;
78
- for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
79
- vol->volumesi = DEFAULT_VOLUME;
80
-}
81
-
82
-struct props {
83
- float volume;
84
- uint32_t n_channels;
85
- uint32_t channel_mapSPA_AUDIO_MAX_CHANNELS;
86
- struct volumes channel;
87
- struct volumes soft;
88
- struct volumes monitor;
89
-};
90
-
91
-static void props_reset(struct props *props)
92
-{
93
- uint32_t i;
94
- props->volume = DEFAULT_VOLUME;
95
- props->n_channels = 0;
96
- for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
97
- props->channel_mapi = SPA_AUDIO_CHANNEL_UNKNOWN;
98
- init_volumes(&props->channel);
99
- init_volumes(&props->soft);
100
- init_volumes(&props->monitor);
101
-}
102
-
103
-struct buffer {
104
- uint32_t id;
105
-#define BUFFER_FLAG_QUEUED (1<<0)
106
- uint32_t flags;
107
- struct spa_list link;
108
- struct spa_buffer *buf;
109
- void *datasMAX_DATAS;
110
-};
111
-
112
-struct port {
113
- uint32_t direction;
114
- uint32_t id;
115
-
116
- struct spa_io_buffers *io;
117
-
118
- uint64_t info_all;
119
- struct spa_port_info info;
120
-#define IDX_EnumFormat 0
121
-#define IDX_Meta 1
122
-#define IDX_IO 2
123
-#define IDX_Format 3
124
-#define IDX_Buffers 4
125
-#define IDX_Latency 5
126
-#define N_PORT_PARAMS 6
127
- struct spa_param_info paramsN_PORT_PARAMS;
128
- char position16;
129
-
130
- struct spa_audio_info format;
131
- uint32_t blocks;
132
- uint32_t stride;
133
-
134
- struct buffer buffersMAX_BUFFERS;
135
- uint32_t n_buffers;
136
-
137
- struct spa_list queue;
138
-
139
- unsigned int have_format:1;
140
-};
141
-
142
-struct impl {
143
- struct spa_handle handle;
144
- struct spa_node node;
145
-
146
- struct spa_log *log;
147
- struct spa_cpu *cpu;
148
-
149
- uint32_t cpu_flags;
150
- uint32_t max_align;
151
- uint32_t quantum_limit;
152
-
153
- struct spa_io_position *io_position;
154
-
155
- uint64_t info_all;
156
- struct spa_node_info info;
157
-#define IDX_PortConfig 0
158
-#define IDX_PropInfo 1
159
-#define IDX_Props 2
160
-#define N_NODE_PARAMS 3
161
- struct spa_param_info paramsN_NODE_PARAMS;
162
-
163
- struct spa_hook_list hooks;
164
-
165
- uint32_t port_count;
166
- uint32_t monitor_count;
167
- struct port *in_portsMAX_PORTS;
168
- struct port *out_portsMAX_PORTS + 1;
169
-
170
- struct spa_audio_info format;
171
- unsigned int have_profile:1;
172
-
173
- struct convert conv;
174
- unsigned int is_passthrough:1;
175
- unsigned int started:1;
176
- unsigned int monitor:1;
177
- unsigned int monitor_channel_volumes:1;
178
-
179
- struct volume volume;
180
- struct props props;
181
-
182
- uint32_t src_remapSPA_AUDIO_MAX_CHANNELS;
183
- uint32_t dst_remapSPA_AUDIO_MAX_CHANNELS;
184
-
185
- struct spa_latency_info latency2;
186
-
187
- uint32_t empty_size;
188
- float *empty;
189
-};
190
-
191
-#define CHECK_IN_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) < this->port_count)
192
-#define CHECK_OUT_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) <= this->monitor_count)
193
-#define CHECK_PORT(this,d,p) (CHECK_OUT_PORT(this,d,p) || CHECK_IN_PORT (this,d,p))
194
-#define GET_IN_PORT(this,p) (this->in_portsp)
195
-#define GET_OUT_PORT(this,p) (this->out_portsp)
196
-#define GET_PORT(this,d,p) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,p) : GET_OUT_PORT(this,p))
197
-
198
-#define PORT_IS_DSP(d,p) (p != 0 || d != SPA_DIRECTION_OUTPUT)
199
-
200
-static void emit_node_info(struct impl *this, bool full)
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/resample.c
Deleted
201
1
2
-/* Spa
3
- *
4
- * Copyright © 2018 Wim Taymans
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
-#include <errno.h>
27
-#include <string.h>
28
-#include <stdio.h>
29
-
30
-#include <spa/support/plugin.h>
31
-#include <spa/support/log.h>
32
-#include <spa/utils/list.h>
33
-#include <spa/utils/names.h>
34
-#include <spa/utils/string.h>
35
-#include <spa/node/node.h>
36
-#include <spa/node/io.h>
37
-#include <spa/node/utils.h>
38
-#include <spa/param/audio/format-utils.h>
39
-#include <spa/param/param.h>
40
-#include <spa/pod/filter.h>
41
-#include <spa/debug/types.h>
42
-
43
-#include "resample.h"
44
-
45
-#undef SPA_LOG_TOPIC_DEFAULT
46
-#define SPA_LOG_TOPIC_DEFAULT log_topic
47
-static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.resample");
48
-
49
-#define DEFAULT_RATE 48000
50
-#define DEFAULT_CHANNELS 2
51
-
52
-#define MAX_BUFFERS 32
53
-
54
-struct impl;
55
-
56
-struct props {
57
- double rate;
58
- int quality;
59
- bool disabled;
60
-};
61
-
62
-static void props_reset(struct props *props)
63
-{
64
- props->rate = 1.0;
65
- props->quality = RESAMPLE_DEFAULT_QUALITY;
66
- props->disabled = false;
67
-}
68
-
69
-struct buffer {
70
- uint32_t id;
71
-#define BUFFER_FLAG_OUT (1 << 0)
72
- uint32_t flags;
73
- struct spa_list link;
74
- struct spa_buffer *outbuf;
75
- struct spa_meta_header *h;
76
-};
77
-
78
-struct port {
79
- uint32_t direction;
80
- uint32_t id;
81
-
82
- uint64_t info_all;
83
- struct spa_port_info info;
84
- struct spa_param_info params8;
85
-
86
- struct spa_io_buffers *io;
87
-
88
- struct spa_audio_info format;
89
- uint32_t stride;
90
- uint32_t blocks;
91
- uint32_t size;
92
- unsigned int have_format:1;
93
-
94
- struct buffer buffersMAX_BUFFERS;
95
- uint32_t n_buffers;
96
-
97
- uint32_t offset;
98
- struct spa_list queue;
99
-};
100
-
101
-struct impl {
102
- struct spa_handle handle;
103
- struct spa_node node;
104
-
105
- struct spa_log *log;
106
- struct spa_cpu *cpu;
107
-
108
- uint32_t quantum_limit;
109
-
110
- struct spa_io_position *io_position;
111
- struct spa_io_rate_match *io_rate_match;
112
-
113
- uint64_t info_all;
114
- struct spa_node_info info;
115
- struct props props;
116
-
117
- struct spa_hook_list hooks;
118
-
119
- struct port in_port;
120
- struct port out_port;
121
-
122
-#define MODE_SPLIT 0
123
-#define MODE_MERGE 1
124
-#define MODE_CONVERT 2
125
- int mode;
126
- unsigned int started:1;
127
- unsigned int peaks:1;
128
- unsigned int drained:1;
129
-
130
- struct resample resample;
131
-
132
- double rate_scale;
133
-};
134
-
135
-#define CHECK_PORT(this,d,id) (id == 0)
136
-#define GET_IN_PORT(this,id) (&this->in_port)
137
-#define GET_OUT_PORT(this,id) (&this->out_port)
138
-#define GET_PORT(this,d,id) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,id) : GET_OUT_PORT(this,id))
139
-
140
-static int setup_convert(struct impl *this,
141
- enum spa_direction direction,
142
- const struct spa_audio_info *info)
143
-{
144
- const struct spa_audio_info *src_info, *dst_info;
145
- int err;
146
-
147
- if (direction == SPA_DIRECTION_INPUT) {
148
- src_info = info;
149
- dst_info = &GET_OUT_PORT(this, 0)->format;
150
- } else {
151
- src_info = &GET_IN_PORT(this, 0)->format;
152
- dst_info = info;
153
- }
154
-
155
- spa_log_info(this->log, "%p: %s/%d@%d->%s/%d@%d", this,
156
- spa_debug_type_find_name(spa_type_audio_format, src_info->info.raw.format),
157
- src_info->info.raw.channels,
158
- src_info->info.raw.rate,
159
- spa_debug_type_find_name(spa_type_audio_format, dst_info->info.raw.format),
160
- dst_info->info.raw.channels,
161
- dst_info->info.raw.rate);
162
-
163
- if (src_info->info.raw.channels != dst_info->info.raw.channels)
164
- return -EINVAL;
165
-
166
- if (this->resample.free)
167
- resample_free(&this->resample);
168
-
169
- this->resample.channels = src_info->info.raw.channels;
170
- this->resample.i_rate = src_info->info.raw.rate;
171
- this->resample.o_rate = dst_info->info.raw.rate;
172
- this->resample.log = this->log;
173
- this->resample.quality = this->props.quality;
174
-
175
- if (this->peaks)
176
- err = resample_peaks_init(&this->resample);
177
- else
178
- err = resample_native_init(&this->resample);
179
-
180
- return err;
181
-}
182
-
183
-static int impl_node_enum_params(void *object, int seq,
184
- uint32_t id, uint32_t start, uint32_t num,
185
- const struct spa_pod *filter)
186
-{
187
- struct impl *this = object;
188
- struct spa_pod *param;
189
- struct spa_pod_builder b = { 0 };
190
- uint8_t buffer4096;
191
- struct spa_result_node_params result;
192
- uint32_t count = 0;
193
-
194
- spa_return_val_if_fail(this != NULL, -EINVAL);
195
- spa_return_val_if_fail(num != 0, -EINVAL);
196
-
197
- result.id = id;
198
- result.next = start;
199
- next:
200
- result.index = result.next++;
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/splitter.c
Deleted
201
1
2
-/* Spa
3
- *
4
- * Copyright © 2018 Wim Taymans
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
-#include <errno.h>
27
-#include <string.h>
28
-#include <stdio.h>
29
-#include <limits.h>
30
-
31
-#include <spa/support/plugin.h>
32
-#include <spa/support/cpu.h>
33
-#include <spa/support/log.h>
34
-#include <spa/utils/list.h>
35
-#include <spa/utils/names.h>
36
-#include <spa/utils/string.h>
37
-#include <spa/node/node.h>
38
-#include <spa/node/utils.h>
39
-#include <spa/node/io.h>
40
-#include <spa/param/audio/format-utils.h>
41
-#include <spa/param/latency-utils.h>
42
-#include <spa/param/param.h>
43
-#include <spa/pod/filter.h>
44
-#include <spa/debug/types.h>
45
-#include <spa/debug/pod.h>
46
-
47
-#include "fmt-ops.h"
48
-
49
-#undef SPA_LOG_TOPIC_DEFAULT
50
-#define SPA_LOG_TOPIC_DEFAULT log_topic
51
-static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.splitter");
52
-
53
-#define DEFAULT_RATE 48000
54
-#define DEFAULT_CHANNELS 2
55
-#define DEFAULT_MASK (1LL << SPA_AUDIO_CHANNEL_FL) | (1LL << SPA_AUDIO_CHANNEL_FR)
56
-
57
-#define MAX_ALIGN FMT_OPS_MAX_ALIGN
58
-#define MAX_BUFFERS 32
59
-#define MAX_DATAS SPA_AUDIO_MAX_CHANNELS
60
-#define MAX_PORTS SPA_AUDIO_MAX_CHANNELS
61
-
62
-struct buffer {
63
- uint32_t id;
64
-#define BUFFER_FLAG_QUEUED (1<<0)
65
- uint32_t flags;
66
- struct spa_list link;
67
- struct spa_buffer *buf;
68
- void *datasMAX_DATAS;
69
-};
70
-
71
-struct port {
72
- uint32_t direction;
73
- uint32_t id;
74
-
75
- struct spa_io_buffers *io;
76
-
77
- uint64_t info_all;
78
- struct spa_port_info info;
79
-#define IDX_EnumFormat 0
80
-#define IDX_Meta 1
81
-#define IDX_IO 2
82
-#define IDX_Format 3
83
-#define IDX_Buffers 4
84
-#define IDX_Latency 5
85
-#define N_PORT_PARAMS 6
86
- struct spa_param_info paramsN_PORT_PARAMS;
87
-
88
- struct spa_dict info_props;
89
- struct spa_dict_item info_props_items2;
90
- char position16;
91
-
92
- bool have_format;
93
- struct spa_audio_info format;
94
- uint32_t blocks;
95
- uint32_t stride;
96
-
97
- struct buffer buffersMAX_BUFFERS;
98
- uint32_t n_buffers;
99
-
100
- struct spa_list queue;
101
-};
102
-
103
-struct impl {
104
- struct spa_handle handle;
105
- struct spa_node node;
106
-
107
- struct spa_log *log;
108
- struct spa_cpu *cpu;
109
-
110
- uint32_t cpu_flags;
111
- uint32_t max_align;
112
- uint32_t quantum_limit;
113
-
114
- struct spa_io_position *io_position;
115
-
116
- uint64_t info_all;
117
- struct spa_node_info info;
118
-#define IDX_PortConfig 0
119
-#define N_NODE_PARAMS 1
120
- struct spa_param_info paramsN_NODE_PARAMS;
121
-
122
- struct spa_hook_list hooks;
123
-
124
- struct port in_ports1;
125
- struct port *out_portsMAX_PORTS;
126
- uint32_t port_count;
127
-
128
- struct spa_audio_info format;
129
- unsigned int have_profile:1;
130
-
131
- struct convert conv;
132
- unsigned int is_passthrough:1;
133
- unsigned int started:1;
134
-
135
- struct spa_latency_info latency2;
136
-
137
- uint32_t src_remapSPA_AUDIO_MAX_CHANNELS;
138
- uint32_t dst_remapSPA_AUDIO_MAX_CHANNELS;
139
-
140
- uint32_t empty_size;
141
- float *empty;
142
-};
143
-
144
-#define CHECK_OUT_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < this->port_count)
145
-#define CHECK_IN_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0)
146
-#define CHECK_PORT(this,d,p) (CHECK_OUT_PORT(this,d,p) || CHECK_IN_PORT (this,d,p))
147
-#define GET_IN_PORT(this,p) (&this->in_portsp)
148
-#define GET_OUT_PORT(this,p) (this->out_portsp)
149
-#define GET_PORT(this,d,p) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,p) : GET_OUT_PORT(this,p))
150
-
151
-static void emit_node_info(struct impl *this, bool full)
152
-{
153
- uint64_t old = full ? this->info.change_mask : 0;
154
- if (full)
155
- this->info.change_mask = this->info_all;
156
- if (this->info.change_mask) {
157
- spa_node_emit_info(&this->hooks, &this->info);
158
- this->info.change_mask = old;
159
- }
160
-}
161
-static void emit_port_info(struct impl *this, struct port *port, bool full)
162
-{
163
- uint64_t old = full ? port->info.change_mask : 0;
164
- if (full)
165
- port->info.change_mask = port->info_all;
166
- if (port->info.change_mask) {
167
- spa_node_emit_port_info(&this->hooks,
168
- port->direction, port->id, &port->info);
169
- port->info.change_mask = old;
170
- }
171
-}
172
-
173
-static int init_port(struct impl *this, enum spa_direction direction,
174
- uint32_t port_id, uint32_t position)
175
-{
176
- struct port *port = GET_OUT_PORT(this, port_id);
177
- const char *name;
178
-
179
- if (port == NULL) {
180
- port = calloc(1, sizeof(struct port));
181
- if (port == NULL)
182
- return -errno;
183
- this->out_portsport_id = port;
184
- }
185
- port->direction = direction;
186
- port->id = port_id;
187
-
188
- name = spa_debug_type_find_short_name(spa_type_audio_channel, position);
189
- snprintf(port->position, sizeof(port->position), "%s", name ? name : "UNK");
190
-
191
- port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
192
- SPA_PORT_CHANGE_MASK_PROPS |
193
- SPA_PORT_CHANGE_MASK_PARAMS;
194
-
195
- port->info = SPA_PORT_INFO_INIT();
196
- port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA;
197
- port->info_props_items0 = SPA_DICT_ITEM_INIT(SPA_KEY_FORMAT_DSP, "32 bit float mono audio");
198
- port->info_props_items1 = SPA_DICT_ITEM_INIT(SPA_KEY_AUDIO_CHANNEL, port->position);
199
- port->info_props = SPA_DICT_INIT(port->info_props_items, 2);
200
- port->info.props = &port->info_props;
201
pipewire-0.3.52.tar.gz/INSTALL.md -> pipewire-0.3.53.tar.gz/INSTALL.md
Changed
123
1
2
## Building
3
4
-PipeWire uses a build tool called *Meson* as a basis for its build
5
+PipeWire uses a build tool called *Meson*(https://mesonbuild.com) as a basis for its build
6
process. It's a tool with some resemblance to Autotools and CMake. Meson
7
-again generates build files for a lower level build tool called *Ninja*,
8
+again generates build files for a lower level build tool called *Ninja*(https://ninja-build.org/),
9
working in about the same level of abstraction as more familiar GNU Make
10
does.
11
12
13
Finally, invoke the build:
14
15
```
16
-$ ninja -C builddir
17
+$ meson compile -C builddir
18
```
19
20
Just to avoid any confusion: `autogen.sh` is a script invoked by *Jhbuild*,
21
22
```
23
24
This will use the default config file to configure and start the daemon.
25
-The default config will also start pipewire-media-session, a default
26
-example media session and pipewire-pulse, a PulseAudio compatible server.
27
+The default config will also start `pipewire-media-session`, a default
28
+example media session and `pipewire-pulse`, a PulseAudio compatible server.
29
30
-You can also enable more debugging with the PIPEWIRE_DEBUG environment
31
+You can also enable more debugging with the `PIPEWIRE_DEBUG` environment
32
variable like so:
33
34
```
35
36
37
## Installing
38
39
-PipeWire comes with quite a bit of libraries and tools, run
40
-inside `builddir`:
41
+PipeWire comes with quite a bit of libraries and tools, run:
42
43
```
44
-sudo meson install
45
+meson install -C builddir
46
```
47
48
to install everything onto the system into the specified prefix.
49
+Depending on the configured installation prefix, the above command
50
+may need to be run with elevated privileges (e.g. with `sudo`).
51
Some additional steps will have to be performed to integrate
52
with the distribution as shown below.
53
54
55
systemd unit using socket activation or as a service.
56
57
Configuration of the PipeWire daemon can be found in
58
-/usr/share/pipewire/pipewire.conf. Please refer to the comments in the
59
+`/usr/share/pipewire/pipewire.conf`. Please refer to the comments in the
60
config file for more information about the configuration options.
61
62
The daemon is started with:
63
64
```
65
66
The plugin will be picked up by alsa when the following files
67
-are in /etc/alsa/conf.d/
68
+are in `/etc/alsa/conf.d/`:
69
70
```
71
/etc/alsa/conf.d/50-pipewire.conf -> /usr/share/alsa/alsa.conf.d/50-pipewire.conf
72
/etc/alsa/conf.d/99-pipewire-default.conf
73
```
74
75
-With this setup, aplay -l should list a pipewire: device that can be used as
76
+With this setup, `aplay -l` should list a pipewire device that can be used as
77
a regular alsa device for playback and record.
78
79
### JACK emulation
80
81
82
```
83
84
-The provided pw-jack script uses LD_LIBRARY_PATH to set the library
85
+The provided `pw-jack` script uses `LD_LIBRARY_PATH` to set the library
86
search path to these replacement libraries. This allows you to run
87
jack apps on both the real JACK server or on PipeWire with the script.
88
89
90
```
91
92
Note that when JACK is replaced by PipeWire, the SPA JACK plugin (installed
93
-in /usr/lib64/spa-0.2/jack/libspa-jack.so) is not useful anymore and
94
+in `/usr/lib64/spa-0.2/jack/libspa-jack.so`) is not useful anymore and
95
distributions should make them conflict.
96
97
98
99
```
100
101
You can also start additional PulseAudio servers listening on other
102
-sockets with the -a option. See `pipewire-pulse -h` for more info.
103
+sockets with the `-a` option. See `pipewire-pulse -h` for more info.
104
105
106
## Uninstalling
107
108
-To uninstall, in the `builddir` directory run:
109
+To uninstall, run:
110
111
```
112
-sudo ninja uninstall
113
+ninja -C builddir uninstall
114
```
115
116
+Depending on the configured installation prefix, the above command
117
+may need to be run with elevated privileges (e.g. with `sudo`).
118
+
119
+Note that at the time of writing uninstallation only works with the
120
+same build directory that was used for installation. Meson stores the
121
+list of installed files in the build directory, and this list is
122
+necessary for uninstallation to work.
123
pipewire-0.3.52.tar.gz/NEWS -> pipewire-0.3.53.tar.gz/NEWS
Changed
93
1
2
+# PipeWire 0.3.53 (2022-06-30)
3
+
4
+This is a bugfix release that is API and ABI compatible with previous
5
+0.3.x releases.
6
+
7
+## Highlights
8
+ - The 44.1KHz samplerate was removed again from the defaults, it caused
9
+ all kinds of problems with various hardware.
10
+ - The ALSA plugin should now be able to deal with unsupported samplerates
11
+ and fall back to the nearest supported one.
12
+ - The rlimits performance tuning wiki page was updated. Please check
13
+ you limits.conf file, the version on the wiki used to give all
14
+ processes a -19 nice level instead of just the pipewire daemon.
15
+ - The audioconvert plugin was rewritten to be more maintainable and
16
+ faster. It also gained support for control ports and dithering with
17
+ optional noise shaping.
18
+ - An impossible buffering situation is avoided in pulse-server that would
19
+ cause some applications (sunshine, ...) to stutter.
20
+
21
+
22
+## PipeWire
23
+ - 44.1KHz was removed from the allowed rates again. It caused all kinds
24
+ of regressions due to driver bugs and timing issues on HDMI.
25
+
26
+## modules
27
+ - filter-chain now does some more error checking and reporting to
28
+ avoid some crashes.
29
+ - filter-chain now supports more channel layouts for input and output
30
+ that does not need to match the plugin layout.
31
+ - Format parsing is now more consistent in the modules.
32
+
33
+## Tools
34
+ - pw-cli can now also work without readline support.
35
+ - pw-cat can now also read multichannel ulaw/alaw/u8/s8.
36
+
37
+## SPA
38
+ - The audioconvert plugin was rewritten. This should make it more
39
+ maintainable. It also fixed some issues such as CPU spikes in some
40
+ cases and crashes in others. The old plugins were removed, for a
41
+ code reduction of some 6000 lines.
42
+ - The audioconvert plugin now supports control ports, which can be
43
+ enabled on nodes in the session manager. This makes it possible to
44
+ control audioconvert properties using timed events or midi.
45
+ - NoteOn 0-velocity MIDI events are no longer filtered out. This is
46
+ a valid event, nodes that can't deal with it should fix it up
47
+ themselves. The JACK layer still filters out these events by default
48
+ but this can now be configured with a per-client property.
49
+ - The running status on midi events is now disabled to match what
50
+ JACK does.
51
+ - The ALSA plugin will now deal with driver bugs when a driver announces
52
+ support for a samplerate but then refuses to use it later.
53
+ - The ALSA plugin has been optimized a little for sample IO.
54
+ - V4L2 now doesn't error when there are no controls.
55
+ - Error handling was improved in the audio converter.
56
+ - The audioconvert plugin now supports rectangular dithering and
57
+ noise shaping.
58
+ - The audioconvert plugin can now insert additional inaudible noise
59
+ that can be used to keep some amplifiers alive. (#705)
60
+ - The audioconvert format conversion was changed so that it now produces
61
+ the full 32 bits range in the C fallback conversion code as well.
62
+ - The resampler window function was changed to a cosh() window
63
+ function. (#2483)
64
+ - Vendor and device id are now in hex.
65
+
66
+## pulse-server
67
+ - Tweak the record buffer attributes some more and make sure we don't
68
+ end up in impossible buffering situations. Fixes an issue with
69
+ distorted sound in sunshine. (#2447)
70
+ - Fix a potential crash when updating the client property list.
71
+ - Some properties on cards were aligned with pulseaudio.
72
+
73
+## Wiki
74
+ - Change "priority" to "nice" in the example limits.conf file. It was
75
+ giving a -19 nice level to all processes, not just the pipewire
76
+ daemon.
77
+
78
+Older versions:
79
+
80
# PipeWire 0.3.52 (2022-06-09)
81
82
This is a bugfix release that is API and ABI compatible with previous
83
84
- Fixes to the source and fd use.
85
- It is now possible to set client properties as well. (#1573)
86
87
-
88
-Older versions:
89
-
90
# PipeWire 0.3.51 (2022-04-28)
91
92
This is a bugfix release that is API and ABI compatible with previous
93
pipewire-0.3.52.tar.gz/meson.build -> pipewire-0.3.53.tar.gz/meson.build
Changed
48
1
2
project('pipewire', 'c' ,
3
- version : '0.3.52',
4
+ version : '0.3.53',
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
9
endif
10
11
summary({'readline (for pw-cli)': readline_dep.found()}, bool_yn: true, section: 'Misc dependencies')
12
+cdata.set('HAVE_READLINE', readline_dep.found())
13
ncurses_dep = dependency('ncursesw', required : false)
14
sndfile_dep = dependency('sndfile', version : '>= 1.0.20', required : get_option('sndfile'))
15
summary({'sndfile': sndfile_dep.found()}, bool_yn: true, section: 'pw-cat/pw-play/pw-dump/filter-chain')
16
17
summary({'WebRTC Echo Canceling': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies')
18
cdata.set('HAVE_WEBRTC', webrtc_dep.found())
19
20
-# On FreeBSD, epoll-shim library is required for eventfd() and timerfd()
21
-epoll_shim_dep = (build_machine.system() == 'freebsd'
22
+# On FreeBSD and MidnightBSD, epoll-shim library is required for eventfd() and timerfd()
23
+epoll_shim_dep = (build_machine.system() == 'freebsd' or build_machine.system() == 'midnightbsd'
24
? dependency('epoll-shim', required: true)
25
: dependency('', required: false))
26
27
-libinotify_dep = (build_machine.system() == 'freebsd'
28
+libinotify_dep = (build_machine.system() == 'freebsd' or build_machine.system() == 'midnightbsd'
29
? dependency('libinotify', required: true)
30
: dependency('', required: false))
31
32
-# On FreeBSD, libintl library is required for gettext
33
+# On FreeBSD and MidnightBSD, libintl library is required for gettext
34
libintl_dep = cc.find_library('intl', required: false)
35
if not libintl_dep.found()
36
libintl_dep = dependency('intl', required: false)
37
38
alsa_dep = dependency('alsa', version : '>=1.1.7', required: need_alsa)
39
summary({'pipewire-alsa': alsa_dep.found()}, bool_yn: true)
40
41
-if build_machine.system() == 'freebsd'
42
-# On FreeBSD the OpenSSL library may come from base or a package.
43
+if build_machine.system() == 'freebsd' or build_machine.system() == 'midnightbsd'
44
+# On FreeBSD and MidnightBSD the OpenSSL library may come from base or a package.
45
# Check for a package first and fallback to the base library if we can't find it via pkgconfig
46
openssl_lib = dependency('openssl', required: false)
47
if not openssl_lib.found()
48
pipewire-0.3.52.tar.gz/pipewire-alsa/alsa-plugins/pcm_pipewire.c -> pipewire-0.3.53.tar.gz/pipewire-alsa/alsa-plugins/pcm_pipewire.c
Changed
10
1
2
#define __USE_GNU
3
4
#include <limits.h>
5
-#ifndef __FreeBSD__
6
+#if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
7
#include <byteswap.h>
8
#endif
9
#include <sys/shm.h>
10
pipewire-0.3.52.tar.gz/pipewire-jack/src/pipewire-jack.c -> pipewire-0.3.53.tar.gz/pipewire-jack/src/pipewire-jack.c
Changed
79
1
2
unsigned int default_as_system:1;
3
int self_connect_mode;
4
int rt_max;
5
+ unsigned int fix_midi_events:1;
6
7
jack_position_t jack_position;
8
jack_transport_state_t jack_state;
9
10
return b.state.offset;
11
}
12
13
-static void convert_to_midi(struct spa_pod_sequence **seq, uint32_t n_seq, void *midi)
14
+static inline void fix_midi_event(uint8_t *data, size_t size)
15
+{
16
+ /* fixup NoteOn with vel 0 */
17
+ if (size > 2 && (data0 & 0xF0) == 0x90 && data2 == 0x00) {
18
+ data0 = 0x80 + (data0 & 0x0F);
19
+ data2 = 0x40;
20
+ }
21
+}
22
+
23
+static void convert_to_midi(struct spa_pod_sequence **seq, uint32_t n_seq, void *midi, bool fix)
24
{
25
struct spa_pod_control *cn_seq;
26
uint32_t i;
27
+ int res;
28
29
for (i = 0; i < n_seq; i++)
30
ci = spa_pod_control_first(&seqi->body);
31
32
while (true) {
33
struct spa_pod_control *next = NULL;
34
uint32_t next_index = 0;
35
+ uint8_t *data;
36
+ size_t size;
37
38
for (i = 0; i < n_seq; i++) {
39
if (!spa_pod_control_is_inside(&seqi->body,
40
41
if (SPA_UNLIKELY(next == NULL))
42
break;
43
44
+ data = SPA_POD_BODY(&next->value);
45
+ size = SPA_POD_BODY_SIZE(&next->value);
46
+
47
switch(next->type) {
48
case SPA_CONTROL_Midi:
49
- jack_midi_event_write(midi,
50
- next->offset,
51
- SPA_POD_BODY(&next->value),
52
- SPA_POD_BODY_SIZE(&next->value));
53
+ if (fix)
54
+ fix_midi_event(data, size);
55
+
56
+ if ((res = jack_midi_event_write(midi, next->offset, data, size)) < 0)
57
+ pw_log_warn("midi %p: can't write event: %s", midi,
58
+ spa_strerror(res));
59
break;
60
}
61
cnext_index = spa_pod_control_next(cnext_index);
62
63
client->filter_name = pw_properties_get_bool(client->props, "jack.filter-name", false);
64
client->locked_process = pw_properties_get_bool(client->props, "jack.locked-process", true);
65
client->default_as_system = pw_properties_get_bool(client->props, "jack.default-as-system", false);
66
+ client->fix_midi_events = pw_properties_get_bool(client->props, "jack.fix-midi-events", true);
67
68
client->self_connect_mode = SELF_CONNECT_ALLOW;
69
if ((str = pw_properties_get(client->props, "jack.self-connect-mode")) != NULL) {
70
71
if (n_seq == MAX_MIDI_MIX)
72
break;
73
}
74
- convert_to_midi(seq, n_seq, ptr);
75
+ convert_to_midi(seq, n_seq, ptr, p->client->fix_midi_events);
76
77
return ptr;
78
}
79
pipewire-0.3.52.tar.gz/pipewire-v4l2/src/pipewire-v4l2.c -> pipewire-0.3.53.tar.gz/pipewire-v4l2/src/pipewire-v4l2.c
Changed
10
1
2
if ((file = find_file(fd)) == NULL)
3
return globals.old_fops.ioctl(fd, request, arg);
4
5
-#ifdef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
if (arg == NULL && (request & IOC_DIRMASK != IOC_VOID)) {
8
#else
9
if (arg == NULL && (_IOC_DIR(request) & (_IOC_WRITE | _IOC_READ))) {
10
pipewire-0.3.52.tar.gz/po/uk.po -> pipewire-0.3.53.tar.gz/po/uk.po
Changed
92
1
2
"Project-Id-Version: pipewire\n"
3
"Report-Msgid-Bugs-To: https://gitlab.freedesktop.org/pipewire/pipewire/-/issue"
4
"s\n"
5
-"POT-Creation-Date: 2022-05-05 03:28+0000\n"
6
-"PO-Revision-Date: 2022-05-05 21:06+0300\n"
7
+"POT-Creation-Date: 2022-05-20 15:26+0000\n"
8
+"PO-Revision-Date: 2022-06-18 13:07+0300\n"
9
"Last-Translator: Yuri Chornoivan <yurchor@ukr.net>\n"
10
"Language-Team: Ukrainian <trans-uk@lists.fedoraproject.org>\n"
11
"Language: uk\n"
12
13
msgstr "Тунель до %s/%s"
14
15
#: src/modules/module-fallback-sink.c:51
16
-#| msgid "Game Output"
17
msgid "Dummy Output"
18
msgstr "Фіктивний вихід"
19
20
21
msgid "%s on %s"
22
msgstr "%s на %s"
23
24
-#: src/tools/pw-cat.c:871
25
+#: src/tools/pw-cat.c:872
26
#, c-format
27
+#| msgid ""
28
+#| "%s options <file>\n"
29
+#| " -h, --help Show this help\n"
30
+#| " --version Show version\n"
31
+#| " -v, --verbose Enable verbose operations\n"
32
+#| "\n"
33
msgid ""
34
-"%s options <file>\n"
35
+"%s options <file>|-\n"
36
" -h, --help Show this help\n"
37
" --version Show version\n"
38
" -v, --verbose Enable verbose operations\n"
39
"\n"
40
msgstr ""
41
-"%s параметри <файл>\n"
42
+"%s параметри <файл>|-\n"
43
" -h, --help вивести довідку\n"
44
" --version вивести дані щодо версії\n"
45
" -v, --verbose ввімкнути відображення докладної "
46
"інформації\n"
47
"\n"
48
49
-#: src/tools/pw-cat.c:878
50
+#: src/tools/pw-cat.c:879
51
#, c-format
52
#| msgid ""
53
#| " -R, --remote Remote daemon name\n"
54
55
#| " or direct samples (256)\n"
56
#| " the rate is the one of the "
57
#| "source file\n"
58
-#| " --list-targets List available targets for --"
59
-#| "target\n"
60
#| "\n"
61
msgid ""
62
" -R, --remote Remote daemon name\n"
63
64
" or direct samples (256)\n"
65
" the rate is the one of the source "
66
"file\n"
67
+" -P --properties Set node properties\n"
68
"\n"
69
msgstr ""
70
" -R, --remote назва віддаленої фонової служби\n"
71
72
"ns)\n"
73
" або безпосередні семпли (256)\n"
74
" частота — частота з файла джерела\n"
75
+" -P --properties встановити властивості вузла\n"
76
"\n"
77
78
-#: src/tools/pw-cat.c:895
79
+#: src/tools/pw-cat.c:897
80
#, c-format
81
msgid ""
82
" --rate Sample rate (req. for rec) (default "
83
84
"(типово, %d)\n"
85
"\n"
86
87
-#: src/tools/pw-cat.c:912
88
+#: src/tools/pw-cat.c:914
89
msgid ""
90
" -p, --playback Playback mode\n"
91
" -r, --record Recording mode\n"
92
pipewire-0.3.52.tar.gz/spa/examples/adapter-control.c -> pipewire-0.3.53.tar.gz/spa/examples/adapter-control.c
Changed
201
1
2
3
static SPA_LOG_IMPL(default_log);
4
5
-#define MIN_LATENCY 1024
6
+#define MIN_LATENCY 1024
7
+#define CONTROL_BUFFER_SIZE 32768
8
+
9
10
struct buffer {
11
struct spa_buffer buffer;
12
13
struct spa_node *sink_follower_node; // alsa-pcm-sink
14
struct spa_node *sink_node; // adapter for alsa-pcm-sink
15
16
+ struct spa_io_position position;
17
struct spa_io_buffers source_sink_io1;
18
struct spa_buffer *source_buffers1;
19
struct buffer source_buffer1;
20
- uint8_t ctrl1024;
21
+
22
+ struct spa_io_buffers control_io;
23
+ struct spa_buffer *control_buffers1;
24
+ struct buffer control_buffer1;
25
+
26
+ int buffer_count;
27
+ bool start_fade_in;
28
+ double volume_accum;
29
+ uint32_t volume_offs;
30
31
bool running;
32
pthread_t thread;
33
34
str = PLUGINDIR;
35
data->plugin_dir = str;
36
37
+ /* start not doing fade-in */
38
+ data->start_fade_in = true;
39
+ data->volume_accum = 0.0;
40
+ data->volume_offs = 0;
41
+
42
/* init the graph */
43
spa_graph_init(&data->graph, &data->graph_state);
44
45
46
return res;
47
}
48
49
-static int on_sink_node_ready(void *_data, int status)
50
+static int fade_in(struct data *data)
51
{
52
- struct data *data = _data;
53
+ struct spa_pod_builder b;
54
+ struct spa_pod_frame f1;
55
+ void *buffer = data->control_buffer->datas0.data;
56
+ uint32_t buffer_size = data->control_buffer->datas0.maxsize;
57
+ data->control_buffer->datas0.chunk0.size = buffer_size;
58
+
59
+ printf ("fading in\n");
60
+
61
+ spa_pod_builder_init(&b, buffer, buffer_size);
62
+ spa_pod_builder_push_sequence(&b, &f0, 0);
63
+ data->volume_offs = 0;
64
+ do {
65
+ spa_pod_builder_control(&b, data->volume_offs, SPA_CONTROL_Properties);
66
+ spa_pod_builder_add_object(&b,
67
+ SPA_TYPE_OBJECT_Props, 0,
68
+ SPA_PROP_volume, SPA_POD_Float(data->volume_accum));
69
+ data->volume_accum += 0.003;
70
+ data->volume_offs += 200;
71
+ } while (data->volume_accum < 1.0);
72
+ spa_pod_builder_pop(&b, &f0);
73
74
- spa_graph_node_process(&data->graph_source_node);
75
- spa_graph_node_process(&data->graph_sink_node);
76
return 0;
77
}
78
79
-static int
80
-on_sink_node_reuse_buffer(void *_data, uint32_t port_id, uint32_t buffer_id)
81
+static int fade_out(struct data *data)
82
+{
83
+ struct spa_pod_builder b;
84
+ struct spa_pod_frame f1;
85
+ void *buffer = data->control_buffer->datas0.data;
86
+ uint32_t buffer_size = data->control_buffer->datas0.maxsize;
87
+ data->control_buffer->datas0.chunk0.size = buffer_size;
88
+
89
+ printf ("fading out\n");
90
+
91
+ spa_pod_builder_init(&b, buffer, buffer_size);
92
+ spa_pod_builder_push_sequence(&b, &f0, 0);
93
+ data->volume_offs = 200;
94
+ do {
95
+ spa_pod_builder_control(&b, data->volume_offs, SPA_CONTROL_Properties);
96
+ spa_pod_builder_add_object(&b,
97
+ SPA_TYPE_OBJECT_Props, 0,
98
+ SPA_PROP_volume, SPA_POD_Float(data->volume_accum));
99
+ data->volume_accum -= 0.003;
100
+ data->volume_offs += 200;
101
+ } while (data->volume_accum > 0.0);
102
+ spa_pod_builder_pop(&b, &f0);
103
+
104
+ return 0;
105
+}
106
+
107
+static void do_fade(struct data *data)
108
+{
109
+ switch (data->control_io.status) {
110
+ case SPA_STATUS_OK:
111
+ case SPA_STATUS_NEED_DATA:
112
+ break;
113
+ case SPA_STATUS_HAVE_DATA:
114
+ case SPA_STATUS_STOPPED:
115
+ default:
116
+ return;
117
+ }
118
+
119
+ /* fade */
120
+ if (data->start_fade_in)
121
+ fade_in(data);
122
+ else
123
+ fade_out(data);
124
+
125
+ data->control_io.status = SPA_STATUS_HAVE_DATA;
126
+ data->control_io.buffer_id = 0;
127
+
128
+ /* alternate */
129
+ data->start_fade_in = !data->start_fade_in;
130
+}
131
+
132
+static int on_sink_node_ready(void *_data, int status)
133
{
134
struct data *data = _data;
135
136
- printf ("reuse_buffer: port_id=%d\n", port_id);
137
- data->source_sink_io0.buffer_id = buffer_id;
138
+ /* only do fade in/out when buffer count is 0 */
139
+ if (data->buffer_count == 0)
140
+ do_fade(data);
141
+
142
+ /* update buffer count */
143
+ data->buffer_count++;
144
+ if (data->buffer_count > 64)
145
+ data->buffer_count = 0;
146
+
147
+ spa_graph_node_process(&data->graph_source_node);
148
+ spa_graph_node_process(&data->graph_sink_node);
149
return 0;
150
}
151
152
static const struct spa_node_callbacks sink_node_callbacks = {
153
SPA_VERSION_NODE_CALLBACKS,
154
.ready = on_sink_node_ready,
155
- .reuse_buffer = on_sink_node_reuse_buffer
156
};
157
158
static int make_nodes(struct data *data, const char *device)
159
160
struct spa_pod_builder b = { 0 };
161
uint8_t buffer1024;
162
char value32;
163
- struct spa_dict_item items1;
164
+ struct spa_dict_item items2;
165
struct spa_audio_info_raw info;
166
struct spa_pod *param;
167
168
+ items0 = SPA_DICT_ITEM_INIT("clock.quantum-limit", "8192");
169
+
170
/* make the source node (audiotestsrc) */
171
if ((res = make_node(data, &data->source_follower_node,
172
- "audiotestsrc/libspa-audiotestsrc.so",
173
- "audiotestsrc",
174
- NULL)) < 0) {
175
+ "audiotestsrc/libspa-audiotestsrc.so",
176
+ "audiotestsrc",
177
+ &SPA_DICT_INIT(items, 1))) < 0) {
178
printf("can't create source follower node (audiotestsrc): %d\n", res);
179
return res;
180
}
181
182
183
/* make the sink adapter node */
184
snprintf(value, sizeof(value), "pointer:%p", data->source_follower_node);
185
- items0 = SPA_DICT_ITEM_INIT("audio.adapt.follower", value);
186
+ items1 = SPA_DICT_ITEM_INIT("audio.adapt.follower", value);
187
if ((res = make_node(data, &data->source_node,
188
- "audioconvert/libspa-audioconvert.so",
189
- SPA_NAME_AUDIO_ADAPT,
190
- &SPA_DICT_INIT(items, 1))) < 0) {
191
+ "audioconvert/libspa-audioconvert.so",
192
+ SPA_NAME_AUDIO_ADAPT,
193
+ &SPA_DICT_INIT(items, 2))) < 0) {
194
printf("can't create source adapter node: %d\n", res);
195
return res;
196
}
197
198
199
/* make the sink follower node (alsa-pcm-sink) */
200
if ((res = make_node(data, &data->sink_follower_node,
201
pipewire-0.3.52.tar.gz/spa/include/spa/buffer/buffer.h -> pipewire-0.3.53.tar.gz/spa/include/spa/buffer/buffer.h
Changed
11
1
2
int32_t stride; /**< stride of valid data */
3
#define SPA_CHUNK_FLAG_NONE 0
4
#define SPA_CHUNK_FLAG_CORRUPTED (1u<<0) /**< chunk data is corrupted in some way */
5
+#define SPA_CHUNK_FLAG_EMPTY (1u<<1) /**< chunk data is empty with media specific
6
+ * neutral data such as silence or black. This
7
+ * could be used to optimize processing. */
8
int32_t flags; /**< chunk flags */
9
};
10
11
pipewire-0.3.52.tar.gz/spa/include/spa/param/audio/layout.h -> pipewire-0.3.53.tar.gz/spa/include/spa/param/audio/layout.h
Changed
10
1
2
extern "C" {
3
#endif
4
5
-#ifndef __FreeBSD__
6
+#if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
7
#include <endian.h>
8
#endif
9
10
pipewire-0.3.52.tar.gz/spa/include/spa/param/audio/raw.h -> pipewire-0.3.53.tar.gz/spa/include/spa/param/audio/raw.h
Changed
10
1
2
3
#include <stdint.h>
4
5
-#ifndef __FreeBSD__
6
+#if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
7
#include <endian.h>
8
#endif
9
10
pipewire-0.3.52.tar.gz/spa/plugins/alsa/90-pipewire-alsa.rules -> pipewire-0.3.53.tar.gz/spa/plugins/alsa/90-pipewire-alsa.rules
Changed
12
1
2
# Sennheiser GSP 670 USB headset
3
ATTRS{idVendor}=="1395", ATTRS{idProduct}=="008a", ENV{ACP_PROFILE_SET}="usb-gaming-headset.conf"
4
5
+# Audioengine HD3 powered speakers support IEC958 but don't actually
6
+# have any digital outputs.
7
+ATTRS{idVendor}=="0a12", ATTRS{idProduct}=="4007", ENV{ACP_PROFILE_SET}="analog-only.conf"
8
+
9
GOTO="pipewire_end"
10
11
LABEL="pipewire_check_pci"
12
pipewire-0.3.52.tar.gz/spa/plugins/alsa/acp/alsa-util.c -> pipewire-0.3.53.tar.gz/spa/plugins/alsa/acp/alsa-util.c
Changed
15
1
2
{
3
int err;
4
const char *name = snd_hctl_elem_get_name(helem);
5
- if (mask & SND_CTL_EVENT_MASK_ADD) {
6
+ // NOTE: The remove event defined as '~0U`.
7
+ if (mask == SND_CTL_EVENT_MASK_REMOVE) {
8
+ // NOTE: unless remove pointer to melem from link-list at private_data of helem, hits
9
+ // assersion in alsa-lib since the list is not empty.
10
+ snd_mixer_elem_detach(melem, helem);
11
+ } else if (mask & SND_CTL_EVENT_MASK_ADD) {
12
snd_ctl_elem_iface_t iface = snd_hctl_elem_get_interface(helem);
13
if (iface == SND_CTL_ELEM_IFACE_CARD || iface == SND_CTL_ELEM_IFACE_PCM) {
14
snd_mixer_elem_t *new_melem;
15
pipewire-0.3.52.tar.gz/spa/plugins/alsa/alsa-pcm-sink.c -> pipewire-0.3.53.tar.gz/spa/plugins/alsa/alsa-pcm-sink.c
Changed
19
1
2
const struct spa_pod *format)
3
{
4
struct state *this = object;
5
- int err;
6
+ int err = 0;
7
8
if (format == NULL) {
9
if (!this->have_format)
10
11
}
12
emit_port_info(this, false);
13
14
- return 0;
15
+ return err;
16
}
17
18
static int
19
pipewire-0.3.52.tar.gz/spa/plugins/alsa/alsa-pcm-source.c -> pipewire-0.3.53.tar.gz/spa/plugins/alsa/alsa-pcm-source.c
Changed
19
1
2
uint32_t flags, const struct spa_pod *format)
3
{
4
struct state *this = object;
5
- int err;
6
+ int err = 0;
7
8
if (format == NULL) {
9
if (!this->have_format)
10
11
}
12
emit_port_info(this, false);
13
14
- return 0;
15
+ return err;
16
}
17
18
static int
19
pipewire-0.3.52.tar.gz/spa/plugins/alsa/alsa-pcm.c -> pipewire-0.3.53.tar.gz/spa/plugins/alsa/alsa-pcm.c
Changed
159
1
2
state->props.device, rchannels, val);
3
if (!SPA_FLAG_IS_SET(flags, SPA_NODE_PARAM_FLAG_NEAREST))
4
return -EINVAL;
5
+ if (fmt->media_subtype != SPA_MEDIA_SUBTYPE_raw)
6
+ return -EINVAL;
7
rchannels = val;
8
+ fmt->info.raw.channels = rchannels;
9
match = false;
10
}
11
12
13
state->props.device, rrate, val);
14
if (!SPA_FLAG_IS_SET(flags, SPA_NODE_PARAM_FLAG_NEAREST))
15
return -EINVAL;
16
+ if (fmt->media_subtype != SPA_MEDIA_SUBTYPE_raw)
17
+ return -EINVAL;
18
rrate = val;
19
+ fmt->info.raw.rate = rrate;
20
match = false;
21
}
22
23
24
snd_pcm_uframes_t written, frames, offset, off, to_write, total_written, max_write;
25
snd_pcm_sframes_t commitres;
26
int res = 0;
27
+ size_t frame_size = state->frame_size;
28
29
check_position_config(state);
30
31
32
written = 0;
33
34
while (!spa_list_is_empty(&state->ready) && to_write > 0) {
35
- uint8_t *dst, *src;
36
size_t n_bytes, n_frames;
37
struct buffer *b;
38
struct spa_data *d;
39
- uint32_t i, index, offs, avail, size, maxsize, l0, l1;
40
+ uint32_t i, offs, size;
41
42
b = spa_list_first(&state->ready, struct buffer, link);
43
d = b->buf->datas;
44
45
- size = d0.chunk->size;
46
- maxsize = d0.maxsize;
47
-
48
- index = d0.chunk->offset + state->ready_offset;
49
- avail = size - state->ready_offset;
50
- avail /= state->frame_size;
51
+ offs = d0.chunk->offset + state->ready_offset;
52
+ size = d0.chunk->size - state->ready_offset;
53
54
- n_frames = SPA_MIN(avail, to_write);
55
- n_bytes = n_frames * state->frame_size;
56
+ offs = SPA_MIN(offs, d0.maxsize);
57
+ size = SPA_MIN(d0.maxsize - offs, size);
58
59
- offs = index % maxsize;
60
- l0 = SPA_MIN(n_bytes, maxsize - offs);
61
- l1 = n_bytes - l0;
62
+ n_frames = SPA_MIN(size / frame_size, to_write);
63
+ n_bytes = n_frames * frame_size;
64
65
if (SPA_LIKELY(state->use_mmap)) {
66
for (i = 0; i < b->buf->n_datas; i++) {
67
- dst = SPA_PTROFF(my_areasi.addr, off * state->frame_size, uint8_t);
68
- src = di.data;
69
-
70
- spa_memcpy(dst, src + offs, l0);
71
- if (SPA_UNLIKELY(l1 > 0))
72
- spa_memcpy(dst + l0, src, l1);
73
+ spa_memcpy(SPA_PTROFF(my_areasi.addr, off * frame_size, void),
74
+ SPA_PTROFF(di.data, offs, void), n_bytes);
75
}
76
} else {
77
- if (state->planar) {
78
- void *bufsb->buf->n_datas;
79
-
80
- for (i = 0; i < b->buf->n_datas; i++)
81
- bufsi = SPA_PTROFF(di.data, offs, void);
82
- snd_pcm_writen(hndl, bufs, l0 / state->frame_size);
83
- if (SPA_UNLIKELY(l1 > 0)) {
84
- for (i = 0; i < b->buf->n_datas; i++)
85
- bufsi = di.data;
86
- snd_pcm_writen(hndl, bufs, l1 / state->frame_size);
87
- }
88
- } else {
89
- src = d0.data;
90
- snd_pcm_writei(hndl, src + offs, l0 / state->frame_size);
91
- if (SPA_UNLIKELY(l1 > 0))
92
- snd_pcm_writei(hndl, src, l1 / state->frame_size);
93
- }
94
+ void *bufsb->buf->n_datas;
95
+ for (i = 0; i < b->buf->n_datas; i++)
96
+ bufsi = SPA_PTROFF(di.data, offs, void);
97
+
98
+ if (state->planar)
99
+ snd_pcm_writen(hndl, bufs, n_frames);
100
+ else
101
+ snd_pcm_writei(hndl, bufs0, n_frames);
102
}
103
104
state->ready_offset += n_bytes;
105
106
spa_log_warn(state->log, "%s: no more buffers", state->props.device);
107
total_frames = frames;
108
} else {
109
- uint8_t *src;
110
- size_t n_bytes, left;
111
+ size_t n_bytes, left, frame_size = state->frame_size;
112
struct buffer *b;
113
struct spa_data *d;
114
uint32_t i, avail, l0, l1;
115
116
117
d = b->buf->datas;
118
119
- avail = d0.maxsize / state->frame_size;
120
+ avail = d0.maxsize / frame_size;
121
total_frames = SPA_MIN(avail, frames);
122
- n_bytes = total_frames * state->frame_size;
123
+ n_bytes = total_frames * frame_size;
124
125
if (my_areas) {
126
left = state->buffer_frames - offset;
127
- l0 = SPA_MIN(n_bytes, left * state->frame_size);
128
+ l0 = SPA_MIN(n_bytes, left * frame_size);
129
l1 = n_bytes - l0;
130
131
for (i = 0; i < b->buf->n_datas; i++) {
132
- src = SPA_PTROFF(my_areasi.addr, offset * state->frame_size, uint8_t);
133
- spa_memcpy(di.data, src, l0);
134
- if (l1 > 0)
135
- spa_memcpy(SPA_PTROFF(di.data, l0, void), my_areasi.addr, l1);
136
+ spa_memcpy(di.data,
137
+ SPA_PTROFF(my_areasi.addr, offset * frame_size, void),
138
+ l0);
139
+ if (SPA_UNLIKELY(l1 > 0))
140
+ spa_memcpy(SPA_PTROFF(di.data, l0, void),
141
+ my_areasi.addr,
142
+ l1);
143
di.chunk->offset = 0;
144
di.chunk->size = n_bytes;
145
- di.chunk->stride = state->frame_size;
146
+ di.chunk->stride = frame_size;
147
}
148
} else {
149
void *bufsb->buf->n_datas;
150
151
bufsi = di.data;
152
di.chunk->offset = 0;
153
di.chunk->size = n_bytes;
154
- di.chunk->stride = state->frame_size;
155
+ di.chunk->stride = frame_size;
156
}
157
if (state->planar) {
158
snd_pcm_readn(state->hndl, bufs, total_frames);
159
pipewire-0.3.52.tar.gz/spa/plugins/alsa/alsa-seq.c -> pipewire-0.3.53.tar.gz/spa/plugins/alsa/alsa-seq.c
Changed
46
1
2
static int init_stream(struct seq_state *state, enum spa_direction direction)
3
{
4
struct seq_stream *stream = &state->streamsdirection;
5
+ int res;
6
stream->direction = direction;
7
if (direction == SPA_DIRECTION_INPUT) {
8
stream->caps = SND_SEQ_PORT_CAP_SUBS_WRITE;
9
} else {
10
stream->caps = SND_SEQ_PORT_CAP_SUBS_READ;
11
}
12
- snd_midi_event_new(MAX_EVENT_SIZE, &stream->codec);
13
+ if ((res = snd_midi_event_new(MAX_EVENT_SIZE, &stream->codec)) < 0) {
14
+ spa_log_error(state->log, "can make event decoder: %s",
15
+ snd_strerror(res));
16
+ return res;
17
+ }
18
+ snd_midi_event_no_status(stream->codec, 1);
19
memset(stream->ports, 0, sizeof(stream->ports));
20
return 0;
21
}
22
23
static int uninit_stream(struct seq_state *state, enum spa_direction direction)
24
{
25
struct seq_stream *stream = &state->streamsdirection;
26
- snd_midi_event_free(stream->codec);
27
+ if (stream->codec)
28
+ snd_midi_event_free(stream->codec);
29
+ stream->codec = NULL;
30
return 0;
31
}
32
33
34
continue;
35
}
36
37
- /* fixup NoteOn with vel 0 */
38
- if ((data0 & 0xF0) == 0x90 && data2 == 0x00) {
39
- data0 = 0x80 + (data0 & 0x0F);
40
- data2 = 0x40;
41
- }
42
-
43
/* queue_time is the estimated current time of the queue as calculated by
44
* the DLL. Calculate the age of the event. */
45
ev_time = SPA_TIMESPEC_TO_NSEC(&ev->time.time);
46
pipewire-0.3.52.tar.gz/spa/plugins/alsa/alsa-udev.c -> pipewire-0.3.53.tar.gz/spa/plugins/alsa/alsa-udev.c
Changed
37
1
2
if ((str = udev_device_get_property_value(dev, "SUBSYSTEM")) && *str) {
3
itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SUBSYSTEM, str);
4
}
5
- if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) {
6
- char *dec = alloca(6); /* 65535 is max */
7
- int32_t val;
8
+ if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str)
9
+ itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, str);
10
11
- if (spa_atoi32(str, &val, 16)) {
12
- snprintf(dec, 6, "%d", val);
13
- itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, dec);
14
- }
15
- }
16
str = udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE");
17
if (!(str && *str)) {
18
str = udev_device_get_property_value(dev, "ID_VENDOR_ENC");
19
20
if (str && *str) {
21
itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_NAME, str);
22
}
23
- if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) {
24
- char *dec = alloca(6); /* 65535 is max */
25
- int32_t val;
26
+ if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str)
27
+ itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, str);
28
29
- if (spa_atoi32(str, &val, 16)) {
30
- snprintf(dec, 6, "%d", val);
31
- itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, dec);
32
- }
33
- }
34
str = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE");
35
if (!(str && *str)) {
36
str = udev_device_get_property_value(dev, "ID_MODEL_ENC");
37
pipewire-0.3.53.tar.gz/spa/plugins/alsa/mixer/profile-sets/analog-only.conf
Added
104
1
2
+# PulseAudio is free software; you can redistribute it and/or modify
3
+# it under the terms of the GNU Lesser General Public License as
4
+# published by the Free Software Foundation; either version 2.1 of the
5
+# License, or (at your option) any later version.
6
+#
7
+# PulseAudio is distributed in the hope that it will be useful, but
8
+# WITHOUT ANY WARRANTY; without even the implied warranty of
9
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+# General Public License for more details.
11
+#
12
+# You should have received a copy of the GNU Lesser General Public License
13
+# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
14
+
15
+; Some USB DACs appear to support IEC958, but don't physically have any
16
+; digital outputs.
17
+
18
+General
19
+auto-profiles = yes
20
+
21
+Mapping analog-stereo
22
+device-strings = front:%f
23
+channel-map = left,right
24
+paths-output = analog-output analog-output-lineout analog-output-speaker analog-output-headphones analog-output-headphones-2
25
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic analog-input-headset-mic
26
+priority = 15
27
+
28
+# If everything else fails, try to use hw:0 as a stereo device...
29
+Mapping stereo-fallback
30
+device-strings = hw:%f
31
+fallback = yes
32
+channel-map = front-left,front-right
33
+paths-output = analog-output analog-output-lineout analog-output-speaker analog-output-headphones analog-output-headphones-2
34
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic analog-input-headset-mic
35
+priority = 1
36
+
37
+# ...and if even that fails, try to use hw:0 as a mono device.
38
+Mapping mono-fallback
39
+device-strings = hw:%f
40
+fallback = yes
41
+channel-map = mono
42
+paths-output = analog-output analog-output-lineout analog-output-speaker analog-output-headphones analog-output-headphones-2 analog-output-mono
43
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headset-mic
44
+priority = 1
45
+
46
+Mapping analog-surround-21
47
+device-strings = surround21:%f
48
+channel-map = front-left,front-right,lfe
49
+paths-input = analog-input analog-input-linein analog-input-mic
50
+paths-output = analog-output analog-output-lineout analog-output-speaker
51
+priority = 13
52
+
53
+Mapping analog-surround-40
54
+device-strings = surround40:%f
55
+channel-map = front-left,front-right,rear-left,rear-right
56
+paths-input = analog-input analog-input-linein analog-input-mic
57
+paths-output = analog-output analog-output-lineout analog-output-speaker
58
+priority = 12
59
+
60
+Mapping analog-surround-41
61
+device-strings = surround41:%f
62
+channel-map = front-left,front-right,rear-left,rear-right,lfe
63
+paths-input = analog-input analog-input-linein analog-input-mic
64
+paths-output = analog-output analog-output-lineout analog-output-speaker
65
+priority = 13
66
+
67
+Mapping analog-surround-50
68
+device-strings = surround50:%f
69
+channel-map = front-left,front-right,rear-left,rear-right,front-center
70
+paths-input = analog-input analog-input-linein analog-input-mic
71
+paths-output = analog-output analog-output-lineout analog-output-speaker
72
+priority = 12
73
+
74
+Mapping analog-surround-51
75
+device-strings = surround51:%f
76
+channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe
77
+paths-input = analog-input analog-input-linein analog-input-mic
78
+paths-output = analog-output analog-output-lineout analog-output-speaker
79
+priority = 13
80
+
81
+Mapping analog-surround-71
82
+device-strings = surround71:%f
83
+channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right
84
+description = Analog Surround 7.1
85
+paths-input = analog-input analog-input-linein analog-input-mic
86
+paths-output = analog-output analog-output-lineout analog-output-speaker
87
+priority = 12
88
+
89
+Mapping multichannel-output
90
+device-strings = hw:%f
91
+channel-map = left,right,rear-left,rear-right
92
+exact-channels = false
93
+fallback = yes
94
+priority = 1
95
+direction = output
96
+
97
+Mapping multichannel-input
98
+device-strings = hw:%f
99
+channel-map = left,right,rear-left,rear-right
100
+exact-channels = false
101
+fallback = yes
102
+priority = 1
103
+direction = input
104
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/audioadapter.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/audioadapter.c
Changed
109
1
2
3
#define DEFAULT_ALIGN 16
4
5
-#define MAX_PORTS SPA_AUDIO_MAX_CHANNELS
6
+#define MAX_PORTS (SPA_AUDIO_MAX_CHANNELS+1)
7
8
/** \cond */
9
10
11
if (format && spa_log_level_enabled(this->log, SPA_LOG_LEVEL_DEBUG))
12
spa_debug_format(0, NULL, format);
13
14
+ if ((res = spa_node_port_set_param(this->follower,
15
+ this->direction, 0,
16
+ SPA_PARAM_Format, flags,
17
+ format)) < 0)
18
+ return res;
19
+ if (res > 0) {
20
+ uint8_t buffer4096;
21
+ struct spa_pod_builder b = { 0 };
22
+ uint32_t state = 0;
23
+ struct spa_pod *fmt;
24
+
25
+ /* format was changed to nearest compatible format */
26
+ spa_pod_builder_init(&b, buffer, sizeof(buffer));
27
+
28
+ if ((res = spa_node_port_enum_params_sync(this->follower,
29
+ this->direction, 0,
30
+ SPA_PARAM_Format, &state,
31
+ NULL, &fmt, &b)) != 1)
32
+ return -EIO;
33
+
34
+ format = fmt;
35
+ }
36
+
37
if (this->target != this->follower && this->convert) {
38
if ((res = spa_node_port_set_param(this->convert,
39
SPA_DIRECTION_REVERSE(this->direction), 0,
40
41
return res;
42
}
43
44
- if ((res = spa_node_port_set_param(this->follower,
45
- this->direction, 0,
46
- SPA_PARAM_Format, flags,
47
- format)) < 0)
48
- return res;
49
-
50
this->have_format = format != NULL;
51
if (format == NULL) {
52
this->n_buffers = 0;
53
54
int res = 0;
55
struct spa_hook l;
56
57
- spa_log_debug(this->log, "%p: passthrough mode %d", this, passthrough);
58
+ spa_log_info(this->log, "%p: passthrough mode %d", this, passthrough);
59
60
if (this->passthrough != passthrough) {
61
if (passthrough) {
62
63
/* set new target */
64
this->target = passthrough ? this->follower : this->convert;
65
66
- if ((res = configure_format(this, 0, format)) < 0)
67
+ if ((res = configure_format(this, SPA_NODE_PARAM_FLAG_NEAREST, format)) < 0)
68
return res;
69
70
if (this->passthrough != passthrough) {
71
72
enum spa_direction dir;
73
enum spa_param_port_config_mode mode;
74
struct spa_pod *format = NULL;
75
- int monitor = false;
76
77
if (this->started) {
78
spa_log_error(this->log, "was started");
79
80
SPA_TYPE_OBJECT_ParamPortConfig, NULL,
81
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(&dir),
82
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(&mode),
83
- SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_OPT_Bool(&monitor),
84
SPA_PARAM_PORT_CONFIG_format, SPA_POD_OPT_Pod(&format)) < 0)
85
return -EINVAL;
86
87
88
89
spa_pod_fixate(format);
90
91
- res = configure_format(this, 0, format);
92
+ res = configure_format(this, SPA_NODE_PARAM_FLAG_NEAREST, format);
93
94
done:
95
spa_node_send_command(this->follower,
96
97
uint32_t idx;
98
99
switch (info->paramsi.id) {
100
+ case SPA_PARAM_EnumPortConfig:
101
+ idx = IDX_EnumPortConfig;
102
+ break;
103
+ case SPA_PARAM_PortConfig:
104
+ idx = IDX_PortConfig;
105
+ break;
106
case SPA_PARAM_PropInfo:
107
idx = IDX_PropInfo;
108
break;
109
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/audioconvert.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/audioconvert.c
Changed
201
1
2
/* Spa
3
*
4
- * Copyright © 2018 Wim Taymans
5
+ * Copyright © 2022 Wim Taymans
6
*
7
* Permission is hereby granted, free of charge, to any person obtaining a
8
* copy of this software and associated documentation files (the "Software"),
9
10
#include <errno.h>
11
#include <string.h>
12
#include <stdio.h>
13
+#include <limits.h>
14
15
#include <spa/support/plugin.h>
16
-#include <spa/support/log.h>
17
#include <spa/support/cpu.h>
18
+#include <spa/support/log.h>
19
#include <spa/utils/result.h>
20
#include <spa/utils/list.h>
21
#include <spa/utils/names.h>
22
#include <spa/utils/string.h>
23
#include <spa/node/node.h>
24
-#include <spa/buffer/alloc.h>
25
#include <spa/node/io.h>
26
#include <spa/node/utils.h>
27
+#include <spa/node/keys.h>
28
#include <spa/param/audio/format-utils.h>
29
#include <spa/param/param.h>
30
+#include <spa/param/latency-utils.h>
31
#include <spa/pod/filter.h>
32
-#include <spa/debug/pod.h>
33
#include <spa/debug/types.h>
34
+#include <spa/debug/pod.h>
35
+
36
+#include "volume-ops.h"
37
+#include "fmt-ops.h"
38
+#include "channelmix-ops.h"
39
+#include "resample.h"
40
41
#undef SPA_LOG_TOPIC_DEFAULT
42
#define SPA_LOG_TOPIC_DEFAULT log_topic
43
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audioconvert");
44
45
-#define DEFAULT_ALIGN 16
46
+#define DEFAULT_RATE 48000
47
+#define DEFAULT_CHANNELS 2
48
+
49
+#define MAX_ALIGN FMT_OPS_MAX_ALIGN
50
+#define MAX_BUFFERS 32
51
+#define MAX_DATAS SPA_AUDIO_MAX_CHANNELS
52
+#define MAX_PORTS (SPA_AUDIO_MAX_CHANNELS+1)
53
+
54
+#define DEFAULT_MUTE false
55
+#define DEFAULT_VOLUME VOLUME_NORM
56
+
57
+struct volumes {
58
+ bool mute;
59
+ uint32_t n_volumes;
60
+ float volumesSPA_AUDIO_MAX_CHANNELS;
61
+};
62
+
63
+static void init_volumes(struct volumes *vol)
64
+{
65
+ uint32_t i;
66
+ vol->mute = DEFAULT_MUTE;
67
+ vol->n_volumes = 0;
68
+ for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
69
+ vol->volumesi = DEFAULT_VOLUME;
70
+}
71
+
72
+struct props {
73
+ float volume;
74
+ uint32_t n_channels;
75
+ uint32_t channel_mapSPA_AUDIO_MAX_CHANNELS;
76
+ struct volumes channel;
77
+ struct volumes soft;
78
+ struct volumes monitor;
79
+ unsigned int have_soft_volume:1;
80
+ unsigned int mix_disabled:1;
81
+ unsigned int resample_quality;
82
+ unsigned int resample_disabled:1;
83
+ double rate;
84
+};
85
86
-#define MAX_PORTS SPA_AUDIO_MAX_CHANNELS
87
+static void props_reset(struct props *props)
88
+{
89
+ uint32_t i;
90
+ props->volume = DEFAULT_VOLUME;
91
+ props->n_channels = 0;
92
+ for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
93
+ props->channel_mapi = SPA_AUDIO_CHANNEL_UNKNOWN;
94
+ init_volumes(&props->channel);
95
+ init_volumes(&props->soft);
96
+ init_volumes(&props->monitor);
97
+ props->mix_disabled = false;
98
+ props->rate = 1.0;
99
+ props->resample_quality = RESAMPLE_DEFAULT_QUALITY;
100
+ props->resample_disabled = false;
101
+}
102
103
struct buffer {
104
- struct spa_list link;
105
-#define BUFFER_FLAG_OUT (1 << 0)
106
+ uint32_t id;
107
+#define BUFFER_FLAG_QUEUED (1<<0)
108
uint32_t flags;
109
- struct spa_buffer *outbuf;
110
- struct spa_meta_header *h;
111
+ struct spa_list link;
112
+ struct spa_buffer *buf;
113
+ void *datasMAX_DATAS;
114
};
115
116
-struct link {
117
- struct spa_node *out_node;
118
- uint32_t out_port;
119
- uint32_t out_flags;
120
- struct spa_node *in_node;
121
- uint32_t in_port;
122
- uint32_t in_flags;
123
- struct spa_io_buffers io;
124
- uint32_t min_buffers;
125
+struct port {
126
+ uint32_t direction;
127
+ uint32_t id;
128
+
129
+ struct spa_io_buffers *io;
130
+
131
+ uint64_t info_all;
132
+ struct spa_port_info info;
133
+#define IDX_EnumFormat 0
134
+#define IDX_Meta 1
135
+#define IDX_IO 2
136
+#define IDX_Format 3
137
+#define IDX_Buffers 4
138
+#define IDX_Latency 5
139
+#define N_PORT_PARAMS 6
140
+ struct spa_param_info paramsN_PORT_PARAMS;
141
+ char position16;
142
+
143
+ struct buffer buffersMAX_BUFFERS;
144
uint32_t n_buffers;
145
- struct spa_buffer **buffers;
146
- unsigned int negotiated:1;
147
+
148
+ struct spa_audio_info format;
149
+ unsigned int have_format:1;
150
+ unsigned int is_dsp:1;
151
+ unsigned int is_monitor:1;
152
+ unsigned int is_control:1;
153
+
154
+ uint32_t blocks;
155
+ uint32_t stride;
156
+
157
+ const struct spa_pod_sequence *ctrl;
158
+ uint32_t ctrl_offset;
159
+
160
+ struct spa_list queue;
161
+};
162
+
163
+struct dir {
164
+ struct port *portsMAX_PORTS;
165
+ uint32_t n_ports;
166
+
167
+ enum spa_param_port_config_mode mode;
168
+
169
+ struct spa_audio_info format;
170
+ unsigned int have_format:1;
171
+ unsigned int have_profile:1;
172
+ struct spa_latency_info latency;
173
+
174
+ uint32_t src_remapMAX_PORTS;
175
+ uint32_t dst_remapMAX_PORTS;
176
+
177
+ struct convert conv;
178
+ unsigned int is_passthrough:1;
179
+ unsigned int control:1;
180
};
181
182
struct impl {
183
184
struct spa_log *log;
185
struct spa_cpu *cpu;
186
187
+ uint32_t cpu_flags;
188
uint32_t max_align;
189
+ uint32_t quantum_limit;
190
+ enum spa_direction direction;
191
192
- struct spa_hook_list hooks;
193
+ struct props props;
194
+
195
+ struct spa_io_position *io_position;
196
+ struct spa_io_rate_match *io_rate_match;
197
198
uint64_t info_all;
199
struct spa_node_info info;
200
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/channelmix-ops-c.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/channelmix-ops-c.c
Changed
101
1
2
channelmix_f32_2_4_c(struct channelmix *mix, void * SPA_RESTRICT dst,
3
const void * SPA_RESTRICT src, uint32_t n_samples)
4
{
5
+ uint32_t i, n_dst = mix->dst_chan;
6
float **d = (float **)dst;
7
const float **s = (const float **)src;
8
const float v0 = mix->matrix00;
9
10
const float v2 = mix->matrix20;
11
const float v3 = mix->matrix31;
12
13
- vol_c(d0, s0, v0, n_samples);
14
- vol_c(d1, s1, v1, n_samples);
15
- vol_c(d2, s0, v2, n_samples);
16
- vol_c(d3, s1, v3, n_samples);
17
+ if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
18
+ for (i = 0; i < n_dst; i++)
19
+ clear_c(di, n_samples);
20
+ }
21
+ else {
22
+ vol_c(d0, s0, v0, n_samples);
23
+ vol_c(d1, s1, v1, n_samples);
24
+ if (mix->upmix != CHANNELMIX_UPMIX_PSD) {
25
+ vol_c(d2, s0, v2, n_samples);
26
+ vol_c(d3, s1, v3, n_samples);
27
+ } else {
28
+ sub_c(d2, s0, s1, n_samples);
29
+
30
+ delay_convolve_run(mix->buffer1, &mix->pos1, BUFFER_SIZE, mix->delay,
31
+ mix->taps, mix->n_taps, d3, d2, -v3, n_samples);
32
+ delay_convolve_run(mix->buffer0, &mix->pos0, BUFFER_SIZE, mix->delay,
33
+ mix->taps, mix->n_taps, d2, d2, v2, n_samples);
34
+ }
35
+ }
36
}
37
38
#define MASK_3_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)
39
40
}
41
}
42
43
+/* FL+FR+FC+LFE -> FL+FR */
44
+void
45
+channelmix_f32_3p1_2_c(struct channelmix *mix, void * SPA_RESTRICT dst,
46
+ const void * SPA_RESTRICT src, uint32_t n_samples)
47
+{
48
+ uint32_t n;
49
+ float **d = (float **) dst;
50
+ const float **s = (const float **) src;
51
+ const float v0 = mix->matrix00;
52
+ const float v1 = mix->matrix11;
53
+ const float clev = (mix->matrix02 + mix->matrix12) * 0.5f;
54
+ const float llev = (mix->matrix03 + mix->matrix13) * 0.5f;
55
+
56
+ if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
57
+ clear_c(d0, n_samples);
58
+ clear_c(d1, n_samples);
59
+ }
60
+ else {
61
+ for (n = 0; n < n_samples; n++) {
62
+ const float ctr = clev * s2n + llev * s3n;
63
+ d0n = s0n * v0 + ctr;
64
+ d1n = s1n * v1 + ctr;
65
+ }
66
+ }
67
+}
68
+
69
/* FL+FR+FC+LFE+SL+SR -> FL+FR */
70
void
71
channelmix_f32_5p1_2_c(struct channelmix *mix, void * SPA_RESTRICT dst,
72
73
channelmix_f32_5p1_4_c(struct channelmix *mix, void * SPA_RESTRICT dst,
74
const void * SPA_RESTRICT src, uint32_t n_samples)
75
{
76
- uint32_t i, n, n_dst = mix->dst_chan;
77
+ uint32_t i, n_dst = mix->dst_chan;
78
float **d = (float **) dst;
79
const float **s = (const float **) src;
80
- const float clev = mix->matrix02;
81
- const float llev = mix->matrix03;
82
- const float v0 = mix->matrix00;
83
- const float v1 = mix->matrix11;
84
const float v4 = mix->matrix24;
85
const float v5 = mix->matrix35;
86
87
88
clear_c(di, n_samples);
89
}
90
else {
91
- for (n = 0; n < n_samples; n++) {
92
- const float ctr = s2n * clev + s3n * llev;
93
- d0n = s0n * v0 + ctr;
94
- d1n = s1n * v1 + ctr;
95
- }
96
+ channelmix_f32_3p1_2_c(mix, dst, src, n_samples);
97
+
98
vol_c(d2, s4, v4, n_samples);
99
vol_c(d3, s5, v5, n_samples);
100
}
101
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/channelmix-ops-sse.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/channelmix-ops-sse.c
Changed
201
1
2
3
#include <xmmintrin.h>
4
5
-void channelmix_copy_sse(struct channelmix *mix, void * SPA_RESTRICT dst,
6
- const void * SPA_RESTRICT src, uint32_t n_samples)
7
+static inline void clear_sse(float *d, uint32_t n_samples)
8
{
9
- uint32_t i, n, unrolled, n_dst = mix->dst_chan;
10
- float **d = (float **)dst;
11
- const float **s = (const float **)src;
12
+ memset(d, 0, n_samples * sizeof(float));
13
+}
14
15
- if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
16
- for (i = 0; i < n_dst; i++)
17
- memset(di, 0, n_samples * sizeof(float));
18
- }
19
- else if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_IDENTITY)) {
20
- for (i = 0; i < n_dst; i++)
21
- spa_memcpy(di, si, n_samples * sizeof(float));
22
- }
23
- else {
24
- for (i = 0; i < n_dst; i++) {
25
- float *di = di;
26
- const float *si = si;
27
- __m128 t4;
28
- const __m128 vol = _mm_set1_ps(mix->matrixii);
29
+static inline void copy_sse(float *d, const float *s, uint32_t n_samples)
30
+{
31
+ spa_memcpy(d, s, n_samples * sizeof(float));
32
+}
33
34
- if (SPA_IS_ALIGNED(di, 16) &&
35
- SPA_IS_ALIGNED(si, 16))
36
- unrolled = n_samples & ~15;
37
- else
38
- unrolled = 0;
39
+static inline void vol_sse(float *d, const float *s, float vol, uint32_t n_samples)
40
+{
41
+ uint32_t n, unrolled;
42
+ if (vol == 0.0f) {
43
+ clear_sse(d, n_samples);
44
+ } else if (vol == 1.0f) {
45
+ copy_sse(d, s, n_samples);
46
+ } else {
47
+ __m128 t4;
48
+ const __m128 v = _mm_set1_ps(vol);
49
+
50
+ if (SPA_IS_ALIGNED(d, 16) &&
51
+ SPA_IS_ALIGNED(s, 16))
52
+ unrolled = n_samples & ~15;
53
+ else
54
+ unrolled = 0;
55
56
- for(n = 0; n < unrolled; n += 16) {
57
- t0 = _mm_load_ps(&sin);
58
- t1 = _mm_load_ps(&sin+4);
59
- t2 = _mm_load_ps(&sin+8);
60
- t3 = _mm_load_ps(&sin+12);
61
- _mm_store_ps(&din, _mm_mul_ps(t0, vol));
62
- _mm_store_ps(&din+4, _mm_mul_ps(t1, vol));
63
- _mm_store_ps(&din+8, _mm_mul_ps(t2, vol));
64
- _mm_store_ps(&din+12, _mm_mul_ps(t3, vol));
65
- }
66
- for(; n < n_samples; n++)
67
- _mm_store_ss(&din, _mm_mul_ss(_mm_load_ss(&sin), vol));
68
+ for(n = 0; n < unrolled; n += 16) {
69
+ t0 = _mm_load_ps(&sn);
70
+ t1 = _mm_load_ps(&sn+4);
71
+ t2 = _mm_load_ps(&sn+8);
72
+ t3 = _mm_load_ps(&sn+12);
73
+ _mm_store_ps(&dn, _mm_mul_ps(t0, v));
74
+ _mm_store_ps(&dn+4, _mm_mul_ps(t1, v));
75
+ _mm_store_ps(&dn+8, _mm_mul_ps(t2, v));
76
+ _mm_store_ps(&dn+12, _mm_mul_ps(t3, v));
77
}
78
+ for(; n < n_samples; n++)
79
+ _mm_store_ss(&dn, _mm_mul_ss(_mm_load_ss(&sn), v));
80
}
81
}
82
83
-void
84
-channelmix_f32_2_4_sse(struct channelmix *mix, void * SPA_RESTRICT dst,
85
+void channelmix_copy_sse(struct channelmix *mix, void * SPA_RESTRICT dst,
86
const void * SPA_RESTRICT src, uint32_t n_samples)
87
{
88
- uint32_t i, n, unrolled, n_dst = mix->dst_chan;
89
+ uint32_t i, n_dst = mix->dst_chan;
90
float **d = (float **)dst;
91
const float **s = (const float **)src;
92
- const float m00 = mix->matrix00;
93
- const float m11 = mix->matrix11;
94
- __m128 in;
95
- const float *sFL = s0, *sFR = s1;
96
- float *dFL = d0, *dFR = d1, *dRL = d2, *dRR = d3;
97
+ for (i = 0; i < n_dst; i++)
98
+ vol_sse(di, si, mix->matrixii, n_samples);
99
+}
100
101
- if (SPA_IS_ALIGNED(sFL, 16) &&
102
- SPA_IS_ALIGNED(sFR, 16) &&
103
- SPA_IS_ALIGNED(dFL, 16) &&
104
- SPA_IS_ALIGNED(dFR, 16) &&
105
- SPA_IS_ALIGNED(dRL, 16) &&
106
- SPA_IS_ALIGNED(dRR, 16))
107
- unrolled = n_samples & ~3;
108
- else
109
- unrolled = 0;
110
+/* FL+FR+FC+LFE -> FL+FR */
111
+void
112
+channelmix_f32_3p1_2_sse(struct channelmix *mix, void * SPA_RESTRICT dst,
113
+ const void * SPA_RESTRICT src, uint32_t n_samples)
114
+{
115
+ float **d = (float **) dst;
116
+ const float **s = (const float **) src;
117
+ const float m0 = mix->matrix00;
118
+ const float m1 = mix->matrix11;
119
+ const float m2 = (mix->matrix02 + mix->matrix12) * 0.5f;
120
+ const float m3 = (mix->matrix03 + mix->matrix13) * 0.5f;
121
122
- if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
123
- for (i = 0; i < n_dst; i++)
124
- memset(di, 0, n_samples * sizeof(float));
125
- }
126
- else if (m00 == 1.0f && m11 == 1.0f) {
127
- for(n = 0; n < unrolled; n += 4) {
128
- in = _mm_load_ps(&sFLn);
129
- _mm_store_ps(&dFLn, in);
130
- _mm_store_ps(&dRLn, in);
131
- in = _mm_load_ps(&sFRn);
132
- _mm_store_ps(&dFRn, in);
133
- _mm_store_ps(&dRRn, in);
134
- }
135
- for(; n < n_samples; n++) {
136
- in = _mm_load_ss(&sFLn);
137
- _mm_store_ss(&dFLn, in);
138
- _mm_store_ss(&dRLn, in);
139
- in = _mm_load_ss(&sFRn);
140
- _mm_store_ss(&dFRn, in);
141
- _mm_store_ss(&dRRn, in);
142
- }
143
+ if (m0 == 0.0f && m1 == 0.0f && m2 == 0.0f && m3 == 0.0f) {
144
+ clear_sse(d0, n_samples);
145
+ clear_sse(d1, n_samples);
146
}
147
else {
148
- const __m128 v0 = _mm_set1_ps(m00);
149
- const __m128 v1 = _mm_set1_ps(m11);
150
+ uint32_t n, unrolled;
151
+ const __m128 v0 = _mm_set1_ps(m0);
152
+ const __m128 v1 = _mm_set1_ps(m1);
153
+ const __m128 clev = _mm_set1_ps(m2);
154
+ const __m128 llev = _mm_set1_ps(m3);
155
+ __m128 ctr;
156
+
157
+ if (SPA_IS_ALIGNED(s0, 16) &&
158
+ SPA_IS_ALIGNED(s1, 16) &&
159
+ SPA_IS_ALIGNED(s2, 16) &&
160
+ SPA_IS_ALIGNED(s3, 16) &&
161
+ SPA_IS_ALIGNED(d0, 16) &&
162
+ SPA_IS_ALIGNED(d1, 16))
163
+ unrolled = n_samples & ~3;
164
+ else
165
+ unrolled = 0;
166
+
167
for(n = 0; n < unrolled; n += 4) {
168
- in = _mm_mul_ps(_mm_load_ps(&sFLn), v0);
169
- _mm_store_ps(&dFLn, in);
170
- _mm_store_ps(&dRLn, in);
171
- in = _mm_mul_ps(_mm_load_ps(&sFRn), v1);
172
- _mm_store_ps(&dFRn, in);
173
- _mm_store_ps(&dRRn, in);
174
+ ctr = _mm_add_ps(
175
+ _mm_mul_ps(_mm_load_ps(&s2n), clev),
176
+ _mm_mul_ps(_mm_load_ps(&s3n), llev));
177
+ _mm_store_ps(&d0n, _mm_add_ps(_mm_mul_ps(_mm_load_ps(&s0n), v0), ctr));
178
+ _mm_store_ps(&d1n, _mm_add_ps(_mm_mul_ps(_mm_load_ps(&s1n), v1), ctr));
179
}
180
for(; n < n_samples; n++) {
181
- in = _mm_mul_ss(_mm_load_ss(&sFLn), v0);
182
- _mm_store_ss(&dFLn, in);
183
- _mm_store_ss(&dRLn, in);
184
- in = _mm_mul_ss(_mm_load_ss(&sFRn), v1);
185
- _mm_store_ss(&dFRn, in);
186
- _mm_store_ss(&dRRn, in);
187
+ ctr = _mm_add_ss(_mm_mul_ss(_mm_load_ss(&s2n), clev),
188
+ _mm_mul_ss(_mm_load_ss(&s3n), llev));
189
+ _mm_store_ss(&d0n, _mm_add_ss(_mm_mul_ss(_mm_load_ss(&s0n), v0), ctr));
190
+ _mm_store_ss(&d1n, _mm_add_ss(_mm_mul_ss(_mm_load_ss(&s1n), v1), ctr));
191
}
192
}
193
}
194
195
const __m128 slev0 = _mm_set1_ps(mix->matrix04);
196
const __m128 slev1 = _mm_set1_ps(mix->matrix15);
197
__m128 in, ctr;
198
- const float *sFL = s0, *sFR = s1, *sFC = s2, *sLFE = s3, *sSL = s4, *sSR = s5;
199
- float *dFL = d0, *dFR = d1;
200
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/channelmix-ops.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/channelmix-ops.c
Changed
143
1
2
#include "channelmix-ops.h"
3
#include "hilbert.h"
4
5
-#undef SPA_LOG_TOPIC_DEFAULT
6
-#define SPA_LOG_TOPIC_DEFAULT log_topic
7
-struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.channelmix");
8
9
#define _M(ch) (1UL << SPA_AUDIO_CHANNEL_ ## ch)
10
#define MASK_MONO _M(FC)|_M(MONO)|_M(UNKNOWN)
11
12
typedef void (*channelmix_func_t) (struct channelmix *mix, void * SPA_RESTRICT dst,
13
const void * SPA_RESTRICT src, uint32_t n_samples);
14
15
+#define MAKE(sc,sm,dc,dm,func,...) \
16
+ { sc, sm, dc, dm, func, #func, __VA_ARGS__ }
17
+
18
static const struct channelmix_info {
19
uint32_t src_chan;
20
uint64_t src_mask;
21
22
uint64_t dst_mask;
23
24
channelmix_func_t process;
25
- uint32_t cpu_flags;
26
const char *name;
27
+
28
+ uint32_t cpu_flags;
29
} channelmix_table =
30
{
31
#if defined (HAVE_SSE)
32
- { 2, MASK_MONO, 2, MASK_MONO, channelmix_copy_sse, SPA_CPU_FLAG_SSE, "copy_sse" },
33
- { 2, MASK_STEREO, 2, MASK_STEREO, channelmix_copy_sse, SPA_CPU_FLAG_SSE, "copy_sse" },
34
- { EQ, 0, EQ, 0, channelmix_copy_sse, SPA_CPU_FLAG_SSE, "copy_sse" },
35
+ MAKE(2, MASK_MONO, 2, MASK_MONO, channelmix_copy_sse, SPA_CPU_FLAG_SSE),
36
+ MAKE(2, MASK_STEREO, 2, MASK_STEREO, channelmix_copy_sse, SPA_CPU_FLAG_SSE),
37
+ MAKE(EQ, 0, EQ, 0, channelmix_copy_sse, SPA_CPU_FLAG_SSE),
38
#endif
39
- { 2, MASK_MONO, 2, MASK_MONO, channelmix_copy_c, 0, "copy_c" },
40
- { 2, MASK_STEREO, 2, MASK_STEREO, channelmix_copy_c, 0, "copy_c" },
41
- { EQ, 0, EQ, 0, channelmix_copy_c, 0 },
42
-
43
- { 1, MASK_MONO, 2, MASK_STEREO, channelmix_f32_1_2_c, 0, "f32_1_2_c" },
44
- { 2, MASK_STEREO, 1, MASK_MONO, channelmix_f32_2_1_c, 0, "f32_2_1_c" },
45
- { 4, MASK_QUAD, 1, MASK_MONO, channelmix_f32_4_1_c, 0, "f32_4_1_c" },
46
- { 4, MASK_3_1, 1, MASK_MONO, channelmix_f32_4_1_c, 0, "f32_4_1_c" },
47
+ MAKE(2, MASK_MONO, 2, MASK_MONO, channelmix_copy_c),
48
+ MAKE(2, MASK_STEREO, 2, MASK_STEREO, channelmix_copy_c),
49
+ MAKE(EQ, 0, EQ, 0, channelmix_copy_c),
50
+
51
+ MAKE(1, MASK_MONO, 2, MASK_STEREO, channelmix_f32_1_2_c),
52
+ MAKE(2, MASK_STEREO, 1, MASK_MONO, channelmix_f32_2_1_c),
53
+ MAKE(4, MASK_QUAD, 1, MASK_MONO, channelmix_f32_4_1_c),
54
+ MAKE(4, MASK_3_1, 1, MASK_MONO, channelmix_f32_4_1_c),
55
+ MAKE(2, MASK_STEREO, 4, MASK_QUAD, channelmix_f32_2_4_c),
56
+ MAKE(2, MASK_STEREO, 4, MASK_3_1, channelmix_f32_2_3p1_c),
57
+ MAKE(2, MASK_STEREO, 6, MASK_5_1, channelmix_f32_2_5p1_c),
58
+ MAKE(2, MASK_STEREO, 8, MASK_7_1, channelmix_f32_2_7p1_c),
59
#if defined (HAVE_SSE)
60
- { 2, MASK_STEREO, 4, MASK_QUAD, channelmix_f32_2_4_sse, SPA_CPU_FLAG_SSE, "f32_2_4_sse" },
61
+ MAKE(4, MASK_3_1, 2, MASK_STEREO, channelmix_f32_3p1_2_sse, SPA_CPU_FLAG_SSE),
62
#endif
63
- { 2, MASK_STEREO, 4, MASK_QUAD, channelmix_f32_2_4_c, 0, "f32_2_4_c" },
64
- { 2, MASK_STEREO, 4, MASK_3_1, channelmix_f32_2_3p1_c, 0, "f32_2_3p1_c" },
65
- { 2, MASK_STEREO, 6, MASK_5_1, channelmix_f32_2_5p1_c, 0, "f32_2_5p1_c" },
66
- { 2, MASK_STEREO, 8, MASK_7_1, channelmix_f32_2_7p1_c, 0, "f32_2_7p1_c" },
67
+ MAKE(4, MASK_3_1, 2, MASK_STEREO, channelmix_f32_3p1_2_c),
68
#if defined (HAVE_SSE)
69
- { 6, MASK_5_1, 2, MASK_STEREO, channelmix_f32_5p1_2_sse, SPA_CPU_FLAG_SSE, "f32_5p1_2_sse" },
70
+ MAKE(6, MASK_5_1, 2, MASK_STEREO, channelmix_f32_5p1_2_sse, SPA_CPU_FLAG_SSE),
71
#endif
72
- { 6, MASK_5_1, 2, MASK_STEREO, channelmix_f32_5p1_2_c, 0, "f32_5p1_2_c" },
73
+ MAKE(6, MASK_5_1, 2, MASK_STEREO, channelmix_f32_5p1_2_c),
74
#if defined (HAVE_SSE)
75
- { 6, MASK_5_1, 4, MASK_QUAD, channelmix_f32_5p1_4_sse, SPA_CPU_FLAG_SSE, "f32_5p1_4_sse" },
76
+ MAKE(6, MASK_5_1, 4, MASK_QUAD, channelmix_f32_5p1_4_sse, SPA_CPU_FLAG_SSE),
77
#endif
78
- { 6, MASK_5_1, 4, MASK_QUAD, channelmix_f32_5p1_4_c, 0, "f32_5p1_4_c" },
79
+ MAKE(6, MASK_5_1, 4, MASK_QUAD, channelmix_f32_5p1_4_c),
80
81
#if defined (HAVE_SSE)
82
- { 6, MASK_5_1, 4, MASK_3_1, channelmix_f32_5p1_3p1_sse, SPA_CPU_FLAG_SSE, "f32_5p1_3p1_sse" },
83
+ MAKE(6, MASK_5_1, 4, MASK_3_1, channelmix_f32_5p1_3p1_sse, SPA_CPU_FLAG_SSE),
84
#endif
85
- { 6, MASK_5_1, 4, MASK_3_1, channelmix_f32_5p1_3p1_c, 0, "f32_5p1_3p1_c" },
86
+ MAKE(6, MASK_5_1, 4, MASK_3_1, channelmix_f32_5p1_3p1_c),
87
88
- { 8, MASK_7_1, 2, MASK_STEREO, channelmix_f32_7p1_2_c, 0, "f32_7p1_2_c" },
89
- { 8, MASK_7_1, 4, MASK_QUAD, channelmix_f32_7p1_4_c, 0, "f32_7p1_4_c" },
90
- { 8, MASK_7_1, 4, MASK_3_1, channelmix_f32_7p1_3p1_c, 0, "f32_7p1_3p1_c" },
91
+ MAKE(8, MASK_7_1, 2, MASK_STEREO, channelmix_f32_7p1_2_c),
92
+ MAKE(8, MASK_7_1, 4, MASK_QUAD, channelmix_f32_7p1_4_c),
93
+ MAKE(8, MASK_7_1, 4, MASK_3_1, channelmix_f32_7p1_3p1_c),
94
95
- { ANY, 0, ANY, 0, channelmix_f32_n_m_c, 0, "f32_n_m_c" },
96
+ MAKE(ANY, 0, ANY, 0, channelmix_f32_n_m_c),
97
};
98
+#undef MAKE
99
100
#define MATCH_CHAN(a,b) ((a) == ANY || (a) == (b))
101
#define MATCH_CPU_FLAGS(a,b) ((a) == 0 || ((a) & (b)) == a)
102
103
_MATRIX(SR,RR) += 1.0f;
104
} else if ((src_mask & STEREO) == STEREO) {
105
spa_log_debug(mix->log, "produce SIDE from STEREO");
106
- _MATRIX(SL,FL) += 1.0f;
107
- _MATRIX(SR,FR) += 1.0f;
108
+ _MATRIX(SL,FL) += slev;
109
+ _MATRIX(SR,FR) += slev;
110
} else if ((src_mask & FRONT) == FRONT) {
111
spa_log_debug(mix->log, "produce SIDE from FC");
112
_MATRIX(SL,FC) += clev;
113
114
_MATRIX(RR,SR) += 1.0f;
115
} else if ((src_mask & STEREO) == STEREO) {
116
spa_log_debug(mix->log, "produce REAR from STEREO");
117
- _MATRIX(RL,FL) += 1.0f;
118
- _MATRIX(RR,FR) += 1.0f;
119
+ _MATRIX(RL,FL) += slev;
120
+ _MATRIX(RR,FR) += slev;
121
} else if ((src_mask & FRONT) == FRONT) {
122
spa_log_debug(mix->log, "produce REAR from FC");
123
_MATRIX(RL,FC) += clev;
124
125
{
126
const struct channelmix_info *info;
127
128
+ if (mix->src_chan > SPA_AUDIO_MAX_CHANNELS ||
129
+ mix->dst_chan > SPA_AUDIO_MAX_CHANNELS)
130
+ return -EINVAL;
131
+
132
info = find_channelmix_info(mix->src_chan, mix->src_mask, mix->dst_chan, mix->dst_mask,
133
mix->cpu_flags);
134
if (info == NULL)
135
136
mix->set_volume = impl_channelmix_set_volume;
137
mix->cpu_flags = info->cpu_flags;
138
mix->delay = mix->rear_delay * mix->freq / 1000.0f;
139
+ mix->func_name = info->name;
140
141
spa_log_debug(mix->log, "selected %s delay:%d options:%08x", info->name, mix->delay,
142
mix->options);
143
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/channelmix-ops.h -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/channelmix-ops.h
Changed
59
1
2
#include <spa/utils/string.h>
3
#include <spa/param/audio/raw.h>
4
5
-#undef SPA_LOG_TOPIC_DEFAULT
6
-#define SPA_LOG_TOPIC_DEFAULT log_topic
7
-extern struct spa_log_topic *log_topic;
8
-
9
#include "crossover.h"
10
#include "delay.h"
11
12
13
#define MASK_7_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)|_M(SL)|_M(SR)|_M(RL)|_M(RR)
14
15
#define BUFFER_SIZE 4096
16
-
17
-#define BUFFER_SIZE 4096
18
#define MAX_TAPS 255
19
20
struct channelmix {
21
22
#define CHANNELMIX_OPTION_NORMALIZE (1<<1) /**< normalize volumes */
23
#define CHANNELMIX_OPTION_UPMIX (1<<2) /**< do simple upmixing */
24
uint32_t options;
25
-#define CHANNELMIX_UPMIX_NONE (0) /**< disable upmixing */
26
-#define CHANNELMIX_UPMIX_SIMPLE (1) /**< simple upmixing */
27
-#define CHANNELMIX_UPMIX_PSD (2) /**< Passive Surround Decoding upmixing */
28
+#define CHANNELMIX_UPMIX_NONE 0 /**< disable upmixing */
29
+#define CHANNELMIX_UPMIX_SIMPLE 1 /**< simple upmixing */
30
+#define CHANNELMIX_UPMIX_PSD 2 /**< Passive Surround Decoding upmixing */
31
uint32_t upmix;
32
33
struct spa_log *log;
34
+ const char *func_name;
35
36
#define CHANNELMIX_FLAG_ZERO (1<<0) /**< all zero components */
37
#define CHANNELMIX_FLAG_IDENTITY (1<<1) /**< identity matrix */
38
39
DEFINE_FUNCTION(f32_2_3p1, c);
40
DEFINE_FUNCTION(f32_2_5p1, c);
41
DEFINE_FUNCTION(f32_2_7p1, c);
42
+DEFINE_FUNCTION(f32_3p1_2, c);
43
DEFINE_FUNCTION(f32_5p1_2, c);
44
DEFINE_FUNCTION(f32_5p1_3p1, c);
45
DEFINE_FUNCTION(f32_5p1_4, c);
46
47
48
#if defined (HAVE_SSE)
49
DEFINE_FUNCTION(copy, sse);
50
-DEFINE_FUNCTION(f32_2_4, sse);
51
+DEFINE_FUNCTION(f32_3p1_2, sse);
52
DEFINE_FUNCTION(f32_5p1_2, sse);
53
DEFINE_FUNCTION(f32_5p1_3p1, sse);
54
DEFINE_FUNCTION(f32_5p1_4, sse);
55
DEFINE_FUNCTION(f32_7p1_4, sse);
56
#endif
57
+
58
+#undef DEFINE_FUNCTION
59
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/fmt-ops-avx2.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-avx2.c
Changed
201
1
2
const int16_t *s = src;
3
float *d0 = dst0;
4
uint32_t n, unrolled;
5
- __m256i in;
6
+ __m256i in = _mm256_setzero_si256();
7
__m256 out, factor = _mm256_set1_ps(1.0f / S16_SCALE);
8
9
if (SPA_LIKELY(SPA_IS_ALIGNED(d0, 32)))
10
11
}
12
for(; n < n_samples; n++) {
13
__m128 out, factor = _mm_set1_ps(1.0f / S16_SCALE);
14
- out = _mm_cvtsi32_ss(out, s0);
15
+ out = _mm_cvtsi32_ss(factor, s0);
16
out = _mm_mul_ss(out, factor);
17
_mm_store_ss(&d0n, out);
18
s += n_channels;
19
20
}
21
for(; n < n_samples; n++) {
22
__m128 out4, factor = _mm_set1_ps(1.0f / S16_SCALE);
23
- out0 = _mm_cvtsi32_ss(out0, s0);
24
+ out0 = _mm_cvtsi32_ss(factor, s0);
25
out0 = _mm_mul_ss(out0, factor);
26
- out1 = _mm_cvtsi32_ss(out1, s1);
27
+ out1 = _mm_cvtsi32_ss(factor, s1);
28
out1 = _mm_mul_ss(out1, factor);
29
_mm_store_ss(&d0n, out0);
30
_mm_store_ss(&d1n, out1);
31
32
s += 12 * n_channels;
33
}
34
for(; n < n_samples; n++) {
35
- out = _mm_cvtsi32_ss(out, read_s24(s));
36
+ out = _mm_cvtsi32_ss(factor, read_s24(s));
37
out = _mm_mul_ss(out, factor);
38
_mm_store_ss(&d0n, out);
39
s += 3 * n_channels;
40
41
s += 12 * n_channels;
42
}
43
for(; n < n_samples; n++) {
44
- out0 = _mm_cvtsi32_ss(out0, read_s24(s));
45
- out1 = _mm_cvtsi32_ss(out1, read_s24(s+3));
46
+ out0 = _mm_cvtsi32_ss(factor, read_s24(s));
47
+ out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
48
out0 = _mm_mul_ss(out0, factor);
49
out1 = _mm_mul_ss(out1, factor);
50
_mm_store_ss(&d0n, out0);
51
52
s += 12 * n_channels;
53
}
54
for(; n < n_samples; n++) {
55
- out0 = _mm_cvtsi32_ss(out0, read_s24(s));
56
- out1 = _mm_cvtsi32_ss(out1, read_s24(s+3));
57
- out2 = _mm_cvtsi32_ss(out2, read_s24(s+6));
58
- out3 = _mm_cvtsi32_ss(out3, read_s24(s+9));
59
+ out0 = _mm_cvtsi32_ss(factor, read_s24(s));
60
+ out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
61
+ out2 = _mm_cvtsi32_ss(factor, read_s24(s+6));
62
+ out3 = _mm_cvtsi32_ss(factor, read_s24(s+9));
63
out0 = _mm_mul_ss(out0, factor);
64
out1 = _mm_mul_ss(out1, factor);
65
out2 = _mm_mul_ss(out2, factor);
66
67
}
68
for(; n < n_samples; n++) {
69
__m128 out4, factor = _mm_set1_ps(1.0f / S24_SCALE);
70
- out0 = _mm_cvtsi32_ss(out0, s0>>8);
71
- out1 = _mm_cvtsi32_ss(out1, s1>>8);
72
- out2 = _mm_cvtsi32_ss(out2, s2>>8);
73
- out3 = _mm_cvtsi32_ss(out3, s3>>8);
74
+ out0 = _mm_cvtsi32_ss(factor, s0>>8);
75
+ out1 = _mm_cvtsi32_ss(factor, s1>>8);
76
+ out2 = _mm_cvtsi32_ss(factor, s2>>8);
77
+ out3 = _mm_cvtsi32_ss(factor, s3>>8);
78
out0 = _mm_mul_ss(out0, factor);
79
out1 = _mm_mul_ss(out1, factor);
80
out2 = _mm_mul_ss(out2, factor);
81
82
}
83
for(; n < n_samples; n++) {
84
__m128 out2, factor = _mm_set1_ps(1.0f / S24_SCALE);
85
- out0 = _mm_cvtsi32_ss(out0, s0>>8);
86
- out1 = _mm_cvtsi32_ss(out1, s1>>8);
87
+ out0 = _mm_cvtsi32_ss(factor, s0>>8);
88
+ out1 = _mm_cvtsi32_ss(factor, s1>>8);
89
out0 = _mm_mul_ss(out0, factor);
90
out1 = _mm_mul_ss(out1, factor);
91
_mm_store_ss(&d0n, out0);
92
93
}
94
for(; n < n_samples; n++) {
95
__m128 out, factor = _mm_set1_ps(1.0f / S24_SCALE);
96
- out = _mm_cvtsi32_ss(out, s0>>8);
97
+ out = _mm_cvtsi32_ss(factor, s0>>8);
98
out = _mm_mul_ss(out, factor);
99
_mm_store_ss(&d0n, out);
100
s += n_channels;
101
102
__m128 in1;
103
__m128i out4;
104
__m128 scale = _mm_set1_ps(S32_SCALE);
105
- __m128 int_min = _mm_set1_ps(S32_MIN);
106
+ __m128 int_max = _mm_set1_ps(S32_MAX);
107
108
if (SPA_IS_ALIGNED(s0, 16))
109
unrolled = n_samples & ~3;
110
111
112
for(n = 0; n < unrolled; n += 4) {
113
in0 = _mm_mul_ps(_mm_load_ps(&s0n), scale);
114
- in0 = _mm_min_ps(in0, int_min);
115
+ in0 = _mm_min_ps(in0, int_max);
116
out0 = _mm_cvtps_epi32(in0);
117
out1 = _mm_shuffle_epi32(out0, _MM_SHUFFLE(0, 3, 2, 1));
118
out2 = _mm_shuffle_epi32(out0, _MM_SHUFFLE(1, 0, 3, 2));
119
120
for(; n < n_samples; n++) {
121
in0 = _mm_load_ss(&s0n);
122
in0 = _mm_mul_ss(in0, scale);
123
- in0 = _mm_min_ss(in0, int_min);
124
+ in0 = _mm_min_ss(in0, int_max);
125
*d = _mm_cvtss_si32(in0);
126
d += n_channels;
127
}
128
129
__m256 in2;
130
__m256i out2, t2;
131
__m256 scale = _mm256_set1_ps(S32_SCALE);
132
- __m256 int_min = _mm256_set1_ps(S32_MIN);
133
+ __m256 int_max = _mm256_set1_ps(S32_MAX);
134
135
if (SPA_IS_ALIGNED(s0, 32) &&
136
SPA_IS_ALIGNED(s1, 32))
137
138
in0 = _mm256_mul_ps(_mm256_load_ps(&s0n), scale);
139
in1 = _mm256_mul_ps(_mm256_load_ps(&s1n), scale);
140
141
- in0 = _mm256_min_ps(in0, int_min);
142
- in1 = _mm256_min_ps(in1, int_min);
143
+ in0 = _mm256_min_ps(in0, int_max);
144
+ in1 = _mm256_min_ps(in1, int_max);
145
146
out0 = _mm256_cvtps_epi32(in0); /* a0 a1 a2 a3 a4 a5 a6 a7 */
147
out1 = _mm256_cvtps_epi32(in1); /* b0 b1 b2 b3 b4 b5 b6 b7 */
148
149
__m128 in2;
150
__m128i out2;
151
__m128 scale = _mm_set1_ps(S32_SCALE);
152
- __m128 int_min = _mm_set1_ps(S32_MIN);
153
+ __m128 int_max = _mm_set1_ps(S32_MAX);
154
155
in0 = _mm_load_ss(&s0n);
156
in1 = _mm_load_ss(&s1n);
157
158
in0 = _mm_unpacklo_ps(in0, in1);
159
160
in0 = _mm_mul_ps(in0, scale);
161
- in0 = _mm_min_ps(in0, int_min);
162
+ in0 = _mm_min_ps(in0, int_max);
163
out0 = _mm_cvtps_epi32(in0);
164
_mm_storel_epi64((__m128i*)d, out0);
165
d += n_channels;
166
167
__m256 in4;
168
__m256i out4, t4;
169
__m256 scale = _mm256_set1_ps(S32_SCALE);
170
- __m256 int_min = _mm256_set1_ps(S32_MIN);
171
+ __m256 int_max = _mm256_set1_ps(S32_MAX);
172
173
if (SPA_IS_ALIGNED(s0, 32) &&
174
SPA_IS_ALIGNED(s1, 32) &&
175
176
in2 = _mm256_mul_ps(_mm256_load_ps(&s2n), scale);
177
in3 = _mm256_mul_ps(_mm256_load_ps(&s3n), scale);
178
179
- in0 = _mm256_min_ps(in0, int_min);
180
- in1 = _mm256_min_ps(in1, int_min);
181
- in2 = _mm256_min_ps(in2, int_min);
182
- in3 = _mm256_min_ps(in3, int_min);
183
+ in0 = _mm256_min_ps(in0, int_max);
184
+ in1 = _mm256_min_ps(in1, int_max);
185
+ in2 = _mm256_min_ps(in2, int_max);
186
+ in3 = _mm256_min_ps(in3, int_max);
187
188
out0 = _mm256_cvtps_epi32(in0); /* a0 a1 a2 a3 a4 a5 a6 a7 */
189
out1 = _mm256_cvtps_epi32(in1); /* b0 b1 b2 b3 b4 b5 b6 b7 */
190
191
__m128 in4;
192
__m128i out4;
193
__m128 scale = _mm_set1_ps(S32_SCALE);
194
- __m128 int_min = _mm_set1_ps(S32_MIN);
195
+ __m128 int_max = _mm_set1_ps(S32_MAX);
196
197
in0 = _mm_load_ss(&s0n);
198
in1 = _mm_load_ss(&s1n);
199
200
in0 = _mm_unpacklo_ps(in0, in1);
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/fmt-ops-c.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-c.c
Changed
201
1
2
}
3
}
4
5
+static inline int32_t
6
+lcnoise(uint32_t *state)
7
+{
8
+ *state = (*state * 96314165) + 907633515;
9
+ return (int32_t)(*state);
10
+}
11
+
12
+static inline void update_dither_c(struct convert *conv, uint32_t n_samples)
13
+{
14
+ uint32_t n;
15
+ float *dither = conv->dither, scale = conv->scale;
16
+ uint32_t *state = &conv->random0;
17
+
18
+ for (n = 0; n < n_samples; n++)
19
+ dithern = lcnoise(state) * scale;
20
+}
21
+
22
+#define SHAPER5(type,s,scale,offs,sh,min,max,d) \
23
+({ \
24
+ type t; \
25
+ float v = s * scale + offs + \
26
+ - sh->eidx * 2.033f \
27
+ + sh->e(idx - 1) & NS_MASK * 2.165f \
28
+ - sh->e(idx - 2) & NS_MASK * 1.959f \
29
+ + sh->e(idx - 3) & NS_MASK * 1.590f \
30
+ - sh->e(idx - 4) & NS_MASK * 0.6149f; \
31
+ t = (type)SPA_CLAMP(v + d, min, max); \
32
+ idx = (idx + 1) & NS_MASK; \
33
+ sh->eidx = t - v; \
34
+ t; \
35
+})
36
+
37
+#define F32_TO_U8_SH(s,sh,d) SHAPER5(uint8_t, s, U8_SCALE, U8_OFFS, sh, U8_MIN, U8_MAX, d)
38
+#define F32_TO_S8_SH(s,sh,d) SHAPER5(int8_t, s, S8_SCALE, 0, sh, S8_MIN, S8_MAX, d)
39
+#define F32_TO_S16_SH(s,sh,d) SHAPER5(int16_t, s, S16_SCALE, 0, sh, S16_MIN, S16_MAX, d)
40
+#define F32_TO_S16S_SH(s,sh,d) bswap_16(F32_TO_S16_SH(s,sh,d))
41
+
42
void
43
conv_f32d_to_u8d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
44
uint32_t n_samples)
45
46
}
47
48
void
49
+conv_f32d_to_u8d_dither_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
50
+ uint32_t n_samples)
51
+{
52
+ uint32_t i, j, k, chunk, n_channels = conv->n_channels, dither_size = conv->dither_size;
53
+ float *dither = conv->dither;
54
+
55
+ update_dither_c(conv, SPA_MIN(n_samples, dither_size));
56
+
57
+ for (i = 0; i < n_channels; i++) {
58
+ const float *s = srci;
59
+ uint8_t *d = dsti;
60
+
61
+ for (j = 0; j < n_samples;) {
62
+ chunk = SPA_MIN(n_samples - j, dither_size);
63
+ for (k = 0; k < chunk; k++, j++)
64
+ dj = F32_TO_U8_D(sj, ditherk);
65
+ }
66
+ }
67
+}
68
+
69
+void
70
+conv_f32d_to_u8d_shaped_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
71
+ uint32_t n_samples)
72
+{
73
+ uint32_t i, j, k, chunk, n_channels = conv->n_channels, dither_size = conv->dither_size;
74
+ float *dither = conv->dither;
75
+
76
+ update_dither_c(conv, SPA_MIN(n_samples, dither_size));
77
+
78
+ for (i = 0; i < n_channels; i++) {
79
+ const float *s = srci;
80
+ uint8_t *d = dsti;
81
+ struct shaper *sh = &conv->shaperi;
82
+ uint32_t idx = sh->idx;
83
+
84
+ for (j = 0; j < n_samples;) {
85
+ chunk = SPA_MIN(n_samples - j, dither_size);
86
+ for (k = 0; k < chunk; k++, j++)
87
+ dj = F32_TO_U8_SH(sj, sh, ditherk);
88
+ }
89
+ sh->idx = idx;
90
+ }
91
+}
92
+
93
+void
94
conv_f32_to_u8_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
95
uint32_t n_samples)
96
{
97
98
}
99
100
void
101
+conv_f32d_to_u8_dither_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
102
+ uint32_t n_samples)
103
+{
104
+ const float **s = (const float **) src;
105
+ uint8_t *d = dst0;
106
+ uint32_t i, j, k, chunk, n_channels = conv->n_channels, dither_size = conv->dither_size;
107
+ float *dither = conv->dither;
108
+
109
+ update_dither_c(conv, SPA_MIN(n_samples, dither_size));
110
+
111
+ for (j = 0; j < n_samples;) {
112
+ chunk = SPA_MIN(n_samples - j, dither_size);
113
+ for (k = 0; k < chunk; k++, j++) {
114
+ for (i = 0; i < n_channels; i++)
115
+ *d++ = F32_TO_U8_D(sij, ditherk);
116
+ }
117
+ }
118
+}
119
+
120
+void
121
+conv_f32d_to_u8_shaped_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
122
+ uint32_t n_samples)
123
+{
124
+ uint8_t *d0 = dst0;
125
+ uint32_t i, j, k, chunk, n_channels = conv->n_channels, dither_size = conv->dither_size;
126
+ float *dither = conv->dither;
127
+
128
+ update_dither_c(conv, SPA_MIN(n_samples, dither_size));
129
+
130
+ for (i = 0; i < n_channels; i++) {
131
+ const float *s = srci;
132
+ uint8_t *d = &d0i;
133
+ struct shaper *sh = &conv->shaperi;
134
+ uint32_t idx = sh->idx;
135
+
136
+ for (j = 0; j < n_samples;) {
137
+ chunk = SPA_MIN(n_samples - j, dither_size);
138
+ for (k = 0; k < chunk; k++, j++)
139
+ dj * n_channels = F32_TO_U8_SH(sj, sh, ditherk);
140
+ }
141
+ sh->idx = idx;
142
+ }
143
+}
144
+
145
+void
146
conv_f32d_to_s8d_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
147
uint32_t n_samples)
148
{
149
150
}
151
152
void
153
+conv_f32d_to_s8d_dither_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
154
+ uint32_t n_samples)
155
+{
156
+ uint32_t i, j, k, chunk, n_channels = conv->n_channels, dither_size = conv->dither_size;
157
+ float *dither = conv->dither;
158
+
159
+ update_dither_c(conv, SPA_MIN(n_samples, dither_size));
160
+
161
+ for (i = 0; i < n_channels; i++) {
162
+ const float *s = srci;
163
+ int8_t *d = dsti;
164
+
165
+ for (j = 0; j < n_samples;) {
166
+ chunk = SPA_MIN(n_samples - j, dither_size);
167
+ for (k = 0; k < chunk; k++, j++)
168
+ dj = F32_TO_S8_D(sj, ditherk);
169
+ }
170
+ }
171
+}
172
+
173
+void
174
+conv_f32d_to_s8d_shaped_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
175
+ uint32_t n_samples)
176
+{
177
+ uint32_t i, j, k, chunk, n_channels = conv->n_channels, dither_size = conv->dither_size;
178
+ float *dither = conv->dither;
179
+
180
+ update_dither_c(conv, SPA_MIN(n_samples, dither_size));
181
+
182
+ for (i = 0; i < n_channels; i++) {
183
+ const float *s = srci;
184
+ int8_t *d = dsti;
185
+ struct shaper *sh = &conv->shaperi;
186
+ uint32_t idx = sh->idx;
187
+
188
+ for (j = 0; j < n_samples;) {
189
+ chunk = SPA_MIN(n_samples - j, dither_size);
190
+ for (k = 0; k < chunk; k++, j++)
191
+ dj = F32_TO_S8_SH(sj, sh, ditherk);
192
+ }
193
+ sh->idx = idx;
194
+ }
195
+}
196
+
197
+void
198
conv_f32_to_s8_c(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
199
uint32_t n_samples)
200
{
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/fmt-ops-sse2.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-sse2.c
Changed
201
1
2
const int16_t *s = src;
3
float *d0 = dst0;
4
uint32_t n, unrolled;
5
- __m128i in;
6
+ __m128i in = _mm_setzero_si128();
7
__m128 out, factor = _mm_set1_ps(1.0f / S16_SCALE);
8
9
if (SPA_LIKELY(SPA_IS_ALIGNED(d0, 16)))
10
11
s += 4*n_channels;
12
}
13
for(; n < n_samples; n++) {
14
- out = _mm_cvtsi32_ss(out, s0);
15
+ out = _mm_cvtsi32_ss(factor, s0);
16
out = _mm_mul_ss(out, factor);
17
_mm_store_ss(&d0n, out);
18
s += n_channels;
19
20
s += 16;
21
}
22
for(; n < n_samples; n++) {
23
- out0 = _mm_cvtsi32_ss(out0, s0);
24
+ out0 = _mm_cvtsi32_ss(factor, s0);
25
out0 = _mm_mul_ss(out0, factor);
26
- out1 = _mm_cvtsi32_ss(out1, s1);
27
+ out1 = _mm_cvtsi32_ss(factor, s1);
28
out1 = _mm_mul_ss(out1, factor);
29
_mm_store_ss(&d0n, out0);
30
_mm_store_ss(&d1n, out1);
31
32
s += 12 * n_channels;
33
}
34
for(; n < n_samples; n++) {
35
- out = _mm_cvtsi32_ss(out, read_s24(s));
36
+ out = _mm_cvtsi32_ss(factor, read_s24(s));
37
out = _mm_mul_ss(out, factor);
38
_mm_store_ss(&d0n, out);
39
s += 3 * n_channels;
40
41
s += 12 * n_channels;
42
}
43
for(; n < n_samples; n++) {
44
- out0 = _mm_cvtsi32_ss(out0, read_s24(s));
45
- out1 = _mm_cvtsi32_ss(out1, read_s24(s+3));
46
+ out0 = _mm_cvtsi32_ss(factor, read_s24(s));
47
+ out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
48
out0 = _mm_mul_ss(out0, factor);
49
out1 = _mm_mul_ss(out1, factor);
50
_mm_store_ss(&d0n, out0);
51
52
s += 12 * n_channels;
53
}
54
for(; n < n_samples; n++) {
55
- out0 = _mm_cvtsi32_ss(out0, read_s24(s));
56
- out1 = _mm_cvtsi32_ss(out1, read_s24(s+3));
57
- out2 = _mm_cvtsi32_ss(out2, read_s24(s+6));
58
- out3 = _mm_cvtsi32_ss(out3, read_s24(s+9));
59
+ out0 = _mm_cvtsi32_ss(factor, read_s24(s));
60
+ out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
61
+ out2 = _mm_cvtsi32_ss(factor, read_s24(s+6));
62
+ out3 = _mm_cvtsi32_ss(factor, read_s24(s+9));
63
out0 = _mm_mul_ss(out0, factor);
64
out1 = _mm_mul_ss(out1, factor);
65
out2 = _mm_mul_ss(out2, factor);
66
67
s += 4*n_channels;
68
}
69
for(; n < n_samples; n++) {
70
- out = _mm_cvtsi32_ss(out, s0>>8);
71
+ out = _mm_cvtsi32_ss(factor, s0>>8);
72
out = _mm_mul_ss(out, factor);
73
_mm_store_ss(&d0n, out);
74
s += n_channels;
75
76
__m128 in1;
77
__m128i out4;
78
__m128 scale = _mm_set1_ps(S32_SCALE);
79
- __m128 int_min = _mm_set1_ps(S32_MIN);
80
+ __m128 int_max = _mm_set1_ps(S32_MAX);
81
82
if (SPA_IS_ALIGNED(s0, 16))
83
unrolled = n_samples & ~3;
84
85
86
for(n = 0; n < unrolled; n += 4) {
87
in0 = _mm_mul_ps(_mm_load_ps(&s0n), scale);
88
- in0 = _mm_min_ps(in0, int_min);
89
+ in0 = _mm_min_ps(in0, int_max);
90
out0 = _mm_cvtps_epi32(in0);
91
out1 = _mm_shuffle_epi32(out0, _MM_SHUFFLE(0, 3, 2, 1));
92
out2 = _mm_shuffle_epi32(out0, _MM_SHUFFLE(1, 0, 3, 2));
93
94
for(; n < n_samples; n++) {
95
in0 = _mm_load_ss(&s0n);
96
in0 = _mm_mul_ss(in0, scale);
97
- in0 = _mm_min_ss(in0, int_min);
98
+ in0 = _mm_min_ss(in0, int_max);
99
*d = _mm_cvtss_si32(in0);
100
d += n_channels;
101
}
102
103
__m128 in2;
104
__m128i out2, t2;
105
__m128 scale = _mm_set1_ps(S32_SCALE);
106
- __m128 int_min = _mm_set1_ps(S32_MIN);
107
+ __m128 int_max = _mm_set1_ps(S32_MAX);
108
109
if (SPA_IS_ALIGNED(s0, 16) &&
110
SPA_IS_ALIGNED(s1, 16))
111
112
in0 = _mm_mul_ps(_mm_load_ps(&s0n), scale);
113
in1 = _mm_mul_ps(_mm_load_ps(&s1n), scale);
114
115
- in0 = _mm_min_ps(in0, int_min);
116
- in1 = _mm_min_ps(in1, int_min);
117
+ in0 = _mm_min_ps(in0, int_max);
118
+ in1 = _mm_min_ps(in1, int_max);
119
120
out0 = _mm_cvtps_epi32(in0);
121
out1 = _mm_cvtps_epi32(in1);
122
123
in0 = _mm_unpacklo_ps(in0, in1);
124
125
in0 = _mm_mul_ps(in0, scale);
126
- in0 = _mm_min_ps(in0, int_min);
127
+ in0 = _mm_min_ps(in0, int_max);
128
out0 = _mm_cvtps_epi32(in0);
129
_mm_storel_epi64((__m128i*)d, out0);
130
d += n_channels;
131
132
__m128 in4;
133
__m128i out4;
134
__m128 scale = _mm_set1_ps(S32_SCALE);
135
- __m128 int_min = _mm_set1_ps(S32_MIN);
136
+ __m128 int_max = _mm_set1_ps(S32_MAX);
137
138
if (SPA_IS_ALIGNED(s0, 16) &&
139
SPA_IS_ALIGNED(s1, 16) &&
140
141
in2 = _mm_mul_ps(_mm_load_ps(&s2n), scale);
142
in3 = _mm_mul_ps(_mm_load_ps(&s3n), scale);
143
144
- in0 = _mm_min_ps(in0, int_min);
145
- in1 = _mm_min_ps(in1, int_min);
146
- in2 = _mm_min_ps(in2, int_min);
147
- in3 = _mm_min_ps(in3, int_min);
148
+ in0 = _mm_min_ps(in0, int_max);
149
+ in1 = _mm_min_ps(in1, int_max);
150
+ in2 = _mm_min_ps(in2, int_max);
151
+ in3 = _mm_min_ps(in3, int_max);
152
153
_MM_TRANSPOSE4_PS(in0, in1, in2, in3);
154
155
156
in0 = _mm_unpacklo_ps(in0, in1);
157
158
in0 = _mm_mul_ps(in0, scale);
159
- in0 = _mm_min_ps(in0, int_min);
160
+ in0 = _mm_min_ps(in0, int_max);
161
out0 = _mm_cvtps_epi32(in0);
162
_mm_storeu_si128((__m128i*)d, out0);
163
d += n_channels;
164
165
conv_f32d_to_s32_1s_sse2(conv, &di, &srci, n_channels, n_samples);
166
}
167
168
+static inline void update_dither_sse2(struct convert *conv, uint32_t n_samples)
169
+{
170
+ uint32_t n;
171
+ const uint32_t *r = SPA_PTR_ALIGN(conv->random, 16, uint32_t);
172
+ float *dither = SPA_PTR_ALIGN(conv->dither, 16, float);
173
+ __m128 scale = _mm_set1_ps(conv->scale), out1;
174
+ __m128i in1, t1;
175
+
176
+ for (n = 0; n < n_samples; n += 4) {
177
+ /* 32 bit xorshift PRNG, see https://en.wikipedia.org/wiki/Xorshift */
178
+ in0 = _mm_load_si128((__m128i*)r);
179
+ t0 = _mm_slli_epi32(in0, 13);
180
+ in0 = _mm_xor_si128(in0, t0);
181
+ t0 = _mm_srli_epi32(in0, 17);
182
+ in0 = _mm_xor_si128(in0, t0);
183
+ t0 = _mm_slli_epi32(in0, 5);
184
+ in0 = _mm_xor_si128(in0, t0);
185
+ _mm_store_si128((__m128i*)r, in0);
186
+
187
+ out0 = _mm_cvtepi32_ps(in0);
188
+ out0 = _mm_mul_ps(out0, scale);
189
+ _mm_store_ps(&dithern, out0);
190
+ }
191
+}
192
+
193
+static void
194
+conv_f32d_to_s32_1s_dither_sse2(struct convert *conv, void * SPA_RESTRICT dst, const void * SPA_RESTRICT src,
195
+ uint32_t n_channels, uint32_t n_samples)
196
+{
197
+ const float *s = src;
198
+ float *dither = SPA_PTR_ALIGN(conv->dither, 16, float);
199
+ int32_t *d = dst;
200
+ uint32_t n, unrolled;
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/fmt-ops-sse41.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-sse41.c
Changed
19
1
2
const uint8_t *s = src;
3
float *d0 = dst0;
4
uint32_t n, unrolled;
5
- __m128i in;
6
+ __m128i in = _mm_setzero_si128();
7
__m128 out, factor = _mm_set1_ps(1.0f / S24_SCALE);
8
9
if (SPA_IS_ALIGNED(d0, 16))
10
11
s += 12 * n_channels;
12
}
13
for(; n < n_samples; n++) {
14
- out = _mm_cvtsi32_ss(out, read_s24(s));
15
+ out = _mm_cvtsi32_ss(factor, read_s24(s));
16
out = _mm_mul_ss(out, factor);
17
_mm_store_ss(&d0n, out);
18
s += 3 * n_channels;
19
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/fmt-ops-ssse3.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops-ssse3.c
Changed
16
1
2
s += 12 * n_channels;
3
}
4
for(; n < n_samples; n++) {
5
- out0 = _mm_cvtsi32_ss(out0, read_s24(s));
6
- out1 = _mm_cvtsi32_ss(out1, read_s24(s+3));
7
- out2 = _mm_cvtsi32_ss(out2, read_s24(s+6));
8
- out3 = _mm_cvtsi32_ss(out3, read_s24(s+9));
9
+ out0 = _mm_cvtsi32_ss(factor, read_s24(s));
10
+ out1 = _mm_cvtsi32_ss(factor, read_s24(s+3));
11
+ out2 = _mm_cvtsi32_ss(factor, read_s24(s+6));
12
+ out3 = _mm_cvtsi32_ss(factor, read_s24(s+9));
13
out0 = _mm_mul_ss(out0, factor);
14
out1 = _mm_mul_ss(out1, factor);
15
out2 = _mm_mul_ss(out2, factor);
16
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/fmt-ops.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops.c
Changed
201
1
2
3
#include "fmt-ops.h"
4
5
+#define DITHER_SIZE (1<<10)
6
+
7
typedef void (*convert_func_t) (struct convert *conv, void * SPA_RESTRICT dst,
8
const void * SPA_RESTRICT src, uint32_t n_samples);
9
10
11
uint32_t src_fmt;
12
uint32_t dst_fmt;
13
uint32_t n_channels;
14
- uint32_t cpu_flags;
15
16
convert_func_t process;
17
+ const char *name;
18
+
19
+ uint32_t cpu_flags;
20
+#define CONV_DITHER (1<<0)
21
+#define CONV_SHAPE (1<<1)
22
+ uint32_t dither_flags;
23
};
24
25
+#define MAKE(fmt1,fmt2,chan,func,...) \
26
+ { SPA_AUDIO_FORMAT_ ##fmt1, SPA_AUDIO_FORMAT_ ##fmt2, chan, func, #func , __VA_ARGS__ }
27
+
28
static struct conv_info conv_table =
29
{
30
/* to f32 */
31
- { SPA_AUDIO_FORMAT_U8, SPA_AUDIO_FORMAT_F32, 0, 0, conv_u8_to_f32_c },
32
- { SPA_AUDIO_FORMAT_U8P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_u8d_to_f32d_c },
33
- { SPA_AUDIO_FORMAT_U8, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_u8_to_f32d_c },
34
- { SPA_AUDIO_FORMAT_U8P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_u8d_to_f32_c },
35
+ MAKE(U8, F32, 0, conv_u8_to_f32_c),
36
+ MAKE(U8, F32, 0, conv_u8_to_f32_c),
37
+ MAKE(U8P, F32P, 0, conv_u8d_to_f32d_c),
38
+ MAKE(U8, F32P, 0, conv_u8_to_f32d_c),
39
+ MAKE(U8P, F32, 0, conv_u8d_to_f32_c),
40
41
- { SPA_AUDIO_FORMAT_S8, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s8_to_f32_c },
42
- { SPA_AUDIO_FORMAT_S8P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s8d_to_f32d_c },
43
- { SPA_AUDIO_FORMAT_S8, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s8_to_f32d_c },
44
- { SPA_AUDIO_FORMAT_S8P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s8d_to_f32_c },
45
+ MAKE(S8, F32, 0, conv_s8_to_f32_c),
46
+ MAKE(S8P, F32P, 0, conv_s8d_to_f32d_c),
47
+ MAKE(S8, F32P, 0, conv_s8_to_f32d_c),
48
+ MAKE(S8P, F32, 0, conv_s8d_to_f32_c),
49
50
- { SPA_AUDIO_FORMAT_ALAW, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_alaw_to_f32d_c },
51
- { SPA_AUDIO_FORMAT_ULAW, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_ulaw_to_f32d_c },
52
+ MAKE(ALAW, F32P, 0, conv_alaw_to_f32d_c),
53
+ MAKE(ULAW, F32P, 0, conv_ulaw_to_f32d_c),
54
55
- { SPA_AUDIO_FORMAT_U16, SPA_AUDIO_FORMAT_F32, 0, 0, conv_u16_to_f32_c },
56
- { SPA_AUDIO_FORMAT_U16, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_u16_to_f32d_c },
57
+ MAKE(U16, F32, 0, conv_u16_to_f32_c),
58
+ MAKE(U16, F32P, 0, conv_u16_to_f32d_c),
59
60
- { SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s16_to_f32_c },
61
- { SPA_AUDIO_FORMAT_S16P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s16d_to_f32d_c },
62
+ MAKE(S16, F32, 0, conv_s16_to_f32_c),
63
+ MAKE(S16P, F32P, 0, conv_s16d_to_f32d_c),
64
#if defined (HAVE_NEON)
65
- { SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32P, 2, SPA_CPU_FLAG_NEON, conv_s16_to_f32d_2_neon },
66
- { SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_NEON, conv_s16_to_f32d_neon },
67
+ MAKE(S16, F32P, 2, conv_s16_to_f32d_2_neon, SPA_CPU_FLAG_NEON),
68
+ MAKE(S16, F32P, 0, conv_s16_to_f32d_neon, SPA_CPU_FLAG_NEON),
69
#endif
70
#if defined (HAVE_AVX2)
71
- { SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32P, 2, SPA_CPU_FLAG_AVX2, conv_s16_to_f32d_2_avx2 },
72
- { SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_AVX2, conv_s16_to_f32d_avx2 },
73
+ MAKE(S16, F32P, 2, conv_s16_to_f32d_2_avx2, SPA_CPU_FLAG_AVX2),
74
+ MAKE(S16, F32P, 0, conv_s16_to_f32d_avx2, SPA_CPU_FLAG_AVX2),
75
#endif
76
#if defined (HAVE_SSE2)
77
- { SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32P, 2, SPA_CPU_FLAG_SSE2, conv_s16_to_f32d_2_sse2 },
78
- { SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_SSE2, conv_s16_to_f32d_sse2 },
79
+ MAKE(S16, F32P, 2, conv_s16_to_f32d_2_sse2, SPA_CPU_FLAG_SSE2),
80
+ MAKE(S16, F32P, 0, conv_s16_to_f32d_sse2, SPA_CPU_FLAG_SSE2),
81
#endif
82
- { SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s16_to_f32d_c },
83
- { SPA_AUDIO_FORMAT_S16P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s16d_to_f32_c },
84
+ MAKE(S16, F32P, 0, conv_s16_to_f32d_c),
85
+ MAKE(S16P, F32, 0, conv_s16d_to_f32_c),
86
87
- { SPA_AUDIO_FORMAT_S16_OE, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s16s_to_f32d_c },
88
+ MAKE(S16_OE, F32P, 0, conv_s16s_to_f32d_c),
89
90
- { SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_F32, 0, 0, conv_copy32_c },
91
- { SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_copy32d_c },
92
+ MAKE(F32, F32, 0, conv_copy32_c),
93
+ MAKE(F32P, F32P, 0, conv_copy32d_c),
94
#if defined (HAVE_SSE2)
95
- { SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_deinterleave_32_sse2 },
96
+ MAKE(F32, F32P, 0, conv_deinterleave_32_sse2, SPA_CPU_FLAG_SSE2),
97
#endif
98
- { SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_deinterleave_32_c },
99
+ MAKE(F32, F32P, 0, conv_deinterleave_32_c),
100
#if defined (HAVE_SSE2)
101
- { SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_interleave_32_sse2 },
102
+ MAKE(F32P, F32, 0, conv_interleave_32_sse2, SPA_CPU_FLAG_SSE2),
103
#endif
104
- { SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_interleave_32_c },
105
+ MAKE(F32P, F32, 0, conv_interleave_32_c),
106
107
#if defined (HAVE_SSE2)
108
- { SPA_AUDIO_FORMAT_F32_OE, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_deinterleave_32s_sse2 },
109
+ MAKE(F32_OE, F32P, 0, conv_deinterleave_32s_sse2, SPA_CPU_FLAG_SSE2),
110
#endif
111
- { SPA_AUDIO_FORMAT_F32_OE, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_deinterleave_32s_c },
112
+ MAKE(F32_OE, F32P, 0, conv_deinterleave_32s_c),
113
#if defined (HAVE_SSE2)
114
- { SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_F32_OE, 0, 0, conv_interleave_32s_sse2 },
115
+ MAKE(F32P, F32_OE, 0, conv_interleave_32s_sse2, SPA_CPU_FLAG_SSE2),
116
#endif
117
- { SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_F32_OE, 0, 0, conv_interleave_32s_c },
118
+ MAKE(F32P, F32_OE, 0, conv_interleave_32s_c),
119
120
- { SPA_AUDIO_FORMAT_U32, SPA_AUDIO_FORMAT_F32, 0, 0, conv_u32_to_f32_c },
121
- { SPA_AUDIO_FORMAT_U32, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_u32_to_f32d_c },
122
+ MAKE(U32, F32, 0, conv_u32_to_f32_c),
123
+ MAKE(U32, F32P, 0, conv_u32_to_f32d_c),
124
125
#if defined (HAVE_AVX2)
126
- { SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_AVX2, conv_s32_to_f32d_avx2 },
127
+ MAKE(S32, F32P, 0, conv_s32_to_f32d_avx2, SPA_CPU_FLAG_AVX2),
128
#endif
129
#if defined (HAVE_SSE2)
130
- { SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_SSE2, conv_s32_to_f32d_sse2 },
131
+ MAKE(S32, F32P, 0, conv_s32_to_f32d_sse2, SPA_CPU_FLAG_SSE2),
132
#endif
133
- { SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s32_to_f32_c },
134
- { SPA_AUDIO_FORMAT_S32P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s32d_to_f32d_c },
135
- { SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s32_to_f32d_c },
136
- { SPA_AUDIO_FORMAT_S32P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s32d_to_f32_c },
137
+ MAKE(S32, F32, 0, conv_s32_to_f32_c),
138
+ MAKE(S32P, F32P, 0, conv_s32d_to_f32d_c),
139
+ MAKE(S32, F32P, 0, conv_s32_to_f32d_c),
140
+ MAKE(S32P, F32, 0, conv_s32d_to_f32_c),
141
142
- { SPA_AUDIO_FORMAT_S32_OE, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s32s_to_f32d_c },
143
+ MAKE(S32_OE, F32P, 0, conv_s32s_to_f32d_c),
144
145
- { SPA_AUDIO_FORMAT_U24, SPA_AUDIO_FORMAT_F32, 0, 0, conv_u24_to_f32_c },
146
- { SPA_AUDIO_FORMAT_U24, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_u24_to_f32d_c },
147
+ MAKE(U24, F32, 0, conv_u24_to_f32_c),
148
+ MAKE(U24, F32P, 0, conv_u24_to_f32d_c),
149
150
- { SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s24_to_f32_c },
151
- { SPA_AUDIO_FORMAT_S24P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24d_to_f32d_c },
152
+ MAKE(S24, F32, 0, conv_s24_to_f32_c),
153
+ MAKE(S24P, F32P, 0, conv_s24d_to_f32d_c),
154
#if defined (HAVE_AVX2)
155
- { SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_AVX2, conv_s24_to_f32d_avx2 },
156
+ MAKE(S24, F32P, 0, conv_s24_to_f32d_avx2, SPA_CPU_FLAG_AVX2),
157
#endif
158
#if defined (HAVE_SSSE3)
159
-// { SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_SSSE3, conv_s24_to_f32d_ssse3 },
160
+// MAKE(S24, F32P, 0, conv_s24_to_f32d_ssse3, SPA_CPU_FLAG_SSSE3),
161
#endif
162
#if defined (HAVE_SSE41)
163
- { SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_SSE41, conv_s24_to_f32d_sse41 },
164
+ MAKE(S24, F32P, 0, conv_s24_to_f32d_sse41, SPA_CPU_FLAG_SSE41),
165
#endif
166
#if defined (HAVE_SSE2)
167
- { SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_SSE2, conv_s24_to_f32d_sse2 },
168
+ MAKE(S24, F32P, 0, conv_s24_to_f32d_sse2, SPA_CPU_FLAG_SSE2),
169
#endif
170
- { SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24_to_f32d_c },
171
- { SPA_AUDIO_FORMAT_S24P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s24d_to_f32_c },
172
+ MAKE(S24, F32P, 0, conv_s24_to_f32d_c),
173
+ MAKE(S24P, F32, 0, conv_s24d_to_f32_c),
174
175
- { SPA_AUDIO_FORMAT_S24_OE, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24s_to_f32d_c },
176
+ MAKE(S24_OE, F32P, 0, conv_s24s_to_f32d_c),
177
178
- { SPA_AUDIO_FORMAT_U24_32, SPA_AUDIO_FORMAT_F32, 0, 0, conv_u24_32_to_f32_c },
179
- { SPA_AUDIO_FORMAT_U24_32, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_u24_32_to_f32d_c },
180
+ MAKE(U24_32, F32, 0, conv_u24_32_to_f32_c),
181
+ MAKE(U24_32, F32P, 0, conv_u24_32_to_f32d_c),
182
183
- { SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s24_32_to_f32_c },
184
- { SPA_AUDIO_FORMAT_S24_32P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24_32d_to_f32d_c },
185
- { SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24_32_to_f32d_c },
186
- { SPA_AUDIO_FORMAT_S24_32P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s24_32d_to_f32_c },
187
+ MAKE(S24_32, F32, 0, conv_s24_32_to_f32_c),
188
+ MAKE(S24_32P, F32P, 0, conv_s24_32d_to_f32d_c),
189
+ MAKE(S24_32, F32P, 0, conv_s24_32_to_f32d_c),
190
+ MAKE(S24_32P, F32, 0, conv_s24_32d_to_f32_c),
191
192
- { SPA_AUDIO_FORMAT_S24_32_OE, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24_32s_to_f32d_c },
193
+ MAKE(S24_32_OE, F32P, 0, conv_s24_32s_to_f32d_c),
194
195
- { SPA_AUDIO_FORMAT_F64, SPA_AUDIO_FORMAT_F32, 0, 0, conv_f64_to_f32_c },
196
- { SPA_AUDIO_FORMAT_F64P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_f64d_to_f32d_c },
197
- { SPA_AUDIO_FORMAT_F64, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_f64_to_f32d_c },
198
- { SPA_AUDIO_FORMAT_F64P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_f64d_to_f32_c },
199
+ MAKE(F64, F32, 0, conv_f64_to_f32_c),
200
+ MAKE(F64P, F32P, 0, conv_f64d_to_f32d_c),
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/fmt-ops.h -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/fmt-ops.h
Changed
201
1
2
*/
3
4
#include <math.h>
5
-#ifdef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
#include <sys/endian.h>
8
#define bswap_16 bswap16
9
#define bswap_32 bswap32
10
11
#endif
12
13
#include <spa/utils/defs.h>
14
+#include <spa/utils/string.h>
15
16
-#define U8_MIN 0
17
-#define U8_MAX 255
18
-#define U8_SCALE 127.5f
19
-#define U8_OFFS 128
20
-#define U8_TO_F32(v) ((((uint8_t)(v)) * (1.0f / U8_OFFS)) - 1.0)
21
-#define F32_TO_U8(v) (uint8_t)((SPA_CLAMP(v, -1.0f, 1.0f) * U8_SCALE) + U8_OFFS)
22
-
23
-#define S8_MIN -127
24
-#define S8_MAX 127
25
-#define S8_MAX_F 127.0f
26
-#define S8_SCALE 127.0f
27
-#define S8_TO_F32(v) (((int8_t)(v)) * (1.0f / S8_SCALE))
28
-#define F32_TO_S8(v) (int8_t)(SPA_CLAMP(v, -1.0f, 1.0f) * S8_SCALE)
29
-
30
-#define U16_MIN 0
31
-#define U16_MAX 65535
32
-#define U16_SCALE 32767.5f
33
-#define U16_OFFS 32768
34
-#define U16_TO_F32(v) ((((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0)
35
-#define U16S_TO_F32(v) (((uint16_t)bswap_16((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0)
36
-#define F32_TO_U16(v) (uint16_t)((SPA_CLAMP(v, -1.0f, 1.0f) * U16_SCALE) + U16_OFFS)
37
-#define F32_TO_U16S(v) ((uint16_t)bswap_16((uint16_t)((SPA_CLAMP(v, -1.0f, 1.0f) * U16_SCALE) + U16_OFFS)))
38
-
39
-#define S16_MIN -32767
40
-#define S16_MAX 32767
41
-#define S16_MAX_F 32767.0f
42
-#define S16_SCALE 32767.0f
43
-#define S16_TO_F32(v) (((int16_t)(v)) * (1.0f / S16_SCALE))
44
-#define S16S_TO_F32(v) (((int16_t)bswap_16((uint16_t)v)) * (1.0f / S16_SCALE))
45
-#define F32_TO_S16(v) (int16_t)(SPA_CLAMP(v, -1.0f, 1.0f) * S16_SCALE)
46
-#define F32_TO_S16S(v) ((int16_t)bswap_16((uint16_t)(SPA_CLAMP(v, -1.0f, 1.0f) * S16_SCALE)))
47
-
48
-#define U24_MIN 0
49
-#define U24_MAX 16777215
50
-#define U24_SCALE 8388607.5f
51
-#define U24_OFFS 8388608
52
-#define U24_TO_F32(v) ((((uint32_t)(v)) * (1.0f / U24_OFFS)) - 1.0)
53
-#define F32_TO_U24(v) (uint32_t)((SPA_CLAMP(v, -1.0f, 1.0f) * U24_SCALE) + U24_OFFS)
54
-
55
-#define S24_MIN -8388607
56
-#define S24_MAX 8388607
57
-#define S24_MAX_F 8388607.0f
58
-#define S24_SCALE 8388607.0f
59
-#define S24_TO_F32(v) (((int32_t)(v)) * (1.0f / S24_SCALE))
60
-#define F32_TO_S24(v) (int32_t)(SPA_CLAMP(v, -1.0f, 1.0f) * S24_SCALE)
61
-
62
-#define U32_TO_F32(v) U24_TO_F32(((uint32_t)(v)) >> 8)
63
-#define F32_TO_U32(v) (F32_TO_U24(v) << 8)
64
-
65
-#define S32_SCALE 2147483648.0f
66
-#define S32_MIN 2147483520.0f
67
-
68
-#define S32_TO_F32(v) S24_TO_F32(((int32_t)(v)) >> 8)
69
-#define S32S_TO_F32(v) S24_TO_F32(((int32_t)bswap_32(v)) >> 8)
70
-#define F32_TO_S32(v) (F32_TO_S24(v) << 8)
71
-#define F32_TO_S32S(v) bswap_32((F32_TO_S24(v) << 8))
72
+#define FMT_OPS_MAX_ALIGN 32
73
+
74
+#define U8_MIN 0u
75
+#define U8_MAX 255u
76
+#define U8_SCALE 127.5f
77
+#define U8_OFFS 128.f
78
+#define U8_TO_F32(v) ((((uint8_t)(v)) * (1.0f / U8_OFFS)) - 1.0f)
79
+#define F32_TO_U8(v) (uint8_t)SPA_CLAMP((v) * U8_SCALE + U8_OFFS, U8_MIN, U8_MAX)
80
+#define F32_TO_U8_D(v,d) (uint8_t)SPA_CLAMP((v) * U8_SCALE + U8_OFFS + (d), U8_MIN, U8_MAX)
81
+
82
+#define S8_MIN -127
83
+#define S8_MAX 127
84
+#define S8_MAX_F 127.0f
85
+#define S8_SCALE 127.0f
86
+#define S8_TO_F32(v) (((int8_t)(v)) * (1.0f / S8_SCALE))
87
+#define F32_TO_S8(v) (int8_t)SPA_CLAMP((v) * S8_SCALE, S8_MIN, S8_MAX)
88
+#define F32_TO_S8_D(v,d) (int8_t)SPA_CLAMP((v) * S8_SCALE + (d), S8_MIN, S8_MAX)
89
+
90
+#define U16_MIN 0u
91
+#define U16_MAX 65535u
92
+#define U16_SCALE 32767.5f
93
+#define U16_OFFS 32768.f
94
+#define U16_TO_F32(v) ((((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0)
95
+#define U16S_TO_F32(v) (((uint16_t)bswap_16((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0)
96
+#define F32_TO_U16(v) (uint16_t)SPA_CLAMP((v) * U16_SCALE + U16_OFFS, U16_MIN, U16_MAX)
97
+#define F32_TO_U16_D(v,d) (uint16_t)SPA_CLAMP((v) * U16_SCALE + U16_OFFS + (d), U16_MIN, U16_MAX)
98
+#define F32_TO_U16S(v) bswap_16(F32_TO_U16(v))
99
+#define F32_TO_U16S_D(v,d) bswap_16(F32_TO_U16_D(v,d))
100
+
101
+#define S16_MIN -32767
102
+#define S16_MAX 32767
103
+#define S16_MAX_F 32767.0f
104
+#define S16_SCALE 32767.0f
105
+#define S16_TO_F32(v) (((int16_t)(v)) * (1.0f / S16_SCALE))
106
+#define S16S_TO_F32(v) (((int16_t)bswap_16(v)) * (1.0f / S16_SCALE))
107
+#define F32_TO_S16(v) (int16_t)SPA_CLAMP((v) * S16_SCALE, S16_MIN, S16_MAX)
108
+#define F32_TO_S16_D(v,d) (int16_t)SPA_CLAMP((v) * S16_SCALE + (d), S16_MIN, S16_MAX)
109
+#define F32_TO_S16S(v) bswap_16(F32_TO_S16(v))
110
+#define F32_TO_S16S_D(v,d) bswap_16(F32_TO_S16_D(v,d))
111
+
112
+#define U24_MIN 0u
113
+#define U24_MAX 16777215u
114
+#define U24_SCALE 8388607.5f
115
+#define U24_OFFS 8388608.f
116
+#define U24_TO_F32(v) ((((uint32_t)(v)) * (1.0f / U24_OFFS)) - 1.0)
117
+#define F32_TO_U24(v) (uint32_t)SPA_CLAMP((v) * U24_SCALE + U24_OFFS, U24_MIN, U24_MAX)
118
+#define F32_TO_U24_D(v,d) (uint32_t)SPA_CLAMP((v) * U24_SCALE + U24_OFFS + (d), U24_MIN, U24_MAX)
119
+
120
+#define S24_MIN -8388607
121
+#define S24_MAX 8388607
122
+#define S24_MAX_F 8388607.0f
123
+#define S24_SCALE 8388607.0f
124
+#define S24_TO_F32(v) (((int32_t)(v)) * (1.0f / S24_SCALE))
125
+#define F32_TO_S24(v) (int32_t)SPA_CLAMP((v) * S24_SCALE, S24_MIN, S24_MAX)
126
+#define F32_TO_S24_D(v,d) (int32_t)SPA_CLAMP((v) * S24_SCALE + (d), S24_MIN, S24_MAX)
127
+
128
+#define U32_MIN 0u
129
+#define U32_MAX 4294967040u
130
+#define U32_SCALE 2147483520.f
131
+#define U32_OFFS 2147483520.f
132
+#define U32_TO_F32(v) ((((uint32_t)(v)) * (1.0f / U32_OFFS)) - 1.0)
133
+#define F32_TO_U32(v) (uint32_t)SPA_CLAMP((v) * U32_SCALE + U32_OFFS, U32_MIN, U32_MAX)
134
+#define F32_TO_U32_D(v,d) (uint32_t)SPA_CLAMP((v) * U32_SCALE + U32_OFFS + (d), U32_MIN, U32_MAX)
135
+
136
+#define S32_MIN -2147483520
137
+#define S32_MAX 2147483520
138
+#define S32_MAX_F 2147483520.f
139
+#define S32_SCALE 2147483648.f
140
+#define S32_TO_F32(v) (((int32_t)(v)) * (1.0f / S32_SCALE))
141
+#define S32S_TO_F32(v) (((int32_t)bswap_32(v)) * (1.0f / S32_SCALE))
142
+#define F32_TO_S32(v) (int32_t)SPA_CLAMP((v) * S32_SCALE, S32_MIN, S32_MAX)
143
+#define F32_TO_S32_D(v,d) (int32_t)SPA_CLAMP((v) * S32_SCALE + (d), S32_MIN, S32_MAX)
144
+#define F32_TO_S32S(v) bswap_32(F32_TO_S32(v))
145
+#define F32_TO_S32S_D(v,d) bswap_32(F32_TO_S32_D(v,d))
146
147
#define U24_32_TO_F32(v) U32_TO_F32((v)<<8)
148
#define U24_32S_TO_F32(v) U32_TO_F32(((int32_t)bswap_32(v))<<8)
149
#define F32_TO_U24_32(v) F32_TO_U24(v)
150
#define F32_TO_U24_32S(v) bswap_32(F32_TO_U24(v))
151
+#define F32_TO_U24_32_D(v,d) F32_TO_U24_D(v,d)
152
+#define F32_TO_U24_32S_D(v,d) bswap_32(F32_TO_U24_D(v,d))
153
154
#define S24_32_TO_F32(v) S32_TO_F32((v)<<8)
155
#define S24_32S_TO_F32(v) S32_TO_F32(((int32_t)bswap_32(v))<<8)
156
#define F32_TO_S24_32(v) F32_TO_S24(v)
157
#define F32_TO_S24_32S(v) bswap_32(F32_TO_S24(v))
158
+#define F32_TO_S24_32_D(v,d) F32_TO_S24_D(v,d)
159
+#define F32_TO_S24_32S_D(v,d) bswap_32(F32_TO_S24_D(v,d))
160
161
static inline uint32_t read_u24(const void *src)
162
{
163
164
#endif
165
}
166
167
-#define MAX_NS 64
168
+#define NS_MAX 8
169
+#define NS_MASK (NS_MAX-1)
170
+
171
+struct shaper {
172
+ float eNS_MAX;
173
+ uint32_t idx;
174
+ float r;
175
+};
176
177
struct convert {
178
+ uint32_t quantize;
179
+ uint32_t noise;
180
+#define DITHER_METHOD_NONE 0
181
+#define DITHER_METHOD_RECTANGULAR 1
182
+#define DITHER_METHOD_TRIANGULAR 2
183
+#define DITHER_METHOD_SHAPED_5 3
184
+ uint32_t method;
185
+
186
uint32_t src_fmt;
187
uint32_t dst_fmt;
188
uint32_t n_channels;
189
+ uint32_t rate;
190
uint32_t cpu_flags;
191
+ const char *func_name;
192
193
unsigned int is_passthrough:1;
194
- float ns_dataMAX_NS;
195
- uint32_t ns_idx;
196
- uint32_t ns_size;
197
+
198
+ float scale;
199
+ uint32_t random16 + FMT_OPS_MAX_ALIGN/4;
200
+ float *dither;
201
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/meson.build -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/meson.build
Changed
17
1
2
-audioconvert_sources = 'audioadapter.c',
3
+audioconvert_sources =
4
+ 'audioadapter.c',
5
'audioconvert.c',
6
- 'fmtconvert.c',
7
- 'channelmix.c',
8
- 'merger.c',
9
- 'plugin.c',
10
- 'resample.c',
11
- 'splitter.c'
12
+ 'plugin.c'
13
+
14
15
simd_cargs =
16
simd_dependencies =
17
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/plugin.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/plugin.c
Changed
35
1
2
#include <spa/support/plugin.h>
3
4
extern const struct spa_handle_factory spa_audioconvert_factory;
5
-extern const struct spa_handle_factory spa_fmtconvert_factory;
6
-extern const struct spa_handle_factory spa_channelmix_factory;
7
-extern const struct spa_handle_factory spa_resample_factory;
8
-extern const struct spa_handle_factory spa_splitter_factory;
9
-extern const struct spa_handle_factory spa_merger_factory;
10
extern const struct spa_handle_factory spa_audioadapter_factory;
11
12
SPA_EXPORT
13
14
*factory = &spa_audioconvert_factory;
15
break;
16
case 1:
17
- *factory = &spa_fmtconvert_factory;
18
- break;
19
- case 2:
20
- *factory = &spa_channelmix_factory;
21
- break;
22
- case 3:
23
- *factory = &spa_resample_factory;
24
- break;
25
- case 4:
26
- *factory = &spa_splitter_factory;
27
- break;
28
- case 5:
29
- *factory = &spa_merger_factory;
30
- break;
31
- case 6:
32
*factory = &spa_audioadapter_factory;
33
break;
34
default:
35
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/resample-native-impl.h -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/resample-native-impl.h
Changed
16
1
2
3
struct resample_info {
4
uint32_t format;
5
- uint32_t cpu_flags;
6
resample_func_t process_copy;
7
+ const char *copy_name;
8
resample_func_t process_full;
9
+ const char *full_name;
10
resample_func_t process_inter;
11
+ const char *inter_name;
12
+ uint32_t cpu_flags;
13
};
14
15
struct native_data {
16
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/resample-native.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/resample-native.c
Changed
109
1
2
return sin(x) / x;
3
}
4
5
-static inline double blackman(double x, double n_taps)
6
+#if 0
7
+static inline double window_blackman(double x, double n_taps)
8
{
9
double alpha = 0.232;
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
}
14
-
15
+#else
16
+static inline double window_cosh(double x, double n_taps)
17
+{
18
+ double R = 95.0;
19
+ double A = -325.1E-6 * (R * R) + 0.1677 * R - 3.149;
20
+ x = 2.0 * M_PI * x / n_taps;
21
+ return cosh(A * sqrt(1 - pow(x / M_PI, 2))) / cosh(A);
22
+}
23
+#endif
24
25
static int build_filter(float *taps, uint32_t stride, uint32_t n_taps, uint32_t n_phases, double cutoff)
26
{
27
28
/* exploit symmetry in filter taps */
29
taps(n_phases - i) * stride + n_taps12 + j =
30
tapsi * stride + (n_taps12 - j - 1) =
31
- cutoff * sinc(t * cutoff) * blackman(t, n_taps);
32
+ cutoff * sinc(t * cutoff) * window_cosh(t, n_taps);
33
}
34
}
35
return 0;
36
37
MAKE_RESAMPLER_FULL(c);
38
MAKE_RESAMPLER_INTER(c);
39
40
+#define MAKE(fmt,copy,full,inter,...) \
41
+ { SPA_AUDIO_FORMAT_ ##fmt, do_resample_ ##copy, #copy, \
42
+ do_resample_ ##full, #full, do_resample_ ##inter, #inter, __VA_ARGS__ }
43
+
44
static struct resample_info resample_table =
45
{
46
#if defined (HAVE_NEON)
47
- { SPA_AUDIO_FORMAT_F32, SPA_CPU_FLAG_NEON,
48
- do_resample_copy_c, do_resample_full_neon, do_resample_inter_neon },
49
+ MAKE(F32, copy_c, full_neon, inter_neon, SPA_CPU_FLAG_NEON),
50
#endif
51
#if defined(HAVE_AVX) && defined(HAVE_FMA)
52
- { SPA_AUDIO_FORMAT_F32, SPA_CPU_FLAG_AVX | SPA_CPU_FLAG_FMA3,
53
- do_resample_copy_c, do_resample_full_avx, do_resample_inter_avx },
54
+ MAKE(F32, copy_c, full_avx, inter_avx, SPA_CPU_FLAG_AVX | SPA_CPU_FLAG_FMA3),
55
#endif
56
#if defined (HAVE_SSSE3)
57
- { SPA_AUDIO_FORMAT_F32, SPA_CPU_FLAG_SSSE3 | SPA_CPU_FLAG_SLOW_UNALIGNED,
58
- do_resample_copy_c, do_resample_full_ssse3, do_resample_inter_ssse3 },
59
+ MAKE(F32, copy_c, full_ssse3, inter_ssse3, SPA_CPU_FLAG_SSSE3 | SPA_CPU_FLAG_SLOW_UNALIGNED),
60
#endif
61
#if defined (HAVE_SSE)
62
- { SPA_AUDIO_FORMAT_F32, SPA_CPU_FLAG_SSE,
63
- do_resample_copy_c, do_resample_full_sse, do_resample_inter_sse },
64
+ MAKE(F32, copy_c, full_sse, inter_sse, SPA_CPU_FLAG_SSE),
65
#endif
66
- { SPA_AUDIO_FORMAT_F32, 0,
67
- do_resample_copy_c, do_resample_full_c, do_resample_inter_c },
68
+ MAKE(F32, copy_c, full_c, inter_c),
69
};
70
+#undef MAKE
71
72
#define MATCH_CPU_FLAGS(a,b) ((a) == 0 || ((a) & (b)) == a)
73
static const struct resample_info *find_resample_info(uint32_t format, uint32_t cpu_flags)
74
75
data->inc = data->in_rate / data->out_rate;
76
data->frac = data->in_rate % data->out_rate;
77
78
- if (data->in_rate == data->out_rate)
79
+ if (data->in_rate == data->out_rate) {
80
data->func = data->info->process_copy;
81
- else if (rate == 1.0)
82
+ r->func_name = data->info->copy_name;
83
+ }
84
+ else if (rate == 1.0) {
85
data->func = data->info->process_full;
86
- else
87
+ r->func_name = data->info->full_name;
88
+ }
89
+ else {
90
data->func = data->info->process_inter;
91
+ r->func_name = data->info->inter_name;
92
+ }
93
94
spa_log_trace_fp(r->log, "native %p: rate:%f in:%d out:%d phase:%d inc:%d frac:%d", r,
95
rate, data->in_rate, data->out_rate, data->phase, data->inc, data->frac);
96
97
build_filter(d->filter, d->filter_stride, n_taps, n_phases, scale);
98
99
d->info = find_resample_info(SPA_AUDIO_FORMAT_F32, r->cpu_flags);
100
- if (SPA_UNLIKELY(!d->info))
101
- {
102
+ if (SPA_UNLIKELY(d->info == NULL)) {
103
spa_log_error(r->log, "failed to find suitable resample format!");
104
- return -1;
105
+ return -ENOTSUP;
106
}
107
108
spa_log_debug(r->log, "native %p: q:%d in:%d out:%d n_taps:%d n_phases:%d features:%08x:%08x",
109
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/resample.h -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/resample.h
Changed
16
1
2
#define RESAMPLE_DEFAULT_QUALITY 4
3
4
struct resample {
5
+ struct spa_log *log;
6
uint32_t cpu_flags;
7
+ const char *func_name;
8
+
9
uint32_t channels;
10
uint32_t i_rate;
11
uint32_t o_rate;
12
- struct spa_log *log;
13
double rate;
14
int quality;
15
16
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/test-audioconvert.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/test-audioconvert.c
Changed
10
1
2
3
extern const struct spa_handle_factory test_source_factory;
4
5
-#define MAX_PORTS SPA_AUDIO_MAX_CHANNELS
6
+#define MAX_PORTS (SPA_AUDIO_MAX_CHANNELS+1)
7
8
struct context {
9
struct spa_handle *convert_handle;
10
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/volume-ops.c -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/volume-ops.c
Changed
34
1
2
typedef void (*volume_func_t) (struct volume *vol, void * SPA_RESTRICT dst,
3
const void * SPA_RESTRICT src, float volume, uint32_t n_samples);
4
5
+#define MAKE(func,...) \
6
+ { func, #func , __VA_ARGS__ }
7
+
8
static const struct volume_info {
9
volume_func_t process;
10
+ const char *name;
11
uint32_t cpu_flags;
12
} volume_table =
13
{
14
#if defined (HAVE_SSE)
15
- { volume_f32_sse, SPA_CPU_FLAG_SSE },
16
+ MAKE(volume_f32_sse, SPA_CPU_FLAG_SSE),
17
#endif
18
- { volume_f32_c, 0 },
19
+ MAKE(volume_f32_c),
20
};
21
+#undef MAKE
22
23
#define MATCH_CPU_FLAGS(a,b) ((a) == 0 || ((a) & (b)) == a)
24
25
26
if (info == NULL)
27
return -ENOTSUP;
28
29
+ vol->cpu_flags = info->cpu_flags;
30
+ vol->func_name = info->name;
31
vol->free = impl_volume_free;
32
vol->process = info->process;
33
return 0;
34
pipewire-0.3.52.tar.gz/spa/plugins/audioconvert/volume-ops.h -> pipewire-0.3.53.tar.gz/spa/plugins/audioconvert/volume-ops.h
Changed
9
1
2
3
struct volume {
4
uint32_t cpu_flags;
5
+ const char *func_name;
6
7
struct spa_log *log;
8
9
pipewire-0.3.52.tar.gz/spa/plugins/audiomixer/audiomixer.c -> pipewire-0.3.53.tar.gz/spa/plugins/audiomixer/audiomixer.c
Changed
54
1
2
struct port *inport = GET_IN_PORT(this, i);
3
struct spa_io_buffers *inio = NULL;
4
struct buffer *inb;
5
+ struct spa_data *bd;
6
+ uint32_t size, offs;
7
8
if (SPA_UNLIKELY(!PORT_VALID(inport) ||
9
(inio = inport->io) == NULL ||
10
11
}
12
13
inb = &inport->buffersinio->buffer_id;
14
- maxsize = SPA_MIN(inb->buffer->datas0.chunk->size, maxsize);
15
+ bd = &inb->buffer->datas0;
16
17
- spa_log_trace_fp(this->log, "%p: mix input %d %p->%p %d %d %d", this,
18
- i, inio, outio, inio->status, inio->buffer_id, maxsize);
19
+ offs = SPA_MIN(bd->chunk->offset, bd->maxsize);
20
+ size = SPA_MIN(bd->maxsize - offs, bd->chunk->size);
21
+ maxsize = SPA_MIN(size, maxsize);
22
23
- datasn_buffers = inb->buffer->datas0.data;
24
- buffersn_buffers++ = inb;
25
+ spa_log_trace_fp(this->log, "%p: mix input %d %p->%p %d %d %d:%d", this,
26
+ i, inio, outio, inio->status, inio->buffer_id,
27
+ offs, size);
28
+
29
+ if (!SPA_FLAG_IS_SET(bd->chunk->flags, SPA_CHUNK_FLAG_EMPTY)) {
30
+ datasn_buffers = SPA_PTROFF(bd->data, offs, void);
31
+ buffersn_buffers++ = inb;
32
+ }
33
inio->status = SPA_STATUS_NEED_DATA;
34
}
35
36
37
38
if (n_buffers == 1) {
39
*outb->buffer = *buffers0->buffer;
40
- }
41
- else {
42
+ } else {
43
struct spa_data *d = outb->buf.datas;
44
45
*outb->buffer = outb->buf;
46
47
d0.chunk->offset = 0;
48
d0.chunk->size = maxsize;
49
d0.chunk->stride = this->stride;
50
+ SPA_FLAG_UPDATE(d0.chunk->flags, SPA_CHUNK_FLAG_EMPTY, n_buffers == 0);
51
52
mix_ops_process(&this->ops, d0.data,
53
datas, n_buffers, maxsize / this->stride);
54
pipewire-0.3.52.tar.gz/spa/plugins/audiomixer/mixer-dsp.c -> pipewire-0.3.53.tar.gz/spa/plugins/audiomixer/mixer-dsp.c
Changed
80
1
2
uint32_t cpu_flags;
3
uint32_t max_align;
4
5
+ struct spa_io_position *io_position;
6
uint32_t quantum_limit;
7
8
struct mix_ops ops;
9
10
11
static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
12
{
13
- return -ENOTSUP;
14
+ struct impl *this = object;
15
+
16
+ spa_return_val_if_fail(this != NULL, -EINVAL);
17
+
18
+ spa_log_debug(this->log, "%p: io %d %p/%zd", this, id, data, size);
19
+
20
+ switch (id) {
21
+ case SPA_IO_Position:
22
+ this->io_position = data;
23
+ break;
24
+ default:
25
+ return -ENOENT;
26
+ }
27
+ return 0;
28
}
29
30
static int impl_node_send_command(void *object, const struct spa_command *command)
31
32
datas = alloca(MAX_PORTS * sizeof(void *));
33
n_buffers = 0;
34
35
- maxsize = UINT32_MAX;
36
+ if (SPA_LIKELY(this->io_position))
37
+ maxsize = this->io_position->clock.duration * sizeof(float);
38
+ else
39
+ maxsize = this->quantum_limit;
40
41
for (i = 0; i < this->last_port; i++) {
42
struct port *inport = GET_IN_PORT(this, i);
43
44
i, inio, outio, inio->status, inio->buffer_id,
45
offs, size);
46
47
- datasn_buffers = SPA_PTROFF(bd->data, offs, void);
48
- buffersn_buffers++ = inb;
49
+ if (!SPA_FLAG_IS_SET(bd->chunk->flags, SPA_CHUNK_FLAG_EMPTY)) {
50
+ datasn_buffers = SPA_PTROFF(bd->data, offs, void);
51
+ buffersn_buffers++ = inb;
52
+ }
53
inio->status = SPA_STATUS_NEED_DATA;
54
}
55
56
57
*outb->buffer = *buffers0->buffer;
58
} else {
59
struct spa_data *d = outb->buf.datas;
60
+
61
*outb->buffer = outb->buf;
62
63
maxsize = SPA_MIN(maxsize, d0.maxsize);
64
65
d0.chunk->offset = 0;
66
d0.chunk->size = maxsize;
67
d0.chunk->stride = sizeof(float);
68
+ SPA_FLAG_UPDATE(d0.chunk->flags, SPA_CHUNK_FLAG_EMPTY, n_buffers == 0);
69
70
spa_log_trace_fp(this->log, "%p: %d mix %d", this, n_buffers, maxsize);
71
72
73
this->max_align = SPA_MIN(MAX_ALIGN, spa_cpu_get_max_align(this->cpu));
74
}
75
76
+ this->quantum_limit = 8192;
77
for (i = 0; info && i < info->n_items; i++) {
78
const char *k = info->itemsi.key;
79
const char *s = info->itemsi.value;
80
pipewire-0.3.52.tar.gz/spa/plugins/bluez5/meson.build -> pipewire-0.3.53.tar.gz/spa/plugins/bluez5/meson.build
Changed
10
1
2
bluez_codec_lc3plus = shared_library('spa-codec-bluez5-lc3plus',
3
'a2dp-codec-lc3plus.c', 'a2dp-codecs.c' ,
4
include_directories : configinc ,
5
- c_args : ldac_args,
6
+ c_args : codec_args,
7
dependencies : spa_dep, lc3plus_dep, mathlib ,
8
install : true,
9
install_dir : spa_plugindir / 'bluez5')
10
pipewire-0.3.52.tar.gz/spa/plugins/ffmpeg/ffmpeg-dec.c -> pipewire-0.3.53.tar.gz/spa/plugins/ffmpeg/ffmpeg-dec.c
Changed
39
1
2
#include <spa/param/video/format.h>
3
#include <spa/pod/filter.h>
4
5
+#include "ffmpeg.h"
6
+
7
#define IS_VALID_PORT(this,d,id) ((id) == 0)
8
#define GET_IN_PORT(this,p) (&this->in_portsp)
9
#define GET_OUT_PORT(this,p) (&this->out_portsp)
10
11
return 0;
12
}
13
14
+static int
15
+impl_clear(struct spa_handle *handle)
16
+{
17
+ spa_return_val_if_fail(handle != NULL, -EINVAL);
18
+
19
+ return 0;
20
+}
21
+
22
+size_t
23
+spa_ffmpeg_dec_get_size(const struct spa_handle_factory *factory, const struct spa_dict *params)
24
+{
25
+ return sizeof(struct impl);
26
+}
27
+
28
int
29
spa_ffmpeg_dec_init(struct spa_handle *handle,
30
const struct spa_dict *info,
31
32
struct port *port;
33
34
handle->get_interface = impl_get_interface;
35
+ handle->clear = impl_clear;
36
37
this = (struct impl *) handle;
38
39
pipewire-0.3.52.tar.gz/spa/plugins/ffmpeg/ffmpeg-enc.c -> pipewire-0.3.53.tar.gz/spa/plugins/ffmpeg/ffmpeg-enc.c
Changed
39
1
2
#include <spa/param/video/format-utils.h>
3
#include <spa/pod/filter.h>
4
5
+#include "ffmpeg.h"
6
+
7
#define IS_VALID_PORT(this,d,id) ((id) == 0)
8
#define GET_IN_PORT(this,p) (&this->in_portsp)
9
#define GET_OUT_PORT(this,p) (&this->out_portsp)
10
11
return 0;
12
}
13
14
+static int
15
+impl_clear(struct spa_handle *handle)
16
+{
17
+ spa_return_val_if_fail(handle != NULL, -EINVAL);
18
+
19
+ return 0;
20
+}
21
+
22
+size_t
23
+spa_ffmpeg_enc_get_size(const struct spa_handle_factory *factory, const struct spa_dict *params)
24
+{
25
+ return sizeof(struct impl);
26
+}
27
+
28
int
29
spa_ffmpeg_enc_init(struct spa_handle *handle,
30
const struct spa_dict *info,
31
32
struct port *port;
33
34
handle->get_interface = impl_get_interface;
35
+ handle->clear = impl_clear;
36
37
this = (struct impl *) handle;
38
39
pipewire-0.3.52.tar.gz/spa/plugins/ffmpeg/ffmpeg.c -> pipewire-0.3.53.tar.gz/spa/plugins/ffmpeg/ffmpeg.c
Changed
46
1
2
3
#include <libavcodec/avcodec.h>
4
5
-int spa_ffmpeg_dec_init(struct spa_handle *handle, const struct spa_dict *info,
6
- const struct spa_support *support, uint32_t n_support);
7
-int spa_ffmpeg_enc_init(struct spa_handle *handle, const struct spa_dict *info,
8
- const struct spa_support *support, uint32_t n_support);
9
+#include "ffmpeg.h"
10
11
static int
12
ffmpeg_dec_init(const struct spa_handle_factory *factory,
13
14
SPA_EXPORT
15
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
16
{
17
- static struct spa_handle_factory f;
18
static char name128;
19
+ static struct spa_handle_factory f = {
20
+ SPA_VERSION_HANDLE_FACTORY,
21
+ .name = name,
22
+ .enum_interface_info = ffmpeg_enum_interface_info,
23
+ };
24
25
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 10, 100)
26
avcodec_register_all();
27
28
29
if (av_codec_is_encoder(c)) {
30
snprintf(name, sizeof(name), "encoder.%s", c->name);
31
+ f.get_size = spa_ffmpeg_enc_get_size;
32
f.init = ffmpeg_enc_init;
33
} else {
34
snprintf(name, sizeof(name), "decoder.%s", c->name);
35
+ f.get_size = spa_ffmpeg_dec_get_size;
36
f.init = ffmpeg_dec_init;
37
}
38
39
- f.name = name;
40
- f.info = NULL;
41
- f.enum_interface_info = ffmpeg_enum_interface_info;
42
-
43
*factory = &f;
44
(*index)++;
45
46
pipewire-0.3.53.tar.gz/spa/plugins/ffmpeg/ffmpeg.h
Added
22
1
2
+#ifndef SPA_FFMPEG_H
3
+#define SPA_FFMPEG_H
4
+
5
+#include <stdint.h>
6
+#include <stddef.h>
7
+
8
+struct spa_dict;
9
+struct spa_handle;
10
+struct spa_support;
11
+struct spa_handle_factory;
12
+
13
+int spa_ffmpeg_dec_init(struct spa_handle *handle, const struct spa_dict *info,
14
+ const struct spa_support *support, uint32_t n_support);
15
+int spa_ffmpeg_enc_init(struct spa_handle *handle, const struct spa_dict *info,
16
+ const struct spa_support *support, uint32_t n_support);
17
+
18
+size_t spa_ffmpeg_dec_get_size(const struct spa_handle_factory *factory, const struct spa_dict *params);
19
+size_t spa_ffmpeg_enc_get_size(const struct spa_handle_factory *factory, const struct spa_dict *params);
20
+
21
+#endif
22
pipewire-0.3.52.tar.gz/spa/plugins/support/cpu.c -> pipewire-0.3.53.tar.gz/spa/plugins/support/cpu.c
Changed
10
1
2
#include <sched.h>
3
#include <fcntl.h>
4
5
-#ifdef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
#include <sys/sysctl.h>
8
#endif
9
10
pipewire-0.3.52.tar.gz/spa/plugins/support/logger.c -> pipewire-0.3.53.tar.gz/spa/plugins/support/logger.c
Changed
10
1
2
3
#include "log-patterns.h"
4
5
-#ifdef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
8
#endif
9
10
pipewire-0.3.52.tar.gz/spa/plugins/v4l2/v4l2-udev.c -> pipewire-0.3.53.tar.gz/spa/plugins/v4l2/v4l2-udev.c
Changed
37
1
2
if ((str = udev_device_get_property_value(dev, "SUBSYSTEM")) && *str) {
3
itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SUBSYSTEM, str);
4
}
5
- if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) {
6
- char *dec = alloca(6); /* 65535 is max */
7
- int32_t val;
8
+ if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str)
9
+ itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, str);
10
11
- if (spa_atoi32(str, &val, 16)) {
12
- snprintf(dec, 6, "%d", val);
13
- itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, dec);
14
- }
15
- }
16
str = udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE");
17
if (!(str && *str)) {
18
str = udev_device_get_property_value(dev, "ID_VENDOR_ENC");
19
20
if (str && *str) {
21
itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_NAME, str);
22
}
23
- if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) {
24
- char *dec = alloca(6); /* 65535 is max */
25
- int32_t val;
26
-
27
- if (spa_atoi32(str, &val, 16)) {
28
- snprintf(dec, 6, "%d", val);
29
- itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, dec);
30
- }
31
- }
32
+ if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str)
33
+ itemsn_items++ = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, str);
34
35
str = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE");
36
if (!(str && *str)) {
37
pipewire-0.3.52.tar.gz/spa/plugins/v4l2/v4l2-utils.c -> pipewire-0.3.53.tar.gz/spa/plugins/v4l2/v4l2-utils.c
Changed
18
1
2
spa_log_debug(this->log, "test control %08x", queryctrl.id);
3
4
if (query_ext_ctrl_ioctl(port, &queryctrl) != 0) {
5
+ if (errno == ENOTTY)
6
+ goto enum_end;
7
if (errno == EINVAL) {
8
if (queryctrl.id != next_fl)
9
goto enum_end;
10
11
}
12
res = -errno;
13
spa_log_error(this->log, "'%s' VIDIOC_QUERYCTRL: %m", this->props.device);
14
+ spa_v4l2_close(dev);
15
return res;
16
}
17
if (result.next & next_fl)
18
pipewire-0.3.52.tar.gz/spa/plugins/vulkan/vulkan-utils.c -> pipewire-0.3.53.tar.gz/spa/plugins/vulkan/vulkan-utils.c
Changed
10
1
2
#include <sys/mman.h>
3
#include <fcntl.h>
4
#include <string.h>
5
-#ifndef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
#include <alloca.h>
8
#endif
9
#include <errno.h>
10
pipewire-0.3.52.tar.gz/spa/tests/stress-ringbuffer.c -> pipewire-0.3.53.tar.gz/spa/tests/stress-ringbuffer.c
Changed
14
1
2
#define ARRAY_SIZE 63
3
#define MAX_VALUE 0x10000
4
5
-#ifdef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
#include <sys/param.h>
8
#if (__FreeBSD_version >= 1400000 && __FreeBSD_version < 1400043) \
9
- || (__FreeBSD_version < 1300523)
10
+ || (__FreeBSD_version < 1300523) || defined(__MidnightBSD__)
11
static int sched_getcpu(void) { return -1; };
12
#endif
13
#endif
14
pipewire-0.3.52.tar.gz/spa/tools/spa-inspect.c -> pipewire-0.3.53.tar.gz/spa/tools/spa-inspect.c
Changed
23
1
2
if ((res =
3
spa_handle_factory_init(factory, handle, NULL, data->support, data->n_support)) < 0) {
4
printf("can't make factory instance: %d\n", res);
5
- return;
6
+ goto out;
7
}
8
9
printf("factory instance:\n");
10
11
else
12
printf("skipping unknown interface\n");
13
}
14
+
15
+ if ((res = spa_handle_clear(handle)) < 0)
16
+ printf("failed to clear handle: %s\n", spa_strerror(res));
17
+
18
+out:
19
+ free(handle);
20
}
21
22
static const struct spa_loop_methods impl_loop = {
23
pipewire-0.3.52.tar.gz/src/daemon/client-rt.conf.in -> pipewire-0.3.53.tar.gz/src/daemon/client-rt.conf.in
Changed
16
1
2
#node.autoconnect = true
3
#resample.quality = 4
4
#channelmix.normalize = false
5
- #channelmix.mix-lfe = true
6
+ #channelmix.mix-lfe = false
7
#channelmix.upmix = true
8
#channelmix.upmix-method = psd # none, simple
9
#channelmix.lfe-cutoff = 150
10
11
#channelmix.rear-delay = 12.0
12
#channelmix.stereo-widen = 0.0
13
#channelmix.hilbert-taps = 0
14
+ #dither.noise = 0
15
}
16
pipewire-0.3.52.tar.gz/src/daemon/client.conf.in -> pipewire-0.3.53.tar.gz/src/daemon/client.conf.in
Changed
7
1
2
#channelmix.rear-delay = 12.0
3
#channelmix.stereo-widen = 0.0
4
#channelmix.hilbert-taps = 0
5
+ #dither.noise = 0
6
}
7
pipewire-0.3.52.tar.gz/src/daemon/jack.conf.in -> pipewire-0.3.53.tar.gz/src/daemon/jack.conf.in
Changed
11
1
2
# ignore-all: Ignore all self connect requests
3
#jack.self-connect-mode = allow
4
#jack.locked-process = true
5
- #jack.default-as-system = false
6
+ #jack.default-as-system = false
7
+ #jack.fix-midi-events = true
8
}
9
10
# client specific properties
11
pipewire-0.3.52.tar.gz/src/daemon/minimal.conf.in -> pipewire-0.3.53.tar.gz/src/daemon/minimal.conf.in
Changed
42
1
2
3
## Properties for the DSP configuration.
4
#default.clock.rate = 48000
5
- #default.clock.allowed-rates = 44100 48000
6
+ #default.clock.allowed-rates = 48000
7
#default.clock.quantum = 1024
8
#default.clock.min-quantum = 32
9
#default.clock.max-quantum = 2048
10
11
#channelmix.stereo-widen = 0.0
12
#channelmix.hilbert-taps = 0
13
channelmix.disable = true
14
+ #dither.noise = 0
15
#node.param.Props = {
16
# params =
17
# audio.channels 6
18
19
adapter.auto-port-config = {
20
mode = dsp
21
monitor = false
22
+ control = false
23
position = unknown # aux, preserve
24
}
25
#node.param.PortConfig = {
26
27
#channelmix.stereo-widen = 0.0
28
#channelmix.hilbert-taps = 0
29
channelmix.disable = true
30
+ #dither.noise = 0
31
#node.param.Props = {
32
# params =
33
# audio.format S16
34
35
adapter.auto-port-config = {
36
mode = dsp
37
monitor = false
38
+ control = false
39
position = unknown # aux, preserve
40
}
41
#node.param.PortConfig = {
42
pipewire-0.3.52.tar.gz/src/daemon/pipewire-pulse.conf.in -> pipewire-0.3.53.tar.gz/src/daemon/pipewire-pulse.conf.in
Changed
9
1
2
#channelmix.rear-delay = 12.0
3
#channelmix.stereo-widen = 0.0
4
#channelmix.hilbert-taps = 0
5
+ #dither.noise = 0
6
}
7
8
pulse.properties = {
9
pipewire-0.3.52.tar.gz/src/daemon/pipewire.conf.in -> pipewire-0.3.53.tar.gz/src/daemon/pipewire.conf.in
Changed
10
1
2
3
## Properties for the DSP configuration.
4
#default.clock.rate = 48000
5
- #default.clock.allowed-rates = 44100 48000
6
+ #default.clock.allowed-rates = 48000
7
#default.clock.quantum = 1024
8
default.clock.min-quantum = 16
9
#default.clock.max-quantum = 2048
10
pipewire-0.3.52.tar.gz/src/gst/gstpipewiresrc.c -> pipewire-0.3.53.tar.gz/src/gst/gstpipewiresrc.c
Changed
94
1
2
#include <unistd.h>
3
4
#include <spa/pod/builder.h>
5
+#include <spa/utils/result.h>
6
7
#include <gst/net/gstnetclientclock.h>
8
#include <gst/allocators/gstfdmemory.h>
9
10
{
11
GstPipeWireSrc *src;
12
GstPipeWirePoolData *data;
13
+ int res;
14
15
data = gst_pipewire_pool_get_data (GST_BUFFER_CAST(obj));
16
17
18
19
data->queued = TRUE;
20
21
- GST_LOG_OBJECT (src, "recycle buffer %p", obj);
22
- pw_stream_queue_buffer (src->stream, data->b);
23
+ if ((res = pw_stream_queue_buffer (src->stream, data->b)) < 0)
24
+ GST_WARNING_OBJECT (src, "can't queue recycled buffer %p, %s", obj, spa_strerror(res));
25
+ else
26
+ GST_LOG_OBJECT (src, "recycle buffer %p", obj);
27
+
28
pw_thread_loop_unlock (src->core->loop);
29
30
GST_OBJECT_UNLOCK (data->pool);
31
32
GstPipeWireSrc *pwsrc = _data;
33
GstPipeWirePoolData *data;
34
35
- GST_DEBUG_OBJECT (pwsrc, "add buffer");
36
gst_pipewire_pool_wrap_buffer (pwsrc->pool, b);
37
data = b->user_data;
38
+ GST_DEBUG_OBJECT (pwsrc, "add buffer %p", data->buf);
39
data->owner = pwsrc;
40
data->queued = TRUE;
41
GST_MINI_OBJECT_CAST (data->buf)->dispose = buffer_recycle;
42
43
GstPipeWireSrc *pwsrc = _data;
44
GstPipeWirePoolData *data = b->user_data;
45
GstBuffer *buf = data->buf;
46
+ int res;
47
48
GST_DEBUG_OBJECT (pwsrc, "remove buffer %p", buf);
49
50
GST_MINI_OBJECT_CAST (buf)->dispose = NULL;
51
52
- if (data->queued)
53
+ if (data->queued) {
54
gst_buffer_unref (buf);
55
- else
56
- pw_stream_queue_buffer (pwsrc->stream, b);
57
+ } else {
58
+ if ((res = pw_stream_queue_buffer (pwsrc->stream, b)) < 0)
59
+ GST_WARNING_OBJECT (pwsrc, "can't queue removed buffer %p, %s", buf, spa_strerror(res));
60
+ }
61
}
62
63
static GstBuffer *dequeue_buffer(GstPipeWireSrc *pwsrc)
64
65
66
pwsrc = GST_PIPEWIRE_SRC (psrc);
67
68
+ pw_thread_loop_lock (pwsrc->core->loop);
69
if (!pwsrc->negotiated)
70
goto not_negotiated;
71
72
- pw_thread_loop_lock (pwsrc->core->loop);
73
while (TRUE) {
74
enum pw_stream_state state;
75
76
77
78
not_negotiated:
79
{
80
+ pw_thread_loop_unlock (pwsrc->core->loop);
81
return GST_FLOW_NOT_NEGOTIATED;
82
}
83
streaming_eos:
84
85
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
86
break;
87
case GST_STATE_CHANGE_PAUSED_TO_READY:
88
+ pw_thread_loop_lock (this->core->loop);
89
this->negotiated = FALSE;
90
+ pw_thread_loop_unlock (this->core->loop);
91
break;
92
case GST_STATE_CHANGE_READY_TO_NULL:
93
gst_pipewire_src_close (this);
94
pipewire-0.3.52.tar.gz/src/modules/module-adapter/adapter.c -> pipewire-0.3.53.tar.gz/src/modules/module-adapter/adapter.c
Changed
81
1
2
struct pw_properties *new;
3
const char *str, *path, *desc, *nick, *name, *node_name, *media_class;
4
char position8, *prefix;
5
- bool is_monitor, is_device, is_duplex, is_virtual;
6
+ bool is_monitor, is_device, is_duplex, is_virtual, is_control = false;
7
8
direction = pw_impl_port_get_direction(port);
9
10
11
if (!is_monitor && direction != n->direction)
12
return;
13
14
+ if ((str = pw_properties_get(old, PW_KEY_FORMAT_DSP)) != NULL)
15
+ is_control = spa_streq(str, "8 bit raw midi");
16
+
17
path = pw_properties_get(n->props, PW_KEY_OBJECT_PATH);
18
media_class = pw_properties_get(n->props, PW_KEY_MEDIA_CLASS);
19
20
21
22
new = pw_properties_new(NULL, NULL);
23
24
- if (is_duplex)
25
+ if (is_control)
26
+ prefix = direction == PW_DIRECTION_INPUT ?
27
+ "control" : "notify";
28
+ else if (is_duplex)
29
prefix = direction == PW_DIRECTION_INPUT ?
30
"playback" : "capture";
31
else if (is_virtual)
32
33
pw_properties_setf(new, PW_KEY_OBJECT_PATH, "%s:%s_%d",
34
path ? path : node_name, prefix, pw_impl_port_get_id(port));
35
36
- pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
37
+ if (is_control)
38
+ pw_properties_setf(new, PW_KEY_PORT_NAME, "%s", prefix);
39
+ else
40
+ pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
41
42
if ((node_name = nick) == NULL && (node_name = desc) == NULL &&
43
(node_name = name) == NULL)
44
node_name = "node";
45
46
- pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s_%s",
47
+ if (is_control)
48
+ pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s",
49
+ node_name, prefix);
50
+ else
51
+ pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s_%s",
52
node_name, prefix, str);
53
54
pw_impl_port_update_properties(port, &new->dict);
55
56
int res, position = POSITION_PRESERVE;
57
struct spa_pod *param;
58
uint32_t media_type, media_subtype;
59
- bool have_format = false, monitor = false;
60
+ bool have_format = false, monitor = false, control = false;
61
struct spa_audio_info format = { 0, };
62
enum spa_param_port_config_mode mode = SPA_PARAM_PORT_CONFIG_MODE_none;
63
struct spa_json it2;
64
65
mode = SPA_PARAM_PORT_CONFIG_MODE_none;
66
} else if (spa_streq(key, "monitor")) {
67
monitor = spa_atob(val);
68
+ } else if (spa_streq(key, "control")) {
69
+ control = spa_atob(val);
70
} else if (spa_streq(key, "position")) {
71
if (spa_streq(val, "unknown"))
72
position = POSITION_UNKNOWN;
73
74
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(n->direction),
75
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(mode),
76
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_Bool(monitor),
77
+ SPA_PARAM_PORT_CONFIG_control, SPA_POD_Bool(control),
78
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(param));
79
pw_impl_node_set_param(n->node, SPA_PARAM_PortConfig, 0, param);
80
81
pipewire-0.3.52.tar.gz/src/modules/module-echo-cancel.c -> pipewire-0.3.53.tar.gz/src/modules/module-echo-cancel.c
Changed
59
1
2
*
3
* - \ref PW_KEY_AUDIO_RATE
4
* - \ref PW_KEY_AUDIO_CHANNELS
5
+ * - \ref SPA_KEY_AUDIO_POSITION
6
* - \ref PW_KEY_MEDIA_CLASS
7
* - \ref PW_KEY_NODE_LATENCY
8
* - \ref PW_KEY_NODE_NAME
9
10
* - \ref PW_KEY_NODE_VIRTUAL
11
* - \ref PW_KEY_NODE_LATENCY
12
* - \ref PW_KEY_REMOTE_NAME
13
- * - \ref SPA_KEY_AUDIO_POSITION
14
*
15
* ## Example configuration
16
*\code{.unparsed}
17
18
PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
19
#define PW_LOG_TOPIC_DEFAULT mod_topic
20
21
+#define DEFAULT_RATE 48000
22
+#define DEFAULT_CHANNELS 2
23
+#define DEFAULT_POSITION " FL FR "
24
+
25
/* Hopefully this is enough for any combination of AEC engine and resampler
26
* input requirement for rate matching */
27
#define MAX_BUFSIZE_MS 100
28
29
*info = SPA_AUDIO_INFO_RAW_INIT(
30
.format = SPA_AUDIO_FORMAT_F32P);
31
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
32
+ if (info->rate == 0)
33
+ info->rate = DEFAULT_RATE;
34
+
35
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
36
+ info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
37
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
38
parse_position(info, str, strlen(str));
39
+ if (info->channels == 0)
40
+ parse_position(info, DEFAULT_POSITION, strlen(DEFAULT_POSITION));
41
}
42
43
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
44
45
46
parse_audio_info(props, &impl->info);
47
48
- if (impl->info.channels == 0) {
49
- impl->info.channels = 2;
50
- impl->info.position0 = SPA_AUDIO_CHANNEL_FL;
51
- impl->info.position1 = SPA_AUDIO_CHANNEL_FR;
52
- }
53
- if (impl->info.rate == 0)
54
- impl->info.rate = 48000;
55
-
56
if ((str = pw_properties_get(props, "source.props")) != NULL)
57
pw_properties_update_string(impl->source_props, str, strlen(str));
58
if ((str = pw_properties_get(props, "sink.props")) != NULL)
59
pipewire-0.3.52.tar.gz/src/modules/module-example-sink.c -> pipewire-0.3.53.tar.gz/src/modules/module-example-sink.c
Changed
124
1
2
* Options with well-known behavior.
3
*
4
* - \ref PW_KEY_REMOTE_NAME
5
+ * - \ref PW_KEY_AUDIO_FORMAT
6
* - \ref PW_KEY_AUDIO_RATE
7
* - \ref PW_KEY_AUDIO_CHANNELS
8
* - \ref SPA_KEY_AUDIO_POSITION
9
10
" node.description=<description of the nodes> " \
11
" audio.format=<format, default:"DEFAULT_FORMAT"> " \
12
" audio.rate=<sample rate, default: "SPA_STRINGIFY(DEFAULT_RATE)"> " \
13
- " audio.channels=<number of channels, default:"SPA_STRINGIFY(EFAULT_CHANNELS) "> " \
14
+ " audio.channels=<number of channels, default:"SPA_STRINGIFY(DEFAULT_CHANNELS) "> " \
15
" audio.position=<channel map, default:"DEFAULT_POSITION"> " \
16
" stream.props=<properties> "
17
18
19
}
20
}
21
22
-static int parse_audio_info(struct impl *impl)
23
+static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
24
{
25
- struct pw_properties *props = impl->stream_props;
26
- struct spa_audio_info_raw *info = &impl->info;
27
const char *str;
28
29
spa_zero(*info);
30
-
31
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
32
str = DEFAULT_FORMAT;
33
info->format = format_from_name(str, strlen(str));
34
+
35
+ info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
36
+ if (info->rate == 0)
37
+ info->rate = DEFAULT_RATE;
38
+
39
+ info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
40
+ info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
41
+ if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
42
+ parse_position(info, str, strlen(str));
43
+ if (info->channels == 0)
44
+ parse_position(info, DEFAULT_POSITION, strlen(DEFAULT_POSITION));
45
+}
46
+
47
+static int calc_frame_size(const struct spa_audio_info_raw *info)
48
+{
49
+ int res = info->channels;
50
switch (info->format) {
51
- case SPA_AUDIO_FORMAT_S8:
52
case SPA_AUDIO_FORMAT_U8:
53
- impl->frame_size = 1;
54
- break;
55
+ case SPA_AUDIO_FORMAT_S8:
56
+ case SPA_AUDIO_FORMAT_ALAW:
57
+ case SPA_AUDIO_FORMAT_ULAW:
58
+ return res;
59
case SPA_AUDIO_FORMAT_S16:
60
- impl->frame_size = 2;
61
- break;
62
+ case SPA_AUDIO_FORMAT_S16_OE:
63
+ case SPA_AUDIO_FORMAT_U16:
64
+ return res * 2;
65
case SPA_AUDIO_FORMAT_S24:
66
- impl->frame_size = 3;
67
- break;
68
+ case SPA_AUDIO_FORMAT_S24_OE:
69
+ case SPA_AUDIO_FORMAT_U24:
70
+ return res * 3;
71
case SPA_AUDIO_FORMAT_S24_32:
72
+ case SPA_AUDIO_FORMAT_S24_32_OE:
73
case SPA_AUDIO_FORMAT_S32:
74
+ case SPA_AUDIO_FORMAT_S32_OE:
75
+ case SPA_AUDIO_FORMAT_U32:
76
+ case SPA_AUDIO_FORMAT_U32_OE:
77
case SPA_AUDIO_FORMAT_F32:
78
- impl->frame_size = 4;
79
- break;
80
+ case SPA_AUDIO_FORMAT_F32_OE:
81
+ return res * 4;
82
case SPA_AUDIO_FORMAT_F64:
83
- impl->frame_size = 8;
84
- break;
85
+ case SPA_AUDIO_FORMAT_F64_OE:
86
+ return res * 8;
87
default:
88
- pw_log_error("unsupported format '%s'", str);
89
- return -EINVAL;
90
- }
91
- info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, DEFAULT_RATE);
92
- if (info->rate == 0) {
93
- pw_log_error("invalid rate '%s'", str);
94
- return -EINVAL;
95
+ return 0;
96
}
97
- info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, DEFAULT_CHANNELS);
98
- if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) == NULL)
99
- str = DEFAULT_POSITION;
100
- parse_position(info, str, strlen(str));
101
- if (info->channels == 0) {
102
- pw_log_error("invalid channels '%s'", str);
103
- return -EINVAL;
104
- }
105
- impl->frame_size *= info->channels;
106
-
107
- return 0;
108
}
109
110
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
111
112
copy_props(impl, props, PW_KEY_NODE_VIRTUAL);
113
copy_props(impl, props, PW_KEY_MEDIA_CLASS);
114
115
- if ((res = parse_audio_info(impl)) < 0) {
116
+ parse_audio_info(impl->stream_props, &impl->info);
117
+
118
+ impl->frame_size = calc_frame_size(&impl->info);
119
+ if (impl->frame_size == 0) {
120
+ res = -EINVAL;
121
pw_log_error( "can't parse audio format");
122
goto error;
123
}
124
pipewire-0.3.52.tar.gz/src/modules/module-example-source.c -> pipewire-0.3.53.tar.gz/src/modules/module-example-source.c
Changed
124
1
2
* Options with well-known behavior.
3
*
4
* - \ref PW_KEY_REMOTE_NAME
5
+ * - \ref PW_KEY_AUDIO_FORMAT
6
* - \ref PW_KEY_AUDIO_RATE
7
* - \ref PW_KEY_AUDIO_CHANNELS
8
* - \ref SPA_KEY_AUDIO_POSITION
9
10
" node.description=<description of the nodes> " \
11
" audio.format=<format, default:"DEFAULT_FORMAT"> " \
12
" audio.rate=<sample rate, default: "SPA_STRINGIFY(DEFAULT_RATE)"> " \
13
- " audio.channels=<number of channels, default:"SPA_STRINGIFY(EFAULT_CHANNELS) "> " \
14
+ " audio.channels=<number of channels, default:"SPA_STRINGIFY(DEFAULT_CHANNELS) "> " \
15
" audio.position=<channel map, default:"DEFAULT_POSITION"> " \
16
" stream.props=<properties> "
17
18
19
}
20
}
21
22
-static int parse_audio_info(struct impl *impl)
23
+static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
24
{
25
- struct pw_properties *props = impl->stream_props;
26
- struct spa_audio_info_raw *info = &impl->info;
27
const char *str;
28
29
spa_zero(*info);
30
-
31
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
32
str = DEFAULT_FORMAT;
33
info->format = format_from_name(str, strlen(str));
34
+
35
+ info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
36
+ if (info->rate == 0)
37
+ info->rate = DEFAULT_RATE;
38
+
39
+ info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
40
+ info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
41
+ if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
42
+ parse_position(info, str, strlen(str));
43
+ if (info->channels == 0)
44
+ parse_position(info, DEFAULT_POSITION, strlen(DEFAULT_POSITION));
45
+}
46
+
47
+static int calc_frame_size(const struct spa_audio_info_raw *info)
48
+{
49
+ int res = info->channels;
50
switch (info->format) {
51
- case SPA_AUDIO_FORMAT_S8:
52
case SPA_AUDIO_FORMAT_U8:
53
- impl->frame_size = 1;
54
- break;
55
+ case SPA_AUDIO_FORMAT_S8:
56
+ case SPA_AUDIO_FORMAT_ALAW:
57
+ case SPA_AUDIO_FORMAT_ULAW:
58
+ return res;
59
case SPA_AUDIO_FORMAT_S16:
60
- impl->frame_size = 2;
61
- break;
62
+ case SPA_AUDIO_FORMAT_S16_OE:
63
+ case SPA_AUDIO_FORMAT_U16:
64
+ return res * 2;
65
case SPA_AUDIO_FORMAT_S24:
66
- impl->frame_size = 3;
67
- break;
68
+ case SPA_AUDIO_FORMAT_S24_OE:
69
+ case SPA_AUDIO_FORMAT_U24:
70
+ return res * 3;
71
case SPA_AUDIO_FORMAT_S24_32:
72
+ case SPA_AUDIO_FORMAT_S24_32_OE:
73
case SPA_AUDIO_FORMAT_S32:
74
+ case SPA_AUDIO_FORMAT_S32_OE:
75
+ case SPA_AUDIO_FORMAT_U32:
76
+ case SPA_AUDIO_FORMAT_U32_OE:
77
case SPA_AUDIO_FORMAT_F32:
78
- impl->frame_size = 4;
79
- break;
80
+ case SPA_AUDIO_FORMAT_F32_OE:
81
+ return res * 4;
82
case SPA_AUDIO_FORMAT_F64:
83
- impl->frame_size = 8;
84
- break;
85
+ case SPA_AUDIO_FORMAT_F64_OE:
86
+ return res * 8;
87
default:
88
- pw_log_error("unsupported format '%s'", str);
89
- return -EINVAL;
90
- }
91
- info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, DEFAULT_RATE);
92
- if (info->rate == 0) {
93
- pw_log_error("invalid rate '%s'", str);
94
- return -EINVAL;
95
+ return 0;
96
}
97
- info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, DEFAULT_CHANNELS);
98
- if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) == NULL)
99
- str = DEFAULT_POSITION;
100
- parse_position(info, str, strlen(str));
101
- if (info->channels == 0) {
102
- pw_log_error("invalid channels '%s'", str);
103
- return -EINVAL;
104
- }
105
- impl->frame_size *= info->channels;
106
-
107
- return 0;
108
}
109
110
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
111
112
copy_props(impl, props, PW_KEY_NODE_VIRTUAL);
113
copy_props(impl, props, PW_KEY_MEDIA_CLASS);
114
115
- if ((res = parse_audio_info(impl)) < 0) {
116
+ parse_audio_info(impl->stream_props, &impl->info);
117
+
118
+ impl->frame_size = calc_frame_size(&impl->info);
119
+ if (impl->frame_size == 0) {
120
+ res = -EINVAL;
121
pw_log_error( "can't parse audio format");
122
goto error;
123
}
124
pipewire-0.3.52.tar.gz/src/modules/module-filter-chain.c -> pipewire-0.3.53.tar.gz/src/modules/module-filter-chain.c
Changed
45
1
2
* graph n_hndl times when needed. */
3
n_hndl = impl->capture_info.channels / n_input;
4
if (n_hndl != impl->playback_info.channels / n_output) {
5
- pw_log_error("invalid channels");
6
+ pw_log_error("invalid channels. The capture stream has %1$d channels and "
7
+ "the filter has %2$d inputs. The playback stream has %3$d channels "
8
+ "and the filter has %4$d outputs. capture:%1$d / input:%2$d != "
9
+ "playback:%3$d / output:%4$d. Check inputs and outputs objects.",
10
+ impl->capture_info.channels, n_input,
11
+ impl->playback_info.channels, n_output);
12
res = -EINVAL;
13
goto error;
14
}
15
if (n_hndl > MAX_HNDL) {
16
- pw_log_error("too many channels");
17
+ pw_log_error("too many channels. %d > %d", n_hndl, MAX_HNDL);
18
res = -EINVAL;
19
goto error;
20
}
21
+ if (n_hndl == 0) {
22
+ n_hndl = 1;
23
+ pw_log_warn("The capture stream has %1$d channels and "
24
+ "the filter has %2$d inputs. The playback stream has %3$d channels "
25
+ "and the filter has %4$d outputs. Some filter ports will be "
26
+ "unconnected..",
27
+ impl->capture_info.channels, n_input,
28
+ impl->playback_info.channels, n_output);
29
+ }
30
pw_log_info("using %d instances %d %d", n_hndl, n_input, n_output);
31
32
/* now go over all nodes and create instances. */
33
34
35
*info = SPA_AUDIO_INFO_RAW_INIT(
36
.format = SPA_AUDIO_FORMAT_F32P);
37
- info->rate = pw_properties_get_int32(props, PW_KEY_AUDIO_RATE, 0);
38
- info->channels = pw_properties_get_int32(props, PW_KEY_AUDIO_CHANNELS, 0);
39
+ info->rate = pw_properties_get_int32(props, PW_KEY_AUDIO_RATE, info->rate);
40
+ info->channels = pw_properties_get_int32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
41
+ info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
42
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
43
parse_position(info, str, strlen(str));
44
}
45
pipewire-0.3.52.tar.gz/src/modules/module-filter-chain/ladspa_plugin.c -> pipewire-0.3.53.tar.gz/src/modules/module-filter-chain/ladspa_plugin.c
Changed
10
1
2
desc->desc.free = ladspa_free;
3
4
desc->desc.name = d->Label;
5
- desc->desc.flags = d->Properties;
6
+ desc->desc.flags = 0;
7
8
desc->desc.n_ports = d->PortCount;
9
desc->desc.ports = calloc(desc->desc.n_ports, sizeof(struct fc_port));
10
pipewire-0.3.52.tar.gz/src/modules/module-loopback.c -> pipewire-0.3.53.tar.gz/src/modules/module-loopback.c
Changed
9
1
2
.format = SPA_AUDIO_FORMAT_F32P);
3
info->rate = pw_properties_get_int32(props, PW_KEY_AUDIO_RATE, 0);
4
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, 0);
5
+ info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
6
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
7
parse_position(info, str, strlen(str));
8
}
9
pipewire-0.3.52.tar.gz/src/modules/module-pipe-tunnel.c -> pipewire-0.3.53.tar.gz/src/modules/module-pipe-tunnel.c
Changed
136
1
2
* Options with well-known behavior.
3
*
4
* - \ref PW_KEY_REMOTE_NAME
5
+ * - \ref PW_KEY_AUDIO_FORMAT
6
* - \ref PW_KEY_AUDIO_RATE
7
* - \ref PW_KEY_AUDIO_CHANNELS
8
* - \ref SPA_KEY_AUDIO_POSITION
9
10
* tunnel.mode = playback
11
* # Set the pipe name to tunnel to
12
* pipe.filename = "/tmp/fifo_output"
13
+ * #audio.format=<sample format>
14
* #audio.rate=<sample rate>
15
* #audio.channels=<number of channels>
16
* #audio.position=<channel map>
17
18
#define DEFAULT_CAPTURE_FILENAME "/tmp/fifo_input"
19
#define DEFAULT_PLAYBACK_FILENAME "/tmp/fifo_output"
20
21
+#define DEFAULT_FORMAT "S16"
22
+#define DEFAULT_RATE 48000
23
+#define DEFAULT_CHANNELS 2
24
+#define DEFAULT_POSITION " FL FR "
25
+
26
PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
27
#define PW_LOG_TOPIC_DEFAULT mod_topic
28
29
30
" node.name=<name of the nodes> " \
31
" node.description=<description of the nodes> " \
32
" node.target=<remote node target name> " \
33
+ " audio.format=<sample format> " \
34
" audio.rate=<sample rate> " \
35
" audio.channels=<number of channels> " \
36
" audio.position=<channel map> " \
37
38
do_unlink_fifo = true;
39
}
40
41
- if ((fd = open(filename, O_RDWR | O_CLOEXEC | O_NONBLOCK, 0)) <= 0) {
42
+ if ((fd = open(filename, O_RDWR | O_CLOEXEC | O_NONBLOCK, 0)) < 0) {
43
res = -errno;
44
pw_log_error("open('%s'): %s", filename, spa_strerror(res));
45
goto error;
46
47
error:
48
if (do_unlink_fifo)
49
unlink(filename);
50
- if (fd > 0)
51
+ if (fd >= 0)
52
close(fd);
53
return res;
54
}
55
56
unlink(impl->filename);
57
free(impl->filename);
58
}
59
- if (impl->fd > 0)
60
+ if (impl->fd >= 0)
61
close(impl->fd);
62
63
pw_properties_free(impl->stream_props);
64
65
return SPA_AUDIO_FORMAT_UNKNOWN;
66
}
67
68
-static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
69
+static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
70
{
71
const char *str;
72
73
- *info = SPA_AUDIO_INFO_RAW_INIT(
74
- .rate = 48000,
75
- .channels = 2,
76
- .format = SPA_AUDIO_FORMAT_S16);
77
-
78
- if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) != NULL) {
79
- uint32_t id;
80
-
81
- id = format_from_name(str, strlen(str));
82
- if (id != SPA_AUDIO_FORMAT_UNKNOWN)
83
- info->format = id;
84
- }
85
+ spa_zero(*info);
86
+ if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
87
+ str = DEFAULT_FORMAT;
88
+ info->format = format_from_name(str, strlen(str));
89
90
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
91
+ if (info->rate == 0)
92
+ info->rate = DEFAULT_RATE;
93
+
94
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
95
+ info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
96
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
97
parse_position(info, str, strlen(str));
98
-
99
+ if (info->channels == 0)
100
+ parse_position(info, DEFAULT_POSITION, strlen(DEFAULT_POSITION));
101
}
102
103
-static int calc_frame_size(struct spa_audio_info_raw *info)
104
+static int calc_frame_size(const struct spa_audio_info_raw *info)
105
{
106
int res = info->channels;
107
switch (info->format) {
108
109
110
parse_audio_info(impl->stream_props, &impl->info);
111
112
- if (impl->info.rate != 0 &&
113
- pw_properties_get(props, PW_KEY_NODE_RATE) == NULL)
114
- pw_properties_setf(props, PW_KEY_NODE_RATE,
115
- "1/%u", impl->info.rate),
116
-
117
- copy_props(impl, props, PW_KEY_NODE_RATE);
118
-
119
impl->frame_size = calc_frame_size(&impl->info);
120
if (impl->frame_size == 0) {
121
pw_log_error("unsupported audio format:%d channels:%d",
122
123
res = -EINVAL;
124
goto error;
125
}
126
+ if (impl->info.rate != 0 &&
127
+ pw_properties_get(props, PW_KEY_NODE_RATE) == NULL)
128
+ pw_properties_setf(props, PW_KEY_NODE_RATE,
129
+ "1/%u", impl->info.rate),
130
+
131
+ copy_props(impl, props, PW_KEY_NODE_RATE);
132
+
133
impl->leftover = calloc(1, impl->frame_size);
134
if (impl->leftover == NULL) {
135
res = -errno;
136
pipewire-0.3.52.tar.gz/src/modules/module-protocol-native.c -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-native.c
Changed
28
1
2
#ifdef HAVE_PWD_H
3
#include <pwd.h>
4
#endif
5
-#if defined(__FreeBSD__)
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
#include <sys/ucred.h>
8
#endif
9
10
11
struct pw_impl_client *client;
12
struct pw_protocol *protocol = s->this.protocol;
13
socklen_t len;
14
-#if defined(__FreeBSD__)
15
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
16
struct xucred xucred;
17
#else
18
struct ucred ucred;
19
20
(int)len, buffer);
21
}
22
}
23
-#elif defined(__FreeBSD__)
24
+#elif defined(__FreeBSD__) || defined(__MidnightBSD__)
25
len = sizeof(xucred);
26
if (getsockopt(fd, 0, LOCAL_PEERCRED, &xucred, &len) < 0) {
27
pw_log_warn("server %p: no peercred: %m", s);
28
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse.c -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse.c
Changed
22
1
2
* VMs usually can't support the low latency settings that are possible on real
3
* hardware.
4
*
5
- * ## Application settings (Rules)
6
- *
7
- * The pulse protocol module supports generic config rules. It provides a `quirks`
8
- * and an `update-props` action.
9
+ * ## Stream settings and rules
10
*
11
* Streams created by module-protocol-pulse will use the stream.properties
12
* section and stream.rules sections as usual.
13
*
14
+ * ## Application settings (Rules)
15
+ *
16
+ * The pulse protocol module supports generic config rules. It supports a pulse.rules
17
+ * section with a `quirks` and an `update-props` action.
18
+ *
19
*\code{.unparsed}
20
* pulse.rules =
21
* {
22
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse/client.c -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/client.c
Changed
48
1
2
pending_sample_free(p);
3
4
if (client->message)
5
- message_free(impl, client->message, false, false);
6
+ message_free(client->message, false, false);
7
8
spa_list_consume(msg, &client->out_messages, link)
9
- message_free(impl, msg, true, false);
10
+ message_free(msg, true, false);
11
12
spa_list_consume(o, &client->operations, link)
13
operation_free(o);
14
15
return 0;
16
17
error:
18
- message_free(impl, msg, false, false);
19
+ message_free(msg, false, false);
20
return res;
21
}
22
23
static int client_try_flush_messages(struct client *client)
24
{
25
- struct impl *impl = client->impl;
26
-
27
pw_log_trace("client %p: flushing", client);
28
29
spa_assert(!client->disconnect);
30
31
} else {
32
if (debug_messages && m->channel == SPA_ID_INVALID)
33
message_dump(SPA_LOG_LEVEL_INFO, m);
34
- message_free(impl, m, true, false);
35
+ message_free(m, true, false);
36
client->out_index = 0;
37
continue;
38
}
39
40
if (m == first && client->out_index > 0)
41
return false;
42
43
- message_free(client->impl, m, true, false);
44
+ message_free(m, true, false);
45
46
return true;
47
}
48
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse/client.h -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/client.h
Changed
10
1
2
struct server *server;
3
4
int ref;
5
- const char *name;
6
+ const char *name; /* owned by `client::props` */
7
8
struct spa_source *source;
9
10
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse/message.c -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/message.c
Changed
82
1
2
uint32_t alloc, diff;
3
void *data;
4
5
+ if (m->length > m->allocated)
6
+ return -ENOMEM;
7
+
8
if (m->length + size <= m->allocated)
9
return size;
10
11
12
diff = alloc - m->allocated;
13
if ((data = realloc(m->data, alloc)) == NULL) {
14
free(m->data);
15
- m->stat->allocated -= m->allocated;
16
+ m->data = NULL;
17
+ m->impl->stat.allocated -= m->allocated;
18
m->allocated = 0;
19
return -errno;
20
}
21
- m->stat->allocated += diff;
22
- m->stat->accumulated += diff;
23
+ m->impl->stat.allocated += diff;
24
+ m->impl->stat.accumulated += diff;
25
m->data = data;
26
m->allocated = alloc;
27
return size;
28
29
msg = spa_list_first(&impl->free_messages, struct message, link);
30
spa_list_remove(&msg->link);
31
pw_log_trace("using recycled message %p size:%d", msg, size);
32
+
33
+ spa_assert(msg->impl == impl);
34
} else {
35
if ((msg = calloc(1, sizeof(*msg))) == NULL)
36
return NULL;
37
38
pw_log_trace("new message %p size:%d", msg, size);
39
- msg->stat = &impl->stat;
40
- msg->stat->n_allocated++;
41
- msg->stat->n_accumulated++;
42
+ msg->impl = impl;
43
+ msg->impl->stat.n_allocated++;
44
+ msg->impl->stat.n_accumulated++;
45
}
46
47
if (ensure_size(msg, size) < 0) {
48
- message_free(impl, msg, false, true);
49
+ message_free(msg, false, true);
50
return NULL;
51
}
52
53
54
return msg;
55
}
56
57
-void message_free(struct impl *impl, struct message *msg, bool dequeue, bool destroy)
58
+void message_free(struct message *msg, bool dequeue, bool destroy)
59
{
60
if (dequeue)
61
spa_list_remove(&msg->link);
62
63
- if (msg->stat->allocated > MAX_ALLOCATED || msg->allocated > MAX_SIZE)
64
+ if (msg->impl->stat.allocated > MAX_ALLOCATED || msg->allocated > MAX_SIZE)
65
destroy = true;
66
67
if (destroy) {
68
pw_log_trace("destroy message %p size:%d", msg, msg->allocated);
69
- msg->stat->n_allocated--;
70
- msg->stat->allocated -= msg->allocated;
71
+ msg->impl->stat.n_allocated--;
72
+ msg->impl->stat.allocated -= msg->allocated;
73
free(msg->data);
74
free(msg);
75
} else {
76
pw_log_trace("recycle message %p size:%d/%d", msg, msg->length, msg->allocated);
77
- spa_list_append(&impl->free_messages, &msg->link);
78
+ spa_list_append(&msg->impl->free_messages, &msg->link);
79
msg->length = 0;
80
}
81
}
82
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse/message.h -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/message.h
Changed
24
1
2
#include <spa/support/log.h>
3
4
struct impl;
5
-struct client;
6
-struct stats;
7
8
struct message {
9
struct spa_list link;
10
- struct stats *stat;
11
+ struct impl *impl;
12
uint32_t extra4;
13
uint32_t channel;
14
uint32_t allocated;
15
16
};
17
18
struct message *message_alloc(struct impl *impl, uint32_t channel, uint32_t size);
19
-void message_free(struct impl *impl, struct message *msg, bool dequeue, bool destroy);
20
+void message_free(struct message *msg, bool dequeue, bool destroy);
21
int message_get(struct message *m, ...);
22
int message_put(struct message *m, ...);
23
int message_dump(enum spa_log_level level, struct message *m);
24
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse/pulse-server.c -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/pulse-server.c
Changed
146
1
2
#define DEFAULT_POSITION " FL FR "
3
4
#define MAX_FORMATS 32
5
-/* The max amount of data we send in one block when capturing. In PulseAudio this
6
- * size is derived from the mempool PA_MEMPOOL_SLOT_SIZE */
7
-#define MAX_FRAGSIZE (64*1024)
8
9
#define TEMPORARY_MOVE_TIMEOUT (SPA_NSEC_PER_SEC)
10
11
12
if (frame_size == 0)
13
frame_size = 4;
14
15
+ pw_log_info("%s maxlength:%u tlength:%u minreq:%u prebuf:%u",
16
+ s->client->name, attr->maxlength, attr->tlength,
17
+ attr->minreq, attr->prebuf);
18
+
19
minreq = frac_to_bytes_round_up(s->min_req, &s->ss);
20
max_latency = defs->quantum_limit * frame_size;
21
22
23
if (frame_size == 0)
24
frame_size = 4;
25
26
+ pw_log_info("%s maxlength:%u fragsize:%u",
27
+ s->client->name, attr->maxlength, attr->fragsize);
28
+
29
if (attr->maxlength == (uint32_t) -1 || attr->maxlength > MAXLENGTH)
30
attr->maxlength = MAXLENGTH;
31
attr->maxlength -= attr->maxlength % frame_size;
32
33
34
if (attr->fragsize == (uint32_t) -1 || attr->fragsize == 0)
35
attr->fragsize = frac_to_bytes_round_up(s->default_frag, &s->ss);
36
- attr->fragsize -= attr->fragsize % frame_size;
37
+ attr->fragsize = SPA_MIN(attr->fragsize, attr->maxlength);
38
+ attr->fragsize = SPA_ROUND_UP(attr->fragsize, frame_size);
39
attr->fragsize = SPA_MAX(attr->fragsize, minfrag);
40
- attr->fragsize = SPA_MAX(attr->fragsize, frame_size);
41
-
42
- if (attr->fragsize > attr->maxlength)
43
- attr->fragsize = attr->maxlength;
44
45
attr->tlength = attr->minreq = attr->prebuf = 0;
46
47
48
} else {
49
latency = attr->fragsize;
50
}
51
+ /* make sure can queue at least to fragsize without overruns */
52
+ if (attr->maxlength < attr->fragsize * 2)
53
+ attr->maxlength = attr->fragsize * 2;
54
55
pw_log_info("%s maxlength:%u fragsize:%u minfrag:%u latency:%u",
56
s->client->name, attr->maxlength, attr->fragsize, minfrag,
57
58
peer = find_linked(manager, peer->id, PW_DIRECTION_OUTPUT);
59
if (peer && pw_manager_object_is_source_or_monitor(peer)) {
60
name = pw_properties_get(peer->props, PW_KEY_NODE_NAME);
61
+ peer_index = peer->index;
62
if (!pw_manager_object_is_source(peer)) {
63
size_t len = (name ? strlen(name) : 5) + 10;
64
- peer_index = peer->index;
65
peer_name = tmp = alloca(len);
66
snprintf(tmp, len, "%s.monitor", name ? name : "sink");
67
} else {
68
- peer_index = peer->index;
69
peer_name = name;
70
}
71
} else {
72
73
s->peer_index = peer->index;
74
75
peer_name = pw_properties_get(peer->props, PW_KEY_NODE_NAME);
76
+ if (peer_name && s->direction == PW_DIRECTION_INPUT &&
77
+ pw_manager_object_is_monitor(peer)) {
78
+ int len = strlen(peer_name) + 10;
79
+ char *tmp = alloca(len);
80
+ snprintf(tmp, len, "%s.monitor", peer_name);
81
+ peer_name = tmp;
82
+ }
83
if (peer_name != NULL)
84
stream_send_moved(s, peer->index, peer_name);
85
}
86
87
changed++;
88
}
89
90
+ client_update_quirks(client);
91
+
92
client->name = pw_properties_get(client->props, PW_KEY_APP_NAME);
93
pw_log_info("%s %s tag:%d", client->name,
94
commandscommand.name, tag);
95
96
- client_update_quirks(client);
97
-
98
if (client->core == NULL) {
99
client->core = pw_context_connect(impl->context,
100
pw_properties_copy(client->props), 0);
101
102
}
103
104
while ((uint32_t)avail >= stream->attr.fragsize) {
105
- towrite = SPA_MIN(avail, MAX_FRAGSIZE);
106
- towrite = SPA_ROUND_DOWN(towrite, stream->frame_size);
107
+ towrite = SPA_MIN((uint32_t)avail, stream->attr.fragsize);
108
109
msg = message_alloc(impl, stream->channel, towrite);
110
if (msg == NULL)
111
112
} else {
113
if (pw_properties_update(client->props, &props->dict) > 0) {
114
client_update_quirks(client);
115
+ client->name = pw_properties_get(client->props, PW_KEY_APP_NAME);
116
pw_core_update_properties(client->core, &client->props->dict);
117
}
118
}
119
120
goto error;
121
error:
122
if (reply)
123
- message_free(impl, reply, false, false);
124
+ message_free(reply, false, false);
125
return res;
126
}
127
128
129
130
error:
131
if (reply)
132
- message_free(impl, reply, false, false);
133
+ message_free(reply, false, false);
134
return res;
135
}
136
137
138
client_free(c);
139
140
spa_list_consume(msg, &impl->free_messages, link)
141
- message_free(impl, msg, true, true);
142
+ message_free(msg, true, true);
143
144
pw_map_for_each(&impl->samples, impl_free_sample, impl);
145
pw_map_clear(&impl->samples);
146
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse/remap.c -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/remap.c
Changed
9
1
2
3
const struct str_map props_key_map = {
4
{ PW_KEY_DEVICE_BUS_PATH, "device.bus_path" },
5
+ { PW_KEY_DEVICE_SYSFS_PATH, "sysfs.path" },
6
{ PW_KEY_DEVICE_FORM_FACTOR, "device.form_factor" },
7
{ PW_KEY_DEVICE_ICON_NAME, "device.icon_name" },
8
{ PW_KEY_DEVICE_INTENDED_ROLES, "device.intended_roles" },
9
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse/server.c -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/server.c
Changed
53
1
2
3
static int handle_packet(struct client *client, struct message *msg)
4
{
5
- struct impl * const impl = client->impl;
6
uint32_t command, tag;
7
int res = 0;
8
9
10
res = cmd->run(client, command, tag, msg);
11
12
finish:
13
- message_free(impl, msg, false, false);
14
+ message_free(msg, false, false);
15
if (res < 0)
16
reply_error(client, command, tag, res);
17
18
19
20
static int handle_memblock(struct client *client, struct message *msg)
21
{
22
- struct impl * const impl = client->impl;
23
struct stream *stream;
24
uint32_t channel, flags, index;
25
int64_t offset, diff;
26
27
stream_send_request(stream);
28
29
finish:
30
- message_free(impl, msg, false, false);
31
+ message_free(msg, false, false);
32
return res;
33
}
34
35
36
}
37
38
if (client->message)
39
- message_free(impl, client->message, false, false);
40
+ message_free(client->message, false, false);
41
42
client->message = message_alloc(impl, channel, length);
43
} else if (client->message &&
44
45
if (address0 != '/') {
46
char runtime_dirPATH_MAX;
47
48
- if ((res = get_runtime_dir(runtime_dir, sizeof(runtime_dir), "pulse")) < 0)
49
+ if ((res = get_runtime_dir(runtime_dir, sizeof(runtime_dir))) < 0)
50
return res;
51
52
res = snprintf(addr.sun_path, sizeof(addr.sun_path),
53
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse/utils.c -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/utils.c
Changed
56
1
2
#include "log.h"
3
#include "utils.h"
4
5
-int get_runtime_dir(char *buf, size_t buflen, const char *dir)
6
+int get_runtime_dir(char *buf, size_t buflen)
7
{
8
- const char *runtime_dir;
9
+ const char *runtime_dir, *dir = NULL;
10
struct stat stat_buf;
11
int res, size;
12
13
runtime_dir = getenv("PULSE_RUNTIME_PATH");
14
- if (runtime_dir == NULL)
15
+ if (runtime_dir == NULL) {
16
runtime_dir = getenv("XDG_RUNTIME_DIR");
17
-
18
+ dir = "pulse";
19
+ }
20
if (runtime_dir == NULL) {
21
pw_log_error("could not find a suitable runtime directory in"
22
"$PULSE_RUNTIME_PATH and $XDG_RUNTIME_DIR");
23
return -ENOENT;
24
}
25
26
- size = snprintf(buf, buflen, "%s/%s", runtime_dir, dir);
27
+ size = snprintf(buf, buflen, "%s%s%s", runtime_dir,
28
+ dir ? "/" : "", dir ? dir : "");
29
if (size < 0)
30
return -errno;
31
if ((size_t) size >= buflen) {
32
- pw_log_error("path %s/%s too long", runtime_dir, dir);
33
+ pw_log_error("path %s%s%s too long", runtime_dir,
34
+ dir ? "/" : "", dir ? dir : "");
35
return -ENAMETOOLONG;
36
}
37
38
39
pw_log_warn("client %p: no peercred: %m", client);
40
} else
41
return ucred.pid;
42
-#elif defined(__FreeBSD__)
43
+#elif defined(__FreeBSD__) || defined(__MidnightBSD__)
44
struct xucred xucred;
45
len = sizeof(xucred);
46
if (getsockopt(client_fd, 0, LOCAL_PEERCRED, &xucred, &len) < 0) {
47
48
FILE *f;
49
int res;
50
51
- if ((res = get_runtime_dir(pid_file, sizeof(pid_file), "pulse")) < 0)
52
+ if ((res = get_runtime_dir(pid_file, sizeof(pid_file))) < 0)
53
return res;
54
55
if (strlen(pid_file) > PATH_MAX - sizeof("/pid")) {
56
pipewire-0.3.52.tar.gz/src/modules/module-protocol-pulse/utils.h -> pipewire-0.3.53.tar.gz/src/modules/module-protocol-pulse/utils.h
Changed
10
1
2
struct client;
3
struct pw_context;
4
5
-int get_runtime_dir(char *buf, size_t buflen, const char *dir);
6
+int get_runtime_dir(char *buf, size_t buflen);
7
int check_flatpak(struct client *client, pid_t pid);
8
pid_t get_client_pid(struct client *client, int client_fd);
9
const char *get_server_name(struct pw_context *context);
10
pipewire-0.3.52.tar.gz/src/modules/module-pulse-tunnel.c -> pipewire-0.3.53.tar.gz/src/modules/module-pulse-tunnel.c
Changed
67
1
2
* Options with well-known behavior.
3
*
4
* - \ref PW_KEY_REMOTE_NAME
5
+ * - \ref PW_KEY_AUDIO_FORMAT
6
* - \ref PW_KEY_AUDIO_RATE
7
* - \ref PW_KEY_AUDIO_CHANNELS
8
* - \ref SPA_KEY_AUDIO_POSITION
9
10
PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
11
#define PW_LOG_TOPIC_DEFAULT mod_topic
12
13
+#define DEFAULT_FORMAT "S16"
14
+#define DEFAULT_RATE 48000
15
+#define DEFAULT_CHANNELS 2
16
+#define DEFAULT_POSITION " FL FR "
17
+
18
#define MODULE_USAGE " remote.name=<remote> " \
19
" node.latency=<latency as fraction> " \
20
" node.name=<name of the nodes> " \
21
" node.description=<description of the nodes> " \
22
" node.target=<remote node target name> " \
23
+ " audio.format=<sample format> " \
24
" audio.rate=<sample rate> " \
25
" audio.channels=<number of channels> " \
26
" audio.position=<channel map> " \
27
28
return SPA_AUDIO_FORMAT_UNKNOWN;
29
}
30
31
-static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
32
+static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
33
{
34
const char *str;
35
36
- *info = SPA_AUDIO_INFO_RAW_INIT(
37
- .rate = 48000,
38
- .channels = 2,
39
- .format = SPA_AUDIO_FORMAT_S16);
40
-
41
- if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) != NULL) {
42
- uint32_t id;
43
-
44
- id = format_from_name(str, strlen(str));
45
- if (id != SPA_AUDIO_FORMAT_UNKNOWN)
46
- info->format = id;
47
- }
48
+ spa_zero(*info);
49
+ if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
50
+ str = DEFAULT_FORMAT;
51
+ info->format = format_from_name(str, strlen(str));
52
53
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
54
+ if (info->rate == 0)
55
+ info->rate = DEFAULT_RATE;
56
+
57
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
58
+ info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
59
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
60
parse_position(info, str, strlen(str));
61
-
62
+ if (info->channels == 0)
63
+ parse_position(info, DEFAULT_POSITION, strlen(DEFAULT_POSITION));
64
}
65
66
static int calc_frame_size(struct spa_audio_info_raw *info)
67
pipewire-0.3.52.tar.gz/src/modules/module-raop-sink.c -> pipewire-0.3.53.tar.gz/src/modules/module-raop-sink.c
Changed
152
1
2
" node.name=<name of the nodes> " \
3
" node.description=<description of the nodes> " \
4
" audio.format=<format, default:"DEFAULT_FORMAT"> " \
5
- " audio.rate=<sample rate, default: "SPA_STRINGIFY(DEFAuLT_RATE)"> " \
6
+ " audio.rate=<sample rate, default: "SPA_STRINGIFY(DEFAULT_RATE)"> " \
7
" audio.channels=<number of channels, default:"SPA_STRINGIFY(DEFAULT_CHANNELS)"> " \
8
" audio.position=<channel map, default:"DEFAULT_POSITION"> " \
9
" stream.props=<properties> "
10
11
DEFAULT_USER_NAME, realm, nonce, resp);
12
}
13
else
14
- return -EINVAL;
15
+ goto error;
16
17
pw_properties_setf(impl->headers, "Authorization", "%s %s",
18
tokens0, auth);
19
20
}
21
}
22
23
-static int parse_audio_info(struct impl *impl)
24
+static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
25
{
26
- struct pw_properties *props = impl->stream_props;
27
- struct spa_audio_info_raw *info = &impl->info;
28
const char *str;
29
30
spa_zero(*info);
31
-
32
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
33
str = DEFAULT_FORMAT;
34
info->format = format_from_name(str, strlen(str));
35
+
36
+ info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
37
+ if (info->rate == 0)
38
+ info->rate = DEFAULT_RATE;
39
+
40
+ info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
41
+ info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
42
+ if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
43
+ parse_position(info, str, strlen(str));
44
+ if (info->channels == 0)
45
+ parse_position(info, DEFAULT_POSITION, strlen(DEFAULT_POSITION));
46
+}
47
+
48
+static int calc_frame_size(struct spa_audio_info_raw *info)
49
+{
50
+ int res = info->channels;
51
switch (info->format) {
52
- case SPA_AUDIO_FORMAT_S8:
53
case SPA_AUDIO_FORMAT_U8:
54
- impl->frame_size = 1;
55
- break;
56
+ case SPA_AUDIO_FORMAT_S8:
57
+ case SPA_AUDIO_FORMAT_ALAW:
58
+ case SPA_AUDIO_FORMAT_ULAW:
59
+ return res;
60
case SPA_AUDIO_FORMAT_S16:
61
- impl->frame_size = 2;
62
- break;
63
+ case SPA_AUDIO_FORMAT_S16_OE:
64
+ case SPA_AUDIO_FORMAT_U16:
65
+ return res * 2;
66
case SPA_AUDIO_FORMAT_S24:
67
- impl->frame_size = 3;
68
- break;
69
+ case SPA_AUDIO_FORMAT_S24_OE:
70
+ case SPA_AUDIO_FORMAT_U24:
71
+ return res * 3;
72
case SPA_AUDIO_FORMAT_S24_32:
73
+ case SPA_AUDIO_FORMAT_S24_32_OE:
74
case SPA_AUDIO_FORMAT_S32:
75
+ case SPA_AUDIO_FORMAT_S32_OE:
76
+ case SPA_AUDIO_FORMAT_U32:
77
+ case SPA_AUDIO_FORMAT_U32_OE:
78
case SPA_AUDIO_FORMAT_F32:
79
- impl->frame_size = 4;
80
- break;
81
+ case SPA_AUDIO_FORMAT_F32_OE:
82
+ return res * 4;
83
case SPA_AUDIO_FORMAT_F64:
84
- impl->frame_size = 8;
85
- break;
86
+ case SPA_AUDIO_FORMAT_F64_OE:
87
+ return res * 8;
88
default:
89
- pw_log_error("unsupported format '%s'", str);
90
- return -EINVAL;
91
- }
92
- info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, DEFAULT_RATE);
93
- if (info->rate == 0) {
94
- pw_log_error("invalid rate '%s'", str);
95
- return -EINVAL;
96
- }
97
- info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, DEFAULT_CHANNELS);
98
- if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) == NULL)
99
- str = DEFAULT_POSITION;
100
- parse_position(info, str, strlen(str));
101
- if (info->channels == 0) {
102
- pw_log_error("invalid channels '%s'", str);
103
- return -EINVAL;
104
+ return 0;
105
}
106
- impl->frame_size *= info->channels;
107
-
108
- return 0;
109
}
110
111
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
112
113
copy_props(impl, props, PW_KEY_NODE_VIRTUAL);
114
copy_props(impl, props, PW_KEY_MEDIA_CLASS);
115
116
- if ((res = parse_audio_info(impl)) < 0) {
117
- pw_log_error( "can't parse audio format");
118
+ parse_audio_info(impl->stream_props, &impl->info);
119
+
120
+ impl->frame_size = calc_frame_size(&impl->info);
121
+ if (impl->frame_size == 0) {
122
+ pw_log_error("unsupported audio format:%d channels:%d",
123
+ impl->info.format, impl->info.channels);
124
+ res = -EINVAL;
125
goto error;
126
}
127
128
129
impl->protocol = PROTO_TCP;
130
else {
131
pw_log_error( "can't handle transport %s", str);
132
+ res = -EINVAL;
133
goto error;
134
}
135
136
137
impl->encryption = CRYPTO_RSA;
138
else {
139
pw_log_error( "can't handle encryption type %s", str);
140
+ res = -EINVAL;
141
goto error;
142
}
143
144
145
impl->codec = CODEC_PCM;
146
else {
147
pw_log_error( "can't handle codec type %s", str);
148
+ res = -EINVAL;
149
goto error;
150
}
151
str = pw_properties_get(props, "raop.password");
152
pipewire-0.3.52.tar.gz/src/modules/module-roc-sink.c -> pipewire-0.3.53.tar.gz/src/modules/module-roc-sink.c
Changed
10
1
2
/* Fixed to be the same as ROC sender config above */
3
info.rate = 44100;
4
info.channels = 2;
5
- info.format = SPA_AUDIO_FORMAT_F32_LE;
6
+ info.format = SPA_AUDIO_FORMAT_F32;
7
info.position0 = SPA_AUDIO_CHANNEL_FL;
8
info.position1 = SPA_AUDIO_CHANNEL_FR;
9
10
pipewire-0.3.52.tar.gz/src/modules/module-roc-source.c -> pipewire-0.3.53.tar.gz/src/modules/module-roc-source.c
Changed
10
1
2
/* Fixed to be the same as ROC receiver config above */
3
info.rate = 44100;
4
info.channels = 2;
5
- info.format = SPA_AUDIO_FORMAT_F32_LE;
6
+ info.format = SPA_AUDIO_FORMAT_F32;
7
info.position0 = SPA_AUDIO_CHANNEL_FL;
8
info.position1 = SPA_AUDIO_CHANNEL_FR;
9
data->stride = info.channels * sizeof(float);
10
pipewire-0.3.52.tar.gz/src/modules/module-rt.c -> pipewire-0.3.53.tar.gz/src/modules/module-rt.c
Changed
19
1
2
#include <stdio.h>
3
#include <errno.h>
4
#include <sys/stat.h>
5
-#ifdef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
#include <sys/thr.h>
8
#endif
9
#include <fcntl.h>
10
11
return (pid_t) gettid();
12
#elif defined(__linux__)
13
return syscall(SYS_gettid);
14
-#elif defined(__FreeBSD__)
15
+#elif defined(__FreeBSD__) || defined(__MidnightBSD__)
16
long pid;
17
thr_self(&pid);
18
return (pid_t)pid;
19
pipewire-0.3.52.tar.gz/src/pipewire/conf.c -> pipewire-0.3.53.tar.gz/src/pipewire/conf.c
Changed
10
1
2
#ifdef HAVE_PWD_H
3
#include <pwd.h>
4
#endif
5
-#ifdef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
#define O_PATH 0
8
#endif
9
10
pipewire-0.3.52.tar.gz/src/pipewire/data-loop.c -> pipewire-0.3.53.tar.gz/src/pipewire/data-loop.c
Changed
26
1
2
int res;
3
4
while (true) {
5
- if (!this->running) {
6
+ if (SPA_UNLIKELY(!this->running)) {
7
res = -ECANCELED;
8
break;
9
}
10
- if ((res = pw_loop_iterate(this->loop, timeout)) < 0) {
11
+ if (SPA_UNLIKELY((res = pw_loop_iterate(this->loop, timeout)) < 0)) {
12
if (res == -EINTR)
13
continue;
14
}
15
16
17
pthread_cleanup_push(thread_cleanup, this);
18
19
- while (this->running) {
20
- if ((res = pw_loop_iterate(this->loop, -1)) < 0) {
21
+ while (SPA_LIKELY(this->running)) {
22
+ if (SPA_UNLIKELY((res = pw_loop_iterate(this->loop, -1)) < 0)) {
23
if (res == -EINTR)
24
continue;
25
pw_log_error("%p: iterate error %d (%s)",
26
pipewire-0.3.52.tar.gz/src/pipewire/keys.h -> pipewire-0.3.53.tar.gz/src/pipewire/keys.h
Changed
9
1
2
* "isa", "pci", "usb", "firewire",
3
* "bluetooth" */
4
#define PW_KEY_DEVICE_SUBSYSTEM "device.subsystem" /**< device subsystem */
5
+#define PW_KEY_DEVICE_SYSFS_PATH "device.sysfs.path" /**< device sysfs path */
6
#define PW_KEY_DEVICE_ICON "device.icon" /**< icon for the device. A base64 blob
7
* containing PNG image data */
8
#define PW_KEY_DEVICE_ICON_NAME "device.icon-name" /**< an XDG icon name for the device.
9
pipewire-0.3.52.tar.gz/src/pipewire/mem.c -> pipewire-0.3.53.tar.gz/src/pipewire/mem.c
Changed
28
1
2
PW_LOG_TOPIC_EXTERN(log_mem);
3
#define PW_LOG_TOPIC_DEFAULT log_mem
4
5
-#if !defined(__FreeBSD__) && !defined(HAVE_MEMFD_CREATE)
6
+#if !defined(__FreeBSD__) && !defined(__MidnightBSD__) && !defined(HAVE_MEMFD_CREATE)
7
/*
8
* No glibc wrappers exist for memfd_create(2), so provide our own.
9
*
10
11
#define HAVE_MEMFD_CREATE 1
12
#endif
13
14
-#ifdef __FreeBSD__
15
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
16
#define MAP_LOCKED 0
17
#endif
18
19
20
pw_log_error("%p: Failed to create memfd: %m", pool);
21
goto error_free;
22
}
23
-#elif defined(__FreeBSD__)
24
+#elif defined(__FreeBSD__) || defined(__MidnightBSD__)
25
b->this.fd = shm_open(SHM_ANON, O_CREAT | O_RDWR | O_CLOEXEC, 0);
26
if (b->this.fd == -1) {
27
res = -errno;
28
pipewire-0.3.52.tar.gz/src/pipewire/meson.build -> pipewire-0.3.53.tar.gz/src/pipewire/meson.build
Changed
10
1
2
'-DOLD_MEDIA_SESSION_WORKAROUND=1'
3
4
5
-if build_machine.system() != 'freebsd'
6
+if build_machine.system() != 'freebsd' and build_machine.system() != 'midnightbsd'
7
libpipewire_c_args +=
8
'-D_POSIX_C_SOURCE'
9
10
pipewire-0.3.52.tar.gz/src/pipewire/pipewire.c -> pipewire-0.3.53.tar.gz/src/pipewire/pipewire.c
Changed
37
1
2
#include <unistd.h>
3
#include <limits.h>
4
#include <stdio.h>
5
-#ifndef __FreeBSD__
6
+#if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
7
#include <sys/prctl.h>
8
#endif
9
#include <pwd.h>
10
11
static char namePATH_MAX;
12
13
spa_memzero(name, sizeof(name));
14
-#if defined(__linux__) || defined(__FreeBSD_kernel__)
15
+#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__MidnightBSD_kernel__)
16
{
17
if (readlink("/proc/self/exe", name, sizeof(name)-1) > 0) {
18
prgname = strrchr(name, '/') + 1;
19
20
}
21
}
22
#endif
23
-#if defined __FreeBSD__
24
+#if defined __FreeBSD__ || defined(__MidnightBSD__)
25
{
26
ssize_t len;
27
28
29
}
30
}
31
#endif
32
-#ifndef __FreeBSD__
33
+#if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
34
{
35
if (prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0) == 0) {
36
prgname = name;
37
pipewire-0.3.52.tar.gz/src/pipewire/private.h -> pipewire-0.3.53.tar.gz/src/pipewire/private.h
Changed
10
1
2
#include <spa/utils/result.h>
3
#include <spa/utils/type-info.h>
4
5
-#ifdef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
struct ucred {
8
};
9
#endif
10
pipewire-0.3.52.tar.gz/src/pipewire/settings.c -> pipewire-0.3.53.tar.gz/src/pipewire/settings.c
Changed
10
1
2
#define NAME "settings"
3
4
#define DEFAULT_CLOCK_RATE 48000u
5
-#define DEFAULT_CLOCK_RATES " 44100 48000 "
6
+#define DEFAULT_CLOCK_RATES " 48000 "
7
#define DEFAULT_CLOCK_QUANTUM 1024u
8
#define DEFAULT_CLOCK_MIN_QUANTUM 32u
9
#define DEFAULT_CLOCK_MAX_QUANTUM 2048u
10
pipewire-0.3.52.tar.gz/src/pipewire/stream.c -> pipewire-0.3.53.tar.gz/src/pipewire/stream.c
Changed
55
1
2
return -EINVAL;
3
}
4
5
- spa_list_append(&stream->controls, &c->link);
6
-
7
pod = spa_pod_get_values(type, &n_vals, &choice);
8
9
c->type = SPA_POD_TYPE(pod);
10
11
vals0 = SPA_POD_VALUE(struct spa_pod_bool, pod);
12
n_vals = 3;
13
}
14
- else
15
+ else {
16
+ free(c);
17
return -ENOTSUP;
18
+ }
19
20
c->container = container != SPA_ID_INVALID ? container : c->type;
21
22
switch (choice) {
23
case SPA_CHOICE_None:
24
- if (n_vals < 1)
25
+ if (n_vals < 1) {
26
+ free(c);
27
return -EINVAL;
28
+ }
29
c->control.n_values = 1;
30
c->control.max_values = 1;
31
c->control.values0 = c->control.def = c->control.min = c->control.max = vals0;
32
break;
33
case SPA_CHOICE_Range:
34
- if (n_vals < 3)
35
+ if (n_vals < 3) {
36
+ free(c);
37
return -EINVAL;
38
+ }
39
c->control.n_values = 1;
40
c->control.max_values = 1;
41
c->control.values0 = vals0;
42
43
c->control.max = vals2;
44
break;
45
default:
46
+ free(c);
47
return -ENOTSUP;
48
}
49
50
c->id = iid;
51
+ spa_list_append(&stream->controls, &c->link);
52
pw_log_debug("%p: add control %d (%s) container:%d (def:%f min:%f max:%f)",
53
stream, c->id, c->control.name, c->container,
54
c->control.def, c->control.min, c->control.max);
55
pipewire-0.3.52.tar.gz/src/pipewire/stream.h -> pipewire-0.3.53.tar.gz/src/pipewire/stream.h
Changed
17
1
2
* \section sec_stream_disconnect Disconnect
3
*
4
* Use \ref pw_stream_disconnect() to disconnect a stream after use.
5
+ *
6
+ * \section sec_stream_configuration Configuration
7
+ *
8
+ * \subsection ssec_config_properties Stream Properties
9
+ *
10
+ * \subsection ssec_config_rules Stream Rules
11
+ *
12
+ * \section sec_stream_environment Environment Variables
13
+ *
14
*/
15
/** \defgroup pw_stream Stream
16
*
17
pipewire-0.3.52.tar.gz/src/pipewire/thread.c -> pipewire-0.3.53.tar.gz/src/pipewire/thread.c
Changed
13
1
2
return NULL;
3
}
4
5
-#ifdef __FreeBSD__
6
+#if defined(__FreeBSD__) || defined(__MidnightBSD__)
7
#include <sys/param.h>
8
-#if __FreeBSD_version < 1202000
9
+#if __FreeBSD_version < 1202000 || defined(__MidnightBSD__)
10
int pthread_setname_np(pthread_t thread, const char *name)
11
{
12
pthread_set_name_np(thread, name);
13
pipewire-0.3.52.tar.gz/src/tools/meson.build -> pipewire-0.3.53.tar.gz/src/tools/meson.build
Changed
20
1
2
)
3
endforeach
4
5
-if readline_dep.found()
6
- executable('pw-cli',
7
- 'pw-cli.c',
8
- install: true,
9
- dependencies: pipewire_dep, readline_dep
10
- )
11
-endif
12
+executable('pw-cli',
13
+ 'pw-cli.c',
14
+ install: true,
15
+ dependencies: pipewire_dep, readline_dep
16
+)
17
18
if ncurses_dep.found()
19
executable('pw-top',
20
pipewire-0.3.52.tar.gz/src/tools/pw-cat.c -> pipewire-0.3.53.tar.gz/src/tools/pw-cat.c
Changed
201
1
2
unsigned int rate;
3
int channels;
4
struct channelmap channelmap;
5
- unsigned int samplesize;
6
unsigned int stride;
7
enum unit latency_unit;
8
unsigned int latency_value;
9
10
} dsf;
11
};
12
13
-static inline int
14
-sf_str_to_fmt(const char *str)
15
-{
16
- if (!str)
17
- return -1;
18
-
19
- if (spa_streq(str, "s8"))
20
- return SF_FORMAT_PCM_S8;
21
- if (spa_streq(str, "u8"))
22
- return SF_FORMAT_PCM_U8;
23
- if (spa_streq(str, "s16"))
24
- return SF_FORMAT_PCM_16;
25
- if (spa_streq(str, "s24"))
26
- return SF_FORMAT_PCM_24;
27
- if (spa_streq(str, "s32"))
28
- return SF_FORMAT_PCM_32;
29
- if (spa_streq(str, "f32"))
30
- return SF_FORMAT_FLOAT;
31
- if (spa_streq(str, "f64"))
32
- return SF_FORMAT_DOUBLE;
33
-
34
- return -1;
35
-}
36
-
37
-static inline const char *
38
-sf_fmt_to_str(int format)
39
-{
40
- int sub_type = (format & SF_FORMAT_SUBMASK);
41
-
42
- if (sub_type == SF_FORMAT_PCM_U8)
43
- return "u8";
44
- if (sub_type == SF_FORMAT_PCM_S8)
45
- return "s8";
46
- if (sub_type == SF_FORMAT_PCM_16)
47
- return "s16";
48
- if (sub_type == SF_FORMAT_PCM_24)
49
- return "s24";
50
- if (sub_type == SF_FORMAT_PCM_32)
51
- return "s32";
52
- if (sub_type == SF_FORMAT_FLOAT)
53
- return "f32";
54
- if (sub_type == SF_FORMAT_DOUBLE)
55
- return "f64";
56
- return "(invalid)";
57
-}
58
+#define STR_FMTS "(ulaw|alaw|u8|s8|s16|s32|f32|f64)"
59
60
-#define STR_FMTS "(u8|s8|s16|s32|f32|f64)"
61
-
62
-/* 0 = native, 1 = le, 2 = be */
63
-static inline int
64
-sf_format_endianess(int format)
65
-{
66
- return 0; /* native */
67
-}
68
+static const struct format_info {
69
+ const char *name;
70
+ int sf_format;
71
+ uint32_t spa_format;
72
+ uint32_t width;
73
+} format_info = {
74
+ { "ulaw", SF_FORMAT_ULAW, SPA_AUDIO_FORMAT_ULAW, 1 },
75
+ { "alaw", SF_FORMAT_ULAW, SPA_AUDIO_FORMAT_ALAW, 1 },
76
+ { "s8", SF_FORMAT_PCM_S8, SPA_AUDIO_FORMAT_S8, 1 },
77
+ { "u8", SF_FORMAT_PCM_U8, SPA_AUDIO_FORMAT_U8, 1 },
78
+ { "s16", SF_FORMAT_PCM_16, SPA_AUDIO_FORMAT_S16, 2 },
79
+ { "s24", SF_FORMAT_PCM_24, SPA_AUDIO_FORMAT_S24, 3 },
80
+ { "s32", SF_FORMAT_PCM_32, SPA_AUDIO_FORMAT_S32, 4 },
81
+ { "f32", SF_FORMAT_FLOAT, SPA_AUDIO_FORMAT_F32, 4 },
82
+ { "f64", SF_FORMAT_DOUBLE, SPA_AUDIO_FORMAT_F32, 8 },
83
+};
84
85
-static inline enum spa_audio_format
86
-sf_format_to_pw(int format)
87
+static const struct format_info *format_info_by_name(const char *str)
88
{
89
- int endianness;
90
-
91
- endianness = sf_format_endianess(format);
92
- if (endianness < 0)
93
- return SPA_AUDIO_FORMAT_UNKNOWN;
94
-
95
- switch (format & SF_FORMAT_SUBMASK) {
96
- case SF_FORMAT_PCM_U8:
97
- return SPA_AUDIO_FORMAT_U8;
98
- case SF_FORMAT_PCM_S8:
99
- return SPA_AUDIO_FORMAT_S8;
100
- case SF_FORMAT_ULAW:
101
- return SPA_AUDIO_FORMAT_ULAW;
102
- case SF_FORMAT_ALAW:
103
- return SPA_AUDIO_FORMAT_ALAW;
104
- case SF_FORMAT_PCM_16:
105
- return endianness == 1 ? SPA_AUDIO_FORMAT_S16_LE :
106
- endianness == 2 ? SPA_AUDIO_FORMAT_S16_BE :
107
- SPA_AUDIO_FORMAT_S16;
108
- case SF_FORMAT_PCM_24:
109
- case SF_FORMAT_PCM_32:
110
- return endianness == 1 ? SPA_AUDIO_FORMAT_S32_LE :
111
- endianness == 2 ? SPA_AUDIO_FORMAT_S32_BE :
112
- SPA_AUDIO_FORMAT_S32;
113
- case SF_FORMAT_DOUBLE:
114
- return endianness == 1 ? SPA_AUDIO_FORMAT_F64_LE :
115
- endianness == 2 ? SPA_AUDIO_FORMAT_F64_BE :
116
- SPA_AUDIO_FORMAT_F64;
117
- case SF_FORMAT_FLOAT:
118
- default:
119
- return endianness == 1 ? SPA_AUDIO_FORMAT_F32_LE :
120
- endianness == 2 ? SPA_AUDIO_FORMAT_F32_BE :
121
- SPA_AUDIO_FORMAT_F32;
122
- break;
123
- }
124
-
125
- return SPA_AUDIO_FORMAT_UNKNOWN;
126
+ uint32_t i;
127
+ for (i = 0; i < SPA_N_ELEMENTS(format_info); i++)
128
+ if (spa_streq(str, format_infoi.name))
129
+ return &format_infoi;
130
+ return NULL;
131
}
132
133
-static inline int
134
-sf_format_samplesize(int format)
135
+static const struct format_info *format_info_by_sf_format(int format)
136
{
137
+ uint32_t i;
138
int sub_type = (format & SF_FORMAT_SUBMASK);
139
-
140
- switch (sub_type) {
141
- case SF_FORMAT_PCM_S8:
142
- case SF_FORMAT_PCM_U8:
143
- case SF_FORMAT_ULAW:
144
- case SF_FORMAT_ALAW:
145
- return 1;
146
- case SF_FORMAT_PCM_16:
147
- return 2;
148
- case SF_FORMAT_PCM_32:
149
- return 4;
150
- case SF_FORMAT_DOUBLE:
151
- return 8;
152
- case SF_FORMAT_FLOAT:
153
- default:
154
- return 4;
155
- }
156
- return -1;
157
+ for (i = 0; i < SPA_N_ELEMENTS(format_info); i++)
158
+ if (format_infoi.sf_format == sub_type)
159
+ return &format_infoi;
160
+ return NULL;
161
}
162
163
static int sf_playback_fill_x8(struct data *d, void *dest, unsigned int n_frames)
164
165
sf_count_t rn;
166
167
rn = sf_read_raw(d->file, dest, n_frames * d->stride);
168
- return (int)rn;
169
+ return (int)rn / d->stride;
170
}
171
172
static int sf_playback_fill_s16(struct data *d, void *dest, unsigned int n_frames)
173
174
}
175
176
static inline fill_fn
177
-sf_fmt_playback_fill_fn(int format)
178
+playback_fill_fn(uint32_t fmt)
179
{
180
- enum spa_audio_format fmt = sf_format_to_pw(format);
181
-
182
switch (fmt) {
183
case SPA_AUDIO_FORMAT_S8:
184
case SPA_AUDIO_FORMAT_U8:
185
186
sf_count_t rn;
187
188
rn = sf_write_raw(d->file, src, n_frames * d->stride);
189
- return (int)rn;
190
+ return (int)rn / d->stride;
191
}
192
193
static int sf_record_fill_s16(struct data *d, void *src, unsigned int n_frames)
194
195
}
196
197
static inline fill_fn
198
-sf_fmt_record_fill_fn(int format)
199
+record_fill_fn(uint32_t fmt)
200
{
201
pipewire-0.3.52.tar.gz/src/tools/pw-cli.c -> pipewire-0.3.53.tar.gz/src/tools/pw-cli.c
Changed
180
1
2
* DEALINGS IN THE SOFTWARE.
3
*/
4
5
+#include "config.h"
6
+
7
#include <unistd.h>
8
#include <errno.h>
9
#include <stdio.h>
10
#include <signal.h>
11
#include <string.h>
12
#include <ctype.h>
13
-#ifndef __FreeBSD__
14
+#if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
15
#include <alloca.h>
16
#endif
17
#include <getopt.h>
18
#include <fnmatch.h>
19
+#ifdef HAVE_READLINE
20
#include <readline/readline.h>
21
#include <readline/history.h>
22
+#endif
23
#include <locale.h>
24
25
#if !defined(FNM_EXTMATCH)
26
27
static void set_prompt(struct remote_data *rd)
28
{
29
snprintf(prompt, sizeof(prompt), "%s>> ", rd->name);
30
+#ifdef HAVE_READLINE
31
rl_set_prompt(prompt);
32
+#else
33
+ printf("%s", prompt);
34
+ fflush(stdout);
35
+#endif
36
}
37
38
static void on_core_done(void *_data, uint32_t id, int seq)
39
40
}
41
42
/* We need a global variable, readline doesn't have a closure arg */
43
-static struct data *readline_dataptr;
44
+static struct data *input_dataptr;
45
46
-static void readline_process_line(char *line)
47
+static void input_process_line(char *line)
48
{
49
- struct data *d = readline_dataptr;
50
+ struct data *d = input_dataptr;
51
char *error;
52
53
if (!line)
54
line = strdup("quit");
55
56
if (line0 != '\0') {
57
+#ifdef HAVE_READLINE
58
add_history(line);
59
+#endif
60
if (!parse(d, line, &error)) {
61
fprintf(stderr, "Error: \"%s\"\n", error);
62
free(error);
63
64
struct data *d = data;
65
66
if (mask & SPA_IO_IN) {
67
- readline_dataptr = d;
68
+ input_dataptr = d;
69
+#ifdef HAVE_READLINE
70
rl_callback_read_char();
71
+#else
72
+ {
73
+ char *line = NULL;
74
+ size_t s = 0;
75
+
76
+ if (getline(&line, &s, stdin) < 0) {
77
+ free(line);
78
+ line = NULL;
79
+ }
80
+ input_process_line(line);
81
+ }
82
+#endif
83
84
if (d->current == NULL)
85
pw_main_loop_quit(d->loop);
86
87
}
88
}
89
90
+#ifdef HAVE_READLINE
91
static char *
92
readline_match_command(const char *text, int state)
93
{
94
95
static void readline_init()
96
{
97
rl_attempted_completion_function = readline_command_completion;
98
- rl_callback_handler_install(">> ", readline_process_line);
99
+ rl_callback_handler_install(">> ", input_process_line);
100
}
101
102
static void readline_cleanup()
103
{
104
rl_callback_handler_remove();
105
}
106
+#endif
107
108
static void do_quit_on_signal(void *data, int signal_number)
109
{
110
111
struct pw_loop *l;
112
char *opt_remote = NULL;
113
char *error;
114
- bool daemon = false;
115
+ bool daemon = false, monitor = false;
116
struct remote_data *rd;
117
static const struct option long_options = {
118
- { "help", no_argument, NULL, 'h' },
119
- { "version", no_argument, NULL, 'V' },
120
- { "daemon", no_argument, NULL, 'd' },
121
- { "remote", required_argument, NULL, 'r' },
122
+ { "help", no_argument, NULL, 'h' },
123
+ { "version", no_argument, NULL, 'V' },
124
+ { "monitor", no_argument, NULL, 'm' },
125
+ { "daemon", no_argument, NULL, 'd' },
126
+ { "remote", required_argument, NULL, 'r' },
127
{ NULL, 0, NULL, 0}
128
};
129
int c, i;
130
131
setlocale(LC_ALL, "");
132
pw_init(&argc, &argv);
133
134
- while ((c = getopt_long(argc, argv, "hVdr:", long_options, NULL)) != -1) {
135
+ while ((c = getopt_long(argc, argv, "hVmdr:", long_options, NULL)) != -1) {
136
switch (c) {
137
case 'h':
138
show_help(&data, argv0, false);
139
140
case 'd':
141
daemon = true;
142
break;
143
+ case 'm':
144
+ monitor = true;
145
+ break;
146
case 'r':
147
opt_remote = optarg;
148
break;
149
150
printf("Welcome to PipeWire version %s. Type 'help' for usage.\n",
151
pw_get_library_version());
152
153
+#ifdef HAVE_READLINE
154
readline_init();
155
+#endif
156
157
pw_loop_add_io(l, STDIN_FILENO, SPA_IO_IN|SPA_IO_HUP, false, do_input, &data);
158
159
pw_main_loop_run(data.loop);
160
161
+#ifdef HAVE_READLINE
162
readline_cleanup();
163
+#endif
164
} else {
165
char buf4096, *p, *error;
166
167
168
fprintf(stderr, "Error: \"%s\"\n", error);
169
free(error);
170
}
171
- if (!data.quit && data.current) {
172
+ while (!data.quit && data.current) {
173
data.current->prompt_pending = pw_core_sync(data.current->core, 0, 0);
174
pw_main_loop_run(data.loop);
175
+ if (!monitor)
176
+ break;
177
}
178
}
179
spa_list_consume(rd, &data.remotes, link)
180