Fix SoundTriggerMiddleware deadlock issues

This change enforces strict lock ordering between the various layers
of the service and the audio policy lock. Previously, we were exposed
to various deadlock scenarios due to nested locking done without
consistent lock ordering, specifically in cases involving callbacks
from SoundTriggerModule to SoundTriggerMiddlewareValidation.



Change-Id: I28382d10c7bc7faaa8f9b33dda3aa9c94a68061e
Bug: 159151235
Test: Manually disable concurrent capture, verify basic soundtrigger
      functionality and do some stress testing by enabling/disabling
      recording quickly and check for deadlocks.
3 files changed