AudioFlinger: limit ability to create a Spatializer effect

A Spatializer effect can only be created from audio policy service
and on a spatializer thread.

Bug: 188502620
Test: make
Change-Id: Ia64ea3b68a536a34a14be104151a582e023c9dad
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 683c4f7..fddd3de 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1336,6 +1336,13 @@
         return BAD_VALUE;
     }
 
+    if (memcmp(&desc->type, FX_IID_SPATIALIZER, sizeof(effect_uuid_t)) == 0
+            && mType != SPATIALIZER) {
+        ALOGW("%s: attempt to create a spatializer effect on a thread of type %d",
+                __func__, mType);
+        return BAD_VALUE;
+    }
+
     switch (mType) {
     case MIXER: {
 #ifndef MULTICHANNEL_EFFECT_CHAIN