post_proc: Fix bassboost/virtualizer not disabled on speaker

When output is unintended device, there's no need to query enable_flag
before setting effect to disabled state. There's possiblity that
enable_flag is 0 as initialized value, which hinder effects from being
disabled.

Change-Id: Ib90c0ad0982dc8274129bb1bed7861e11670fbdb
diff --git a/post_proc/bundle.c b/post_proc/bundle.c
index a0d9fcb..0db2e37 100644
--- a/post_proc/bundle.c
+++ b/post_proc/bundle.c
@@ -186,6 +186,7 @@
     int ret = 0;
     struct listnode *node;
     char mixer_string[128];
+    output_context_t * out_ctxt = NULL;
 
     ALOGV("%s output %d pcm_id %d", __func__, output, pcm_id);
 
@@ -199,7 +200,7 @@
         goto exit;
     }
 
-    output_context_t *out_ctxt = (output_context_t *)
+    out_ctxt = (output_context_t *)
                                  malloc(sizeof(output_context_t));
     if (!out_ctxt) {
         ALOGE("%s fail to allocate for output context", __func__);
@@ -217,6 +218,7 @@
         ALOGE("Failed to open mixer");
         out_ctxt->ctl = NULL;
         ret = -EINVAL;
+        free(out_ctxt);
         goto exit;
     } else {
         out_ctxt->ctl = mixer_get_ctl_by_name(out_ctxt->mixer, mixer_string);
@@ -225,6 +227,7 @@
             mixer_close(out_ctxt->mixer);
             out_ctxt->mixer = NULL;
             ret = -EINVAL;
+            free(out_ctxt);
             goto exit;
         }
     }
@@ -535,12 +538,12 @@
 
     pthread_mutex_lock(&lock);
     if (!effect_exists(context)) {
-        status = -EINVAL;
+        status = -ENOSYS;
         goto exit;
     }
 
     if (context->state != EFFECT_STATE_ACTIVE) {
-        status = -EINVAL;
+        status = -ENODATA;
         goto exit;
     }
 
@@ -560,13 +563,13 @@
     pthread_mutex_lock(&lock);
 
     if (!effect_exists(context)) {
-        status = -EINVAL;
+        status = -ENOSYS;
         goto exit;
     }
 
     ALOGV("%s: ctxt %p, cmd %d", __func__, context, cmdCode);
     if (context == NULL || context->state == EFFECT_STATE_UNINITIALIZED) {
-        status = -EINVAL;
+        status = -ENOSYS;
         goto exit;
     }
 
@@ -752,6 +755,9 @@
     return 0;
 }
 
+bool effect_is_active(effect_context_t * ctxt) {
+    return ctxt->state == EFFECT_STATE_ACTIVE;
+}
 
 /* effect_handle_t interface implementation for offload effects */
 const struct effect_interface_s effect_interface = {