audio policy: remove effects before releasing input

modify releaseInput() implementation so that effects added by policy
rules are removed before closing the input stream to avoid
failure to destroy the effect chain

make sure that orphan effect chains are checked when an EffectHandle is
disconnected after thread destruction.

Test: make and run Hangouts
Bug: 32707507

Change-Id: I7833b4c5e42c0057a4477eb4485a20dd26ca2f90
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index d745121..dc29ce0 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -95,6 +95,7 @@
     const wp<ThreadBase>& thread() { return mThread; }
 
     status_t addHandle(EffectHandle *handle);
+    ssize_t  disconnectHandle(EffectHandle *handle, bool unpinIfLast);
     ssize_t removeHandle(EffectHandle *handle);
     ssize_t removeHandle_l(EffectHandle *handle);