audioflinger: check for condition before waiting

AsyncCallbackThread must check for any condition that
was already been satisfied before waiting.

CRs-Fixed: 581978
Change-Id: I7a37c03cddcf7fdaa61c826d71a4d527979ce9e1
libstagefright: Delay release of wakelock

Delay release of wakelock till the last event
in the event queue of TimedEventQueue has been processed.
This ensures AP shutdown does not happen while an event
is ready but hasn't been processed yet.

CRs-Fixed: 583053
Change-Id: I597c0b9887b02b070c708401e5f3c40a0a2289d0
Merge remote-tracking branch 'CyanogenMod/cm-11.0' into cm-11.0