bluez5: iso-io: add debug option for forcing same data in all streams

When debugging desync issues, it's useful to force same data be sent on
all ISO streams. Add option for that.
This commit is contained in:
Pauli Virtanen 2026-01-06 16:11:37 +02:00
parent d0309b4e1e
commit 0003d7a2d0
4 changed files with 39 additions and 0 deletions

View File

@ -1382,6 +1382,10 @@ Latency adjustment to apply on the node. Larger values add a
constant latency, but reduces timing jitter caused by Bluetooth
transport.
@PAR@ node-prop bluez5.debug.iso-mono = false # boolean
Debugging option for forcing ISO sinks send identical packets out for
all streams.
# PORT PROPERTIES @IDX@ props
Port properties are usually not directly configurable via PipeWire

View File

@ -257,6 +257,7 @@ static void group_on_timeout(struct spa_source *source)
struct stream *stream;
bool resync = false;
bool fail = false;
bool debug_mono = false;
uint64_t exp;
uint64_t now_realtime;
int res;
@ -295,6 +296,8 @@ static void group_on_timeout(struct spa_source *source)
if (!group->started && !stream->idle && stream->this.size > 0)
group->started = true;
debug_mono = debug_mono || stream->this.debug_mono;
}
if (group_latency_check(group)) {
@ -303,6 +306,30 @@ static void group_on_timeout(struct spa_source *source)
goto done;
}
/* Force same data in all streams */
if (debug_mono) {
struct stream *s0 = NULL;
spa_list_for_each(stream, &group->streams, link) {
if (!stream->sink)
continue;
if (stream->this.size) {
s0 = stream;
break;
}
}
if (s0) {
spa_list_for_each(stream, &group->streams, link) {
if (!stream->sink)
continue;
if (stream != s0) {
stream->this.size = s0->this.size;
memcpy(stream->this.buf, s0->this.buf, s0->this.size);
}
}
}
}
/* Produce output */
spa_list_for_each(stream, &group->streams, link) {
int res = 0;

View File

@ -35,6 +35,8 @@ struct spa_bt_iso_io
struct spa_audio_info format; /**< Audio format */
void *codec_data; /**< Codec data */
bool debug_mono; /**< Duplicate packets from first sink to other sinks */
void *user_data;
};

View File

@ -159,6 +159,7 @@ struct impl {
unsigned int is_duplex:1;
unsigned int is_internal:1;
unsigned int iso_debug_mono:1;
struct spa_source source;
int timerfd;
@ -1566,6 +1567,8 @@ static int transport_start(struct impl *this)
this->codec->description);
return -EIO;
}
this->transport->iso_io->debug_mono = this->iso_debug_mono;
} else {
this->own_codec_data = false;
this->codec_data = this->transport->iso_io->codec_data;
@ -2625,6 +2628,9 @@ impl_init(const struct spa_handle_factory *factory,
if (info && (str = spa_dict_lookup(info, "api.bluez5.internal")) != NULL)
this->is_internal = spa_atob(str);
if (info && (str = spa_dict_lookup(info, "bluez5.debug.iso-mono")) != NULL)
this->iso_debug_mono = spa_atob(str);
if (info && (str = spa_dict_lookup(info, SPA_KEY_API_BLUEZ5_TRANSPORT)))
sscanf(str, "pointer:%p", &this->transport);