From 3651d42e50e4c2519718d5e33b22222c01848b87 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 10 Aug 2022 12:22:01 -0400 Subject: Fix spurious transport messages The beats_per_minute from JACK is only valid if JackPositionBBT is set. On some JACK implementations (at least pipewire), this value is otherwise garbage, which causes a lot of transport message spam. --- NEWS | 3 ++- src/jack.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 0bf2ec8..d01b9ae 100644 --- a/NEWS +++ b/NEWS @@ -12,13 +12,14 @@ jalv (1.6.7) unstable; urgency=medium * Fix man page headers * Fix memory leaks * Fix outdated man pages + * Fix spurious transport messages * Flush stdout after printing control values in console interface * Print status information consistently to stdout * Remove Gtkmm interface * Remove Qt4 support * Switch to meson build system - -- David Robillard Mon, 08 Aug 2022 22:39:54 +0000 + -- David Robillard Wed, 10 Aug 2022 16:17:35 +0000 jalv (1.6.6) stable; urgency=medium diff --git a/src/jack.c b/src/jack.c index 8bdc42e..eff07d5 100644 --- a/src/jack.c +++ b/src/jack.c @@ -94,9 +94,10 @@ jack_process_cb(jack_nframes_t nframes, void* data) (jack_transport_query(client, &pos) == JackTransportRolling); // If transport state is not as expected, then something has changed + const bool has_bbt = (pos.valid & JackPositionBBT); const bool xport_changed = (rolling != jalv->rolling || pos.frame != jalv->position || - pos.beats_per_minute != jalv->bpm); + (has_bbt && pos.beats_per_minute != jalv->bpm)); uint8_t pos_buf[256]; LV2_Atom* lv2_pos = (LV2_Atom*)pos_buf; @@ -110,7 +111,7 @@ jack_process_cb(jack_nframes_t nframes, void* data) lv2_atom_forge_long(forge, pos.frame); lv2_atom_forge_key(forge, jalv->urids.time_speed); lv2_atom_forge_float(forge, rolling ? 1.0 : 0.0); - if (pos.valid & JackPositionBBT) { + if (has_bbt) { lv2_atom_forge_key(forge, jalv->urids.time_barBeat); lv2_atom_forge_float(forge, pos.beat - 1 + (pos.tick / pos.ticks_per_beat)); @@ -142,7 +143,7 @@ jack_process_cb(jack_nframes_t nframes, void* data) // Update transport state to expected values for next cycle jalv->position = rolling ? pos.frame + nframes : pos.frame; - jalv->bpm = pos.beats_per_minute; + jalv->bpm = has_bbt ? pos.beats_per_minute : jalv->bpm; jalv->rolling = rolling; switch (jalv->play_state) { -- cgit v1.2.1