4a-hal-generic: aborting with "Can't enter dispatch while in dispatch!" when a phone is connected via bluetooth
Description
When a phone is connected, 4a ends aborts, with the following error:
"Can't enter dispatch while in dispatch!"
After analysis, this is because a sync call (dynamic creation of the needed streams in softmixer) is performed. Replacing the afb_api_call_sync by a afb_api_call fixes it.
Environment
None
Activity
Show:
jose bollo
February 8, 2019 at 11:53 AM
Thierry patched its binding accordlingly to the guidelines above
jose bollo
February 7, 2019 at 9:57 AM
This happens when connecting to the systemd's event loop of the binder. (see function afb_api_get_event_loop [1]) It that case, it is not possible to call a synchronous call from the callback of the event. The reason is that the call back has to return before the even loop can be used. This limitation comes from systemd (but notice that reading an input in the callback is generally needed to avoid endless call to the event handler callback).
When you do a call_sync in the systemd event handler callback, the binder now emit the message "Can't enter dispatch while in dispatch!" and calls abort.
The implementation of the systemd event handler has to be changed to not block. You can use the asynchronous call variants if needed [2].
When a phone is connected, 4a ends aborts, with the following error:
"Can't enter dispatch while in dispatch!"
After analysis, this is because a sync call (dynamic creation of the needed streams in softmixer) is performed. Replacing the afb_api_call_sync by a afb_api_call fixes it.