Pipewireパッケージ(ちょっと変更)
Revision | 0da572474fb1541bb1b880aa7a6f1b5fea8312e9 (tree) |
---|---|
Zeit | 2023-09-07 22:54:28 |
Autor | Wim Taymans <wtaymans@redh...> |
Commiter | Wim Taymans |
modules: forward tag param
@@ -20,6 +20,7 @@ | ||
20 | 20 | #include <spa/utils/json.h> |
21 | 21 | #include <spa/support/cpu.h> |
22 | 22 | #include <spa/param/latency-utils.h> |
23 | +#include <spa/param/tag-utils.h> | |
23 | 24 | #include <spa/pod/dynamic.h> |
24 | 25 | #include <spa/debug/types.h> |
25 | 26 |
@@ -1109,7 +1110,7 @@ static void param_latency_changed(struct impl *impl, const struct spa_pod *param | ||
1109 | 1110 | struct spa_pod_builder b; |
1110 | 1111 | const struct spa_pod *params[1]; |
1111 | 1112 | |
1112 | - if (spa_latency_parse(param, &latency) < 0) | |
1113 | + if (param == NULL || spa_latency_parse(param, &latency) < 0) | |
1113 | 1114 | return; |
1114 | 1115 | |
1115 | 1116 | spa_pod_builder_init(&b, buffer, sizeof(buffer)); |
@@ -1121,6 +1122,21 @@ static void param_latency_changed(struct impl *impl, const struct spa_pod *param | ||
1121 | 1122 | pw_stream_update_params(impl->playback, params, 1); |
1122 | 1123 | } |
1123 | 1124 | |
1125 | +static void param_tag_changed(struct impl *impl, const struct spa_pod *param) | |
1126 | +{ | |
1127 | + struct spa_tag_info tag; | |
1128 | + const struct spa_pod *params[1] = { param }; | |
1129 | + void *state = NULL; | |
1130 | + | |
1131 | + if (param == 0 || spa_tag_parse(param, &tag, &state) < 0) | |
1132 | + return; | |
1133 | + | |
1134 | + if (tag.direction == SPA_DIRECTION_INPUT) | |
1135 | + pw_stream_update_params(impl->capture, params, 1); | |
1136 | + else | |
1137 | + pw_stream_update_params(impl->playback, params, 1); | |
1138 | +} | |
1139 | + | |
1124 | 1140 | static void state_changed(void *data, enum pw_stream_state old, |
1125 | 1141 | enum pw_stream_state state, const char *error) |
1126 | 1142 | { |
@@ -1208,6 +1224,9 @@ static void param_changed(void *data, uint32_t id, const struct spa_pod *param) | ||
1208 | 1224 | case SPA_PARAM_Latency: |
1209 | 1225 | param_latency_changed(impl, param); |
1210 | 1226 | break; |
1227 | + case SPA_PARAM_Tag: | |
1228 | + param_tag_changed(impl, param); | |
1229 | + break; | |
1211 | 1230 | } |
1212 | 1231 | return; |
1213 | 1232 |
@@ -171,13 +171,11 @@ struct impl { | ||
171 | 171 | struct pw_stream *capture; |
172 | 172 | struct spa_hook capture_listener; |
173 | 173 | struct spa_audio_info_raw capture_info; |
174 | - struct spa_latency_info capture_latency; | |
175 | 174 | |
176 | 175 | struct pw_properties *playback_props; |
177 | 176 | struct pw_stream *playback; |
178 | 177 | struct spa_hook playback_listener; |
179 | 178 | struct spa_audio_info_raw playback_info; |
180 | - struct spa_latency_info playback_latency; | |
181 | 179 | |
182 | 180 | unsigned int do_disconnect:1; |
183 | 181 | unsigned int recalc_delay:1; |
@@ -317,18 +315,16 @@ static void playback_process(void *d) | ||
317 | 315 | } |
318 | 316 | |
319 | 317 | static void param_latency_changed(struct impl *impl, const struct spa_pod *param, |
320 | - struct spa_latency_info *info, struct pw_stream *other) | |
318 | + struct pw_stream *other) | |
321 | 319 | { |
322 | 320 | struct spa_latency_info latency; |
323 | 321 | uint8_t buffer[1024]; |
324 | 322 | struct spa_pod_builder b; |
325 | 323 | const struct spa_pod *params[1]; |
326 | 324 | |
327 | - if (spa_latency_parse(param, &latency) < 0) | |
325 | + if (param == NULL || spa_latency_parse(param, &latency) < 0) | |
328 | 326 | return; |
329 | 327 | |
330 | - *info = latency; | |
331 | - | |
332 | 328 | spa_pod_builder_init(&b, buffer, sizeof(buffer)); |
333 | 329 | params[0] = spa_latency_build(&b, SPA_PARAM_Latency, &latency); |
334 | 330 | pw_stream_update_params(other, params, 1); |
@@ -336,6 +332,15 @@ static void param_latency_changed(struct impl *impl, const struct spa_pod *param | ||
336 | 332 | impl->recalc_delay = true; |
337 | 333 | } |
338 | 334 | |
335 | +static void param_tag_changed(struct impl *impl, const struct spa_pod *param, | |
336 | + struct pw_stream *other) | |
337 | +{ | |
338 | + const struct spa_pod *params[1] = { param }; | |
339 | + if (param == NULL) | |
340 | + return; | |
341 | + pw_stream_update_params(other, params, 1); | |
342 | +} | |
343 | + | |
339 | 344 | static void recalculate_buffer(struct impl *impl) |
340 | 345 | { |
341 | 346 | if (impl->target_delay > 0.0f) { |
@@ -414,7 +419,10 @@ static void capture_param_changed(void *data, uint32_t id, const struct spa_pod | ||
414 | 419 | break; |
415 | 420 | } |
416 | 421 | case SPA_PARAM_Latency: |
417 | - param_latency_changed(impl, param, &impl->capture_latency, impl->playback); | |
422 | + param_latency_changed(impl, param, impl->playback); | |
423 | + break; | |
424 | + case SPA_PARAM_Tag: | |
425 | + param_tag_changed(impl, param, impl->playback); | |
418 | 426 | break; |
419 | 427 | } |
420 | 428 | } |
@@ -453,7 +461,10 @@ static void playback_param_changed(void *data, uint32_t id, const struct spa_pod | ||
453 | 461 | |
454 | 462 | switch (id) { |
455 | 463 | case SPA_PARAM_Latency: |
456 | - param_latency_changed(impl, param, &impl->playback_latency, impl->capture); | |
464 | + param_latency_changed(impl, param, impl->capture); | |
465 | + break; | |
466 | + case SPA_PARAM_Tag: | |
467 | + param_tag_changed(impl, param, impl->capture); | |
457 | 468 | break; |
458 | 469 | } |
459 | 470 | } |