From 37987b822e8f0f57f27c867ef6c573f98791b5bd Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 22 Jan 2022 10:52:13 +0100 Subject: [PATCH] Make acksync optional for AOA initialization Acksync is used to delay HID events until some request (in practice, device clipboard synchronization) is acknowledged by the device. This mechanism will not be necessary for OTG mode. PR #2974 --- app/src/usb/aoa_hid.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/usb/aoa_hid.c b/app/src/usb/aoa_hid.c index 0925d9e4..6e3bd2e7 100644 --- a/app/src/usb/aoa_hid.c +++ b/app/src/usb/aoa_hid.c @@ -53,8 +53,6 @@ log_libusb_error(enum libusb_error errcode) { bool sc_aoa_init(struct sc_aoa *aoa, struct sc_usb *usb, struct sc_acksync *acksync) { - assert(acksync); - cbuf_init(&aoa->queue); if (!sc_mutex_init(&aoa->mutex)) { @@ -248,6 +246,11 @@ run_aoa_thread(void *data) { if (ack_to_wait != SC_SEQUENCE_INVALID) { LOGD("Waiting ack from server sequence=%" PRIu64_, ack_to_wait); + + // If some events have ack_to_wait set, then sc_aoa must have been + // initialized with a non NULL acksync + assert(aoa->acksync); + // Do not block the loop indefinitely if the ack never comes (it // should never happen) sc_tick deadline = sc_tick_now() + SC_TICK_FROM_MS(500); @@ -294,7 +297,9 @@ sc_aoa_stop(struct sc_aoa *aoa) { sc_cond_signal(&aoa->event_cond); sc_mutex_unlock(&aoa->mutex); - sc_acksync_interrupt(aoa->acksync); + if (aoa->acksync) { + sc_acksync_interrupt(aoa->acksync); + } } void