bluez a2dp - fix wait_for_start() synchronization

On entry to wait_for_start() it's possible we are in state
A2DP_STATE_NONE if a2dp_thread() has not completed bluetooth_init().
Also, we call the pthread_mutex_*() functions more frequently than
we really need to.

Move the mutex locking outside the loop and let condition wait
take care of the locking. Also move the A2DP_STATE_NONE check
below the condition wait so we can be sure the state machine
has been poked before we test it.

Change-Id: I020bea365a623e88cb1a5f7e5fccd8f8aa948518
1 file changed