config: merge named and unnamed stream lists

Keeping separate lists of named and unnamed streams doesn't
work well because a PCM/compressed stream could also be given
a name. Removes the named_stream_list and puts all streams
onto the same list.

Change-Id: Idc87b3369a9a776979cb2cd7024396e9d8d4fb77
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
diff --git a/audio_config.c b/audio_config.c
index db2a6db..34bccd3 100644
--- a/audio_config.c
+++ b/audio_config.c
@@ -133,7 +133,7 @@
     struct hw_stream  info;   /* must be first member */
 
     struct config_mgr*  cm;
-    const char* name;       /* used for named custom streams */
+    const char* name;
 
     int     ref_count;
     int     max_ref_count;
@@ -161,7 +161,6 @@
 
     struct dyn_array device_array;
     struct dyn_array stream_array;
-    struct dyn_array named_stream_array;
 };
 
 /*********************************************************************
@@ -582,12 +581,14 @@
 static struct stream *find_named_stream(struct config_mgr *cm,
                                    const char *name)
 {
-    struct stream *s = cm->named_stream_array.streams;
+    struct stream *s = cm->stream_array.streams;
     int i;
 
-    for (i = cm->named_stream_array.count - 1; i >= 0; --i) {
-        if (strcmp(s->name, name) == 0) {
-            return s;
+    for (i = cm->stream_array.count - 1; i >= 0; --i) {
+        if (s->name) {
+            if (strcmp(s->name, name) == 0) {
+                return s;
+            }
         }
         s++;
     }
@@ -1134,7 +1135,6 @@
     }
     mgr->device_array.elem_size = sizeof(struct device);
     mgr->stream_array.elem_size = sizeof(struct stream);
-    mgr->named_stream_array.elem_size = sizeof(struct stream);
     pthread_mutex_init(&mgr->lock, NULL);
     return mgr;
 }
@@ -1640,7 +1640,6 @@
     const char *type = state->attribs.value[e_attrib_type];
     const char *dir = state->attribs.value[e_attrib_dir];
     const char *name = state->attribs.value[e_attrib_name];
-    struct dyn_array *array;
     bool out;
     uint32_t card;
     uint32_t device;
@@ -1659,12 +1658,9 @@
             ALOGE("Stream '%s' already declared", name);
             return -EINVAL;
         }
-        array = &state->cm->named_stream_array;
-    } else {
-        array = &state->cm->stream_array;
     }
 
-    s = new_stream(array, state->cm);
+    s = new_stream(&state->cm->stream_array, state->cm);
     if (s == NULL) {
         return -ENOMEM;
     }
@@ -2148,12 +2144,6 @@
         }
         dyn_array_free(&cm->stream_array);
 
-        stream_array = &cm->named_stream_array;
-        for(stream_idx = stream_array->count - 1; stream_idx >= 0; --stream_idx) {
-            free_usecases(&stream_array->streams[stream_idx]);
-        }
-        dyn_array_free(&cm->stream_array);
-
         if (cm->mixer) {
             mixer_close(cm->mixer);
         }