netjack2: handle 0 in sync frames

JACK2 only sends -1 as the frames, meaning we should take the value from
the negotiated period as the frames to process.

We however send the actual number of frames and use the sync value to
decide how many frames to process. We need to be careful because a value
of 0 will cause a division by 0 so treat <= 0 frames the negotiated period
size as well.
This commit is contained in:
Wim Taymans 2026-05-08 11:38:28 +02:00
parent 753eae9302
commit 7fd3e13a3e

View file

@ -752,7 +752,7 @@ static inline int32_t netjack2_driver_sync_wait(struct netjack2_peer *peer)
}
peer->sync.is_last = ntohl(sync.is_last);
peer->sync.frames = ntohl(sync.frames);
if (peer->sync.frames == -1)
if (peer->sync.frames <= 0)
peer->sync.frames = peer->params.period_size;
peer->sync.frames = SPA_MIN(peer->sync.frames, (int32_t)peer->quantum_limit);
@ -793,7 +793,7 @@ static inline int32_t netjack2_manager_sync_wait(struct netjack2_peer *peer)
peer->sync.cycle = ntohl(sync.cycle);
peer->sync.is_last = ntohl(sync.is_last);
peer->sync.frames = ntohl(sync.frames);
if (peer->sync.frames == -1)
if (peer->sync.frames <= 0)
peer->sync.frames = peer->params.period_size;
peer->sync.frames = SPA_MIN(peer->sync.frames, (int32_t)peer->quantum_limit);