Destroy acksync immediately on error

If AOA or HID keyboard may not be initialized for some reason, acksync
is useless.
This commit is contained in:
Romain Vimont 2022-01-01 19:47:47 +01:00
parent f04812fc71
commit 7121a0dc53

View file

@ -454,25 +454,27 @@ scrcpy(struct scrcpy_options *options) {
goto end; goto end;
} }
acksync = &s->acksync;
ok = sc_aoa_init(&s->aoa, serial, acksync); ok = sc_aoa_init(&s->aoa, serial, acksync);
if (!ok) { if (!ok) {
sc_acksync_destroy(&s->acksync);
goto aoa_hid_end; goto aoa_hid_end;
} }
if (!sc_hid_keyboard_init(&s->keyboard_hid, &s->aoa)) { if (!sc_hid_keyboard_init(&s->keyboard_hid, &s->aoa)) {
sc_acksync_destroy(&s->acksync);
sc_aoa_destroy(&s->aoa); sc_aoa_destroy(&s->aoa);
goto aoa_hid_end; goto aoa_hid_end;
} }
if (!sc_aoa_start(&s->aoa)) { if (!sc_aoa_start(&s->aoa)) {
sc_acksync_destroy(&s->acksync);
sc_hid_keyboard_destroy(&s->keyboard_hid); sc_hid_keyboard_destroy(&s->keyboard_hid);
sc_aoa_destroy(&s->aoa); sc_aoa_destroy(&s->aoa);
goto aoa_hid_end; goto aoa_hid_end;
} }
kp = &s->keyboard_hid.key_processor; kp = &s->keyboard_hid.key_processor;
acksync = &s->acksync;
aoa_hid_initialized = true; aoa_hid_initialized = true;