tree: 579cf3d3b1fa7770f0698446a9bb2061a09581c3 [path history] [tgz]
  1. AudioSessionProviderImpl.java
  2. ConversionUtil.java
  3. Dumpable.java
  4. ExternalCaptureStateTracker.java
  5. HalException.java
  6. HalFactory.java
  7. Hw2CompatUtil.java
  8. ISoundTriggerHw2.java
  9. ISoundTriggerMiddlewareInternal.java
  10. ObjectPrinter.java
  11. OWNERS
  12. README.md
  13. RecoverableException.java
  14. SoundTriggerHw2Compat.java
  15. SoundTriggerHw2Enforcer.java
  16. SoundTriggerMiddlewareImpl.java
  17. SoundTriggerMiddlewareLogging.java
  18. SoundTriggerMiddlewareService.java
  19. SoundTriggerMiddlewareValidation.java
  20. SoundTriggerModule.java
  21. TEST_MAPPING
  22. UuidUtil.java
  23. ValidationUtil.java
services/core/java/com/android/server/soundtrigger_middleware/README.md

Sound Trigger Middleware

TODO: Add component description.

Notes about thread synchronization

This component has some tricky thread synchronization considerations due to its layered design and due to the fact that it is involved in both in-bound and out-bound calls from / to external components. To avoid potential deadlocks, a strict locking order must be ensured whenever nesting locks. The order is:

  • SoundTriggerMiddlewareValidation lock.
  • Audio policy service lock. This one is external - it should be assumed to be held whenever we're inside the ExternalCaptureStateTracker.setCaptureState() call stack AND to be acquired from within our calls into AudioSessionProvider.acquireSession().
  • SoundTriggerModule lock.

This dictates careful consideration of callbacks going from SoundTriggerModule to SoundTriggerMiddlewareValidation and especially those coming from the setCaptureState() path. We always invoke those calls outside of the SoundTriggerModule lock, so we can lock SoundTriggerMiddlewareValidation. However, in the setCaptureState() case, we have to use atomics in SoundTriggerMiddlewareValidation and avoid the lock.