bluez a2dp - fix state machine synchronization

Using a worker thread implementation for A2DP means that if we don't
have some way to syncroniize state transitions we can get overlap of
requested command functions or lost signals. In order for the A2DP
state machine to function each command operation must complete before
the next is initiated or we will get errors caused by these out of
sequence commands. And if we signal the thread when it is not waiting
on the condition the signal will be missed.

This could be partly resolved by implementing a queue but then there
is an overhead with also implementing a wait mechamism for state
transitions. It's much easier and simpler to just hold the mutex
during command processing which also deals with the lost signals issue.
This may well not achieve the original goal of the worker thread
implementation but neither would a queue implementation. It looks
like this is just the way things are!
1 file changed